2014-11-13 04:07 PM
Hello,
I need a way to flush the usart2 receive buffer . Will the following line do the trick or is it necessary to do something with the received rubbish bytes? // If buffer contains garbage, do nothing while (USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == SET); Kind Regards Bob2014-11-13 05:16 PM
Read the data register.
2014-11-14 01:51 AM
2014-11-14 01:54 AM
Hi Clive,
Thanks for the reply. I don't have a lot of memory left in order to create a thrash buffer so would this suffice....? If I do nothing as in my original suggestion, will the data not be clocked out eventually as in a fifo or must you actually read the data out to clear it....kinda basic question already which I've probably answered, but just need clarification. Bob . char rubbish[10]; int counter = 0; while (USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == SET){ rubbish[counter++] = USART1->RDR; if (counter == 9) counter = 0; }