Timer Stack Size

grunnels@gmail.com
Posts: 9
Joined: Wed Mar 16, 2022 7:20 pm

Timer Stack Size

Postby grunnels@gmail.com » Thu Jun 23, 2022 6:12 pm

How do I set the Timer (not task) stack size? And do all of the timers within a given application have the same stack size?

I tried setting up a FreeRTOSconfig.h file in the app directory (same directory as the "src" folder). That didn't seem to do anything.

I'm using Visual Studio with PlatformIO.

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

Re: Timer Stack Size

Postby ESP_Sprite » Fri Jun 24, 2022 12:18 am

It's in menuconfig, if I recall correctly somewhere under components -> freertos.

grunnels@gmail.com
Posts: 9
Joined: Wed Mar 16, 2022 7:20 pm

Re: Timer Stack Size

Postby grunnels@gmail.com » Fri Jun 24, 2022 6:58 pm

Thanks for the reply! So, silly question, how/where do I run menuconfig? Does it run on my development computer and update config files there?

grunnels@gmail.com
Posts: 9
Joined: Wed Mar 16, 2022 7:20 pm

Re: Timer Stack Size

Postby grunnels@gmail.com » Fri Jun 24, 2022 7:57 pm

Looks like I cannot run menuconfig because I'm using PlatformIO with the Arduino framework. Looks like a port to espidf framework would be a lot of work. Complicating it is the fact that I can't find compatible libraries to replace the ones I'm using.

Is there a way to run menuconfig (or equivalent) when using the Arduino Framework?

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

Re: Timer Stack Size

Postby ESP_Sprite » Fri Jun 24, 2022 11:56 pm

Phew, it gets a lot more complicated then... Can I ask in what situation you're runnning into a timer stack overflow? If it's in your code, it may be fixed in some other way.

grunnels@gmail.com
Posts: 9
Joined: Wed Mar 16, 2022 7:20 pm

Re: Timer Stack Size

Postby grunnels@gmail.com » Sat Jun 25, 2022 1:26 am

I have a timer using xTimerCreate and xTimerStart. It fires every hour (probably once a day eventually). One of the things it does is check for a code update using the esp32fota library. That's what makes it crash. Error is:
Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception).
Debug exception reason: Stack canary watchpoint triggered (Tmr Svc)

I had originally coded it with a task using xTaskCreatePinnedToCore. This worked fine with a stack size of 4096. I changed to the timer for a couple reasons; 1) I thought it would use fewer system resources, and 2) I hoped that it would fire with more accurate timing.

To expand on the more accurate timing...I would like to fire a task off at the same time every period. With the task I can't really do that because the delay is within the continuous loop. With the timer set to repeat, I'm hoping it fires at the same period regardless of the code it is running. In other words, with a timer set to auto reload do the follow on firings happen at (OrigTimerFire + TimerDelay) or does it fire at (OrigTimerFire + CodeExecutionTime + TimerDelay)?

I guess bottom line question is what is the best way to fire a task say every hour?

Thanks for your help!

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

Re: Timer Stack Size

Postby ESP_Sprite » Sat Jun 25, 2022 2:58 am

I think you were on the right path with the separate task; you really shouldn't put intense and long-running things in a timer callback (as it stops other timer events from happening as long as the callback is running). You probably want to take a look at vTaskDelayUntil to solve your other problem.

grunnels@gmail.com
Posts: 9
Joined: Wed Mar 16, 2022 7:20 pm

Re: Timer Stack Size

Postby grunnels@gmail.com » Sat Jun 25, 2022 11:14 am

Yes, that looks like the ticket! Thanks.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], HighVoltage and 116 guests