标题: STC单片机printf()输出的和UART输出的数据不一致 [打印本页]

作者: suning    时间: 2022-10-9 18:05
标题: STC单片机printf()输出的和UART输出的数据不一致
这是通过UART向PC机输出数据,
void Data_send(u8 send_count)
        { u8 count;                                                                                                                                                                                                                                    
                for(count=0;count<send_count;count++){    //发送send_count个数据,接口来自Sgl_lim_count
                    SBUF=(AD7606_u16_votlage_data[count]>>8)&0XFF;
                                while(!TI); //等待发送完成
        TI=0; //清TI标志位
                                
                }
        }
在串口助手上显示的数据为0x30,0x07,0x07,0x07,0x07,0x07,


这是通过printf()输出向PC机输出数据
        void Data_send(u8 send_count)
        { u8 count;                                                                                                                                                                                                                                    
    ES=OFF;                                                                                                                                                                                                                                            //关闭串口中断
                for(count=0;count<send_count;count++){  //发送send_count个数据,接口来自Sgl_lim_count
                    printf("%x\n",(AD7606_u16_votlage_data[count]>>8)&0XFF); //按顺序从0发送16bit电压数据数组中的每一个数据        
                }
                ES=ON;               
                }
在串口助手上显示的数据为0x30,0x30,0x30,0x30,0x30,0x30,

AD7606_u16_votlage_data中的数据期间没有被篡改,求救大佬
作者: 18701931930    时间: 2022-10-9 23:27
把%x改成%u试试
作者: suning    时间: 2022-10-10 10:25
18701931930 发表于 2022-10-9 23:27
把%x改成%u试试

多谢,问题已经解决




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1