Hi Team,
There are some issues from the customer need your help:
Using SCI perform a simple transmit and receive control, acting as a slave, which returns data back to upper-position machine(ComMonitor) via a array. Place the transmit task function in Timer 0, set the timer period to 10 ms, send and receive messages normally, accept and transmit data consistently. However, the timer is set to 1 ms and the return and transmit information are completely different. The clock frequency for the SCI is the default LSPCLK setting. Is this question related to the timer period?
Also, 5ms and 50ms can be used but errors pop out a lot, see the error flag indicating that stop bit is missing. It also happens to 1ms, and even more strangely, the data received and sent at 1 ms is inconsistent (basically wrong), and occasionally incorrect at 5 ms.
And also, whether resetting the error flag bit through SWRESET has an effect on subsequent communications.
Sent function code:
void scitx_a(void) { int i = 0; for(i=0;i<RXD_iSciA;i++) { SciaRegs.SCITXBUF = tdata[i]; while(0==SciaRegs.SCICTL2.bit.TXEMPTY); //TEXMPTY :0 SCITXBUF or TXSHF contain data } RXD_iSciA = 0; SCIA_TX_L; //发送禁止 SCIA_RX_H; } void SCI_work(void) { int i = 0; for(i=0;i<RXD_iSciA;i++) { tdata[i]=rdata[i]; } SCIA_RX_L; SCIA_TX_H; //发送使能 }
In the Timer0:
interrupt void TIM0_IRQn(void) { LED_work(&LED_count); SCI_work(); scitx_a(); // SCIA_RX_H; PieCtrlRegs.PIEACK.bit.ACK1 = 1; }
Could you help check this case?
Thanks & Regards,
Ben