Skip to main content
Visitor II
January 22, 2004
Question

Help Needed with ST7 Lite Timer Interrupt

  • January 22, 2004
  • 5 replies
  • 988 views
Posted on January 22, 2004 at 05:05

Help Needed with ST7 Lite Timer Interrupt

    This topic has been closed for replies.

    5 replies

    fxdifAuthor
    Visitor II
    January 21, 2004
    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 ]
    Visitor II
    January 21, 2004
    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 ]
    fxdifAuthor
    Visitor II
    January 21, 2004
    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

    }

    Visitor II
    January 21, 2004
    Posted on January 21, 2004 at 13:50

    Do you mean

    @interrupt void INT_LTovf(void)

    rather than

    @void INT_LTovf(void)

    Regards

    sjo
    fxdifAuthor
    Visitor II
    January 22, 2004
    Posted on January 22, 2004 at 05:05

    you're right

    @interrupt void INT_LTovf(void)

    my typo error