UBW32: Getting Started – Part 1

In my last post the features of the UBW32 were laid out for you. It should now be apparent that it is quite a bit more powerful than your typical Arduino. In this post I’ll walk you through getting your computer set up so you can upload sketches to the UBW32. The Arduino IDE really shines in the ease-of-use department when it comes to uploading and compiling code. The UBW32 requires a bit more effort to get set up initially, but it’s not nearly as complicated as it seems at first glance. Read on and I’ll explain how MPLAB differs from the Arduino IDE, and what all the different software packages you require are used for.

You’ll need the following software packages installed in this order to get code on the UBW32 for Windows:

  • MPLAB v8.8*
  • MPLAB C32 Compiler (Registration Required)
  • Microchip Application Libraries (MAL)
  • HIDBootloader.exe

*I’m not using MPLAB X for these guides as it is still in Beta

It’s worth noting at this point that many people before me have installed this software and written guides on how to get it installed. I won’t be focusing on how to proceed through install process other than to link you to the UBW32 page on Firmware Build Instructions which goes over where to get the software you need. There’s also a handy pdf linked to on the UBW32 main site that has detailed installation instructions [pdf] for you. I’ll leave the install process guide to those before me and try to explain what all the various components do and why you need what seems like so much more than the simple single Arduino IDE installer.

MPLAB v8.8 is the Microchip IDE. This is the equivalent to the Arduino IDE as far as development is concerned. It is a program that combines your editor, file management, and compiling into one. You’ll be using this program to do most of your development for the UBW32 just like you use the Arduino IDE to do your development for the Arduino. One key difference is that you will not be uploading your code directly from the IDE to your UBW32 unless you use a PIC programmer like the PICKit2 or PICKit3 (I’ll explain more about alternate programmers later).

In order for MPLAB to be able to compile the example projects and code available to you to run on the UBW32, it needs to have the C32 Compiler software from Microchip. This is not included in the MPLAB base install, as MPLAB supports many more chipsets than the Arduino IDE does. Many people have no use for the PIC32 compiler as they are only working with PIC18s or PIC24s or other PIC lines, so compilers are offered seperate to keep the install size down. In addition to the C32 compiler software, Microchip provides a large number of libraries and sample code for their 32-bit MCUs. This code provides a number of #defines and built-in functions that make programming in C on the PIC32 line of processors much more manageable, and all the code samples used on this site assume you’ll have the MAL installed. These MAL are the equivalent of the Arduino Example Code and Libraries which (mostly) come with the Arduino IDE. Even in the Arduino you may need to download new libraries to get your projects running, and these MAL are just the PIC32 libraries provided by Microchip. The UBW32 install guide mentions you’ll just need the “Microchip” folder out of the MAL, but I recommend getting them all so that you can check out the impressive library of example code Microchip has provided for use with their MCUs.

The last piece of software needed is a program called HIDBootloader.exe. This program is the interface that will actually move your compiled .hex file generated in MPLAB over to your PIC32 chip. It operates by interacting with the bootloader software that comes installed on the UBW32 and copying the hex file into the PIC’s program memory space. This is the main difference between the Arduino IDE and working with the UBW32. The arduino IDE supports uploading your compiled code to the ATMega328p in the IDE with a single click. MPLAB, on the other hand, was not designed for use with the UBW32 specifically, so you’ll have to activate the bootloader and upload your code manually. That means that when developing for the UBW32, you’ll have 2 programs running instead of just 1 like the Arduino did, but they serve the same purpose. In time you’ll hardly notice the extra 2 steps to get your code onto the board.

If you are using a PIC32MX795 or a PIC32MX460 (This is for the older versions of the UBW32 board from Sparkfun) you should be able to download and install the UBW32 bootloader onto the chip by downloading the bootloader hex files (or compiling your own from the source files in that link) and using one of the many programmers they list on the UBW32 main page to load it onto your PIC.

I had originally intended to walk through uploading the bootloader to the PIC32MX795 using a PICKit3 Programmer in this post, but I am experiencing some technical difficulties. I successfully programmed the PIC with the bootloader once, but any subsequent attempts were met with a “PK3Err0035: Failed to get Device ID” error. After some googling and trying all the mentioned solutions I found, it seems I am not alone in having these troubles. In light of being unable to upload code consistently, I will be delaying the post about programming with the PICKit3 and moving on to compiling and uploading some sample code for the UBW32. Specifically my user-friendly sample code that I’ve commented to be as similar to an Arduino as possible.

The second part of this post containing the sample project and code analysis, as well as instructions for uploading to the UBW32 can be found here.

2 Comments.

  1. Great Article, Please if you ever figure out the reason for PK3Err0035 please post many thanks again

    • I plan to try and get to the bottom of my programmer woes this evening. I’ll let you know how it goes.