The Resistors

Me En 495R Mechatronics Competition, Brigham Young University

Serial Peripheral Interface

We decided to use to PIC24F04KA201 microprocessors to maintain modularity within our robot as well as to distribute the memory demand on the processors. To simultaneously utilize two microprocessors, we needs a means of communication. We selected SPI(serial peripheral interface) as our serial communication protocol. SPI, among many other protocols, is simply a means of communicating between multiple peripherals, in our case between two PIC24F microcontrollers. SPI is a synchronous method of communication, meaning that it requires all communicating peripherals to operate on the same clock. For more information on SPI and serial communication, refer to the Wikipedia commons.


Although the idea of implementing SPI on the PIC24F is very straightforward, it practice it proved to be quite cumbersome. To test the SPI module, we wired two PIC24F04KA201s on a breadboard together. Debug LEDs were wired to visually see when the master and slave sent and received messages to each other successfully. The master toggled an LED every time it sent a message. The slave toggled between two different LEDs depending on the message received.

The source code for this module is included on the download page. It contains functions to configure the SPI module as either master or slave. Additionally, it contains both read and write functions.