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 โ†’