Hello,
I have stale data from previous reading in the RX Buffer. This disturbs my current reading if I don't read the whole 16byte cycle. How can I flush/reset the RX UART FIFO ?
Regards,
Ahmed
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.
Hello,
I have stale data from previous reading in the RX Buffer. This disturbs my current reading if I don't read the whole 16byte cycle. How can I flush/reset the RX UART FIFO ?
Regards,
Ahmed
Veikko Immonen said:flushing the transmit FIFO (by disabling & re-enabling the FIFO
Poster Veikko offers what appears to be a worthwhile suggestion - but does not (fully) detail the "how."
Simple, "disable/re-enable" seems a bit too "gentle" to this reporter.
Suspect that poster seeks, "quick/dirty/easy" method - might a, "UART Peripheral Reset" (targeting just your specified UART) prove more comprehensive - thus more effective?
As Veikko suggests - experimentation seems "best bet" until vendor staff (armed w/the always delightful, "insider info") return from hiatus...
Pardon but (exclusive) use of software seems to overly complicate.
Our group past encountered a similar situation. (invalid data arriving @ random intervals) Amit (here) directs that the UART be disabled - then re-enabled - just prior to the "next command" is to be sent. In our case - we achieved that same effect via the toggle of a GPIO - which blocked the data-flow into UART_RX - and proved both far faster and less cumbersome than an, "all software, peripheral impacting" alternative.
We note that this thread has (only) one (errant) "suggested Answer" highlight - earlier (now verified) answer - from this reporter - remains uncredited/unmarked. That's not right...
Amit Ashara said:There are indeed multiple ways to do so...
Hi Amit,
Indeed - there are - but does the, "Disable" of UART prevent the arrival of "illegal/invalid" data @ UART_RX from (still) triggering an (now unwanted) interrupt(s)? This was our past finding - and why we disabled via our level shifter. (it is possible that we did this on another's M4 - our "escape" of interrupts dictated that we block UART input...)
Thanks Amit, it is a good idea. I will modify the code as your second suggestion. So, I will read the FIFO if any junk data has come, then I will send my command for the RF circuit and receive the expected data. I will use a loop up to 16 to read NonBlocking UART data. An example
////////////////////////////
for(int i=0; i<16; i++)
{
InJunk=UART_InCharNonBlocking(); //use non blocking not to stop the code at waiting forever in case there is no junk data.
}
//Send the command for RF circuit
//Read data from RF circuit
//////////////////////////
Regards,
Ahmed