Page 1 of 1

How to prevent ESP32 from switching tasks?

Posted: Thu May 09, 2019 4:05 am
by whoyoume
Hello forks.
I would like to let ESP32 read data at constant interval. But it seems that ESP32 occasionally freeze for a while.
I could that using AVR. but slow.
Thank you.

Re: How to prevent ESP32 from switching tasks?

Posted: Thu May 09, 2019 8:02 am
by ESP_Sprite
Can you give a bit more info; what data are you trying to read and at what frequency?

Re: How to prevent ESP32 from switching tasks?

Posted: Thu May 09, 2019 8:17 am
by whoyoume
Thank you.
It will be 10Msps, at least 1M.
I think ESP32 performs best, by sending a command to RTos, which preventing RTos from switching tasks.
Is it right?
Thank you.

Re: How to prevent ESP32 from switching tasks?

Posted: Thu May 09, 2019 11:27 am
by ESP_Sprite
It depends. The ESP32 has a RTOS system that makes it somewhat of an issue to disable task switching (you can only do it up to a certain point). However, in contrast to an AVR, the ESP32 has a lot of versatile peripherals to do stuff in hardware, without the CPU actually having to actively do the transfers. Hence my question: what data are you trying to read? As in: where does it come from, what protocol does it have?

Re: How to prevent ESP32 from switching tasks?

Posted: Sat May 11, 2019 6:12 am
by whoyoume
It is 1-wire transfer protocol. And it is an original one.

BTY, I found a code shown below works well. ESP32 no longer go into panic.

portMUX_TYPE mutex = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL(&mutex);
vTaskDelay(8000 / portTICK_PERIOD_MS);
portEXIT_CRITICAL(&mutex);

Thank you.

Re: How to prevent ESP32 from switching tasks?

Posted: Sat May 11, 2019 6:36 am
by WiFive