Programming the UART1 peripheral in STM32F1 controller for bi-directional communication. Echo characters received from UART and transmit time elapsed since boot every 5 seconds.
STM32F1 Blue pill is a versatile board and can be programmed in various ways. I have created following variations of this project which differs in programming language, use of RTOS and framework. Clone the repository and follow steps mentioned in the respective variations for building and flashing.
The controller has 3 USART peropherals with varying functionality. The peripheral registers can be accessed as half word (16 bit) as well as words (32 bit).
This project uses USART1 with pinc PA9 and PA10 for demonstration.
Connect the board with host through USB to TTL converter (FTDI board in our case). The connections are described as follows.
Pin on Blue Pill | Pin on FTDI |
---|---|
PA9 | Rx |
PA10 | Tx |
Gnd | Gnd |
The application prints time elapsed since boot in interval of 5 seconds. Configure serial onitor on host for 9600 baudrate to be able to read and write to blue pill using uart. Following output can be observed on UART.
Click in Run and Debug
option in VsCode sidebar. Then launch Cortex Debug
target.
Happy debugging....