How to prevent ESP32 from switching tasks?

whoyoume
Posts: 23
Joined: Fri Sep 07, 2018 2:42 am

How to prevent ESP32 from switching tasks?

Postby whoyoume » Thu May 09, 2019 4:05 am

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.

ESP_Sprite
Posts: 8926
Joined: Thu Nov 26, 2015 4:08 am

Re: How to prevent ESP32 from switching tasks?

Postby ESP_Sprite » Thu May 09, 2019 8:02 am

Can you give a bit more info; what data are you trying to read and at what frequency?

whoyoume
Posts: 23
Joined: Fri Sep 07, 2018 2:42 am

Re: How to prevent ESP32 from switching tasks?

Postby whoyoume » Thu May 09, 2019 8:17 am

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.

ESP_Sprite
Posts: 8926
Joined: Thu Nov 26, 2015 4:08 am

Re: How to prevent ESP32 from switching tasks?

Postby ESP_Sprite » Thu May 09, 2019 11:27 am

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?

whoyoume
Posts: 23
Joined: Fri Sep 07, 2018 2:42 am

Re: How to prevent ESP32 from switching tasks?

Postby whoyoume » Sat May 11, 2019 6:12 am

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.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: How to prevent ESP32 from switching tasks?

Postby WiFive » Sat May 11, 2019 6:36 am


Who is online

Users browsing this forum: Bing [Bot], StuartsProjects and 60 guests