-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Adds support to change LoopTask Stack size #6025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
11b16dd
Adds support to change LoopTask Stack size
SuGlider 7ce004e
Adds support to change LoopTask Stack size
SuGlider 301f93d
Adds support to change LoopTask Stack size
SuGlider b640900
Adds support to change LoopTask Stack size
SuGlider b436ab7
Merge branch 'master' into ArduinoStack
SuGlider File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
libraries/ESP32/examples/ArduinoStackSize/ArduinoStackSize.ino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
ESP32 Arduino creates a task to run setup() and then to execute loop() continuously | ||
This task can be found at https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/main.cpp | ||
|
||
By default "loopTask" will be created with a stack size of 8KB. | ||
This should be plenty for most general sketches. | ||
|
||
There is a way to change the stack size of this task by using | ||
SET_LOOP_TASK_STACK_SIZE(size); | ||
It will bypass the default stack size of 8KB and allow the user to define a new size. | ||
|
||
It is recommend this value to be higher than 8KB, for instance 16KB. | ||
This increasing may be necessary for the sketches that use deep recursion for instance. | ||
|
||
In this example, you can verify it by changing or just commenting out SET_LOOP_TASK_STACK_SIZE(); | ||
*/ | ||
|
||
#define ARDUINO_TASK_STACK_SIZE (16*1024) // 16KB | ||
|
||
// This sets Arduino Stack Size - comment this line to use default 8K stack size | ||
SET_LOOP_TASK_STACK_SIZE(ARDUINO_TASK_STACK_SIZE); | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
|
||
Serial.printf("Arduino Stack was set to %d bytes", getArduinoLoopTaskStackSize()); | ||
|
||
// Print unused stack for the task that is running setup() | ||
Serial.printf("\nSetup() - Free Stack Space: %d", uxTaskGetStackHighWaterMark(NULL)); | ||
} | ||
|
||
void loop() { | ||
delay(1000); | ||
|
||
// Print unused stack for the task that is running loop() - the same as for setup() | ||
Serial.printf("\nLoop() - Free Stack Space: %d", uxTaskGetStackHighWaterMark(NULL)); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.