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.

[参考译文] MSP430F5529:不#39;itoa'在库中。 ##39;ltoa##39;无法正常工作

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1438721/msp430f5529-no-itoa-in-library-ltoa-does-not-work-correctly

器件型号:MSP430F5529

工具与软件:

多年来、我一直将此代码与标准库"itoa"一起使用、用于将无符号字符值添加到字符串并显示它。

使用"ltoa (char str、int val、int radx)"时无法正常工作。

我知道某些 CCS 版本"ltoa"没有基数、但也不是问题。

请注意、"rawText (int x、int y、unsigned int FG_color、unsigned int bg_color、char const * string)" 函数在程序中的其他地方已经过多次验证。

它打印此文件:  从时钟#XS

应打印:  从时钟#3

void dispClkID()
{
    unsigned char clk_id;
    char s1[20], s2[3];

/* hardware detection not built yet.
 * clk_id is hard coded until then.
 */
clk_id= 3;

    if (clk_id == 1)  {
        strcpy(s1," MASTER CLOCK #1 ");
        drawText(TEXT_BG_CENTER,textY(0),BLACK,ORANGE,s1);
    }
    else if ((clk_id > 1)&&(clk_id < 5))  {
        ltoa(clk_id,s2,10);
        strcpy(s1,"  SLAVE CLOCK #");
        strcat(s1,s2);
        strcat(s1,"  ");
        drawText(TEXT_BG_CENTER,textY(0),BLACK,ORANGE,s1);
    }
    else  {
        strcpy(s1,"Clock ID not set");
        drawText(TEXT_BG_CENTER,textY(0),RED,BLACK,s1);
    }

}

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

    固定!

    我将 clk_id 更改为 long 与 unsigned char 、因此上层似乎有一些垃圾?