cancel
Showing results for 
Search instead for 
Did you mean: 

Help Needed with ST7 Lite Timer Interrupt

fxdif
Associate II
Posted on January 22, 2004 at 05:05

Help Needed with ST7 Lite Timer Interrupt

5 REPLIES 5
fxdif
Associate II
Posted on January 21, 2004 at 12:54

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 ]
sjo
Associate II
Posted on January 21, 2004 at 13:19

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 ]
fxdif
Associate II
Posted on January 21, 2004 at 13:36

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

}

sjo
Associate II
Posted on January 21, 2004 at 13:50

Do you mean

@interrupt void INT_LTovf(void)

rather than

@void INT_LTovf(void)

Regards

sjo
fxdif
Associate II
Posted on January 22, 2004 at 05:05

you're right

@interrupt void INT_LTovf(void)

my typo error