10 years, 6 months ago.

I am using the serial port on FRDM kl25z and is there any way to flush the receive buffer?

/media/uploads/CraciunCP91/si_testare_kl25z_-1-.bin

2 Answers

10 years, 6 months ago.

If you want to share code either publish it, or if it is a small program copy paste the code. We cannot see what you have in a bin file.

Why would you want to flush the receive buffer? AFAIK it isn't possible, however it also only has a length of like two. Here is how the MODSERIAL version for the KL25 does it: http://mbed.org/users/Sissors/code/MODSERIAL/file/f42def64c4ee/Device/MODSERIAL_KL25Z.h, simply reading until it is empty.

10 years, 6 months ago.

Sorry for bin file. I was in a hurry, i didn't realize. The thing is I'm using something like Serial mySerial(pintx, pinrx); after i receive one character , i'm getting it with mySerial.getc() and then i want to flush the buffer.

With the KL25 the only nice way I am aware of is simply reading until the buffer is empty. There is no special flush option, because it is only a very small buffer. It might be possible to reset the entire peripheral, but that is not what I would call a good solution to flush two registers.

posted by Erik - 31 Oct 2013