This project intends to be a boilerplate for integrating unit testing in a PIC32 environment. It contains a sample unit test for a Neopixel. The I2C drivers have also been enabled using Harmony to show how to compile and link them.
The tests has just been run on Linux (Debian).
- Install MPLAB X IDE and IPE v3.61
- Install XC32 1.43 at
/opt/microchip/xc32/v1.43/
- Install Harmony v1.11 at
/opt/microchip/harmony/v1_11/
. Be careful not to use version 2.x which is currently in a beta stage. - Open MPLAB, go to Tools > Plugins Downloads and install the Harmony Configurator v1.0.10.0 DO NOT INSTALL v2
- Install ceedling using
sudo gem install ceedling
These paths can be modified at the beginning of rakefile.rb
.
- Open MPLAB
- Click File > Open Project and go to the firmware folder and select the folder test_ceedling.X
- Right click on the project name (left panel) and click Set as Main Project
- Now we need to generate the Harmony related files. Go to Tools > Embedded > MPLAB Harmony Configurator and once inside click the button in the top to generate the code.
- Now click Clean and build
- Finally, to upload the code click Make and Program Device Main Project
Please note that MPLAB X IPE is required to program the target.
rake release
generates the.elf
output.rake convert
converts the.elf
intto a.hex
file.rake program
uploades the.hex
to the target hardware using a PICKit 3.
There are some basic commands for executing ceedling from $PROJECT_PATH/firmware
:
rake test:all
runs all tests in the MPLAB-SIM Simulator using the Microchip Debugger (MDB).rake release
generates the.elf
output.rake convert
converts the.elf
intto a.hex
file.rake program
uploades the.hex
to the target hardware using a PICKit 3.
The main tools used here (Ceedling, Unity and CMock) have been developed by the Throw The Switch community. Thanks for your work!
The project is based on this repository for 16 bit PICs. A detailed explanation of how to setup this project can be read in this other blog post.
The book Test-Driven Development for Embedded C by James W. Grenning is a great introduction to Unit Testing in embedded devices. Some other people has also written great posts on this topic.