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.
ARGH!
Everywhere in my thousands-of-lines code that I use sprintf(), I have no issues..
..except ONE function. Here's the function:
void UpdateTestStatus(unsigned char *Payload) { unsigned int nTemp; char pMsg[60]; LCD_Clear(0x0, TRUE); GrContextFontSet(&sContext, &g_sFontCmsc12); nTemp = (Payload[0] << 8) | Payload[1]; // Cycle count sprintf(pMsg, "Cycle Count %u", nTemp); cdcSendDataInBackground((uint8_t*)pMsg, strlen((const char *)pMsg), CDC0_INTFNUM, 1); GrStringDraw(&sContext, (const char *)pMsg, -1, 4, 4, 0); GrFlush(&sContext); nTemp = (Payload[2] << 8) | Payload[3]; // Max current sprintf(pMsg, "Max current %d", nTemp); cdcSendDataInBackground((uint8_t*)pMsg, strlen((const char *)pMsg), CDC0_INTFNUM, 1); GrStringDraw(&sContext, (const char *)pMsg, -1, 4, 24, 0); GrFlush(&sContext); return; }
Only in this function do I see pMsg[] filled with random binary trash and not a nice, printable string.
The stack high-water mark is 272 and the stack is 512, so I'm not blowing the stack.
Does anyone know why this could even be a thing?I use sprintf() in all 7 tasks and I see no errors there.
Any help enormously appreciated!
Ed Averill