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.

[参考译文] TMS320F280049:浮点数时出现 sprintf 错误

Guru**** 2898830 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1407160/tms320f280049-sprintf-error-with-floats

器件型号:TMS320F280049

工具与软件:

您好、先生们、

我正在尝试使用适用于 int 变量的 sprintf 函数、但我的软件与 float 变量崩溃、您是否知道我出错了??

错误代码:

  case potenzaAttiva:
    rl = working_data.phases[0].readings.active_power;

    f1 = rl;
    f1 /= 1000.0;
    sprintf(str,"%f", f1); // f1 is float
  break;

正确的代码

  case potenzaAttiva:
    rg = working_data.phases[0].readings.active_power;
    sprintf(str,"%d", rg);  // rg is int
  break;

我想使用浮点变量、但我不能、为什么? 程序崩溃、我收到错误中断、该中断影响 ESTOP0。