Difference between revisions of "Programming HID Bootloader on PIC32"

From Mech
Jump to navigationJump to search
Line 19: Line 19:


= Installing a Bootloader on the PIC32 =
= Installing a Bootloader on the PIC32 =
These directions detail how to install the HID Bootloader on the PIC32 with the [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010046 Microchip MPLAB ICD 2] (In-Circuit Debugger). Before starting, [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&redirects=mplab Microchip MPLAB], [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en536656 Microchip C32 Compiler] and the [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en537044 Microchip Applications Library] must be installed.
These directions detail how to start a new MPLAB project and program the HID Bootloader on the PIC32 with the [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010046 Microchip MPLAB ICD 2] (In-Circuit Debugger). Before starting, [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&redirects=mplab Microchip MPLAB], [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en536656 Microchip C32 Compiler] and the [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en537044 Microchip Applications Library] must be installed.





Revision as of 13:42, 21 August 2009

The HID (Human Interface Device) bootloader is used to install programs on the PIC32 without using an external programmer like ICD2 and does not require any drivers on the computer. The HID bootloader for the PC is supplied with the Microchip Applications Library.

Software

PIC software

You can download the PIC32 hex file and source files here. I recommend placing these files in a new folder. This will become your project folder.

PC software

If you downloaded the Microchip Applications Library, the PC HID Bootloader program is located under the start menu Programs -> Microchip -> MCHPFSUSB v2.5 -> Tools -> HIDBootLoader You can also download the executable here. Running this requires a sufficiently recent version of the .NET Framework, which you may not have if you are running XP or earlier versions of Windows. You can download a sufficiently recent version here (the install takes a while): .NET Framework download.

Required circuitry

For the UBW32 and NU32 board, this circuitry is already on the board. This information is for people who are interested in making their own board.

A button must be wired to a pin that has been initialized as a digital input (similar to the RESET button). This PROGRAM button is used to put the PIC in Bootloading Mode. The UBW32 and NU32 board has the button wired to PIN E7 and PIN E5, respectively. The button can be put on any pin that supports digital input, but the bootloading program will have to be modified accordingly.

The PIC goes into Bootloading Mode when the PROGRAM button is held down when a RESET is called (ie hold down both PROGRAM and RESET and then release RESET). LEDS on the boards will flash to indicate that the PIC is in Bootloading Mode.

Installing a Bootloader on the PIC32

These directions detail how to start a new MPLAB project and program the HID Bootloader on the PIC32 with the Microchip MPLAB ICD 2 (In-Circuit Debugger). Before starting, Microchip MPLAB, Microchip C32 Compiler and the Microchip Applications Library must be installed.


Under Construction (ignore what's below)

Notes - Create New Project - Add files - Include Search Path - Add Device Name - Add Source Files USB


  • Open MPLAB IDE.


  • Choose Configure>Select Device to select the PIC you are working with. In the Device dialog, select the PIC you are using from the list if it’s not already selected. The lights show which software is supported for that PIC.
MPLAB DeviceConfigure.jpg


  • Choose Project>Project Wizard to start a new project. Click Next
MPLAB ProjectWizardStart.jpg


  • Select the PIC from the drop down menu. Click Next
MPLAB ProjectWizardDevice.jpg


  • Select the Microchip PIC32 C-Compiler Toolsuite from the drop down menu. Click Next
MPLAB ProjectWizardToolsuite.jpg


  • Create a new project (I called it HIDBoot) in the folder where you want the project to be stored. I recommend creating a folder that contains the source code for each project. Click Next
MPLAB ProjectWizardNewProject.jpg


  • Add the following the c files to the project.
    • HardwareProfile.h (generic header file for many different boards)
    • HardwareProfile_NU32.h (hardware profile for the NU32, if you have your own hardware profile you will need to add it to the generic HardwareProfile.h)
    • main.c (the main source file)
    • main.h
    • procdefs.ld (a linker file read here for more discussion of why this linker file is important)
    • usb_config.h (header file to configure usb communication)
    • usb_descriptors.c (source file for usb communication)

Click Next

MPLAB ProjectWizardAddFiles.jpg


  • Click Finish
MPLAB ProjectWizardFinish.jpg


The project has now been created. It will not compile because it does not know where the common header files of the Microchip Framework are located.

  • Choose Project>Build Options>Project.
  • In the directories tab, choose the Include Search Path.
  • Add a New path - Browse to find the include folder (<Installation Folder> \pic32_solutions\Microchip\Include)
  • Add a New path - type a period '.' (this will search the project folder)
  • Click Apply and then OK
MPLAB IncludeSearchPath.jpg