Overview

Communication blocks provide serial interfaces for data exchange, sensor connectivity, and network integration. The MPLAB Blockset offers comprehensive support for UART (asynchronous serial), SPI (high-speed synchronous), I2C (multi-master bus), and CAN (automotive/industrial networking) protocols across all Microchip device families.

UART Blocks - Asynchronous Serial Communication

UART Config - UART Configuration and Initialization


UART Tx - UART Transmit


UART Rx - UART Receive


UART TxMatlab - UART Transmit to MATLAB


UART Break and Autobaud - UART Break Detection and Auto-Baud


SPI Blocks - Synchronous Serial Interface

SPI - SPI Master/Slave


I2C Blocks - Multi-Master Bus

I2C Master - I2C Master Controller


CAN Blocks - Controller Area Network

CAN Config - CAN Configuration


CAN Tx - CAN Transmit


CAN Rx - CAN Receive


Block Selection Guide

By Communication Protocol

ProtocolBlock(s)SpeedWiringBest For
UARTConfig + Tx + RxUp to 10 Mbps2-wire (TX/RX)Point-to-point, GPS, Bluetooth, debug console
SPISPI Master/SlaveUp to 50 Mbps4-wire (MOSI/MISO/SCK/CS)High-speed sensors, displays, SD cards
I2CI2C MasterUp to 1 Mbps2-wire (SDA/SCL)Multi-device bus, EEPROMs, sensors, RTCs
CANConfig + Tx + RxUp to 1 Mbps2-wire (CAN_H/CAN_L)Automotive, industrial networks, robust environments

By Application Requirements

ApplicationRecommended ProtocolBlock Choice
GPS ModuleUARTUART_Config + UART_Rx
Bluetooth ModuleUARTUART_Config + UART_Tx + UART_Rx
SD Card InterfaceSPISPI Master
IMU SensorSPI or I2CSPI (fast) or I2C (multi-device)
OLED DisplaySPI or I2CSPI (high-speed) or I2C (minimal wiring)
EEPROMI2CI2C Master
Real-Time ClockI2CI2C Master
Motor Control NetworkCANCAN_Config + CAN_Tx + CAN_Rx
Automotive ECUCANCAN_Config + CAN_Tx + CAN_Rx
MATLAB Data LoggingUARTUART_TxMatlab + picgui

By Device Family Capabilities

Device FamilyUARTSPII2CCAN
dsPIC30F✅ Up to 2✅ Up to 2✅ Up to 2✅ Up to 2
dsPIC33F✅ Up to 2✅ Up to 2✅ Up to 2✅ Up to 2
dsPIC33E✅ Up to 4✅ Up to 3✅ Up to 3✅ Up to 2
dsPIC33C✅ Up to 4✅ Up to 4✅ Up to 4✅ Up to 2
dsPIC33A✅ Up to 4✅ Up to 4✅ Up to 4✅ Up to 2
PIC24✅ Up to 2✅ Up to 2✅ Up to 2
PIC32MK✅ Up to 6✅ Up to 6✅ Up to 5✅ Up to 4
PIC32MZ✅ Up to 6✅ Up to 6✅ Up to 5✅ Up to 4
SAM E5x/D5x✅ Up to 6✅ Up to 8✅ Up to 8✅ CAN FD
SAM E7x/S7x/V7x✅ Up to 3✅ Up to 3✅ Up to 3✅ CAN FD (MCAN)

Note: Actual peripheral count is device-dependent. Consult datasheet for exact numbers.


Device Family Support Summary

Communication BlockdsPIC30FdsPIC33FdsPIC33EdsPIC33CdsPIC33APIC24PIC32SAM
UART_Config
UART_Tx
UART_Rx
UART_TxMatlab
SPI
I2C_Master
CAN_Config
CAN_Tx
CAN_Rx

Legend: ✅ Full Support | ❌ Not Available

Notes:

  • I2C: dsPIC30F uses different peripheral register structure, I2C_Master block designed for newer families
  • CAN: PIC24 devices typically lack CAN peripheral; SAM devices support CAN FD (MCAN)
  • Actual peripheral count varies by device. Consult datasheet for specific availability.

Protocol Comparison

Speed vs. Complexity

ProtocolMax SpeedWiresDevices per BusComplexityUse Case Priority
UART10 Mbps22 (point-to-point)🟢 Straightforward1. Debug console
2. GPS/Bluetooth
3. Sensors
SPI50 Mbps4Multiple (star)🟡 Moderate1. High-speed data
2. Displays
3. SD cards
I2C1 Mbps2127 (bus)🟡 Moderate1. Multi-sensor
2. EEPROM/RTC
3. Low-speed control
CAN1 Mbps2127 (bus)🔴 Advanced1. Automotive
2. Industrial
3. Noisy environments

Troubleshooting Common Issues

UART

Problem: No data received

  • Check: Baud rate matches on both sides
  • Check: TX/RX pins not swapped
  • Check: Ground connection between devices

Problem: Corrupted data

  • Check: Baud rate tolerance (< 2% error)
  • Check: Cable length (< 15 m for high speeds)
  • Check: Electrical noise (use shielded cable if needed)

SPI

Problem: No communication

  • Check: SPI mode (CPOL/CPHA) matches slave device
  • Check: Clock speed within slave specifications
  • Check: CS signal active during transaction

Problem: Data corruption

  • Check: Clock speed not too fast for slave
  • Check: Ground connection between master and slave
  • Check: Cable length (keep short, < 1 m for high speeds)

I2C

Problem: No acknowledgment from slave

  • Check: Pull-up resistors on SDA/SCL (typically 2.2 kΩ - 10 kΩ)
  • Check: Correct slave address (7-bit vs. 8-bit notation)
  • Check: Slave device powered and ready

Problem: Bus hangs or clock stretching

  • Check: Slave device not stuck (power cycle)
  • Check: Timeout settings in master
  • Check: Bus capacitance (shorter wires, fewer devices)

CAN

Problem: No messages received

  • Check: Bit rate matches network
  • Check: Termination resistors (120Ω at both ends)
  • Check: CAN_H and CAN_L not swapped
  • Check: Message filters configured correctly

Problem: Bus errors

  • Check: Electrical noise (use proper CAN cabling)
  • Check: Ground loops (ensure common ground)
  • Check: Maximum bus length not exceeded (40 m @ 1 Mbps)

See Also

Related Block Categories:

Application Notes:

  • AN1045 - Implementing a UART Bootloader in Software
  • AN1088 - CAN Bus Application Design
  • AN754 - Implementing I2C Multi-Master Mode

Example Projects:


💡 Quick Selection Guide:

  • Need point-to-point communication? → UART
  • Need high-speed data transfer? → SPI
  • Need multiple sensors on 2 wires? → I2C
  • Need robust automotive/industrial network? → CAN
  • Need MATLAB real-time logging? → UART_TxMatlab

UART

Universal Asynchronous Receiver/Transmitter blocks for serial communication with configurable baud rates, hardware flow control, and interrupt-driven or DMA data transfer.

Read more →

CAN

Controller Area Network blocks for robust automotive and industrial communication with configurable filters, masks, and multi-channel message handling.

Read more →

I2C Master - Communication Block

BUS I2C MASTER Block The BUS I2C Master block configures and executes I2C (Inter-Integrated Circuit) communication sequences as a bus master. This …

Read more →

SPI Master/Slave - Communication Block

BUS SPI Block The BUS SPI block configures and executes SPI (Serial Peripheral Interface) communication sequences as either Master or Slave. This …

Read more →