Page 1 of 1

Processing multiple interrupts sources

Posted: Thu Mar 16, 2017 10:13 pm
by dave111
Hi, I'm looking at this code: http://www.lucadentella.it/en/2017/02/2 ... interrupts

What this code does: 1 interrupt source --> 1 ISR handler --> 1 semaphore --> 1 loop processing events delivered via xSemaphoreTake().

But I need to handle a multiple interrupts sources.

If I pass individual ID's as arg to gpio_isr_handler_add(), I can handle multiple interrupt sources and I still only need 1 ISR handler. This is great! But how am I supposed to forward the individual ID's through the semaphore mechanism? Do I need to use a list of semaphores, 1 per event source? Oh no. And then I also need to code and run a dedicated loop for each semaphore?? That can't be right. Hopefully someone can point me in a better direction. Thank you.

Re: Processing multiple interrupts sources

Posted: Fri Mar 17, 2017 1:16 am
by WiFive
Task notification, event group, queue, ... Depends on how much info you need to send to the task

http://www.freertos.org/RTOS_Task_Notif ... Group.html

Re: Processing multiple interrupts sources

Posted: Fri Mar 17, 2017 11:07 am
by dave111
Thank you. This makes a lot of sense.

Unfortunately after switching from xSemaphoreGiveFromISR() to xTaskNotifyFromISR() I now get this:
Untested FreeRTOS function xTaskNotifyFromISR
/home/dave/code/esp32/esp-idf/components/freertos/./tasks.c:4780 (xTaskNotifyFromISR)- assert failed!
abort() was called at PC 0x4008503a
Guru Meditation Error: Core 0 panic'ed (abort)
I then rolled back the changes to my task method (went back from xTaskNotifyWait() to xSemaphoreTake()) but Guru Meditation still occurs. So my task method is not being triggered by xTaskNotifyFromISR(). It just sits there doing nothing. It should definitely not be involved.

Only if I out-remark the call to xTaskNotifyFromISR() from my ISR, do I get rid of the Guru Meditation. Is there some working xTaskNotifyFromISR() sample code for ESP32 anywhere to look at / try out?

Also: portYIELD_FROM_ISR(xHigherPriorityTaskWoken) does not seem to be supported. However portYIELD_FROM_ISR() appears to be. So I don't need to use xHigherPriorityTaskWoken, right? Thx.

Re: Processing multiple interrupts sources

Posted: Fri Mar 17, 2017 7:26 pm
by WiFive
Oops didn't realize this was on the untested blacklist. You can disable the abort in menuconfig if you want to try it.

Re: Processing multiple interrupts sources

Posted: Fri Mar 17, 2017 8:12 pm
by dave111
It doesn't say "Untested FreeRTOS... abort() was called" any more. But it still says "Guru Meditation" as soon as xTaskNotifyFromISR() has been called. Only now with a slightly different remark:
Error: Core 0 panic'ed (Interrupt wdt timeout on CPU1)
"wdt" = Watch Dog Timer, correct? I've tried several values, including portMAX_DELAY. No change.

What else can I try? I only need to send 8 (or 16) bits from ISR to task.

Re: Processing multiple interrupts sources

Posted: Fri Mar 17, 2017 8:42 pm
by WiFive

Re: Processing multiple interrupts sources

Posted: Sat Mar 18, 2017 12:39 am
by dave111
Event Groups are working well. Thank you so much.