All posts
41 posts, newest first. The home page has the same posts grouped by topic.
2024
-
Using USB Endpoint 0 in host mode and how to send handshakes and request packets
How to use the USBE0CSR0 handshake bits in USB host mode to send setup packets, request data and complete status stages on endpoint 0.
-
USB Host HID Keyboard
Harmony-free PIC32MZ USB host code that reads an HID boot keyboard, handles shift, caps lock, LEDs and key repeat, and outputs to UART4.
-
USB HID Host
A short announcement that the PIC32MZ USB peripheral now works in host mode with an HID keyboard, without any Harmony code.
2022
-
USB HID joystick: schematic, code and KiCad files
The schematic, board render, C source code and KiCad files for the author's PIC32MZ USB HID joystick.
-
USB HID joystick: it works
A short announcement that the author's PIC32MZ USB HID joystick works, with KiCad files and source code promised in a few days.
2021
-
How to make a USB Mass Storage Device part 2
How to implement USB mass storage Read(10) and Write(10) with multi-block SD card transfers, double buffering and USB DMA for faster speeds.
-
Using the PIC32MZ EF USB module in host mode
How to start the PIC32MZ USB module in host mode, catch device connection, reset the device and exchange setup packets on endpoint 0.
2020
-
How to make a USB Mass Storage Device part 1
A reference to the SCSI commands, CBW and CSW structures, and Request Sense error handling needed for a USB mass storage device.
-
USB MSD code
Downloadable PIC32MZ USB mass storage device code that exposes an SPI-connected SD card to the PC, with the pin settings to change.
-
USB progress update
A progress note on a working USB HID keyboard and an SD card USB mass storage device reaching about 3.8 MB/s reads.
-
Finishing the USB CDC device
How to finish a PIC32MZ USB CDC device: handling endpoint 0 requests, setting the address, and echoing data over bulk endpoint 2.
-
USB descriptors and how to send and receive data on endpoint 0
How to receive setup packets and send device, configuration and string descriptors on USB endpoint 0, including byte-wide FIFO access.
-
Initialising the USB peripheral
How to initialise the PIC32MZ USB peripheral in High Speed device mode, handle the reset interrupt, and configure endpoints, FIFOs and transfer types.
-
USB
Downloadable Harmony-free USB CDC virtual COM port code for the PIC32MZ, with a descriptor fix and the reference sources used.
-
A quick update!
A short site update after a 10-month break, explaining the slowdown and promising replies to comments and some new schematics.
2019
-
Choosing which pins to use on a PIC32MZ project
A worked method for assigning PIC32MZ pins for I2S, SPI, I2C and UART peripherals, checking fixed pins, PPS options and errata first.
-
Shared pins on the PIC32MZ's ADC
A caution that PIC32MZ ADC inputs AN45 to AN49 share ADC0 to ADC4 with AN0 to AN4, so each pair cannot be sampled together.
-
ADC on the PIC32MZ
How the PIC32MZ ADC input classes work and how to set up and software-trigger class 1 inputs AN0 to AN2, step by step.
-
Powerbeats Pro Rant / Review
A user review of the Powerbeats Pro paired with a Galaxy Watch, describing volume resets, unwanted reconnections and weak Bluetooth range.
-
SQI on the PIC32MZ
How the PIC32MZ SQI peripheral and its buffered registers work, with examples reading ID and writing data to a PSRAM in single and quad-lane mode.
-
My PIC32MZ Dev Board
A tour of the author's 100 mm PIC32MZ dev board with its peripherals, PCB ordering tips, bill of materials, Gerber and Eagle files.
-
Updated SPI SD DMA code and DMA Pattern Matching
An updated, more stable SPI SD card DMA driver with board settings in mmcpic32.h, a read callback, and notes on pattern matching leftovers.
-
DMA SD card reads on the PIC32MZ
How to read SD card blocks over SPI using two PIC32MZ DMA channels, with pattern matching for the 0xFE token and a state machine.
-
Direct Memory Access on the PIC32MZ
An introduction to PIC32MZ DMA: coherent buffers, virt_to_phys addresses, IRQ-triggered transfers to the PMP, completion interrupts and pattern matching.
-
Working on DMA
A progress note on DMA-based SD card reads, with a speed comparison chart and early mmcpic32_dma.c code reaching about 5 MB/s.
2018
-
I2C on the PIC32MZ
How the I2C protocol works and how to write I2C1 master start, stop, read and write functions on the PIC32MZ, tested on an MPU-9250.
-
I2S and Reference Clocks on the PIC32MZ
How to drive a CS4334 DAC over PIC32MZ I2S, using Reference Clock Output 1 for MCLK and the SPI baud rate generator for SCLK.
-
The difference between PWM and an I2S DAC
A short preview comparing oscilloscope captures of PWM audio, RC-filtered PWM audio and a CS4334 I2S DAC output.
-
Playing MP3s using PWM audio
How to decode SD card MP3 files with the Helix decoder and play them in stereo through two PWM channels using a circular buffer.
-
Using Pulse Width Modulation (PWM) to play audio
How to play 44.1 kHz 8-bit audio through a PWM Output Compare channel driven by a timer interrupt, and smooth it with RC low-pass filters.
-
Pulse Width Modulation (PWM) and servos on the PIC32MZ
How to generate hardware PWM with the PIC32MZ Output Compare module and Timer 2, and use it to position a hobby servo motor.
-
Timers and Interrupts on the PIC32MZ
How PIC32MZ timers, period registers and prescalers work, and how to write a multi-vectored Timer 2 interrupt handler that toggles a pin at 1 kHz.
-
PMP and LCDs on the PIC32MZ
How to configure the Parallel Master Port in master mode 2 and use it to drive a 16-bit SSD1963 LCD and draw an RGB565 image.
-
Update and posts to come
A site update showing the author's new PIC32MZ dev board and listing planned posts on interrupts, PMP, PWM audio, I2S, I2C, MP3 and USB.
-
FATFS on the PIC32MZ
Step by step setup of the FatFs library with an mmcpic32.c SPI driver to read files from an SD card on the PIC32MZ.
-
SPI on the PIC32MZ
How SPI works and how to set up PIC32MZ SPI2 at 50 MHz, covering PPS pins, the baud rate formula and Enhanced Buffer mode.
-
UART and Peripheral Pin Select (PPS) on PIC32MZ
How to map UART5 to pins with Peripheral Pin Select, calculate the baud rate from PBCLK2, and redirect printf by overriding _mon_putc.
-
Delays on PIC32MZ
How to write millisecond and microsecond delay functions using the PIC32MZ Core Timer, with no timer peripheral setup, then blink an LED.
-
A PIC32MZ program skeleton
A reusable PIC32MZ program skeleton covering the usual startup traps: ANSEL analog defaults, JTAG stealing port A pins, and watchdog and debug fuses.
-
Configuration without Harmony 1
How to set the PIC32MZ PLL configuration fuses, peripheral bus clock dividers, prefetch and cache to run at 200 MHz without Harmony, line by line.
-
A world without Harmony
Why this blog exists: plain-register PIC32MX and PIC32MZ examples for hobbyists who want to avoid PLIB, Harmony and expensive dev boards.