When to use:
When NOT to use:


33AK512MPS512Inputs: None (receives from hardware UART peripheral)
Outputs:
| Port Name | Data Type | Size | Description | Optional |
|---|---|---|---|---|
| Nbr | uint8/uint16 | Scalar | Number of bytes received (buffer fill level) | Yes (enable via Flag_Out parameter) |
| Rx | uint8 | Scalar or Vector N | Received data (configurable size) | No (always present) |
| Parameter | Options | Description |
|---|---|---|
| Rx_Size_popup | User defined | Inherited via back propagation |
| Rx_Size | Positive integer or [] | User-defined size (when Rx_Size_popup = “User defined”) |
Explicitly set output vector size:
Rx_Size = 1: Scalar output (single byte)Rx_Size = N: Vector output N x 1Rx_Size = []: Treated as “Inherited via back propagation”Output size determined by connected downstream block requirements. Simulink propagates size backward from output port connection.
Automatically calculate optimal buffer size based on:
Formula:
Rx_Size = ceil((Baud_Rate / 10) * Sample_Time) + Buffer_Margin
| Parameter | Options | Description |
|---|---|---|
| Flag_Out | On/Off checkbox | Enable ‘Nbr’ output port (number of bytes received) |
| OutputDefault_popup | Fill-in output vector with specified value | Add one trailing 0 |
| OutputDefault | Numeric value (e.g., 0, 255) | Fill value when OutputDefault_popup = “Fill-in” |
OutputDefaultThe block outputs uint8 data values directly from the UART receive buffer.
| Output Type | Range | Description |
|---|---|---|
| uint8 | 0 to 255 | Raw received byte data |
Note: Output vector size is configurable via Rx_Size parameter or can be automatically determined based on baud rate and sample time.
Reception behavior depends on the implementation mode selected in the UART Config block:
| Mode ID | Implementation | Description | Hardware FIFO |
|---|---|---|---|
| 0 | Not Configured | RX disabled in UART Config | N/A |
| 1 | Bare (Simplest) | Direct read from hardware FIFO/buffer | 1/4/8 bytes (device dependent) |
| 2 | Circular Buffer | Software buffer with interrupt-driven reception | Plus user-defined circular buffer |
| 3 | DMA Ping-Pong | Two DMA buffers alternating (SAM only) | DMA with ping-pong buffers |
| 4 | DMA Single Buffer | Not implemented for RX | N/A |
| 6 | DMA Circular Buffer | DMA refills a circular buffer in Repeated One-Shot mode with no per-byte Rx interrupt (zero CPU-side Rx ISR). Supported on dsPIC33CK/CH/CDV/AK/AKV (gated on the DMA RELOAD feature). Select it in UART Config โ Rx Implementation = DMA Circular Buffer; the choice persists across model save/reopen. | DMA + circular buffer, no Rx ISR |
Lowest-CPU reception. The DMA Circular Buffer Rx mode moves every received byte into the software circular buffer by DMA hardware, so there is no Rx interrupt per byte โ ideal for sustained high-baud links (e.g. XCP External Mode, telemetry). It is also the recommended Rx path for External Mode on supported dsPIC targets.
If no UART Config block is found for the selected UART:
Problem: Rx output size doesn’t match downstream block requirements.Solutions:
| Family | Series | Architecture ID | Implementation Files |
|---|---|---|---|
| dsPIC | 30F, 24F, 33F, 33E, 33C, 33A | 1, 2, 3, 4, 8 | PIC bare, Interrupt (Circular Buffer) |
| PIC32 | MK, MZ, MX, PIC32A | Included in dsPIC arch | Same as dsPIC (PIC implementations) |
| SAM E7x/S7x | SAME70, SAMS70, V71, PIC32CZ MC70 | 5 | SAMx7 bare, Interrupt, DMA ping-pong |
| SAM E5x/D5x | SAME5x, SAMD5x | 6 | SAMx5 bare, Interrupt, DMA ping-pong |
| SAM C2x/D2x | SAMC2x, SAMD2x, SAMDA1 | 7 | SAMx5 implementations (shared) |
Add UART Config block (configure for UART 1, Circular Buffer Rx)
Add UART Rx block
Configure UART Rx:
UART Module: 1
Rx_Size_popup: “User defined”
Rx_Size: 10
Flag_Out: On (monitor bytes received)
OutputDefault_popup: “Fill-in output vector with specified value”
OutputDefault: 0
Connect Rx output [10x1] to downstream processing
Monitor Nbr output to see actual bytes received (0-10)
UART Config: UART 1, 115200 baud, Circular Buffer (256 bytes)
UART Rx block:
UART Module: 1
Rx_Size_popup: “Inherited via internal rule”
SampleTime: 0.01 (10 ms)
Block automatically calculates:
Baud throughput: 115200 / 10 = 11520 bps
Bytes per sample: (11520 * 0.01) / 8 โ 144 bytes
Configure UART Rx:
Rx_Size_popup: “User defined”
Rx_Size: 64 (max string length)
Flag_Out: On
OutputDefault_popup: “Add one trailing 0”
Received string automatically null-terminated
Use Nbr output to find actual string length
Compatible with C string functions
UART Rx configuration:
Rx_Size_popup: “Inherited via back propagation”
Rx_Size: [] (or any value, ignored)
Connect Rx output to a block requiring [20x1] input
Simulink automatically sets Rx port size to [20x1]
No manual sizing needed
% Add block to model
add_block('MCHP_Blockset/BUS UART/UART Rx', [mdl '/UART_Rx']);
% Configure key parameters
set_param([mdl '/UART_Rx'], 'UART_REF', '1');
set_param([mdl '/UART_Rx'], 'Rx_Size', '16');
Problem: UART Rx block present but Rx output always zero/empty.Solutions:
Problem: Some bytes missing from received data.Solutions:
Problem: Rx output vector has unexpected values in unused positions.Solutions:
Reads directly from hardware FIFO:
data[i] = U%RXREG; /* Direct read from receive register */