UART_Printf Example Description

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

Then the SystemClock_Config() function is used to configure the system clock (SYSCLK) to run at 48 MHz.

- Board : NUCLEO-C071RB
- Tx Pin: PA.02: available through ST-Link
- Rx Pin: PA.03: available through ST-Link

LED1 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

- UART/UART_Printf/Inc/stm32c0xx_hal_conf.h    HAL configuration file
- UART/UART_Printf/Inc/stm32c0xx_it.h          IT interrupt handlers header file
- UART/UART_Printf/Inc/main.h                   Header for main.c module
- UART/UART_Printf/Src/stm32c0xx_it.c          Interrupt handlers
- UART/UART_Printf/Src/main.c                   Main program
- UART/UART_Printf/Src/stm32c0xx_hal_msp.c     HAL MSP module
- UART/UART_Printf/Src/system_stm32c0xx.c      STM32C0xx system source file

Hardware and Software environment

How to use it ?

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