Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 months, 1 week ago.
how to reliably read from UART
Hi, I am trying to read a serial datastream at 115200 baud. this does work with my code, but sometimes (about 1 of 1000bytes) 1 byte is received incorrectly. I am receiving with UARTSerial and sending the received stuff out over BLE in paralell.
I have confirmed no buffer is overflowing (except for the hardware buffer... but I dont think so..) I am on an NRF52840.
Is there anything I am missing in order to make it more reliable? Do I have to split receiving and sending into seperate threads maybe? would that help? also I have the feeling, that the problem gets worse, with more CPU load.
what can I do about this?
8 months ago.
I would need more information for clarifying this issue.
Where's the error byte occurring? Is it on UART receive side or on BLE receive side?
Have you checked readble() before read()?
For increasing CPU load, maybe you can use a smaller connection interval and no slave latency, under this configuration, would it be easier for reproducing this issue?
In you current implementation, where do you put UART receiving, is it in ISR or main thread?