Skip to main content Skip to local navigation

Modifying an Arduino for MPLAB X

Modifying an Arduino for MPLAB X

We can program an Arduino Uno using MPLAB X and the PICKit 4 programmer.
You can use MPLAB X and the PICKit 4 (or SNAP) programmer to write programs in C for the Arduino Uno. Here's how we do it.

To allow the UNO to be programmed by the PICKit 4 via the ICSP header (circled in blue, below), we need to cut the reset signal trace that links the '328P processor to the USB Bridging chip that is also found on the UNO, the MEGA16U2. There are also two other wires that we won't cut, the USART RX and TX lines, because we want to continue to use those to permit us to later write programs that allow the ATMEGA328P to send and receive serial information via the USB line to our computer. In the image below we will be cutting the circuit trace shown in orange at the segment shown in fuchsia.

Schematic view of the circuit trace that we'll need to cut on the Arduino Uno board. This is the "reset" signal sent by the ATMEGA16 to the ATMEGA328P during programming in the Arduino IDE. We'll keep the two USART lines between those chips, however.

The cutting can be done with a knife like I show in the video and illustrated here:

cutting the trace with a knife

After you cut the trace you can wire up the PICKIT4 and Arduino like this:

After you've wired up the two devices and powered them up by connecting up the USB cables to each, you can start programming the board in MPLAB X. I recommend pulling the memory contents off the ATMEGA328P chip first, just in case you want to restore the Arduino later. The process is described in this video on YouTube.

MPLAB X allows for reading and writing the "fuse" bits on the Arduino's ATMEGA328P. The traditional way is described here. In MPLAB X you can view the configuration memory and then copy out the existing configuration fuses:

Reading the configuration bits in MPLAB X begins like this.  Start with Window -> Target Memory View -> Configuration Bits.
Reading the configuration bits in MPLAB X begins like this. Start with Window -> Target Memory View -> Configuration Bits.

After the bits are read, MPLAB X can provide the C-code equivalent that you can incorporate into your own program. Here is what was provided when I pulled the Uno's configuration bits:

#include <avr/io.h>

FUSES = {

        0xFF, // LOW{SUT_CKSEL=EXTXOSC_8MHZ_XX_16KCK_14CK_65MS, CKOUT=CLEAR, CKDIV8=CLEAR}

        0xDE, // HIGH{BOOTRST=SET, BOOTSZ=256W_3F00, EESAVE=CLEAR, WDTON=CLEAR, SPIEN=SET, DWEN=CLEAR, RSTDISBL=CLEAR}

        0xFD, // EXTENDED{BODLEVEL=2V7}

};

LOCKBITS = {

        0xFF, // LOCKBIT{LB=NO_LOCK, BLB0=NO_LOCK, BLB1=NO_LOCK}

};

Here is the video summary of the process.