打印
[PIC®/AVR®/dsPIC®产品]

PIC单片机串口输出问题

[复制链接]
456|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
xwr121|  楼主 | 2022-7-21 16:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

为什么我串口传输的数据在电脑打印输出不是'S',但是如果我使用#define定义KS 为'S'时就能正常打印输出‘S’?这两者有什么区别吗?

单片机代码如下:
void main(void)
{
    // initialize the device
    SYSTEM_Initialize();

    // When using interrupts, you need to set the Global and Peripheral Interrupt Enable bits
    // Use the following macros to:

    // Enable the Global Interrupts
    //INTERRUPT_GlobalInterruptEnable();

    // Enable the Peripheral Interrupts
    //INTERRUPT_PeripheralInterruptEnable();

    // Disable the Global Interrupts
    //INTERRUPT_GlobalInterruptDisable();

    // Disable the Peripheral Interrupts
    //INTERRUPT_PeripheralInterruptDisable();
    char KS;
    KS= 'S';
    while (1)
    {
        // Add your application code
        putch(KS);
    }
}

使用特权

评论回复
沙发
ynwa| | 2022-7-21 21:00 | 只看该作者
不知道你这个宏定义具体写成什么样子。宏定义用的时候要注意,它只是编译时简单的替换,不同于变量定义。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

4

帖子

0

粉丝