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.

XCH 指令如何会影响高优先级的中断的?



因为要捕获外部中断,在看中断代码时有些疑问,

hal_mcu.h 文件中有如下代码:

#ifdef __IAR_SYSTEMS_ICC__  

/* IAR library uses XCH instruction with EA. It may cause the higher priority interrupt to be  locked out, therefore, may increase interrupt latency.  It may also create a lockup condition.  This workaround should only be used with 8051 using IAR compiler. When IAR fixes this by  removing XCH usage in its library, compile the following macros to null to disable them.    */  

       #define HAL_ENTER_ISR()   { halIntState_t _isrIntState = EA; EA = 1;  

       #define HAL_EXIT_ISR()                  EA = _isrIntState; }

 #else  

     #define HAL_ENTER_ISR()  

     #define HAL_EXIT_ISR()

#endif /* __IAR_SYSTEMS_ICC__ */

我想请教的问题是: (抱歉,这个问题和BLE没有直接关系)

1. XCH 指令如何会影响高优先级的中断,增加中断延时的?

2.进入中断程序为什么要特别将EA=1, 使能总中断,使高优先级能够中断吗?那为什么退出中断程序就不要管EA?