Hi,
I am about to start with the fascinating world of AVR and, although
I do not have the STK500 for real tests, I'm playing around with the
AVR Studio.
I made a small test program to simulate, but run into the following
problem: when I run it and the subroutine "doStep" comes at the "ret"
instruction, the program counter jumps back to the "main" label instead
of the instruction after the "rcall" instruction.
What am I doing wrong?
Regards,
Geert
.include "8515def.inc"
;
; Stepper output ports and pins
;
.equ sPort = PORTB
.equ sVertStep = 0
.equ sVertDir = 1
.equ sHorStep = 2
.equ sHorDir = 3
;
; Position registers
;
.def moveH = r18
.def moveL = r19
.def posVertL = r20
.def posVertH = r21
.def posHorL = r22
.def posHorH = r23
;
; Steps per count
;
.equ stepsPerCount = 8
;
; General vars
;
.def tmp1 = r10
.def tmp2 = r11
.def tmp3 = r12
;
; Org
;
.org 0x0000
;
; Interrupts
;
;rjmp main
;--------------------------------------------------
; Start of program
;
main:
;
; Init counters
;
ldi posVertH, 0x00
ldi posVertL, 0x00
ldi posHorH, 0x00
ldi posHorL, 0x00
;
; Test
;
ldi moveH, 0x00
ldi moveL, 0x0A
rcall doStep
ldi r17, 0x00
ldi r17, 0x00
ldi r17, 0x00
ldi moveH, 0x01
ldi moveL, 0x03
rcall doStep
;--------------------------------------------------
; doStep
;
doStep:
cpi moveL, 0x00
brne doStepLow
cpi moveH, 0x00
breq doStepEnd
dec moveH
ldi moveL, 0xFF
doStepLow:
dec moveL
rjmp doStep
doStepEnd:
ldi r17, 0x00
retMessage
Newbie rcall question
2004-12-03 by Geert De Pecker
Attachments
- No local attachments were found for this message.