Stack pointer set correctly but call not working

96 Views Asked by At

I'm using TI Code Composer Studio for the MSP430F1232. Starting from a template in assembler, a call to a routine doesn't work but when I put the routine directly in the code,it works. Why does the call won't work?

;generated code, the watchdog is stopped and the stack pointer is set correctly
RESET       mov.w   #__STACK_END,SP         ; Initialize stackpointer
StopWDT     mov.w   #WDTPW|WDTHOLD,&WDTCTL  ; Stop watchdog timer
;-------------------------------------------------------------------------------
; Main loop here
;-------------------------------------------------------------------------------
            mov.b   #0FFh,P1DIR
            mov.b   #0,P1OUT
$1
            call    delay

            xor.b   #001h,P1OUT
            jmp     $1

            .newblock ;reuse local labels
delay       push    r14
            mov     #1000,r14
$1
            dec     r14
            jne     $1
            pop     r14
            ret
1

There are 1 best solutions below

0
On

I reproduced the problem with a similar micro (MSP430FR2433). It turned out that the addressing mode was wrong. With other microprocessor types, we use

call MySubroutine
...
MySubroutine:

For the MSP430 and similar, we should use

call #MySubroutine
...
MySubroutine