SciaRegs.SCICCR 的STOP BITS 设定为0时1个停止位时,通讯不正常;
设定为1时2个停止位,通讯正常,想问一下为什么?
peter shi:
回复 Jones Chen:
void scia_fifo_init()
{
SciaRegs.SCICCR.all =0x0087; // 2 stop bit, No loopback
// no parity,8 char bits,
// async mode, idle-line protocol
SciaRegs.SCICTL1.all =0x0007; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
SciaRegs.SCICTL2.bit.TXINTENA =1;
SciaRegs.SCICTL2.bit.RXBKINTENA =1;
SciaRegs.SCIHBAUD = 0x0000;
SciaRegs.SCILBAUD = 0x0060;
// SciaRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back
SciaRegs.SCIFFTX.all=0xC028;
SciaRegs.SCIFFRX.all=0x0021;
SciaRegs.SCIFFCT.all=0x00;
SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
SciaRegs.SCIFFTX.bit.TXFIFOXRESET=1;
SciaRegs.SCIFFRX.bit.RXFIFORESET=1;
}
上面的程序能正常工作
void scia_fifo_init()
{
SciaRegs.SCICCR.all =0x0007; // 1stop bit, No loopback
// no parity,8 char bits,
// async mode, idle-line protocol
SciaRegs.SCICTL1.all =0x0007; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
SciaRegs.SCICTL2.bit.TXINTENA =1;
SciaRegs.SCICTL2.bit.RXBKINTENA =1;
SciaRegs.SCIHBAUD = 0x0000;
SciaRegs.SCILBAUD = 0x0060;
// SciaRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back
SciaRegs.SCIFFTX.all=0xC028;
SciaRegs.SCIFFRX.all=0x0021;
SciaRegs.SCIFFCT.all=0x00;
SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
SciaRegs.SCIFFTX.bit.TXFIFOXRESET=1;
SciaRegs.SCIFFRX.bit.RXFIFORESET=1;
}
改成一个停止位就不行,为什么?
SciaRegs.SCICCR 的STOP BITS 设定为0时1个停止位时,通讯不正常;
设定为1时2个停止位,通讯正常,想问一下为什么?
peter shi:
回复 peter shi:
interrupt void sciaTxFifoIsr(void)
{
Uint16 i;
EINT;
if(SdataA_Num<=16)
{
for(i=0; i< SdataA_Num; i++)
{
while (SciaRegs.SCIFFTX.bit.TXFFST != 0){}
SciaRegs.SCITXBUF=SdataA[i]; // Send data
}
EDIS; // This is needed to disable write to EALLOW protected registers
PieCtrlRegs.PIEIER9.bit.INTx2=0; // PIE Group 9, INT2
EINT;
SciaRegs.SCIFFTX.bit.TXFFINTCLR=1; // Clear SCI Interrupt flag
PieCtrlRegs.PIEACK.all|=0x100; // Issue PIE ACK
}
SdataA_Num = 7 ,我上位机只能收到5个字节,CRC校验的字节丢失。
SciaRegs.SCICCR 的STOP BITS 设定为0时1个停止位时,通讯不正常;
设定为1时2个停止位,通讯正常,想问一下为什么?
Jones Chen:
回复 peter shi:
用历程也不行么?
SciaRegs.SCICCR 的STOP BITS 设定为0时1个停止位时,通讯不正常;
设定为1时2个停止位,通讯正常,想问一下为什么?
peter shi:
回复 Jones Chen:
历程一个停止位是没问题的,我以上两个程序,只相差SciaRegs.SCICCR.all =0x0007; SciaRegs.SCICCR.all =0x0087; 一个停止位,一个能工作,一个不能工作,很奇怪