how does one determine enough stack is reserv

I am running 5.0.0 with microchip C30 3.10 on a dspic33fj256. I have set the freertos heap size to 18,000 bytes. I create 6 tasks with a total of 4K of stack specified. I am getting address errors at times and stack errors at other times depending on the number of tasks I use. If I remove one task the errors go away. If I put that back and remove a different one the errors go away. If I change the stack sizes specified I can chase these around too. How does one determine the heap size required for the rtos config in relation to those called out for all of the task creations? If I have 18,000 bytes reserved and have speced out a total of, say 10K that should give my tasks plenty, then why does increasing the speced amount of stack on the task creates cause more address and stack errors? Increasing stack for a task that may be suspect of running out should make it go away, not make it happen. If I run any one task it will run without address or stack errors. Does this mean that I have given it enough stack alloc in the task creation? One would think so. Where am I going wrong? Could this be a microchip C30 problem that has been alluded to elsewhere? thanks, rich

how does one determine enough stack is reserv

I forgot to mention I am using the heap1 method. Also, if when I specify the queue sizes and stack sizes and I exceed some limit then would I not be told with an error return during this queue and stack creation steps? rich

how does one determine enough stack is reserv

When using heap_1 you need only check the xNextFreeByte variable within heap_1.c to see how much of the total heap space you have used. If after creating all your tasks and queues there is heap space left you can reduce the configTOTAL_HEAP_SIZE setting accordingly. Calls to xTaskCreate() and xQueueCreate() return an error if there was not enough heap available for the create to complete. Also TaskStartScheduler() will return if there is not enough heap to create the idle task. Its a good idea to put a while(1); at the end of main to catch TaskStartScheduler() returning unexpectedly. Unfortunately the PIC24 stack grows up rather than the more conventional down so the uxTaskGetStackHighWaterMark() function does not work. You can always look at the stack in the memory window to see how much is unused as it is filled with 0xa5 when it is created. Or you could look at the implementation of uxTaskGetStackHighWaterMark() and change it to work for stacks that grow the wrong way.