Example Path: examples/SPI/PicKitSerialSPIDemoBd
SPI PicKit Serial Demo Board Application
Overview
This application demonstrates the use of the Microchip PicKit Serial SPI Demo Board with NetBurner embedded systems using the DSPI API. The demo communicates with seven different SPI peripheral devices through an interactive serial menu, and serves a built-in web documentation page.
API
This application uses the NetBurner DSPI API for SPI communication:
- DSPIModule – SPI module instance configured per device (baud rate, chip select, clock polarity/phase)
- RegisterSem() – register a semaphore signalled when a transfer completes
- Start() – begin a SPI transfer with TX/RX buffers and chip-select control
Each peripheral is driven by its own DSPIModule instance because the devices run at different baud rates and clock modes.
Supported Platforms
- MODM7AE70 - SAME70 based module
- SBE70LC - SAME70 based single board computer
- SOMRT1061 - i.MX RT1061 based module
- MODRT1171 - i.MX RT1176 based module
- MOD5441X - MCF5441X ColdFire based module
- NANO54415 - MCF54415 ColdFire based module
SPI Peripherals Demonstrated
The application interfaces with the following Microchip SPI devices:
- 25LC020A EEPROM - 2Kbit (256 x 8) serial EEPROM
- TC77-5.0 - Thermal sensor with 3-wire SPI interface
- MCP3201 ADC - 2.7V 12-bit Analog-to-Digital Converter
- MCP4822 DAC - Dual 12-bit Digital-to-Analog Converter with internal 2.048V reference
- MCP41010 - 256-position single digital potentiometer
- MCP6S92 - Single-ended, rail-to-rail I/O, low-gain Programmable Gain Amplifier (PGA)
- MCP23S08 - 8-bit I/O expander connected to LEDs
Features
Web Interface
Access the built-in web page at http://<device-ip>/ for:
- SPI device table with part numbers and descriptions
- Serial console command reference
- Per-platform hardware connection guide
- DSPI API reference
Interactive Serial Menu
The application provides a serial console menu with the following options:
- 1 - Erase EEPROM (fill with 0xFF)
- 2 - Read EEPROM and display contents in hex format
- 3 - Write incrementing sequence to EEPROM (0x00, 0x01, 0x02...)
- A - Read ADC voltage value
- D - DAC ramp test on both channels (press any key to stop)
- G - Programmable Gain Amplifier (PGA) gain sweep
- T - Read temperature sensor (Fahrenheit, Celsius, Kelvin)
- P - Set digital potentiometer (prompts for wiper value 0-255)
- L - Toggle LEDs on the MCP23S08 GPIO expander
Hardware Pin Connections
The SPI pin map and peripheral selection (controller, chip select) for every supported platform live in SpiPinConfig.h, which UserMain() applies through a common set of SPI_CFG_*() macros. A few platforms also include commented-out alternate pinouts in that header (e.g. LPSPI1 on MODRT1171, LPSPI2 on SOMRT1061) that can be swapped in by commenting out the active set.
MODM7AE70 (P2 Header)
| Signal | Header Pin | Function |
| CS | P2[30] | SPI0 NPCS2 - Chip Select |
| SCK | P2[25] | SPI0 SPCK - Clock |
| MISO | P2[27] | SPI0 MISO - Data In |
| MOSI | P2[28] | SPI0 MOSI - Data Out |
SBE70LC (J1 Header)
| Signal | Header Pin | Function |
| CS | J1[14] | SPI0 NPCS0 - Chip Select |
| SCK | J1[7] | SPI0 SPCK - Clock |
| MISO | J1[6] | SPI0 MISO - Data In |
| MOSI | J1[4] | SPI0 MOSI - Data Out |
SOMRT1061 (Module Pins)
| Signal | Module Pin | Function |
| CS | Pin 26 | LPSPI1 PCS0 - Chip Select |
| SCK | Pin 27 | LPSPI1 SCK - Clock |
| MISO | Pin 24 | LPSPI1 SDI - Data In |
| MOSI | Pin 25 | LPSPI1 SDO - Data Out |
MODRT1171 (P1 Header)
| Signal | Header Pin | Function |
| CS | P1[43] | LPSPI5 PCS0 - Chip Select |
| SCK | P1[42] | LPSPI5 SCK - Clock |
| MISO | P1[45] | LPSPI5 SDI - Data In |
| MOSI | P1[44] | LPSPI5 SDO - Data Out |
MOD5441X (J2 Header)
| Signal | Header Pin | Function |
| CS | J2[30] | DSPI1 PCS0 - Chip Select |
| SCK | J2[25] | DSPI1 SCK - Clock |
| MISO | J2[27] | DSPI1 SIN - Data In |
| MOSI | J2[28] | DSPI1 SOUT - Data Out |
NANO54415 (Module Pins)
| Signal | Module Pin | Function |
| CS | Pin 15 | DSPI1 PCS0 - Chip Select |
| SCK | Pin 31 | DSPI1 SCK - Clock |
| MISO | Pin 33 | DSPI1 SIN - Data In |
| MOSI | Pin 35 | DSPI1 SOUT - Data Out |
Also connect GND and 3.3V to power the PicKit board.
Key Functions
EEPROM Operations (25LC020A)
- EepromWriteBuf() - Writes data with automatic 16-byte page boundary handling and write-enable/WIP polling
- EepromRead() - Reads data from the EEPROM
Sensor Reading
- GetTemp() - Reads the TC77 thermal sensor over its 3-wire SPI bus (tri-states MOSI to read, then restores it)
- ReadADC() - Reads the MCP3201 12-bit ADC and converts to voltage (3.3V reference)
- LoopDAC() - Ramps the MCP4822 dual DAC output on both channels until a key is pressed
Configuration / Control
- SetPotentiometer() - Sets the MCP41010 wiper position (0-255)
- SetPGA() - Sweeps the MCP6S92 amplifier through its gain settings
- ToggleLEDs() - Toggles the LEDs via the MCP23S08 GPIO expander
Technical Details
3-wire SPI (TC77)
The TC77 temperature sensor shares MOSI and MISO on a single data line. Before reading the sensor the example tri-states the MOSI pin, performs the read, then restores the pin to its SPI function. The 13-bit signed temperature reading is sign-extended before scaling at 0.0625 degrees C per LSB.
Data Conversion
- ADC values are converted to voltage (3.3V reference, 12-bit resolution)
- DAC values support a 0-2.048V reference with 2x output gain (10-bit ramp in this example)
- Temperature is reported in Fahrenheit, Celsius, and Kelvin
Usage Instructions
- Connect the Microchip PicKit Serial SPI Demo Board to your NetBurner development board's SPI pins (CS, SCK, MISO, MOSI, GND, 3.3V) per the table above
- Compile and load the application onto your target platform
- Access the web interface at http://<device-ip>/ for documentation
- Connect to the serial console (typically 115200 baud)
- Use the interactive menu to test different SPI peripherals
Troubleshooting
If the TC77 read reports "Error: TC77 not detected":
- Verify the PicKit board is properly connected
- Confirm the MISO/MOSI wiring matches the table for your platform
- Ensure correct voltage levels (3.3V)
Requirements
- NetBurner development tools and runtime system
- Microchip PicKit Serial SPI Demo Board
- Compatible NetBurner hardware platform
Project Structure
PicKitSerialSPIDemoBd/
+-- src/
| +-- main.cpp - Main application code
| +-- SpiPinConfig.h - Per-platform SPI pin map & peripheral selection
| +-- htmldata.cpp - Auto-generated web content
+-- html/
| +-- index.html - Web documentation page
| +-- style.css - Self-contained stylesheet
| +-- logo.png - NetBurner logo
+-- makefile - Build configuration
+-- ReadMe.txt - This file