Reputation: 11
I'm reading some data on ADC channels on dsPIC30F6014A.
For that I have implemented a separate task for each ADC(say 7 channels-7 tasks).
I have created all the tasks at the start only, My heap size is 5120, I'm using heap_4.c and I have allocated stack for each task is configMINIMAL_Stack
(i.e. 115).
These tasks are running continuously and periodically(just vTaskSuspend()
and vTaskResume()
is what I'm doing)
At start all tasks are working fine but after some time vApplicationStackOverflowHook()
occurs, i.e. stack gets overflowed.
Is there any possibility of wrong handling of memory?
Upvotes: 0
Views: 1447
Reputation: 3246
It would seem wasteful to create a task per ADC input. What else are the tasks doing other than reading the ADC?
I would guess your task is very close to the edge of its stack and at some point you happen to get an interrupt just when you are at the maximum stack depth and that causes an overflow. You can make periodic calls to uxTaskGetStackHighWaterMark() to determine how close to the end of the stack you have reached.
Upvotes: 4