This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ISR bug?

Other Parts Discussed in Thread: TMS320C5515

I have a simple program which turns the LED on and off when the RTC expires. Here is the ISR code.

interrupt void RTC_Isr(void)
{
   
    Uint16 temp;

    // clear RTC int flag
    IFR1 = 0x0004;
   
    temp =RTC_STAT;
    RTC_STAT = temp;
    if((ST1_55&0x2000) != 0)
    {
        // turn off LED
        ST1_55 &=0xDFFF;
    }
    else
    {
        //turn on LED
        ST1_55 |=0x2000;
    }

}

The code executes correctly, and the led turns on and off at the correct times, however when the ISR exits, if the LED was turned on, it immediately turns off. Why??

  • I am assuming you are using a TMS320C5515/14/05/04 device. Correct me if I am wrong. 

    Try clearing the RTCINTFL (ioport register 1920h) by writing 1 to the corresponding bit field instead of clearing the IFR1. The CPU should clear the IFR1 register automatically. 

  • I think I found the problem...as it turns out, this particular LED is controlled by setting a bit in the ST1_55 CPU status register. If I'm not mistaken, CPU status registers are backed up pre-interrupt, then restored post interrupt. Because of this, the LED state cannot be changed from within an interrupt.

  • Thanks, Timothy. I am having this problem as well. Not sure why they connect a LED to that pin!

  • Can anyone briefly explain to me how ST1_55 works? Or point me to any relevant document. I only found that it is a CPU register.

    I try to monitor it by setting breakpoints but it appears that the ST1_55 is always 0 under the register watch.

     

    Im using the USB_Stick_AudioFilter code, which is very similar to the code posted above.

    What confuses me the most is when i monitor the temp value read from ST1_55, it appears to be always the same (0x6100 for LED on OR 0x4100 for LED off). Therefore I don't know why sometimes it step into IF((ST1_55&0x2000)!=0) and sometimes it doesn't.

    regards,

    Chen Chiu-Hao (Ted)

  • Nevermind, I got it. Such a simple question. Sorry for trouble caused!

    regards,

    ted.