在调试ST72F561和PC上位机的串口通讯,程序如下,单片机向上位机发送16进制数0x32,结果在上位机总是显示00 00 00.请指点!注:ST72F561是LINSCI通讯接口,这是不是和平常遇到的有所不同? #include "ST72_F_561_A_R9.h"
#define SR_TC 0x40 #define CR2_TCIE 0x40 #define CR2_TE 0x08
typedef unsigned char uchar; uchar *OutString; void SCISend(unsigned char Data);
void main(void) { //PDDDR=0x00; //PDOR=0x00; //SCI1ETPR = 0; SCI2BRR =0xd2; // 设置发送接收波特率为9600 SCI2CR1 = 0; // 允许SCI,1个停止位,8个数据位,一个结束位,无奇偶校 SCI2CR2=0x2C; //enable TE,RE,RIE SCISend(0x32); // 发送字符串 }
void SCISend(unsigned char Data) { unsigned char SCItemp; SCItemp=SCI2SR; //it's used to clear TDRE which is useful for the check of sending process SCI2DR=Data; while((SCI2SR&0x80)!=0x80); }
|