Skip to content

Boilerplate for integrating unit testing in a PIC32 environment

License

Notifications You must be signed in to change notification settings

crespum/Ceedling-PIC32

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Ceedling + PIC32 + Harmony boilerplate

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.

Prerequisites

The tests has just been run on Linux (Debian).

  1. Install MPLAB X IDE and IPE v3.61
  2. Install XC32 1.43 at /opt/microchip/xc32/v1.43/
  3. 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.
  4. Open MPLAB, go to Tools > Plugins Downloads and install the Harmony Configurator v1.0.10.0 DO NOT INSTALL v2
  5. Install ceedling using sudo gem install ceedling

These paths can be modified at the beginning of rakefile.rb.

Build and program the firmware using MPLAB

  1. Open MPLAB
  2. Click File > Open Project and go to the firmware folder and select the folder test_ceedling.X
  3. Right click on the project name (left panel) and click Set as Main Project
  4. 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.
  5. Now click Clean and build
  6. Finally, to upload the code click Make and Program Device Main Project

Build and program the firmware using Ceedling

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.

Build and run the unit tests

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.

Acknowledgements

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.

About

Boilerplate for integrating unit testing in a PIC32 environment

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published