cancel
Showing results for 
Search instead for 
Did you mean: 

ST32F103RB test UART for character?

Phill Harvey-Smith
Associate II
Posted on June 20, 2018 at 11:03

Hi All,

I'm just getting started with STM32 micros but have previously used Atmel AVRs in several projects (in both C and asm), so I'm not new to microcontrollers, just this platform

I'm currenbtly using the NEUCLEO-F103RB board.

I've been playing about with the Demo code to do UART send / recieve mostly using the HAL_ functions, however they have one significant disadvantage for recieving characters coming in over a serial link from a terminal, the need to know how many characters will be received in advance.

Is there a way of testing to see if there are characters ready (already recieved), before calling the polled recieve functions to get them, so that you can recieve the incoming stream a character at a time and implement things like backspace and line editing?

Or if there is a better way of doing this please be free to suggest it.

Cheers.

Phill.

1 REPLY 1
Posted on June 20, 2018 at 11:25

Is there a way of testing to see if there are characters ready (already recieved)

Yes - one character, by checking USART_SR.RXNE. I don't Cube so don't know its incantation for this. You may want to read the USART chapter in RM0008.

JW