How to guard time critical sections from RTOS interrupts?

btomic
Posts: 3
Joined: Thu May 04, 2017 7:01 pm

How to guard time critical sections from RTOS interrupts?

Postby btomic » Thu Apr 05, 2018 6:15 am

I'm using ESP8266_RTOS_SDK and the 1-Wire bus to connect with DS18B20 temperature sensors. When the wifi is in STATION_MODE there are occasional CRC errors when reading the temperature value from the sensors. When the wifi is turned off (i.e. in NULL_MODE) there are no errors at all.

The 1-wire bus is timing sensitive and some operations must not be interrupted. All sensitive portions of the code (which last for about 60 us) are guarded by the taskENTER_CRITICAL/taskEXIT_CRITICAL pair but the problem still occurs. It looks like that wifi interrupts are still interrupting critical sections and affecting critical timing on the 1-Wire bus.

I tried instead to guard critical sections with taskDISABLE_INTERRUPTS/taskENABLE_INTERRUPTS pair but the problem is still there. In this case the scheduler can still interrupt the critical sections. An attempt to both disable interrupts and use taskENTER_CRITICAL does not work at all.

Is there any way in ESP8266_RTOS_SDK to absolutely protect critical sections from high priority wifi interrupts (and still using the wifi)?

Who is online

Users browsing this forum: No registered users and 9 guests