Wednesday, 20 August 2008
 
  Home arrow PIC arrow USB arrow PIC USB Bootloader using Microchip firmware and C#  
Main Menu
Home
Car PC
PIC
Electronics
Brewing
Links
Contact Me
FAQs
Forums
PayPal Donation

Enter Amount:

PIC USB Bootloader using Microchip firmware and C# PDF Print E-mail
Written by Evan   
Wednesday, 23 August 2006
Article Index
PIC USB Bootloader using Microchip firmware and C#
Page 2 - Monitoring Communication
Page 3 - Dealing with HEX files
Page 4 - Bootloader Interface Class

The bootloader application on the PC side needs to be able to perform 2 main tasks: read and write HEX files, and perform bootloading tasks by communicating with the PIC.  Since you need to have something to send or recieve when attempting to implement the bootloader, I chose to start by first tackling the HEX file side.

Dealing with HEX files 

Hex files are a reasonably easy format to deal with, but it still took some time for me to put together the necessary code.  If you're very good with C#, you could probably do it a whole lot faster. 

Rather than explain all about the hex file format, please visit http://www.keil.com/support/docs/1584.htm for information.

As you can see, the 2-byte address given on each line is only the lower 16 bits of the full address being referenced on the PIC.  The higher bits are accessed using the "extended linear address" command, so often the first line of a hex file will be:

:020000040000FA

 Which sets the upper 2 bytes of the full 32-bit address to 0x0000.  Note that the 2 bytes set with this command apply to all subsequent regular data transmissions, until they are changed again.  Since the PIC program memory is 0x000000 to 0x007FFF, this command is issued one time, and applies to all the data that goes in program memory.  Some compilers/assemblers do not include that, I guess zero is assumed for the initial value.  It will be issued again when the ID locations (starting at 0x200000) and configuration bits (starting at 0x300000) need to be accessed, if the hex file contains that information.

Following that, the rest of the hex file typically looks something like:

:0800000083011F308A00042F68
:103E080083010A168A152F2F83120313C8000C1E6C
:103E18000B2F48089900080083120313C801C90131
etc... 
:103E580003180034142F0A308316031399002430F2
:103E68009800903083129800640010273B3A031999
:02400E00763FFB
:00000001FF

Where that last line (of transaction type 0x01) is the end of file marker. 

I have implemented the HexInterpreter class to deal with reading and writing HEX files.  This class is covered in the Bootloader Interface DLL code documentation, or you can dig into the code if you want to know more.

The OLD version of the example project is available here.  I don't know why you'd want it (it's kind of a mess) but it's here until I finish phasing it out.

DOWNLOAD OLD EXAMPLE PROJECT

{mos_sb_discuss:8}  



Last Updated ( Sunday, 29 June 2008 )
 
< Prev   Next >
Partner Site
Visit my friends over at Dream-Technology, producing radio controlled and switch adapted toys for children with physical disabilities.
Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 License.
For usage outside the terms of this license, contact me by email to discuss.

© 2008 eegeek.net
Joomla! is Free Software released under the GNU/GPL License.

Get The Best Free Joomla Templates at www.joomla-templates.com