I’m attempting to balance the stack use on my PIC32 by using the High Water mark function to let me know what is left of each of the stacks. Most of them make sense – except the TCPIP stack.
Berlow is the code as I create my tasks:
void SYS
Tasks ( void )
{
/* Create OS Thread for Sys Tasks. */
xTaskCreate((TaskFunctiont)
SYSTasks,
“Sys Tasks”,
170, NULL, 6, NULL);
/* Create task for System Timer state machine*/
/* Create OS Thread for GFX_STACK Tasks. */
xTaskCreate((TaskFunction_t) _GFX_STACK_Tasks,
"GFX_STACK Tasks",
100, NULL, 7, NULL);
/* Create task for System Timer state machine*/
/* Create OS Thread for LIBARIA Tasks. */
xTaskCreate((TaskFunction_t) _LIBARIA_Tasks,
"LIBARIA Tasks",
1024, NULL, 5, NULL);
/* Create task for TCPIP state machine*/
/* Create OS Thread for TCPIP Tasks. */
xTaskCreate((TaskFunction_t) _TCPIP_Tasks,
"TCPIP Tasks",
1180, NULL, 1, NULL);
/* Create OS Thread for APPTCPSRVR Tasks. */
xTaskCreate((TaskFunction_t) _APPTCPSRVR_Tasks,
"APPTCPSRVR Tasks",
220, NULL, 4, NULL);
/* Create OS Thread for ANYBUSAPP Tasks. */
xTaskCreate((TaskFunction_t) _ANYBUSAPP_Tasks,
"ANYBUSAPP Tasks",
200, NULL, 2, NULL);
/* Create OS Thread for SONARTRACAPP Tasks. */
xTaskCreate((TaskFunction_t) _SONARTRACAPP_Tasks,
"SONARTRACAPP Tasks",
256, NULL, 3, NULL);
/**************
* Start RTOS *
**************/
vTaskStartScheduler(); /* This function never returns. */
in each task I print out the results of the High Water mark function, for example:
static void
SONARTRACAPPTasks(void)
{
UBaseType_t uxHighWaterMark;
while(1)
{
SONARTRACAPP_Tasks();
vTaskDelay(25 / portTICK_PERIOD_MS);
uxHighWaterMark = uxTaskGetStackHighWaterMark( NULL );
if (uxHighWaterMarkPrev[10] != uxHighWaterMark)
{
uxHighWaterMarkPrev[10] = uxHighWaterMark;
SYS_CONSOLE_PRINT("TaskStack: _SONARTRACAPP_Tasks: %unr", uxHighWaterMark);
}
}
}
so it only prints out if there is a change...
I've tried to reduce everything as much as possible. And I get the following numbers:
TaskStack:
SYSTasks: 42
TaskStack:
GFXSTACK
Tasks: 30
TaskStack: _ANYBUSAPPTasks: 34
TaskStack:
APPTCPSRVRTasks: 78
TaskStack:
SONARTRACAPPTasks: 56
TaskStack:
TCPIPTasks: 862
A little buffer for each, BUT if I attempt to reduce the TCPIP task to anything below 1180 the code will stop.
Why does uxTaskGetStackHighWaterMark return a number like 862? If I understand that number, I should be able to reduce the TCPIP task’s stack quite a bit,, but if I do the code stops.
I’m pretty early on in my development, so if I need to play games already with space I’m concerned.
My total heap size is 57060
Are there other settings I should be concerned about?
Any advice on this? Thanks!
-Ed