Main Content

UART/USART Read

Read data from the Universal Asynchronous Receiver Transmitter (UART/USART) port

Since R2022a

Add-On Required: This feature requires the Embedded Coder Support Package for STMicroelectronics STM32 Processors add-on.

  • UART read block

Libraries:
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32F3xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32F4xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32F7xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32G4xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32H7xx Based Boards (Dual-core)
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32H7xx Based Boards (Single-core)
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32L4xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32L5xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32U5xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32WBxx Based Boards

Description

Read serial data from the Universal Asynchronous Receiver/ Transmitter (UART/USART) port.

The UART/USART Read block outputs the read values as an [Nx1] array. You can specify the data type and the data length that you want to read using the block.

Ports

Output

expand all

Outputs the read data from the UART/USART port.

Data Types: int8 | uint8 | int16 | uint16 | int32 | uint32 | single | double | Boolean

The port outputs the number of elements received.

Dependencies

To enable this port, select the Output read length parameter.

Data Types: uint8

The status port outputs 0 i.e. no error in data reception or Success or any one of the bit values shown in the following table.

The table represents the bits and error associated with it.

Status

Bits1514131211109876543210
Error

X

X

X

X

X

X

ARBE_ERROR

RX_BUSY

TX_BUSY

TX_FAILED

RX_BUFFER_FULL

NOISE_ERROR

FRAME_ERROR

PARITY_ERROR

OVERRUN ERROR

DATA_NOT_AVAILABLE

Port outputs status 7(transmit failed) and 8(transmit busy)which are valid only for UART/USART Write blocks.

  • 0 — requested data length not received

  • 1 — represents overrun error

  • 2 — represents parity error

  • 3 — represents frame error

  • 4 — represents noise error

  • 5 — represents receive buffer full

  • 6 — represents transmit failed

  • 7 — represents transmit busy

  • 8 — represents receive busy

  • 9 — represents arbe error

Dependencies

To enable this port, select the Output status parameter.

Data Types: uint8

Parameters

expand all

Select the UART/USART module for the block.

Select the type of the data the block reads from the host. The size of each element depends on its data type.

Specify the data length to receive.

Specify the number of elements that you want to receive in each data length. The data length must be scalar values.

  • On - When you select this parameter, the read operation runs in the Blocking mode. The read operation is blocked while waiting for the requested data to be available. If data is available, the Data port outputs data. If data is not available, the Data port waits for data.

  • Off - When you clear this parameter, the read operation runs in the Non-blocking mode. When reading data, if data is not available, the Data port contains the data received in the previous time step. In this mode, the block does not wait for the requested data to be available.

Specify the time in seconds for blocking mode.

Dependencies

To enable this parameter, select the Enable blocking mode parameter.

The number of elements block received. When you select the Output read length parameter, the block configures an output port, length.

When you select the Output Status parameter, the block configures an output port, Status. The port outputs the status of UART/USART message.

Specify how often the block receives message, in seconds. When you specify this parameter as -1, Simulink® determines the best sample time for the block based on the block context within the model.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2022a