Action
Clear serial input or output buffer
Syntax
CLEAR bufname
Remarks
Bufname |
Serialbuffer name such as Serialin, Serialin1 , Serialout or Serialout1 For chips with more UARTS : SERIALIN2, SERIALIN3, SERIALOUT2, SERIALOUT3 |
When you use buffered serial input or buffered serial output, you might want to clear the buffer.
While you can make the head pointer equal to the tail pointer, an interrupt could be active which might result in an update of the buffer variables, resulting in an unexpected result.
The CLEAR statement will reset the head and tail pointers of the ring buffer, and it will set the buffer count variable to 0. The buffer count variable is new and introduced in 1.11.8.3. It counts how many bytes are in the buffer.
The internal buffercount variable is named _RS_BUFCOUNTxy , where X is R for Receive, and W for Write, and y is 0 for the first UART, and 1 for the second UART.
The
See also
CONFIG SERIALIN, CONFIG SERIALOUT
ASM
Calls _BUF_CLEAR from MCS.LIB
Example
CLEAR SERIALIN