You can skip this chapter if you use a PIC USB Demo Board. The microcontroller on this demo board already contains compiled and ready to use bootloader.
USB PIC Bootloader is distributed with its source code. The most recent version you can download from the Diolan website. The distribution contains all the necessary MPLAB project files. Bootloader is developed on PIC18 assembler language. MPASM compiler is all you need to compile it. At the time of writing this documentation MPASM compiler is free and can be downloaded from Microchip company website. MPASM is also part of an integrated development environment MPLAB. Further description of the compilation process implies the use of MPLAB.
To compile the bootloader you will need:
- Bootloader - source code of the program, which you can download from the Diolan company web site;
- MPLAB - integrated development environment for PIC microcontrollers;
- MPASM - assembler for PIC18 microcontrollers.
Download the file with bootloader source code and unzip it. To unpack the archive you can use WinZIP, WinRAR or any other ZIP format archiver. If you use OS Windows XP, you can use the built-in unpacker. To do this, click right mouse button over the archive file and select "Extract" from the menu. As a result, you will get pic_bootloader folder, containing Diolan USB PIC Bootloader source code.
Use MPLAB to compile bootloader source code. If you do not have MPLAB, you can download it from Microchip web site and install. MPLAB has its own documentation for installation and usage. We encourage you to read this documentation before compiling the bootloader source code. During the installation you have to choose support for 8 bit PIC18 microcontrollers and MPASM Suite.
Start MPLAB and open the bootloader project with "File->Open Workspace" menu. To do this in the file open window go to the directory containing the unpacked bootloader and choose the bootloader.mcw file. You will see a list of bootloader source code files in the project window.
Bootloader uses its own linker command file - Bootloader.lkr. Verify that this file is specified in the list of project files. Verify the configuration options to specify your type of the microcontroller. To select the microcontroller type, use "Configuration->Select Device" menu and select PIC18F4455. Then, using the menu "Configure->Configuration Bits" open the window with the configuration bits and select checkbox "Configuration Bits set in code".
Open the project settings dialog using the menu "Project->Build options->Project", select Microchip MPLAB Suite tab and verify that the check box marked "Extended mode" is on. Bootloader has to be compiled in PIC18 advanced mode. See microcontroller documentation for detailed information on different operation modes.
Use the menu "Project->Build" or click the Build button on the toolbar to start the compilation. After the compilation bootloader can be programmed into the target microcontroller.