小生最近做个东东,用到FSL的串口,可怎么也发送不正确,可否看看,提个醒 1:串口初始化 void init_SCI(void) { /* ### Init_SCI init code */ //Baud rate = BUSCLK / (16 x SBR12:SBR0) /* SCIBD: SBR12=0,SBR11=0,SBR10=0,SBR9=0,SBR8=0,SBR7=0,SBR6=0,SBR5=0,SBR4=1,SBR3=1,SBR2=0,SBR1=1,SBR0=0 */ SCIBD = BUSCLK/16/SciBandRate; //设置波特率 /* SCIC1: LOOPS=0,SCISWAI=0,RSRC=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */ SCIC1 = 0x00; /* SCIC2: TIE=1,TCIE=0,RIE=1,ILIE=0,TE=0,RE=1,RWU=0,SBK=0 */ SCIC2 = 0xa4; /* SCIC3: R8=0,T8=0,TXDIR=1,TXINV=0,ORIE=0,NEIE=0,FEIE=0,PEIE=0 */ //SCIC3 = 0x20; /* SCIS2: BRK13=0,RAF=0 */ //SCIS2 = 0x00; } 2:接收的数据整理 void UartCheckData(void) { unsigned char i; if( !SystemFlag.Bits.Transmitting) {
if( SystemFlag.Bits.ReceiveOK == 1) {
for( i=0; i<8; i++) { txBuff = rxBuff; }
//SCIC2_TIE = 1; SCIC2_TE = 1; SystemFlag.Bits.ReceiveOK=0; SystemFlag.Bits.Transmitting = 1; } } } 3,发送中断 __interrupt 16 void SCITx_isr(void) { unsigned char temp; if( txPtr == putPtr) { SCIC2_TE = 0; SCIC2_RE = 1; txPtr = 0; putPtr = 0; SystemFlag.Bits.Transmitting = 0; } else{ if( SCIC2_TIE ) { while(SCIS1_TDRE ==0) ; /*等待发送缓冲区空 */ temp = SCIS1; SCID = 0x55 ;//SCID = txBuff[txPtr++] ; ++txPtr; } } } 小生刚学FSL,多指教,谢谢
|