单片机向串口发送汉字,超级终端为啥显示是乱码?

2020-01-19 19:43发布

单片机向串口发送汉字,超级终端为啥显示是乱码?

效果如下:
绀哄姛浠浇鑽风數鍘嬫槸: 1497mV
Channel '1' voltage is 1835mV
Channel '2' voltage is 1270mV
鍔犻€熷害浼犳劅鍣ㄧ數鍘嬫槸: 2426mV
Channel '4' voltage is 1524mV
Channel '5' voltage is 4mV
Channel '6' voltage is 657mV
鐢垫睜鐢靛帇鏄? 2394mV
Channel '8' degree is 160.139800
绀哄姛浠浇鑽风數鍘嬫槸: 1497mV
Channel '1' voltage is 1835mV
Channel '2' voltage is 1270mV
鍔犻€熷害浼犳劅鍣ㄧ數鍘嬫槸: 2426mV
Channel '4' voltage is 1524mV
Channel '5' voltage is 4mV
Channel '6' voltage is 657mV
鐢垫睜鐢靛帇鏄? 2394mV
Channel '8' degree is 160.139800

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
8条回答
dengxm2009
2020-01-20 18:49
解决了,原来还是字符编码问题。
手工转码:

char sgy_jsd_volt[17]={0xBC,0xD3,0xCB,0xD9,0xB6,0xC8,0xB5,0xE7,0xD1,0xB9,0xD6,0xB5,0xCA,0xC7,0x0};//“加速度电压值是”汉字转ASC码
char sgy_bat_volt[17]={0xB5,0xE7,0xB3,0xD8,0xB5,0xE7,0xD1,0xB9,0xD6,0xB5,0xCA,0xC7,0x0};//“电池电压值是”汉字转ASC码
char sgy_tempre_volt[19]={0xD0,0xBE,0xC6,0xAC,0xB5,0xC4,0xC4,0xDA,0xB2,0xBF,0xCE,0xC2,0xB6,0xC8,0xD6,0xB5,0xCA,0xC7,0x0};//“芯片温度值是”汉字转ASC码

sprintf(main_buf,"Channel '%d': %s     %5.1fmV ",i,sgy_jsd_volt, voltage);
SimUart1_WriteString(main_buf,strlen(main_buf));


Channel '1' voltage is   4.8mV
Channel '2' voltage is   4.8mV
Channel '3': 加速度电压值是       9.6mV
Channel '4' voltage is   9.6mV
Channel '5' voltage is   0.0mV
Channel '6' voltage is   4.8mV
Channel '7': 电池电压值是     1134.1mV
Channel '8': 芯片的内部温度值是  34.9

一周热门 更多>