|
Page 2 of 4 The bootloader firmware used in this example is the standard Microchip bootloader, as a precompiled HEX. For the PC software, I have included my own bootloader application (which has its own article with more information), but it can also be used with the Microchip standard demo bootloader application. IMPORTANT You must download Microchip's code package for their FS USB demo board, MCHPFSUSB, which is accessible from the FS USB Demo Board site. The file you need is an executable installer, which (by default) installs to C:\MCHPFSUSB. The link name changes occasionally as they update the code, presently the file you want is titled "MCHPFSUSB v1.2 USB Framework and Examples". It contains a lot of important stuff: the code and hex for the standard bootloader firmware, their PC demo bootloader application, the windows device driver, mpusbapi.dll, and a number of example programs for the demo board, which form the basis of the demo code in this article. DOWNLOAD CODE PACKAGE FOR THIS ARTICLE (last updated 2/16/08 - Updated code to implement new USB interface DLL with 'safe' code) DOWNLOAD CODE FOR PICUSB.DLL This is the code for the DLL file used in the above demo app, in case you want to see the details of how it works. Last updated 3/1/08 Now, you need the bootloader firmware. I have included it in the code package as bootloader.hex - but FYI, it is exactly the same file as the official microchip bootloader firmware, normally located at C:\MCHPFSUSB\fw\Boot\_output\MCHPUSB.hex, from the MCHPFSUSB demo code package linked above. Getting the bootloader set up is relatively easy, however it does require that you have a working PIC programmer that is compatible with the 18F4550. I used a JDM-style cheap serial programmer, with the software WinPIC800. You need to make sure you get the right configuration settings. The default oscillator is 20MHz, so if you choose a different speed make sure to choose the right clock divider when doing the config. The necessary settings are shown here, taken from the bootloader code project in MPLAB. 
Also, here are the same settings in WinPIC800. The easiest way of verifying you have the right settings in any given programming application is to compare all the hex values to those from MPLAB.
Once you have successfully programmed the bootloader firmware onto the PIC, you can do your first test of the USB connectivity. When you plug the PIC in to your computer via USB, not much will happen, but if you hold the bootload button and press the reset button, two of the LEDs should begin flashing, and the computer should detect it as a new USB device, and ask you for a driver; direct it to the MCHPFSUSB driver and all should be OK, and you will see it in device manager. The next step is to open up the bootloader software. This is the program you will use to download application firmware to your PIC. Open up the bootloader application, and when the PIC is ready it should read "PIC detected in BOOT mode". From here you can read what's on the PIC, erase it, or issue an execute command, which just resets the PIC so it goes into user code.
Next, it's time to put some useful code on it!
|