modiallen wrote on Thursday, April 26, 2012:
hallo everyone,
i am using freertos with Codecomposer and the msp430f5438.
i have question about the stacksize, that will be given to tasks, when they are created,
in this example:
xTaskCreate( protReceiveByte, ( signed char * ) “protByte”, 2000, NULL , tskIDLE_PRIORITY + 3, NULL );
the task protReceiveByte is beeing created and has 2000 as stacksize.
now this task usese another functions like “rbRead” or “pdSetHeader” and others, as to see in the code below:
void protReceiveByte(void *pvParameters)
{
char xReceivedMessage;
unsigned int uIntData;
for( ;; )
{
while (!rbIsEmpty(&Buffer))
{
xReceivedMessage = rbRead(&Buffer);
uIntData = (unsigned int)xReceivedMessage;
/* Zustand */
if (protInstance.state == PROT_STOP)
{
if(xReceivedMessage == PROT_START_SEQ)
{
protInstance.state = PROT_HEADER_1;
}
break;
}
/* Zustand */
if (protInstance.state == PROT_HEADER_1)
{
pdSetHeader(protInstance.protd, uIntData);
protInstance.state = PROT_HEADER_2;
break;
}
/* Zustand */
if (protInstance.state == PROT_HEADER_2)
{
pdAddToHeader(protInstance.protd, (256 * uIntData));
/* Check for valid/used header */
if(headerGetPayloadLength(pdGetHeader(protInstance.protd)) == 0)
{
protInstance.state = PROT_ERROR;
continue;
}
else {
protInstance.state = PROT_LENGTH_1;
break;
}
}
/* Zustand */
if (protInstance.state == PROT_LENGTH_1)
{
pdSetLength(protInstance.protd, uIntData);
protInstance.state = PROT_LENGTH_2;
break;
}
/* Zustand */
if (protInstance.state == PROT_LENGTH_2)
{
pdAddToLength(protInstance.protd, (256 * uIntData));
protInstance.pdLength = pdGetLength(protInstance.protd);
if (protInstance.pdLength < 1) {
protInstance.state = PROT_ERROR;
continue;
}
protInstance.byteCount = 0;
/* Check for a valid “header/payload length” combination */
if(protInstance.pdLength == headerGetPayloadLength(pdGetHeader(protInstance.protd)))
{
protInstance.state = PROT_DATA;
break;
}
else {
protInstance.state = PROT_ERROR;
continue;
}
}
/* Receive the data bytes */
if (protInstance.state == PROT_DATA)
{
pdSetByte(protInstance.protd, protInstance.byteCount, xReceivedMessage);
//pdInstance.data=xReceivedMessage;
protInstance.byteCount++;
/* When all data bytes have been received, expect end sequence byte next. */
if(protInstance.byteCount == protInstance.pdLength) {
protInstance.state = PROT_END;
}
break;
}
/* Receive end sequence byte */
if (protInstance.state == PROT_END)
{
if(xReceivedMessage == PROT_END_SEQ)
{
/* Valid packet was received */
/* Create event */
xQueueSend(xPROTQueue,&pdInstance,0);
/* Reset protocol automaton */
protInstance.protd = &pdInstance; /* new, empty protocol data object */
protInstance.pdLength = 0; /* empty payload length */
protInstance.byteCount = 0; /* no payload bytes received */
protInstance.state = PROT_STOP; /* initial protocol automaton state */
break;
}
else
{
protInstance.state = PROT_ERROR;
continue;
}
}
/* Zustand */
if (protInstance.state == PROT_ERROR)
{
pdSetHeader(protInstance.protd, 0); /* reset header */
pdSetLength(protInstance.protd, 0); /* reset length */
protInstance.state = PROT_STOP; /* initial protocol automaton state */
break;
}
/* This code should never be reached, but go to PROT_ERROR if it happens. */
protInstance.state = PROT_ERROR;
}
}
}
now my question: did these functions get another stack on the RAM than the stack, that is given to the task, or it will be part of the created task, and have the same stack, that was given to this created task?
best Regards.