Skip to Content
Block descriptionsUSARTUSART AddToTransmitBuffer

USART AddToTransmitBuffer Block Description

This block is used to append data to the USART/UART transmit buffer in STM microcontrollers. To actually transmit the data accumulated in the buffer, you must use the USART Transmit block. There is an option to select between UART, USART, or LPUART interfaces.

Splitting this functionality into two separate blocks – one for adding data to the buffer and another for transmitting it – stems from how DMA transmission operates in non-blocking mode. In this mode, sending data can take longer than a single execution period of the function loop. Attempting to restart a transmission before the previous one completes would yield an error indicating that the DMA controller is busy. Utilizing two blocks allows you to first gather all required data into the buffer and then transmit it in a single operation.



USART AddToTransmitBuffer block

Table of Contents

Inputs

Input NameTypeDescription
Input lengthuint32Optional input
The amount of data to be transmitted. This input is optional and depends on the Enable input length parameter.
DataautoThe actual data to be transmitted.

Outputs

Output NameTypeDescription
Statusuint8Transmission status. Returns:
1 transmission successful
0 transmission failed

Block Parameters

ParameterDescription
USART/UART module numberNumber of the USART/UART module.
TypePeripheral interface type:
UART/USART - UART or USART interface
LPUART - LPUART interface
Number of transmissionsNumber of times the data transmission is repeated.
Enable input lengthEnables the Input length port.
Conditional Parameter
Input length
Fixed length of data to transmit in bytes. This parameter is only accessible when the Enable input length option is disabled.
Enable HeaderEnables adding a fixed header to the data frame.
Hex header formatDetermines how the header is interpreted. When enabled, the header is treated as a sequence of hexadecimal (hex) values; when disabled, it is treated as an ASCII character string.
HeaderAllows setting a fixed header for the data frame. It should be enclosed between [' and '].
Enable TerminatorEnables adding a fixed terminator to the data frame.
Hex terminator formatDetermines how the terminator is interpreted. When enabled, the terminator is treated as a sequence of hexadecimal (hex) values; when disabled, it is treated as an ASCII character string.
TerminatorThe terminator string used to filter received data frames. It should be enclosed between [' and '].
Timeout [ms]The time limit the system waits for the block execution to complete.


Block parameters for USART

CubeMX Configuration for a Given MCU Model

The interface configuration instructions are located on the subpage CubeMX Configuration for a Given MCU Model.

See Also

Last updated on