This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
通过串口实际发送 01 02 03 04 05 串口接收到 0002030405 但是调试中单片机显示接收的数据为 02 03 04 05 02 为何与我发送的数据不一样 ?
程序中设置如下
发送6个数据 SciaRegs.SCIFFTX.all=0xC026;
接收5 个数据
SciaRegs.SCIFFRX.all=0x0025;
但是如果我都设置为4 个数据 SciaRegs.SCIFFTX.all=0xC024; SciaRegs.SCIFFRX.all=0x0024; 显示都是正常的。
for(i = 0; i<8; i++)
{
sdataA[i] = i;
rdataA[i] = 0;
}
__interrupt void
sciaTxFifoIsr(void)
{
Uint16 i;
for(i=0; i<6; i++)
{
SciaRegs.SCITXBUF=sdataA[i]; // Send data
}
count++;
PieCtrlRegs.PIEACK.all|=0x100; // Issue PIE ACK
}
//
// sciaRxFifoIsr -
//
__interrupt void
sciaRxFifoIsr(void)
{
Uint16 i;
for(i=0;i<5;i++)
{
rdataA[i]=SciaRegs.SCIRXBUF.all; // Read data
}
SciaRegs.SCIFFRX.bit.RXFFOVRCLR=1; // Clear Overflow flag
SciaRegs.SCIFFRX.bit.RXFFINTCLR=1; // Clear Interrupt flag
SciaRegs.SCIFFTX.bit.TXFFINTCLR=1; // Clear SCI Interrupt flag
PieCtrlRegs.PIEACK.all|=0x100; // Issue PIE ack
}
//
// scia_fifo_init -
//
void
scia_fifo_init()
{
//
// 1 stop bit, No loopback, No parity,8 char bits, async mode,
// idle-line protocol
//
SciaRegs.SCICCR.all =0x0007;
// enable TX, RX, internal SCICLK, Disable RX ERR, SLEEP, TXWAKE
//
SciaRegs.SCICTL1.all =0x0003; //RXE
SciaRegs.SCICTL2.bit.TXINTENA =1;
SciaRegs.SCICTL2.bit.RXBKINTENA =1;
SciaRegs.SCIHBAUD =0x0001;
SciaRegs.SCILBAUD =0x0024;
SciaRegs.SCIFFTX.all=0xC026;
SciaRegs.SCIFFRX.all=0x0025;
SciaRegs.SCIFFCT.all=0x00;
SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
SciaRegs.SCIFFTX.bit.TXFIFOXRESET=1;
SciaRegs.SCIFFRX.bit.RXFIFORESET=1;
}
//
// End of File
//