UART_Printf Example Description

Re-routing of the C library printf function to the UART. The UART outputs a message on the HyperTerminal.

Board: NUCLEO-C031C6

LED4 toggles when there is an error.

The USART is configured as follows:

- BaudRate = 115200 baud
- Word Length = 8 Bits (7 data bit + 1 parity bit)
- One Stop Bit
- Odd parity
- Hardware flow control disabled (RTS and CTS signals)
- Reception and transmission are enabled in the time

Notes

  1. When the parity is enabled, the computed parity is inserted at the MSB position of the transmitted data.

  2. Care must be taken when using HAL_Delay(), this function provides accurate delay (in milliseconds) based on variable incremented in SysTick ISR. This implies that if HAL_Delay() is called from a peripheral ISR process, then the SysTick interrupt must have higher priority (numerically lower) than the peripheral interrupt. Otherwise the caller ISR process will be blocked. To change the SysTick interrupt priority you have to use HAL_NVIC_SetPriority() function.

  3. The application needs to ensure that the SysTick time base is always set to 1 millisecond to have correct HAL operation.

Keywords

Connectivity, UART/USART, Printf, baud rate, RS-232, HyperTerminal, full-duplex, Interrupt, Transmitter, Receiver, Asynchronous

Directory contents

Hardware and Software environment

How to use it ?

In order to make the program work, you must do the following :