This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C-func call in ISR seems to cause stack corruption

Target: ST uPSD3454 running at 36.8864 Mhz

What seems simple is causing extreme confusion.

Enhanced template code from Keil:

;  Define instructions executed on a hardware timer interrupt.
HW_TIMER_CODE   MACRO
        EXTRN   CODE (TIMER_Update)
        USING   2       ; Registerbank 2 for following code
        LCALL   TIMER_Update ; C-func
        RETI
        ENDM


C-func:

void TIMER_Update( void )
{   unsigned char data i;

    for( i=0; i<NUM_TIMERS; i++ )
    {   timers[i]--;
        if( timers[i] == 0 )
        {   timers[i] = reload[i];
            if( events[i] < 255 )
                events[i]++;
        }
    }
}


HW_TIMER_CODE is ISR and occurring ever 10ms.
TIMER_update is attempt to implement software timers for additional systems functionality.

After about the 3rd HW_TIMER_CODE execution (between 30 and 50ms) system resets.

No stack corruption is detected in trace.

What silly thing am I overlooking?