void scib_fifo_init()
{
ScibRegs.SCICCR.all =0x000F; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
ScibRegs.SCICTL1.all =0x0003; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
ScibRegs.SCICTL2.bit.TXINTENA =1;
ScibRegs.SCICTL2.bit.RXBKINTENA =1;
ScibRegs.SCIHBAUD =0x0000;
ScibRegs.SCILBAUD =0x006c; //28.8Kbps
ScibRegs.SCICCR.bit.LOOPBKENA =0; // Enable loop back
ScibRegs.SCIFFTX.all=0xC021;
ScibRegs.SCIFFRX.all=0x4021;
ScibRegs.SCIFFCT.all=0x00;
ScibRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
ScibRegs.SCIFFTX.bit.TXFIFOXRESET=1;
ScibRegs.SCIFFRX.bit.RXFIFORESET=1;
}
interrupt void scibTxFifoIsr(void)
{
ScibRegs.SCIFFTX.bit.TXFFINTCLR=1; // Clear Interrupt flag
 ieCtrlRegs.PIEACK.all|=0x100; // Issue PIE ACK
}
//======================================
//RS485发送函数
//======================================
void scib_xmit(int TargetAddr,int DataNum,int *TransData)
{
Uint16 i;
TX_EN;
for (i=0;i<30;i++)
{
;
}
ScibRegs.SCICTL1.bit.TXWAKE=1; //发送模式唤醒
ScibRegs.SCITXBUF=TargetAddr; //发送地址
while (ScibRegs.SCICTL2.bit.TXEMPTY!=1); //等待发送完毕, 清除发送中断标志
ScibRegs.SCICTL1.bit.TXWAKE=0; //关闭唤醒
ScibRegs.SCICCR.bit.ADDRIDLE_MODE =0; // 空闲地址为协议
for (i=0;i<DataNum;i++)
{
ScibRegs.SCITXBUF=*TransData; //发送数据
while (ScibRegs.SCICTL2.bit.TXEMPTY!=1); //等待发送完毕, 清除发送中断标志
TransData++;
}
TX_EN; // Load output latch
ScibRegs.SCICCR.bit.ADDRIDLE_MODE =1; // 选择地址为协议
for (i=0;i<30;i++)
{
;
}
}
我的程序能发送出去数据,但是地址发送不出去,从机响应不了,这个程序有啥问题了啊??
|