B4R Question How to call long-working subs ?

peacemaker

Expert
Licensed User
Longtime User
Hi, All

There are libs where event subs must be finished ASAP (else the MCU can be self-rebooted due to some internal libs errors).
If not to use this event, or use it very fast - all is OK.

But when some action sub called from such capricious event is working rather long time ... how to call it correctly ?
I have tried CallSubPlus and timers - it does not help.
 

peacemaker

Expert
Licensed User
Longtime User
Actually, it's just make ADC measurement (loop of several measurements and averaging) and saving the result into Nvs. In another code module.
But even just one ADC measurement does not help.
If to use timer say for 10 seconds - the MCU saves to NVS OK, and in 10 seconds again self-rebooted by async_tcp.

Guru Meditation Error: Core 1 panic'ed (Unhandled debug exception).
Debug exception reason: Stack canary watchpoint triggered (async_tcp)

Other buttons with other functions work OK.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
What exactly does it mean in MCU ? Blocking what ?
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
I do not know if this is valid for ESP32 but in ESP8266 I overcame this problem by adding in the long running function some Delay(1) functions or some inline C with theyield(); command.
 
Upvote 0

Gerardo Tenreiro

Active Member
Licensed User
Hello
I have this working with a loop that does just that, I have all the data collection in a module and I call this module directly from the beginning of the program with "AddLooper" so each thread runs at maximum speed without blocking the others,
For example, the analog capture and the average are done in this loop, then every second I read the average and manage it
I have about 6 blocks set up like this and it works correctly.
One of them is where I manage the times of the functions to be performed with the result of the others.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…