如何彻底关闭中断

jiangteng
Posts: 25
Joined: Wed Jan 30, 2019 7:08 am

如何彻底关闭中断

Postby jiangteng » Tue Aug 06, 2019 5:53 am

现在要实现一个ns级的延时函数,用nop指令已经调试完成,然而问题在于这个延时函数经常被中断,导致延时时间不可控,我在延时函数前后加了
  1. portENTER_CRITICAL(&delay_spinlock);
  2. portEXIT_CRITICAL(&delay_spinlock);
这两个宏,似乎并没有任何作用,延时依然不可控,这是什么原因呢?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: 如何彻底关闭中断

Postby ESP_igrr » Tue Aug 06, 2019 7:01 am

These 2 macros disable interrupts up to and including level 3. Interrupts level 4 and 5 are still allowed in FreeRTOS critical sections. In practice, you may find that disabling interrupts up to level 4 will give the result you need. Note however that your timing requirements come from some bitbanging procedure, it may be better to use one of the ESP32's peripherals (RMT, I2S) instead.

jiangteng
Posts: 25
Joined: Wed Jan 30, 2019 7:08 am

Re: 如何彻底关闭中断

Postby jiangteng » Tue Aug 06, 2019 7:35 am

ESP_igrr wrote:
Tue Aug 06, 2019 7:01 am
These 2 macros disable interrupts up to and including level 3. Interrupts level 4 and 5 are still allowed in FreeRTOS critical sections. In practice, you may find that disabling interrupts up to level 4 will give the result you need. Note however that your timing requirements come from some bitbanging procedure, it may be better to use one of the ESP32's peripherals (RMT, I2S) instead.
Thanks for reply.
Yeah, my timing requirements come from a custom protocal, it's not suitable for stantard peripherals , like I2C etc.
Now I found it works well if I do not start wifi task, so maybe a high level interrupt was allocated to wifi task? which function or macro can disable high level interrupts.

jiangteng
Posts: 25
Joined: Wed Jan 30, 2019 7:08 am

Re: 如何彻底关闭中断

Postby jiangteng » Tue Aug 06, 2019 9:31 am

I've tried changing
#define XCHAL_EXCM_LEVEL 3 /* level masked by PS.EXCM */
to
#define XCHAL_EXCM_LEVEL 5 /* level masked by PS.EXCM */

but it doesn't work.

Who is online

Users browsing this forum: No registered users and 195 guests