UART Tx

<< Click to Display Table of Contents >>

Navigation:  STM32F4 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?

uart_tx_blocking_block

What can be configured?

1. Blocking mode

1.1 Transmit Binary packet

This is configuration mode is to use UART Tx block as "Blocking" with "Binary" packet.

uart_tx_blocking_binary_mask

Configuration item

Selectable option/ Value

Description

UART Module

1| 2| 3| 4| 5| 6

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


1.2 Transmit Ascii packet

This is configuration mode is to use UART Tx block as "Blocking" with "Ascii" packet.

uart_tx_blocking_ascii_mask

Configuration item

Selectable option/ Value

Description

UART Module

1| 2| 3| 4| 5| 6

(See previous topic)

Transfer mode

Blocking| Non-Blocking

Note: This configuration mode is "Blocking"

(See previous topic)

Packet mode

Binary| Ascii| String Buffer

Note: This configuration is "Ascii"

(See previous topic)

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


1.3 Transmit ascii from String Buffer

This is configuration mode is to use UART Tx block as "Blocking" with "Ascii", the packet transmitting is from a String Buffer.

uart_tx_blocking_stringbuffer_mask

Configuration item

Selectable option/ Value

Description

UART Module

1| 2| 3| 4| 5| 6

(See previous topic)

Transfer mode

Blocking| Non-Blocking

Note: This configuration mode is "Blocking"

(See previous topic)

Packet mode

Binary| Ascii| String Buffer

Note: This configuration is "String Buffer"

(See previous topic)

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


2. Non-Blocking mode

This configuration mode is same as previous mode, but the difference is transmitting behavior.

Different behavior between transmit with Blocking and Non-Block

Blocking mode

uart_tx_blocking_behavior_mdl

 

uart_tx_blocking_behavior_pic

Non-blocking mode

uart_tx_nonblocking_behavior_mdl

 

uart_tx_nonblocking_behavior_pic

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

1.Host PC and Target
2.Host PC and Target hi-speed communication
3.Two boards communication, blocking mode
4.Two boards communication, non-blocking mode