At this moment I'm testing simple thread with uart3 print. Uart3 is used in this thread only. I don't use I-class function.
Here is my test code, only one from 4 buff operation is active in test.
I got hardfault or pannic with sprintf function only, I have test another lite sprintf version like xsprintf with the same issue.
Code: Select all
char buff[40] = "buf init \n\r";
void uart3Print(const char *string) {
uartStartSend(&UARTD3, strlen(string), string);
}
void get_dec_str(uint8_t* str, size_t len, uint32_t val)
{
uint8_t i;
for (i = 1; i <= len; i++)
{
str[len - i] = (uint8_t) ((val % 10UL) + '0');
val /= 10;
}
}
THD_WORKING_AREA(waThreadDump, 256);
THD_FUNCTION(threadDump, arg)
{
int x = 1, y = 2, z = 3;
while (1)
{
buff[9] = x++; //works
get_dec_str(&buff[11], 3, x++); //works
sprintf(buff, 15, "buf sprintf %d \n\r", x); //HardFault
sprintf(buff, 38, "OUT: 1:%d 2:%d 3:%d\n\r", x, y, z); //panic
uart3Print(buff);
chThdSleepMilliseconds(5000);
}
}