This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/CC2538: device hanging randomely

Part Number: CC2538
Other Parts Discussed in Thread: Z-STACK

Tool/software: TI-RTOS

Hi,

I am using cc2538 evaluation module as my ZigBee coordinator. I am facing some performance issues in my code.

1. Sometimes If I put UART prints code working or if I remove UART prints its working fine otherwise required functionality not calling or device hanging.

2. In my coordinator, i am parsing the UART commands using strtok(); the following commands I am parsing 

(1) KC_SW_1,1,4ef3,5$ -> this command using strtok parsing 1st _ and 2nd _ and then all comma finally dollar. so I am getting all values those values I am sending to another one event loop using osal send msg

token = strtok(newBuffer, "_");

if(strcmp(token, "KC") == 0||strcmp(token, " KC") == 0||strcmp(token, "KC ") == 0)
{
token = strtok(NULL, "_");
HalUARTWrite ( MT_UART_DEFAULT_PORT, token, strlen(token) );
HalUARTWrite ( MT_UART_DEFAULT_PORT, "\r\n", strlen("\r\n") );

if(strcmp(token, "SW") == 0){
HalUARTWrite ( MT_UART_DEFAULT_PORT, token, strlen(token) );
HalUARTWrite ( MT_UART_DEFAULT_PORT, "\r\n", strlen("\r\n") );

uint16 switchCommand;
uint16 OnOffCommand;
int networkAddr;
int Brightness;

token = strtok(NULL, ",");
switchCommand = atoi(token);

token = strtok(NULL, ",");
OnOffCommand = atoi(token);

token = strtok(NULL, ",");
networkAddr = (int)strtol(token, NULL, 16);

token = strtok(NULL, "$");
Brightness = atoi(token);

memset(newBuffer, 0, strlen(newBuffer));


sprintf(newBuf1, "sw, onoff, brt = %d_%d_%d$\r\n",switchCommand,OnOffCommand,Brightness);
HalUARTWrite ( MT_UART_DEFAULT_PORT, newBuf1, strlen(newBuf1) );

sprintf(newBuf1, "nwAddr = %x$\r\n",networkAddr);
HalUARTWrite ( MT_UART_DEFAULT_PORT, newBuf1, strlen(newBuf1) );
char dataBuf1[64];
sprintf(dataBuf1, "%x,KC_CS_%d_STS_%d_%d$,", networkAddr, switchCommand,OnOffCommand,Brightness);
mtSysAppMsg_t *msgStruct;
msgStruct = (mtSysAppMsg_t *)osal_msg_allocate(sizeof(mtSysAppMsg_t) + (strlen(dataBuf1)));

HalUARTWrite ( MT_UART_DEFAULT_PORT, dataBuf1, strlen(dataBuf1) );
HalUARTWrite ( MT_UART_DEFAULT_PORT, "\r\n", strlen("\r\n") );


msgStruct->hdr.event = MT_SYS_APP_MSG;
msgStruct->appDataLen = strlen(dataBuf1);
msgStruct->appData = (uint8*)(msgStruct+1);

HalUARTWrite ( MT_UART_DEFAULT_PORT, dataBuf1, strlen(dataBuf1) );
HalUARTWrite ( MT_UART_DEFAULT_PORT, "\r\n", strlen("\r\n") );

osal_memcpy( msgStruct->appData, dataBuf1, strlen(dataBuf1));
osal_msg_send( Zigbee_TaskID, (uint8 *)msgStruct );

HalUARTWrite ( MT_UART_DEFAULT_PORT, dataBuf1, strlen(dataBuf1) );
HalUARTWrite ( MT_UART_DEFAULT_PORT, "\r\n", strlen("\r\n") );

}

in above code if I remove those bold uart prints code not working.

2. Another command KC_SEN_1,1,4ef3$

here  iam using same like above code

token = strtok(NULL, ",");
switchCommand = atoi(token);

token = strtok(NULL, ",");
OnOffCommand = atoi(token);

token = strtok(NULL, ",");
networkAddr = (int)strtol(token, NULL, 16);
//
// token = strtok(NULL, "$");
// Brightness = atoi(token);

the commanded code i dont want, if i remove those code its not working. Like this always iam getting unknown problem. I cont find out the error reason also. If i remove the command then its working.