Cerebot MX4cK Resources

Software and Documentation for the Digilent Cerebot MX4cK


The Cerebot MX4cK is a microcontroller development board based on the PIC32 microcontroller. This page provides resources and source code for using basic features of the MX4cK. Example programs were developed using MPLAB X and are written in C.
Note: (from site)=resource copied from site, (at site)=link to resource at site

Cerebot MX4cK product page  (at DigilentInc.com)
DigilentInc.com manufactures the Cerebot MX4cK
Microchip.com manufactures the PIC32 microprocessor on the MX4cK
freeRTOS.org a free open source RTOS used in projects on this page

Cerebot MX4cK Hardware

MX4cK Specification PDF (from Digilent)
MX4cK IO Pin Out Diagram PDF   -   (quickview)
Editable SVG version of the MX4cK IO Pin Out Diagram - zipped    (Free SVG Editor inkscape.org)
PIC32 Data Sheet PDF (from Microchip)
See below for additional resources

MPLAB X Development System

MPLAB X is a cross platform Integrated Development Environment (IDE) for Microchip processors. MPLAB X is based on NetBeans and runs under Java. MPLAB X supports the XC32 compiler (based on GCC) and communicates with the programmer and license debugger built into the MX4cK. MPLAB X allows source level debugging on the MX4cK and includes a simulator. Currently the simulator is slow and is only practical for simple programs. All of these tools are free.

To download these tools visit the Microchip MPLAB X development tools site and click on the download tab near the center of that page. Install MPLAB X first. Then install XC32. The XC32 free mode was used in all the projects. The MPLAB X installation includes its own private version of the Java VM.

MPLAB X and XC32 Downloads   Select download tab near center of page
MPLAB X Users Guide PDF (from Microchip.com)
XC32 Compiler Users Guide PDF (from Microchip.com)
XC32 Compiler Perpherial Guide PDF (from Microchip.com)
MPLAB X IDE Wiki and Developers Center
MPLAB Archives

Important: The version of freeRTOS used in the examples on this page will not link correctly using XC32 v1.3. A fix is described here or download and install XC32 v1.21 (at Microchip.com archive).


FreeRTOS is a free open source real-time operating system for embedded systems. It supports many processors, included the PIC32 used in the MX4cK. The OS is well supported and has a very lenient licensing agreement. Minimal, but adequate, documentation for the OS is available one line. Detailed documentation in a PDF is available form the developers for a modest fee.

freeRTOS is used in most of the example projects on this page because it provides a straight forward framework for handling common data acquisition tasks. In all of the example projects freeRTOS is configured with a 1ms tick. This limits the fastest sample rate achievable when using freeRTOS. If your projects require higher sample rates you will need to control timing directly using hardware timer on PIC32 (see the Timer Interrupts and External Interrupts projects below).

freeRTOS overview
freeRTOS API documentation

Example Projects

The following projects require MPLAB X and the XC32 compiler. All projects are self-contained - they include all of the files required for the project. This means that library files are duplicated across projects. Developer who plan on modifying and reusing libraries may want to restructure the file system so a single copy of the library can be used across multiple projects. Projects that use freeRTOS are denoted with (RTOS). Some of the projects denoted with (RTOS) do not require the RTOS, but are implement in this environment as an example.
Projects updated May 10,2013.

Note: Projects were created using MPLABX v1.8 IDE, the XC32 v1.21 Compliler and freeRTOS v7.3.0. If you are using a different compiler you may need to update the project properties. Select File->Project Properties and select the correct compiler in the default configuration.

Setting up the MX4cK for the projects below PDF   -    (quickview)

Minimal Project

A minimal starter project that configures the system and built-in LEDs and buttons.
Download project files

Timer Interrupts

Uses hardware timers and interrupts to poll built-in button and control built-in LEDs. This is an example of how to handle multiple actions using timers and interrupts. The project does not use freeRTOS. This is a good place to start if not using an RTOS.
Download project files

UART to PC Communication

Simple project (no RTOS) that prints and reads messages to the PC screen through the UART. Requires use of a terminal program such as PuTTY
Settings: Set power jumper to UART and connect MX4cK to PC using UART port. You can also have the Debug port connected to a different PC USB port. The PC will recognize the UART and create a COM# port equivalent. Note the number of the COM port and set your terminal program to read from that port. Additional instructions are provided in the main.c of the project.
Download project files


Demonstrates use of freeRTOS threads and timers to interact with built-in buttons and LEDs. Also demonstrates the use of a mutex to control access to a resource shared between threads. This is a good starter project when using freeRTOS.
Download project files

Digital IO (RTOS)

Configures and uses digital IO - including configuring an output as Open-Drain. The project requires connection to external components to demonstration IO.
Download project files

Analog Input and PWM Output (RTOS)

Demonstrates how to read from an analog inputs and how to output a PWM signal and change its duty cycle. The project requires connection to external components to demonstration IO.
Download project files

External Interrupts (RTOS)

Demonstrates how to use external interrupts and change notices. Also demonstrates how to wrap an interrupt ISR so it is compatible with the RTOS.
Download project files

I2C bus - read and write to the MX4cK's 32K EEPROM and DAC

Example of reading and writing data to the EEPROM and demonstrates how to set the output of the 12bit DAC. Both devices are on the I2C bus.
Board settings: enable I2C pull-up resistors using jumpers J3 and J4.
Download project files

MX4cK as a USB device (RTOS)

Configure the MX4cK as a USB device. Implements a simple FAT12 file system so you can connect to a PC through the OTG USB connector and read and write to the MX4cK's 32K EEPROM as if it were a thumb drive.
Board settings: jumper J17 to OTG, enable I2C pull-up resistors using jumpers J3 and J4.
Download project files

Write data to a USB thumb drive + queues (RTOS)

Configure the MX4cK as a USB host so you can store data on a USB thumb drive. The software implements a RTOS queue to pass data between a data collection thread and the USB handler. The example also demonstrates use of RTOS diagnostics by storing RTOS heap and stack usage on the USB drive.
Board settings: jumpers J16 to VBUSON, JP10 jumpered, and J17 to Host.
Download project files

Control Servos + queue (RTOS)

Demonstrates how to control hobby servos. The example uses a high prioity thread to send the servo pulses and a queue to update the servo position.
Download project files

OLED Display from Digilent Inc (RTOS)

Demonstrates how use the PmodOLED display. The example uses a queue to communicate between display thread and button monitoring thread.  Additional information on PmodOLED at www.DigilentInc.com
Download project files

Additional Resources

PIC32 Reference Manuals

Interrupts - Section 8 PDF  (from Microchip)
IO Ports - Section 12 PDF  (from Microchip)
Timers - Section 14 PDF  (from Microchip)
ADC (analog digital converter) - Section 17 PDF  (from Microchip)
Complete PIC32 Reference Manual   Filter by "PIC32" (at Microchip)

freeRTOS Documentation

Configuration parameters in freeRTOSConfig.h  Includes explanation of how interrupts are handled


To contribute to this resource, contact

Greg Mason
Mechanical Engineering
Seattle University