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.

[参考译文] LP-MSP430FR2476:在 TeraTerm 中打印两位整数

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1050581/lp-msp430fr2476-printing-two-digit-integers-in-teraterm

器件型号:LP-MSP430FR2476

您好!

我在中添加了 UART 打印功能  

第9课:UART–简单嵌入式

UART_putchar (RXData[3]+'0');

这用于将单个数字打印为字符。 两位整数打印为空白。 如何解决此问题?

谢谢、

Priya

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

    您需要使用诸如 K&R 中的 itoa()之类的内容创建字符串

    如果*仅*需要两位整数,则可以执行以下操作:

    int i = 42;

    //打印 MSD

    CHAR MSD =(I/10)+"0";

    UART_putchar (MSD);

    //打印 LSD

    字符 LSD =(I % 10)+"0";

    UART_putchar (LSD)