8 April 2008

7. Bootloading

The picpack bootloader is based on the Sparkfun bootloader / screamer combination, which in turn is based on other bootloaders. I’ve got it working on two 16f variety chips and two 18f variety – and others shouldn’t be too hard to get working. If you do get it working on other types, please send me your settings so everyone can take use them.

Here, I’m going to assume you have a 16f88 chip.

Grab the 16f88 boostbloader hex file, program your pic. To get the serial connections going you’ll need to have some sort of conversion hardware to get it to rs232 levels – I use the sparkfun module, and the Olimex boards have it built in (but not connected).

Run up the screamer application (which is the windows program that sends your program to the pic) and select your com port. Select a .hex file to download (say, the flasher program from the last tutorial) and choose download. Reset your pic, either by powering it on, or using your MCLR reset button.

The pic will boot, send a byte to the screamer application to indicate it’s ready to accept a new program. Screamer will then send the contents of the .hex file – the boostbloader program will store the program in flash, and then execute it. If screamer doesn’t respond, it will then go and run the last program that was downloaded.

It really should be that easy. The nice thing about the screamer app, is that when you’ve finished the download, it can flip to the terminal page, and then you can see what the pic is doing by using the serial library, printing out statements, variables, etc. It’s all very neat and a great way to debug programs.

The other thing to remember is that using a bootloader, you don’t need to worry about config bits, since these are already programmed as part of the booloader itself being put into the chip. Of course, if you need something in the config changed, you do need to compile and re-download yourself a custom bootloader, but you’ll get pretty comfortable with all this soon.

So hopefully you’re now at the point of having your leds flash again, but this time under bootloader control. You won’t need to pull your pic out of circuit and put it in a zif socket anymore, or power it down to use ICSP. Life is great.

Now it’s time to start doing more exciting things than just flash leds, cool as this is. Our first point of call is to create a terminal program so you can type commands and get your pic to respond. On to the next tutorial…

No comments: