2004-01-21 08:05 PM
Help Needed with ST7 Lite Timer Interrupt
2004-01-21 03:54 AM
Hi,
I can't seem to get the Lit Timer interrupt to work properly. My code will service the interrupt but after that it won't exit it and return to the main loop. I am using the Cosmic Compiler and my code is essentially this.... #define sim() _asm(''sim\n'') //Disable interrupts #define rim() _asm(''rim\n'') //Enable interrupts extern void INT_LTovf(); void main (void) { LTCSR = 0x30; //Set interrupt parameters rim (); //Enable interrupts LTCSR |= 0x10; //Enable Lite Timer interrupt while (1) //Main Loop { } } void INT_LTovf(void) //ISR { unsigned char cLTCSR_Reg; cLTCSR_Reg = LTCSR; //Read LTCSR. Clear interrupt flag???? PADR ^= 0x02; //Toggle port pin } ANy help would be greatly appreciated fxdif[ This message was edited by: fxdif on 21-01-2004 17:26 ]2004-01-21 04:19 AM
You need to let the compiler know about the interrupt routine, eg.
@interrupt void INT_LTovf(void) { } also make sure the interrupt is pointing to the correct vector in the vector.c file. Without the @interrupt the compiler will use a ret instead of an iret instruction. Regards sjo[ This message was edited by: sjo on 21-01-2004 17:52 ]2004-01-21 04:36 AM
Thanks, thats fixed it!
Code now reads............................. #define sim() _asm(''sim\n'') //Disable interrupts #define rim() _asm(''rim\n'') //Enable interrupts extern void INT_LTovf(); void main (void) { LTCSR = 0x30; //Set interrupt parameters rim (); //Enable interrupts LTCSR |= 0x10; //Enable Lite Timer interrupt while (1) //Main Loop { } } @void INT_LTovf(void) //ISR { unsigned char cLTCSR_Reg; cLTCSR_Reg = LTCSR; //Read LTCSR. Clear interrupt flag???? PADR ^= 0x02; //Toggle port pin }2004-01-21 04:50 AM
Do you mean
@interrupt void INT_LTovf(void) rather than @void INT_LTovf(void) Regards sjo2004-01-21 08:05 PM
you're right
@interrupt void INT_LTovf(void) my typo error