(resolved) is there a way to make a function uninterruptible?
(resolved) is there a way to make a function uninterruptible?
Hi all -
I'm still contending with an I2C library issue that causes my app to crash. I'm wondering whether there is a compiler option for making a particular function uninterruptible. (The keyword "atomic" is used in other IDEs.) Does anyone know of such an option?
Thanks...
I'm still contending with an I2C library issue that causes my app to crash. I'm wondering whether there is a compiler option for making a particular function uninterruptible. (The keyword "atomic" is used in other IDEs.) Does anyone know of such an option?
Thanks...
Last edited by mzimmers on Thu Jun 13, 2019 5:07 pm, edited 1 time in total.
Re: is there a way to make a function uninterruptible?
Excellent...thanks.
The wording in the FreeRTOS doc is a little odd:
Calls to taskENTER_CRITICAL() and taskEXIT_CRITICAL() are designed to nest. Therefore, a critical section will only be exited when one call to taskEXIT_CRITICAL() has been executed for every preceding call to taskENTER_CRITICAL().
That sounds like the opposite of nesting to me...but I just work here.
EDIT: I just tried adding this, and I get this compiler error:
So, do I correctly understand that ESP32 has overridden the FreeRTOS syntax, and requires me to supply a mutex for this purpose?
The wording in the FreeRTOS doc is a little odd:
Calls to taskENTER_CRITICAL() and taskEXIT_CRITICAL() are designed to nest. Therefore, a critical section will only be exited when one call to taskEXIT_CRITICAL() has been executed for every preceding call to taskENTER_CRITICAL().
That sounds like the opposite of nesting to me...but I just work here.
EDIT: I just tried adding this, and I get this compiler error:
I looked in task.h, and found this section:C:/esp32_projects/wifibutton/main/max77818.cpp:610:13: warning: 'taskENTER_CRITICAL(mux)' is deprecated in ESP-IDF, consider using 'portENTER_CRITICAL(mux)'
Code: Select all
#ifdef _ESP_FREERTOS_INTERNAL
#define taskENTER_CRITICAL(mux) portENTER_CRITICAL(mux)
#else
#define taskENTER_CRITICAL(mux) _Pragma("GCC warning \"'taskENTER_CRITICAL(mux)' is deprecated in ESP-IDF, consider using 'portENTER_CRITICAL(mux)'\"") portENTER_CRITICAL(mux)
#endif
#define taskENTER_CRITICAL_ISR(mux) portENTER_CRITICAL_ISR(mux)
Re: is there a way to make a function uninterruptible?
I added the FreeRTOS critical calls, and now I'm getting this on startup:
The trace goes to the I2C library.Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0)
Core 0 register dump:
PC : 0x40093184 PS : 0x00060934 A0 : 0x800919b7 A1 : 0x3ffb6080
A2 : 0x3ffb8724 A3 : 0x3ffb6394 A4 : 0x3ffbdda8 A5 : 0x00000001
A6 : 0x00060923 A7 : 0x00000001 A8 : 0x3ffb6394 A9 : 0x3ffb6394
A10 : 0x00000018 A11 : 0x00000018 A12 : 0x00000034 A13 : 0x00000001
A14 : 0x00060923 A15 : 0x00000001 SAR : 0x0000000d EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
ELF file SHA256: 8c0bd7f04eb15f6a795d7a787f130e8c53daa7c22543731544723a14b6b5f6ca
Backtrace: 0x40093184:0x3ffb6080 0x400919b4:0x3ffb60a0 0x40092bec:0x3ffb60c0 0x4015f7da:0x3ffb6100 0x401242a3:0x3ffb6140 0x40124a25:0x3ffb61b0 0x40124bb7:0x3ffb6200 0x40110802:0x3ffb6240 0x40108796:0x3ffb6260 0x400d097a:0x3ffb62c0 0x40092279:0x3ffb62e0
Re: is there a way to make a function uninterruptible?
How is your mux variable init looks like?
You need to pass mix as pointer, and in my case I am using this to init it:
and pas it by reference.
You need to pass mix as pointer, and in my case I am using this to init it:
Code: Select all
portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED;
Re: is there a way to make a function uninterruptible?
Yes, that's exactly what I did.
Code: Select all
portMUX_TYPE mutex = portMUX_INITIALIZER_UNLOCKED;
taskENTER_CRITICAL(&mutex);
taskEXIT_CRITICAL(&mutex);
Re: is there a way to make a function uninterruptible?
IMO It is nesting (or re-entrant). You will not be "non-critical" until you exit after enter. IOW, you can enter the critical section with the same thread over and over, vs another thread trying to get the critical section being blocked. But you won't be "non-critical" until each call to enter has a matching call to exit. So you could have a re-entrant function calling itself and entering the critical section as deep as you need to go.mzimmers wrote: ↑Tue Apr 16, 2019 6:08 pmExcellent...thanks.
The wording in the FreeRTOS doc is a little odd:
Calls to taskENTER_CRITICAL() and taskEXIT_CRITICAL() are designed to nest. Therefore, a critical section will only be exited when one call to taskEXIT_CRITICAL() has been executed for every preceding call to taskENTER_CRITICAL().
That sounds like the opposite of nesting to me...but I just work here.
John A
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: is there a way to make a function uninterruptible?
Also note the interrupt watchdog triggers when you stay in a critical section too long (or forget to exit it properly. 'Too long' by default is 300mS, but it's configurable in menuconfig.
Re: is there a way to make a function uninterruptible?
Oh...that's good to know. Does a WDT expiration manifest as a panic?
I don't think I'm spending 300ms in this routine anyway, but I'll take a closer look in the morning.
I don't think I'm spending 300ms in this routine anyway, but I'll take a closer look in the morning.
Re: is there a way to make a function uninterruptible?
This is WDT reason (from your logs):
Code: Select all
Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0)
Who is online
Users browsing this forum: No registered users and 100 guests