#include <hidef.h> /* common defines and macros */ #include <mc9s12dp256.h> /* derivative information */ #pragma LINK_INFO DERIVATIVE "mc9s12dp256b"
int i,m=0;char t[]="ABCD "; void main() {DisableInterrupts; /*禁止中断*/ //初始化SCI SCI0BDL=0x34; /*波特率常数为52,设置波特率为9600*/ SCI0BDH=0x00; SCI0CR1=0x00; //SCI0CR1_LOOPS=0; /*正常工作模式*/ //SCI0CR1_SCISWAI=0; /*等待模式下继续工作*/ //SCI0CR1_RSRC=0; /*LOOPS为零此位无效*/ //SCI0CR1_M=0; /*传输数据位为8位*/ //SCI0CR1_WAKE=0; /*介质唤醒方式*/ //SCI0CR1_ILT=0; /*保守检测*/ //SCI0CR1_PE=0; /*不进行奇偶校验*/ //SCI0CR1_PT=0; /*SCI0CR1_PE=0;此位无效*/
SCI0CR2=0x08; //SCI0CR2_SCTIE=0; /*禁止发送器中断*/ //SCI0CR2_TCIE=0; /*禁止发送结束中断*/ //SCI0CR2_RIE=0; /*禁止接受中断*/ //SCI0CR2_ILIE=0; /*禁止空闲中断*/ //SCI0CR2_TE=1; /*发送允许*/ //SCI0CR2_RE=0; /*禁止接收*/ //SCI0CR2_RWU=0; /*接收器正常唤醒*/ //SCI0CR2_SBK=0; /*中止符发送器关闭*/ i=SCI0SR1; /*清除标志位*/ i=SCI0DRL; //发送数"ABCD" while(1) {if(SCI0SR1_TDRE==1) {SCI0DRL=t[m]; /*发送字符串*/ SCI0DRH=0; m++; } if(m==5)SCI0CR2_TE=0; /*发送完成禁止发送器工作*/ } }
小弟是新手,调SCI时出现问题,我的理解是: SCI0SR1 寄存器里有个TDRE(发送保持器空标志位),程序烧写入单片机之后,单步运行,发现TDRE位一直为0(满),导致数据无法传输。
我是将板子的串口与PC机串口连接,用串口助手测试发送,一直没有显示。各位看看问题出在什么地方?谢谢!!
|