Cannot Start Task in ISR

vanthome
Posts: 2
Joined: Sat Dec 03, 2016 11:32 pm

Cannot Start Task in ISR

Postby vanthome » Sun Dec 04, 2016 1:16 am

Hi, when I start a task in an ISR, I end up with this:

Code: Select all

Intr GPIO17 ,val: 1
***ERROR*** A stack overflow in task IDLE has been detected.
***ERROR*** A stack overflow in task IDLE has been detected.
***ERROR*** A stack overflow in task IDLE has been detected.
I (20865) nfiot: DNS lookup succeeded. IP=192.168.178.28
***ERROR*** A stack overflow in task IDLE has been detected.
***ERROR*** A stack overflow in task IDLE has been detected.
***ERROR*** A stack overflow in task IDLE has been detected.
Guru Meditation Error: Core   0 panic'ed (Interrupt wdt timeout on CPU0)
Register dump:
PC      :  40084853  PS      :  00060b34  A0      :  80083ba7  A1      :  3ffbfa80  
A2      :  3ffc410c  A3      :  3ffc36fc  A4      :  00060b21  A5      :  3ffbfa60  
A6      :  00000003  A7      :  00060b23  A8      :  3ffc36fc  A9      :  3ffc36fc  
A10     :  00000019  A11     :  00000019  A12     :  00060b23  A13     :  b33f0000  
A14     :  b33fffff  A15     :  00060b23  SAR     :  00000015  EXCCAUSE:  00000005  
EXCVADDR:  00000000  LBEG    :  4000c2e0  LEND    :  4000c2f6  LCOUNT  :  ffffffff  
Rebooting...
I guess this is due to the fact that you must not call something like xTaskCreate in an ISR.
But what are my alternatives?


http://www.freertos.org/RTOS-Cortex-M3-M4.html

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

Re: Cannot Start Task in ISR

Postby WiFive » Sun Dec 04, 2016 2:30 am

Send a message from the isr to a running task to create the new task? Have the task running and idle waiting for semaphore from isr?

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

Re: Cannot Start Task in ISR

Postby ESP_Sprite » Mon Dec 05, 2016 3:16 am

In general, keep in mind that FreeRTOS does not like any functions that do not have FromISR at the end of their name to be called in an ISR. Doing so will cause weirdness, as you've experienced.

vanthome
Posts: 2
Joined: Sat Dec 03, 2016 11:32 pm

Re: Cannot Start Task in ISR

Postby vanthome » Mon Dec 05, 2016 8:41 am

ok, thx, seems to work with semaphores

jmattsson
Posts: 34
Joined: Fri Jun 03, 2016 5:37 am
Contact:

Re: Cannot Start Task in ISR

Postby jmattsson » Tue Dec 06, 2016 12:04 am

@ESP_Sprite On that note, I saw that the default implementation of esp_event_send() uses xQueueSendToBack() rather than xQueueSendToBackFromISR(). Does that imply that esp_event_send() should never be called from an ISR, or are the queues safe regardless?

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

Re: Cannot Start Task in ISR

Postby ESP_igrr » Tue Dec 06, 2016 2:20 am

The assumption is that esp_event_send is not called from an ISR. We can change it to use *FromISR version if you have a use case for calling esp_event_send from an ISR though...

jmattsson
Posts: 34
Joined: Fri Jun 03, 2016 5:37 am
Contact:

Re: Cannot Start Task in ISR

Postby jmattsson » Tue Dec 06, 2016 2:56 am

Nope, no need from my direction. It was a point of curiosity since our (NodeMCU) event post function most certainly is used from ISRs (and uses the ...FromISR() versions).

Who is online

Users browsing this forum: No registered users and 142 guests