Replies: 5 comments 1 reply
-
You are conflating several important memory concepts. The best thing to do is to understand the difference between "program storage space", aka Flash memory, and "Global Variables" and "Local Variables", aka RAM, in C and C++. Once you understand those differences then this answer will make more sense. Your Uno is probably hanging because either the Idle Task stack space is being exceeded, or the stack in another Task is being exceeded. The Idle Task is equivalent to You can check the usage of the stack assigned in FreeRTOS using the You can add many more lines of code to the "Program Space". This has nothing to do with your Uno hanging. |
Beta Was this translation helpful? Give feedback.
-
Thanks @feilipu for your advise and I understand about memory concepts and am not sure whether I have explained properly. Basically, I would like to re-iterate below are steps are successful even after adding the more lines within the program storage space. Successful steps
Failed area of code Please advise. |
Beta Was this translation helpful? Give feedback.
-
Good. If you're having issues with task creation, then the best thing to do is to analyse what you are doing with the memory allocation for the each task. Note if your program cannot complete the task allocation there is a serious issue with your code. If you are loading 60% of the Flash with your program, it is likely that it is already very large. Try breaking it down into smaller components, and try to get them working piece by piece. Please read the FreeRTOS task creation API notes and copy examples that are known to work, as a starting point. If insufficient RAM remains following task creation to allow the creation of the Idle task, then there will be a fast LED blink to indicate the heap shortage, as noted in the ReadMe. |
Beta Was this translation helpful? Give feedback.
-
@feilipu Thanks for your advise and will modify the code as you described. |
Beta Was this translation helpful? Give feedback.
-
Fantastic explanation. I ran into the same issue as @digidhamu and was able to figure out I also had a stack overflow causing my Uno to do nothing. Of course the amount of heap memory used will vary based on the task but I noticed that I am able to enable up to 3 tasks without overflowing (each task has a stack of 128). After reducing the stack size of some of these to 64 (other than my TaskSerial), I was able to run 5 total tasks. Seems like there is a lot of optimization to do here. Either analyze your tasks and figure out how much bytes you are using or reduce each tasks bit by bit until you have enough to create a new task. Regarding uxTaskGetStackHighWaterMark(), perhaps I am using this function incorrectly but my return value would consistently show up as '21' until I changed my vTaskDelay(10) to vTaskDelay(1) in my TaskSerial. Sounds like this is a value that should be tracked in every task if you want an exact analysis of your free bytes. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Need your assistance why Arduino Uno hangs beyond 60% as I could not add even single line of code.
I have checked settings in the below files but could not figure out anything.
FreeRTOSConfig.h
FreeRTOSVariant.h
Output
Would like to get your advise.
Beta Was this translation helpful? Give feedback.
All reactions