Peripheral Library Code Examples


This directory contains PIC32 Peripheral Library code examples for MPLAB XC32 C compiler. This directory may contain more than one code example.
Each code example directory contains complete source code and MPLAB project files. The remainder of this document provides a brief overview of each example

Peripheral Library Examples

Note: These examples use peripheral library binaries distributed with MPLAB XC32.

Peripheral/Topic

Example Name

Path

Description

Operation in IDLE mode

operate_in_idle_mode

operate_in_idle_mode

Configures Timer1 to operate in IDLE mode, places CPU in IDLE mode and uses Timer1 interrupt to exit the IDLE mode.

A/D Converter

adc10_basic

adc10/adc10_ basic

Converts 2 analog inputs

Bus Matrix

bmx_ basic

bmx/bmx_ basic

Partitions RAM in user and kernel mode

Analog Comparator

cmp_ basic

cmp/cmp_ basic

Configures comparator in simple mode

Comparator Voltage Reference

cvref_basic

cvref/cvref_ basic

Generates a triangle wave on CVref output pin

DMA Controller

led_txfer

dma/led_txfer

Blink LED on an Explorer16 board using the DMA and a pattern stored in Flash.

pmp_txfer

dma/pmp_txfer

Performs a transfer from RAM to the PMP port

crc_calculation

dma/crc_calculation

Calculates CRC of flash memory using DMA CRC method

m2m_copy

dma/m2m_copy

Copies data from one memory region to another memory region

uart_echo

dma/uart_echo

Uses DMA channel to receive and transmit UART data

spi_txfer

dma/spi_txfer

Uses DMA channel to receive and transmit SPI data

I2C

i2c_master

I2c/i2c_master

Interfaces to Microchip serial EEPROM 24LC256 as an I2C master

Input Capture

incap_capture_event

incap/incap_capture_event

Captures and time stamps an external event

Interrupts

int_multi_vector

int/int_multi_vector

Uses Multi-vector interrupt mode

int_single_vector

int/int_single_vector

Uses Single-vector interrupt mode

NVM Controller

nvm_simple

nvm/nvm_simple

Erases, writes, and verifies a block of flash program memory

Output Compare

ocmp_simple_pwm

ocmp/ocmp_simple_pwm

Generates a PWM waveform

Oscillator

osc_basic

osc/osc_basic

Changes SYSCLK and PBCLK divider values while CPU is running

Prefetch-Cache

pcache_init

pcache/pcache_init

Configures Prefetch-Cache for basic operation

 

pcache_stat

pcache/pcache_stat

Demonstrates the effect of Prefetch cache code execution

Parallel Master Port

pmp_master_mode2

pmp/pmp_master_mode2

Writes a block of data to an external memory using master mode 2 & 16-bit configuration

Ports

ports_basic

ports/ports_basic

Exercises all features of PORT I/O pins

 

blinky_leds

ports/blinky_leds

Blinks LEDs on Explorer-16 board

Power Modes

power_basic

power/power_basic

Configures CPU to wakeup from SLEEP using Watchdog timer

RESETs

reset_basic

teset/reset_basic

Demonstrates how application can detect various RESET conditions

RTCC

alarm

ttcc/alarm

Demonstrates RTCC alarm feature

time_date

ttcc/time_date

Configures RTCC for current time and date

SPI

burst_master

spi/burst_master

Performs burst data transfer in a master mode

burst_slave

spi/burst_slave

Performs burst data transfer in a slave mode

loopback

spi/loopback

Performs SPI loopback test

master_slave

spi/master_slave

Uses two SPI channels to establish master/ & slave connection

Timers

core_timer_int

yimer/core_timer_int

Configures core timer to generate recurring interrupt

timer1_int

timer/timer1_int

Configures Timer1 to generate recurring interrupt

UART

uart_basic

uart/uart_basic

Uses UART in polling mode to send and receive data

uart_interrupt

uart/uart_interrupt

Uses UART to do interrupt-driven receive and polled transmission

Watchdog Timer

wdt_basic

wdt/wdt_basic

Demonstrates simple WDT usage

 


Microchip Technology Inc. 2355 W. Chandler Blvd. Chandler, AZ 85224