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.
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
Hi Ben,
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.
How long does it take to transmit the desired data? If you don't include it within a timer ISR but within the normal program flow?
Best Regards,
Marlyn
Hi Marlyn,
The exact time for transmitting data is not calculated, but it is very short. The baud rate is 19200, the data transmitted by the upper bit is 12 34 56, and the transmission period is 300 ms. The function that sends the data on the 28335 side is placed in Timer0. The period is 1ms, 5ms, 10ms, 50ms, 5ms or more, and the data is essentially the same. There is only occasional stop bit loss (as seen by the register's flag bits), and 1 ms of transmit and receive data is not consistent. The configuration for sending and receiving data is in the above. The following are the Timer0 configurations.
EALLOW;
PieVectTable.TINT0 = &TIM0_IRQn; //Timer0
EDIS;
interrupt void TIM0_IRQn(void)
{
LED_work(&LED_count);
SCI_work();
scitx_a(); //data transmit
// SCIA_RX_H;
PieCtrlRegs.PIEACK.bit.ACK1 = 1;
}
ConfigCpuTimer(&CpuTimer0,150,1000); //1ms
Best Regrads,
Ben
Ben,
Thank you for the additional information. Is there occasional stop bit loss when the timer is not used or this only occurs when the timer is used?
Best Regards,
Marlyn
Hi Marlyn,
Customer tried and it will have occasional stop bit loss when the timer is not used. That caused can't enter ISR, now resolved by reset. Now the problem is if accept one byte data alone is ok, for example 01, but it will have mistake if multiple bytes accept, like the master send 01 00 02, the slave received data becomes other.
Best Regards,
Ben
Marlyn is out-of-the office (and so are many other subject-matter-experts). She will be back in the first week of January, at which time you can expect a response. Thank you for your understanding and patience.
Hi Ben,
but it will have mistake if multiple bytes accept, like the master send 01 00 02, the slave received data becomes other.
I am glad the missing stop bit issue has been resolved. Can you please describe what the mistake is when multiple bytes are accepted?
Could you please try adding two stop bits instead of one?
Best Regards,
Marlyn