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.
void dbg_printf(const char *ftm, ...)
{
static char sprint_buf[255] = {0};
int n = 0,i = 0;
va_list vlist;
va_start(vlist, ftm);
n = vsprintf(sprint_buf, ftm, vlist);
va_end(vlist);
for (i = 0; i < n ;i++) {
while(SciaRegs.SCICTL2.bit.TXRDY == 0);
SciaRegs.SCITXBUF = (int) sprint_buf[i];
}
}
程序里 用这个映射 printf 打印函数, 打印整型 字符都很正常, 为什么打印浮点类型 系统就死了, 追到里面是 __TI_printfi 这个函数, 没法跟踪了,
请问是哪里的问题导致系统死了, 关键不知道 死在哪里,为什么死了
dbg_printf("%0.3f, %0.3f \r\n",(float)1.256, (float)3.256697); 这样系统死机
dbg_printf("%d, %d \r\n",(int)1.256, (int)3.256697); 这样系统正常
dbg_printf(“fasdfasdfasfasdf ”\r\n"); 这样系统正常
sprintf 这些都是c标准库里的东西,为什么在这里不能直接用, 是工程熟悉哪里没选好还是什么问题啊,
C 标准库里的东西,难道还要找源码 在ccs工程里 重新造轮子吗
看一下这个wiki:
http://processors.wiki.ti.com/index.php/Printf_support_in_compiler
The valid values are:
参考这个 重写了 sprintf ,目前是这样的。
http://www.verysource.com/code/7004834_1/sprintf.cpp.html