32-bit PIC MCU have more advantages over the 8-bit and 16-bit PICs we have used. They are faster (max clock rate of 80 MHz compared to 40 MHz), have more peripherals available, offer more program memory (flash) and data memory (RAM), and have significantly more computational horsepower due to the 32-bit address and data buses and single-cycle multiply for 32-bit math. The primary disadvantages are that they come only in surface mount packages, making them harder to work with for fast prototyping compared to the DIP (dual-inline packages) 8-bit PICs that can be plugged into a breadboard; and they must be powered by 2.3-3.6 V, unlike the 5 V of DIP 8-bit PICs and some DIP chips we would like to interface with.
Therefore Cytron has come out with SKPIC32 in SK (Starter Kit) category. SKPIC32 is designed to support Microchip’s most advanced 32-bit PIC MCU (at the time of this writing). Unlike others SK series, Cytron has soldered 100-pin surface mount packages of PIC32 MCU, PIC32MX795F512L, on the board by default. Apart from that, this start-up kit also come with all the basic components needed for the PIC32 to run right from the box. Furthermore, the chip has been pre-program with Microchip’s HID bootloader which allow you to load the program without hardware programmer. Initially, SKPIC32 comes with a sample code of LED Blinking in the chip.
Figure above shows the SKPIC32 board. Most of the components are surface mount packages to minimize the size of the board. Below are some explanation on the board.
- In order to power up the SKPIC32, users must connect 5V either from JP2 or USB. There is a 3.3V regulator on board to regulate the 5V input to 3.3V output. Thus, users only need to plug in the USB from computer without worrying spoilt the PIC32 chip. A green LED indicator label as POWER will lit on when there is a power.
- USB mini B socket to connect to the computer.
- All the pins from PIC32MX795F512L are breakout into 0.1 inch standard of header pins. Users are free to connect the pins according to their application. All the breakout pins are label clearly with their port name.
- There are two push button on board. One is reset button, another one is programable push button which connect to RG15 of the PIC32.
- 2 red color programmable LED indicator which connected to RB0 and RB1.
6. ICSP (In circuit serial programming) connection to program the PIC32MX795F512L when bootloader is no needed.
Figure below shows the family datasheet of PIC32MX795F512L and the MCU core specification
- 80MHz, 1.56 DMIPS/MHz, 32-bit MIPS M4K® Core
- USB 2.0 On-The-Go Peripheral with integrated PHY
- 10/100 Ethernet MAC with MII/RMII Interfaces
- 2 x CAN2.0b modules with 1024 buffers
- 8 Dedicated DMA Channels for USB OTG, Ethernet, and CAN
- 5 Stage pipeline, Harvard architecture
- MIPS16e mode for up to 40% smaller code size
- Single cycle multiply and hardware divide unit
SKPIC32’s schematic is opened and it is free to download at its product webpage.
We are going to install MPLAB (software used for editing, compiling, and debugging code), the C32 compiler (software to create the program) and the Microchip Applications Library (common source files for programming) in order to use SKPIC32.
1. Download MPLAB IDE Full Release Zipped Installation at the microchip website under Design>MPLAB@IDE. You need to log in in order to get the MPLab IDE. If you already own this software on you computer, ignore this step. After download, extract the files it it is a zip file. Double-click on the setup launcher, run it, and choose “complete setup.” Let it install in the default location. Install everything is required. If MPLAB IDE Document Select appears, you can just close it. Now the MPLAB IDE is installed.
2. Download and install the MPLAB C32 C Compiler ver1.11 on SKPIC32 product webpage. At the time of writing, the latest MPLAB C32 C Compiler in microchip website is Ver2.1 which is not compatible with SKPIC32’s bootloader. Microchip hasn’t release new bootloader files for PIC32 in the latest MAL (Microchip Application Libraries). So if you wish to use bootloader to program the chip, you will have to install MPLAB C32 C Compiler ver1.11 because the current bootloader for PIC32 cannot work with the latest compiler which is available on Microchip’s website. However, if you are NOT using the bootloader, you can compile your code with any compiler version and program the chip using PICkit 3.
3. Download the MAL (Microchip Application Libraries) at microchip website. Save the zip file to your desktop and extract the files. Run the installer and install to the default. This MAL nclude many of software libraries like graphic library, TCP/IP stack, Accessory Framework for Android™ and etc. You can select any projects that you need for your application.
4. Download the sample code provided in SKPIC32 product webpage including LED Blinking and HID Bootloader. LED Blinking sample code is to help user to get started their PIC32 programming in MPLab IDE. While HID Bootloader folder contains Bootloader project code for SKPIC32, PC software for loading the program into the chip in Bootloader mode, and some useful linker scripts. Actually the HID Bootloader can also be downloaded from the MAL. It is inside one of the USB framework library.
After you have done everything above. It is time to get started with the programming. The provided LED Blinking sample source code will be used as example.
- Open the Microchip MPLAB project file named SKPIC32 Blinking at “<Your Save Directory>\LED Blinking – SKPIC32\LED Blinking\SKPIC32 Blinking.mcp”. Please make sure the device selected is PIC32MX795F512L and the MPLAB C32 C Compiler is version 1.11(b).
- If you try to build the sample source code at this stage, you will get Build Failed message. It is because the compiler cannot find some .c and .h files. Those file in project window are showing “files not found” in bracket.
However all these files can be found at “<Your Save Directory>\LED Blinking – SKPIC32\Microchip\Common” and “<Your Save Directory>\LED Blinking – SKPIC32\Microchip\Include”. Remove the files by right click and add those files again. Remove the file not found and add the file again
3. After adding each necessary files, you can now build the source code by clicking the icon.
To kick start, plug in the USB cable to the USB socket on board. The green LED labeled with POWER should be lit on. This indicate that the board is being power up and is ready to use. As mentioned in the introduction, this SKPIC32 is pre-programmed with a sample code, LED Blinking. After power up the board, try press the switch labeled with SW, the two red LEDs on board will keep blinking simultanuesly until it is reset.
The purpose of a bootloader is to load programs onto a microcontroller over a serial line without the need of a high voltage or otherwise hardware orientated programmer. What this means to you is that you will now be able to load programs much faster and much easier onto PICs then you ever dreamed of. Of course, bootloader firmware must programmed into the microcontroller at the first time. But no worries, the SKPIC32 is ready programmed with the bootloader firmware. The steps to load the program into SKPIC32 is shown below:
- Please follow the steps on section 3.0 in order to get the hex code. Please make sure that the HID Bootloader Linker Script is included in the project as shown at the figure below. This file is designed to be used by an application that will be loaded with the HID bootloader.
- Press and hold the SW on board and at the same time reset the SKPIC32 either press and release the reset button or plug in the USB socket. Once the HID bootloader is recognize by computer, release the SW button. Two red LEDs on board will blink alternatively. You have enter the bootloader mode!
3. Open the bootloader PC software which is located at “<Your Save Directory>\HID Bootloader – SKPIC32\PC Software\HIDBootLoader.exe”. If you have enter the bootloader mode, the PC software should look like the figure below, with some accessable button and showing device attached.
However, if the board is not in bootloader mode, all the button in the PC software is not accessable and it is showing device detached.
PC Software – USB Bootloader when not in Bootloader Mode
Please try with step 1 again if you are not in bootloader mode.
4. You are ready to load the program into PIC32 if the HID Bootloader is recognized by your computer. Click on the “Open Firmware Image” button, select the hex code of your application. Click on the “Erase/Program/Verify Device” button to start loading the hex code into the PIC32 chip. It may take several second in order to complete. If the dialog showing You may now unplug or reset the device, it is done! You can now reset your SKPIC32, and it should be run according to your program.
If you wish to program the SKPIC32 wihtout using bootloader, there is a ICSP connection for user to program the SKPIC32 with PICKit3 (or ICD3) as shown at the figure below.
Please remove the HID Bootloader Linker Script in the project before building the code if you are using SKPIC32 LED Blinking sample project.
This action will erase the Bootloader Firmware inside the PIC32MX795F512L. Thus, the chip won’t be able to enter bootloader mode again. If you wish to use the bootloader again, you can program the bootloader hex code into it. You can get the bootloader hex code at “<Your Save Directory>\HID Bootloader – SKPIC32\HID Bootloader for SKPIC32.hex” which you previously download at product page at section 3.