PIC32 Tutorial – Part 1 – Objective

Josef van Niekerk" rel="author">Josef van Niekerk

This tutorial is aimed at beginners and hobbyists like myself (I need to mention I’m both). It’s a rough guide where I’m sharing about my trials and tribulations at setting up a Microchip PIC32MX microcontroller on a breadboard. The objective of this tutorial is to be as simple as possible, and the idea is to have the absolute minimum setup configured, which can be used as a foundation on which more complexity can be added at later iterations.

[responsive imageid=’99’ size1=’0′ size2=’600′ size3=’1000′]

Pestilent Delays

It has taken me weeks to get to this point where I can finally start writing my first tutorial ever! I’ve been delayed with having to build my blog theme. More delays frustrated me with waiting for my PICkit 3 programmer to arrive from the US, finding out it’s faulty, wasting more time in waiting for Microchip to send a replacement.

I’m pretty much exhausted with unanticipated hangups, yet excited with loads of latent stuff I want to get into. Let’s hope that’s the last few snakes on my plane, and from here on, things hopefully start getting some traction.

In essence, I believe, as a friend once taught me, that even complicated things, are conglomerations of smaller, simpler, less complicated things.

Walking in Circles

Being a beginner enthusiast, I’ve been looking around for different types of MCUs to tinker with. I’ve looked at various ARM Cortex processors, fiddled with an Arduino Mega 2560, as well as a nifty STM32F4 Discovery board from STMicroelectronics. Community support for the Arduino products are the best, the STM32F was packed with features, and there are loads of helpful resources available online.

Yet, I wanted to work with something a bit more low level that could be built from scratch. I had lost a few battles with setting up an GNU ARM Toolchain on my Mac for quite a few weeks, and eventually saw victory in this war waged against compiling compilers.

Finally, discovering what a steep learning curve is attached to ARM processors, I had to keep looking around a bit more. So I discovered Microchip, and became quite interested in their PIC32 MCUs. Ordered my first PIC32MX chip to play with, and must say I never looked back.

This is a hobby, I’m not a genius, and I don’t have the time for steep learning curves, it takes the fun out of everything. So let’s see how simple programming a PIC32 can really be.

About the PIC32MX250F128B

So I went shopping, and in conjunction with something easier to learn, I had two particular requirements.

First, I needed a chip that can be inserted into a breadboard, so the SPDIP configuration the PIC32MX250F128B comes in, fits perfectly, with a tiny bit of manipulation, that is. Normally you would need to bend the pins inward only a slight bit to make them line up and fit with the holes on your breadboard.

The second requirement was that I needed USB 2.0 support. There are a lots of other implements available on this MCU, but the PIC32MX250F128B has a USB 2.0 OTG module capable or running USB 1.1 at 1.5Mbps, as well as USB 2.0 at 12Mbps, also known as USB Full Speed.

I won’t be bothering with USB High Speed, even though 480Mbps sounds inviting and potentially gives Chuck Norris chills down his spine, there are two problems. Currently, there aren’t any PIC32MX’s that support High Speed USB. 480Mbps is also rather fast for us hobbyists, and this kind of speed introduces more EMI issues, that would require more complicated, multi layered PCB layouts. There is probably not going to be even the slightest possibility of prototyping a circuit running at these frequencies on a breadboard anyways.

There has been mention at the 2013 Microchip Masters Conference about a new PIC32MZ range that will support USB HS (High Speed), but I fail to see an official press release from Microchip announcing official or even estimated release dates on this MCU range.

The 28-pin PIC32MX250F128B is capable of running at 50MHz 1.56 DMIPS/MHz, has 128KB of program memory and sports a few peripherals including DMA, SPI, I²C, UART, 10-bit ADC, PWM, USB OTG, PPS which allows you to remap some digital peripherals to other pin locations, 8MHz and 32KHz internal oscillators and more.

The list goes on with PMP for graphics interfaces, support for mTouch capacitive touch, on chip temperature measurement, support for about 4 different audio interface modes, JTAG, multiple ports for programming the MCU with for example a PICkit 3, ICD 3 or Real ICE, from Microchip.

In the next few parts of this guide, or tutorial, I’ll be covering PIC32 setup on a breadboard, and writing a very simple LED flashing application to the MCU, using a PICkit 3 programmer. I’ll try and keep the articles as clear as possible, and share with you, all the mistakes I made and hopefully help others to become acquainted with the PIC32MX250.


It is advisable to download a copy of the PIC32MX1/2 datasheet. When you view the datasheet, you’ll notice that it not only covers the PIC32MX250 we’re going to use, but it also includes information for quite a few other MCUs.

The datasheet covers in particular two families of PIC32MX MPUs, the PIC32MX1 and PIC32MX2.

Differences in the Family

The major differences when comparing the MX1 and MX2 families, as far as I can see, is that the MX1 family doesn’t have USB OTG. The rest boils down to Program Memory and Data Memory.

It’s easy to determine how much Program Memory a PIC32 chip has, simply by looking at it’s name. For example, in the PIC32MX250F128B, we can easily spot that the chip has 128kB of program + 3KB of boot flash memory. The B at the end of the name depicts the package type, in this case, B indicates that the chip is either a SOIC, SPDIP, SSOP or QFN package with 28 pins.

Here’s a brief table outlining only the above mentioned differences between the chips in the MX1/2 families:

Device Program Memory (KB) Data Memory USB OTG
PIC32MX110F016B 16+3 4 No
PIC32MX120F032B 32+3 8 No
PIC32MX130F064B 64+3 16 No
PIC32MX150F128B 128+3 32 No
PIC32MX210F016B 16+3 4 Yes
PIC32MX220F032B 32+3 8 Yes
PIC32MX230F064B 64+3 16 Yes
PIC32MX250F128B 128+3 32 Yes

As we can see, the MCUs vary mainly by the amount of Program Memory and Data Memory. You’ll also notice that the Program Memory is 4 times more than the Data Memory, no reason for this I guess, but helps remind us how much program vs. data memory your MCU has.

The thing that’s important to notice here, is pin compatibility. With the exception of the USB pins, you should be able to use any of the above MCUs to follow this tutorial. Up to the point where we add USB support, you’ll be limited to using the MX210, MX220, MX230 or MX250. I guess the biggest reason for having this variants, is to allow companies the ability to optimise their production costs, by picking the MCU, that has just enough memory to run their applications.

In the next step we’ll cover the Bill of Materials and required tools. Keep an eye on the Sparkbuzz Facebook Page for updates on the when the next articles are released.