USART_Communication_Tx_Init Example Description

This example shows how to configure GPIO and USART peripherals to send characters asynchronously to an HyperTerminal (PC) in Polling mode. If the transfer could not be completed within the allocated time, a timeout allows to exit from the sequence with a Timeout error code. This example is based on STM32C0xx USART LL API. Peripheral initialization is done using LL unitary services functions for optimization purpose (performance and size).

USART Peripheral is configured in asynchronous mode (115200 bauds, 8 data bit, 1 start bit, 1 stop bit, no parity). No HW flow control is used. GPIO associated to User push-button is linked with EXTI. Virtual Com port feature of STLINK could be used for UART communication between board and PC.

Example execution:

On press on push button , first character of buffer to be transmitted is written into USART Transmit Data Register (TDR) Program then starts polling on USART TXE flag before sending next character. On last character, program polls on TC flag to ensure transmit of last character is completed.

At completion of Tx Buffer sending, LED4 is turned On.

In case of errors, LED4 is blinking (1sec period).

Program is written so that, any new press on User push-button will lead to new transmission of complete buffer.

Keywords

Connectivity, UART/USART, Asynchronous, RS-232, baud rate, Polling, HyperTerminal, Transmitter

Directory contents

Hardware and Software environment

How to use it ?

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