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.

Clearing a pending HWI

Other Parts Discussed in Thread: AM3359, SYSBIOS

Greetings!

I have a situation where, according to ROV, a HWI is enabled = false, but pending = true, even though the hardware is not driving the interrupt.

As a result, when the HWI is enabled, the interrupt is taken immediately. 

How can I clear the pending status before enabling the HWI? 

I tried Hwi_clearinterrupt(), but that did nothing.  As a workaround,  I put a trap in my ISR to catch and ignore the unwanted interrupt.

How can I determine programmaticly that the HWI is pending while it is still disabled?

BIOS: 6.34.03.19 for ARM

Hardware: AM3359 DMTimer4

Gerry Belanger

  • We don't have an API specifically for testing the pending status of an interrupt however I believe the following untested code should work:

    #include <ti/sysbios/family/arm/a8/intcps/Hwi.h>
    /*
     * if intNum is pending, this function
     * will return a non-zero value
     */
    UInt Hwi_isInterruptPending(UInt intNum)
    {
        if ( intNum < 32 ) {
            return (Hwi_intc.ITR0 & (1 << intNum)) ;
        }
        else if ( intNum < 64 ) {
            intNum %= 32;    // normalize to 0 - 31
            return (Hwi_intc.ITR1 & (1 << intNum)) ;
        }
        else if ( intNum < 96 ) {
            intNum %= 32;    // normalize to 0 - 31
            return (Hwi_intc.ITR2 & (1 << intNum));
        }
        else {
            intNum %= 32;    // normalize to 0 - 31
            return (Hwi_intc.ITR3 & (1 << intNum));
        }
    }

    As far as I can tell, the A8 interrupt controller does not have a mechanism for clearing a pending interrupt.

    Hwi_clearInterrupt() only forces the interrupt controller to re-evaluate the current set of interrupts to determine which is the currently at the highest priority.

    For Hwi_clearInterrupt() to work, the interrupt has to have been cleared from its source (ie at the peripheral) prior to calling Hwi_clearInterrupt().

    Alan

  • Alan,

    I agree that the function will id the HWI's view of the pending interrupt.  I did run Hwi_clearInterrupt with the interrupt cleared at the source, but it still did not clear the pending interrupt.  I worked around it by checking the hardware flag in the ISR and simply returning if this happens.

    Gerry Belanger

  • Gerry

    If you've moved on from this issue ok.

    But if you have time and are willing to run an experiment for me, can you call the function I provided above before and after you clear the interrupt at the source and confirm that the call after clearing it agrees that the interrupt is no longer pending?

    If it is no longer pending, and then Hwi_clearInterrupt() is called, I would expect that the interrupt controller not to serve up that interrupt's id when the dispatcher reads the SIR_IRQ register.

    Alan

  • Alan,

    I will be happy to try this, once I can get my application to load/run again.  It appears to load via the XDS100v2 interface, but the run to main() hangs up in what appears to be copy_decompress_rle.c.  Since I do not know whether this is an emulator, or C-startup, or SYSBIOS startup problem, I posted it in the CCS forum.

    Until I can get past this, I am stuck.

    Gerry Belanger.

  • Hi Gerry,

    Gerard Belanger said:
    but the run to main() hangs up in what appears to be copy_decompress_rle.c

    .

    Its not hang, it takes more time to reach main. In order to reduce the code size compiler uses RLE technique to compress the code, while executing it will decompress it so it takes time. You can turn off this feature by using proper compiler option.