UART Config Block Icon
UART_Config Block The UART Config block configures a UART (Universal Asynchronous Receiver/Transmitter) module for serial communication. This block sets up baud rate, pin assignments, operating modes, and implementation methods for both transmit and receive operations.

Block Inputs/Outputs

Inputs: None (configuration block only)

Outputs: None (configuration block only)

This is a configuration block that sets up UART peripheral parameters. It does not have signal portsโ€”use UART Tx and UART Rx blocks for data transmission and reception.

Supported Device Families

FamilySeriesArchitecture IDNotes
dsPIC30F, 24F, 33F, 33E, 33C, 33A1, 2, 3, 4, 8Full support including IrDA on capable devices
PIC32MK, MZ, MX, PIC32AIncluded in dsPIC archStandard UART functionality
SAME7x, E5x, D5x, C2x, D2x5, 6, 7USART peripheral (SAMx callback variants)

Block Parameters

UART Selection
ParameterDescription
UART ModuleSelect UART/USART number (1 to N, depending on device)

Number of available UARTs detected automatically from selected chip.

Baud Rate Configuration
ParameterOptionsDescription
Baud Rate SelectionPopup list or CustomChoose from standard rates (110 to 12M baud) or enter custom value
Standard Rates110, 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, …Up to 12000000 baud on capable devices
Custom BaudUser-definedEnter any baud rate value (validated against FCY)
Init Sequence BaudSame optionsOptional different baud rate for initialization sequence
Operating Modes
ModeDescriptionAvailability
Full DuplexDefault mode - independent Tx and RxAll devices
Half DuplexOne-wire Rx-Tx (shared pin)All devices
IrDA ModeInfrared communication (requires IrDA encoder/decoder)Only on devices with UxMODE bit 12
Transmit (Tx) Implementation
ModeDescriptionUse Case
Do not implement TxNo transmit capabilityReceive-only applications
Simplest1, 4, or 8 byte internal buffer (device dependent)Low data rate, minimal overhead
Circular BufferSoftware circular buffer with interruptModerate data rate, reliable
DMA Ping-PongTwo DMA buffers alternatingHigh throughput, no data loss
DMA Circular BufferDMA with circular bufferContinuous streaming
DMA Single BufferSingle DMA buffer (possible data loss)High speed, can tolerate data loss
Receive (Rx) Implementation
ModeDescriptionUse Case
Do not implement RxNo receive capabilityTransmit-only applications
Simplest1, 4, or 8 byte internal bufferLow data rate polling
Circular BufferSoftware circular buffer with interruptReliable reception, moderate rate
DMA Ping-PongTwo DMA buffers alternatingHigh throughput reception
Pin Configuration
ParameterDescription
RX PinReceive data pin (remappable on PPS-capable devices)
TX PinTransmit data pin (remappable on PPS-capable devices)
CTS PinClear To Send (hardware flow control, optional)
RTS PinRequest To Send (hardware flow control, optional)
DTR PinData Terminal Ready (dsPIC CK/33A only)
DSR PinData Set Ready (dsPIC CK/33A only)
Advanced Options
ParameterDescription
Idle Time ControlInsert phantom bytes for idle time on Tx line (dsPIC CK only)
Initialization SequenceConfigure different settings at startup
External PIL CommunicationEnable for Processor-in-the-Loop testing

Registers Configured

dsPIC/PIC32 Registers

**``**``**``**``**``**

RegisterDescriptionConfigured Fields
UxBRG
UxMODE
UxSTA
UxBRGH
UxMODEH
UxSTAH

SAM Registers (USART)

SAM devices use USART peripheral with different register structure:

  • US_CR - Control Register
  • US_MR - Mode Register
  • US_BRGR - Baud Rate Generator
  • US_IER/IDR - Interrupt Enable/Disable

Usage Example

Basic UART Setup (9600 baud, Full Duplex)

  • Add UART Config block to model

  • Configure parameters:

  • UART Module: 1

  • Baud Rate: 9600

  • Duplex Mode: Full duplex

  • Tx Implementation: Circular Buffer

  • Rx Implementation: Circular Buffer

  • RX Pin: Select from dropdown (e.g., RP36/RB4)

  • TX Pin: Select from dropdown (e.g., RP37/RB5)

  • Add UART Tx block (same UART number)

  • Add UART Rx block (same UART number)

  • Build and deploy

High-Speed UART with DMA (115200 baud)

  • Configure UART Config block:

  • Baud Rate: 115200

  • Tx Implementation: DMA Ping-Pong Mode

  • Rx Implementation: DMA Ping-Pong

  • Ensure DMA channels are available on selected device

  • Configure buffer sizes in Tx/Rx blocks

Implementation Details

Baud Rate Calculation

For dsPIC/PIC32 devices: UxBRG = (FCY / (4 * BaudRate)) - 1 (BRGH = 1) UxBRG = (FCY / (16 * BaudRate)) - 1 (BRGH = 0) The block automatically selects BRGH mode for best accuracy.

Buffer Management

  • Circular Buffer: Size configurable in Tx/Rx blocks, uses interrupts
  • DMA: Requires DMA-capable device, minimal CPU overhead
  • Ping-Pong: Two buffers alternate, prevents data loss during buffer swap
  • [UART Tx] - Transmit data
  • [UART Rx] - Receive data
  • [UART TxMatlab] - MATLAB interface for testing
  • [UART Brk/Autobaud] - Break detection and autobaud

Troubleshooting

Baud Rate Error Too High

Problem: Desired baud rate cannot be achieved with acceptable error.Solution: Adjust system clock (FCY) or choose a different baud rate that divides evenly.

Pin Not Available

Problem: Selected pin not available for UART function.Solution: Check device datasheet for UART pin mapping. Ensure PPS is configured correctly on remappable devices.

DMA Not Working

Problem: DMA mode selected but not functioning.Solution: Verify device has DMA capability. Check DMA channel availability in model (other blocks may use DMA).

See Also

[Communication Blocks] | [UART Tx] | [UART Rx] | Code Generation