大家好,我用的cpu是MC9S12DP512,现在在调试串口,以下是做简单的给超级终端发字符的小程序,可是超级终端接受到的总是乱码,感觉波特率设置没有错误,请教!
#include <hidef.h> /* common defines and macros */ #include <mc9s12dp512.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dp512" #define uchar unsigned char #define uint unsigned int
void main(void) { /* put your own code here */ uchar i; uint j; uchar a[]={'H','E','L','L','O'}; SCI0BDH=0x00;//波特率设置9600 SCI0BDL=0x68; SCI0CR1_M=0;//设置停止位等 while(1) { if (SCI0SR1_TDRE==0) //检查状态寄存器的发射数据标志位是否为空 SCI0CR2_TE=1; //开启控制寄存器的发送使能位 i=0; for(i=0;i<=5;i++) {SCI0DRL=a;} /* wait forever */ for(j=0;j<12500;j++);//延时 }
}
|