UART Tx

<< Click to Display Table of Contents >>

Navigation:  STM32F0 Target > Block References > On-chip Peripherals > UART >

UART Tx

Previous pageReturn to chapter overviewNext page

User Interface

How this block appears in a Simulink model?

stm32f0_uart_tx_block

What can be configured?

1. Ascii mode

stm32f0_uart_tx_ascii_mask

Configuration item

Selectable option/ Value

Description

UART Module

1| 2| 3| 4

Select UART/ USART module to receive the Rx data from

Transfer mode

Blocking| Non-Blocking

Note: This configuration mode is "Blocking"

Blocking: The block will wait until all bytes in a packet transmit before goto next process.

Non-Block: After writing transmit packet data, the block will not wait until transfer finish. The packet transmitting will handled by DMA module.

Packet mode

Binary| Ascii| String Buffer

Note: This configuration is "Ascii"

Binary: This mode is transmit the binary packet.

Ascii: This block will generate a ascii buffer packet using sprintf, input data to port is parameter to sprintf corresponding to format specifier.

String Buffer: The block transmit data from String Buffer.

Format

Ascii format pattern for sscanf

Example: "Value=%d"

Scanf format specifier, start with %. Below is supported by block.

%u, %i, %d, %o, %x : sscanf output will be type of uint32

%e, %g, %f : sscanf output will be type of single

%s : sscanf output will be type of string. Note: output buffer of %s will be limit to 127 charactor maximum, so recommended to use %127s instead of %s.

%c : sscanf output will return int8

Terminator

LF| CR| CRLF

(Specify the terminator pattern of packet to receive)

 

Terminator in ascii mode is used for specify the end of packet.

Sample Time (sec)

Sample time configuration of a block


2. Binary mode

stm32f0_uart_tx_binary_mask

Configuration item

Selectable option/ Value

Description

UART Module

1| 2| 3| 4

Select UART/ USART module to receive the Rx data from

Transfer mode

Blocking| Non-Blocking

Blocking: The block will wait until all bytes in a packet transmit before goto next process.

Non-Block: After writing transmit packet data, the block will not wait until transfer finish. The packet transmitting will handled by DMA module.

Packet mode

Binary| Ascii| String Buffer

Note: This configuration is "Binary"

Binary: This mode is transmit the binary packet.

Ascii: This block will generate a ascii buffer packet using sprintf, input data to port is parameter to sprintf corresponding to format specifier.

String Buffer: The block transmit data from String Buffer.

Header

(Specify the Header pattern of packet to transmit)

Example: If a packet contains 2 bytes of header, [0x7E 0x7E]

Writing header bytes to specify the start of packet.

Number of data port, type DOUBLE

(Number of data type double in transmitting packet)

1 data port of this data type will extracted to 8bytes in transmit packet.

Number of data port, type SINGLE

(Number of data type single in transmitting packet)

1 data port of this data type will extracted to 4bytes in transmit packet.

Number of data port, type INT8

(Number of data type int8 in transmitting packet)

1 data port of this data type will extracted to 1byte in transmit packet.

Number of data port, type UINT8

(Number of data type uint8 in transmitting packet)

1 data port of this data type will extracted to 1byte in transmit packet.

Number of data port, type INT16

(Number of data type int16 in transmitting packet)

1 data port of this data type will extracted to 2bytes in transmit packet.

Number of data port, type UINT16

(Number of data type uint16 in transmitting packet)

1 data port of this data type will extracted to 2bytes in transmit packet.

Number of data port, type INT32

(Number of data type int32 in transmitting packet)

1 data port of this data type will extracted to 4bytes in transmit packet.

Number of data port, type UINT32

(Number of data type uint32 in transmitting packet)

1 data port of this data type will extracted to 4bytes in transmit packet.

Terminator

(Specify the terminator pattern of packet to transmit)

Example: If a packet contains 2 bytes of terminator, [0x03 0x03]

Use terminator bytes to specify end of packet.

Sample Time (sec)

Sample time configuration of a block


3. String Buffer mode

stm32f0_uart_tx_stringbuffer_mask

Configuration item

Selectable option/ Value

Description

UART Module

1| 2| 3| 4

Select UART/ USART module to receive the Rx data from

Transfer mode

Blocking| Non-Blocking

Note: This configuration mode is "Blocking"

Blocking: The block will wait until all bytes in a packet transmit before goto next process.

Non-Block: After writing transmit packet data, the block will not wait until transfer finish. The packet transmitting will handled by DMA module.

Packet mode

Binary| Ascii| String Buffer

Note: This configuration is "String Buffer"

Binary: This mode is transmit the binary packet.

Ascii: This block will generate a ascii buffer packet using sprintf, input data to port is parameter to sprintf corresponding to format specifier.

String Buffer: The block transmit data from String Buffer.

Buffer

Select String Buffer name to transmit

Note: The buffer name will available for selection when drop the volatile data storage block with configure type as string.

Terminator

LF| CR| CRLF

(Specify the terminator pattern of packet to receive)

 

Terminator in ascii mode is used for specify the end of transmit packet.

Sample Time (sec)

Sample time configuration of a block


When to use this block?

Use this block to transmit data to UART when application need communication between device to device via UART protocol.

How does this block work?

The block using DMA buffer of the specified UART module to handle data transmit.

Demos

UART demo