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.

External Interrupt and Enable/Disable bit in XINTnCR

I have a question regarding external interrupts. I have configured one of the GPIO's as a external interrupt source. And I've lately discovered that if I temporarily disable the interrupt like in the following example:

 

XIntruptRegs.XINTnCR.bit.ENABLE = 0;

//do something

 XIntruptRegs.XINTnCR.bit.ENABLE = 1;

 

and if the interrupt will occur exactly between those two instructions then the interrupt is lost.

I thought that there is something like interrupt flag, and the pending interrupt will be  serviced as soon as the interrupt is enabled.

Is this really like this and is my observation correct? I have not found any information on this in the manuals.

Best regards,

Andy

  • Hi Andy what you are doing is actually disabling and enabling XINT module, which in turn prevents setting appropriate interrupt flags. What you want to is either disable intterupts either within PIE (PieCtrlRegs.PIEIER1.bit.XINT1 = 0) or within the CPU (IER &= M_INT1). The examples assume you are using F2808 Regards Mitja
  • Thanks Mitja,

    I always  tried to disable/enable interrupts on the peripheral level (this is what TI recommends) but in this case it clearly wasn't good idea.

    PS. It should be IER &= ~M_INT1. But if you are using some other interrupts in this PIE group it is not the best solution.

    Regards,

    Andy

     

     

  • But according to "TMS320x2833x, 2823x System Control and Interrupts Reference Guide (Rev. C)", page 130:

    "The proper procedure for enabling or disabling an interrupt is by using the peripheral interrupt
    enable/disable flags. The primary purpose of the PIEIER and CPU IER registers is for software
    prioritization of interrupts within the same PIE interrupt group. The software package C280x C/C++
    Header Files and Peripheral Examples in C (literature number SPRC530) includes an example that
    illustrates this method of software prioritizing interrupts.


    Should bits within the PIEIER registers need to be cleared outside of this context, one of the following two
    procedures should be followed. The first method preserves the associated PIE flag register so that
    interrupts are not lost. The second method clears the associated PIE flag register."

    So it seems that the easiest and safest method for what I want to do is to use EINT/DINT or even better __disable_interrupts() and __restore_interrupts() intrinsics.