Page 1 of 1

Cannot Start Task in ISR

Posted: Sun Dec 04, 2016 1:16 am
by vanthome
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

Re: Cannot Start Task in ISR

Posted: Sun Dec 04, 2016 2:30 am
by WiFive
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?

Re: Cannot Start Task in ISR

Posted: Mon Dec 05, 2016 3:16 am
by ESP_Sprite
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.

Re: Cannot Start Task in ISR

Posted: Mon Dec 05, 2016 8:41 am
by vanthome
ok, thx, seems to work with semaphores

Re: Cannot Start Task in ISR

Posted: Tue Dec 06, 2016 12:04 am
by jmattsson
@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?

Re: Cannot Start Task in ISR

Posted: Tue Dec 06, 2016 2:20 am
by ESP_igrr
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...

Re: Cannot Start Task in ISR

Posted: Tue Dec 06, 2016 2:56 am
by jmattsson
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).