Back to PIC Interface.

Uploading Hex Files to the Main PIC Board




1. Connect the main PIC board to your computer using a straight thru serial cable.

2. Start HyperTerminal, the first time you will get a 'New Connection' dialog, give it a name such as 'PICLoader' and choose an icon, click OK.

The next dialog box 'Connect To' pops up. Choose the port your serial connection uses. In the 'Connect using', select 'Direct to Com2', or whatever port you are using, click OK.

In the Com* Properties dialog that pops up next, choose the following settings. Bits per second - 9600, Data bits - 8, Parity - None, Stop bits - 1, Flow Control - None. Click OK.

The Hyperterminal Window should now pop up...still a few settings to deal with so bring the 'File' menu up and select 'Properties'. Click on the 'Settings' tab. Select 'Windows Keys' , Ctrl+H, Emulation: ANSI. Now click on 'ASCII Setup'. Set 'Line delay' to 100 milliseconds, click OK.

Before you do anything, go to 'File' and select 'Save'. This will save all the settings you just made so that you won't have to do it next time you run the HyperTerminal session. I also drag a short-cut icon to my desktop so its nice and handy. Now you are ready to roll.

3. Load the hex file you generated into NotePad.

If you are using PicBasicPro or MPLAB assembler you will have to find and delete one line in the hex file. This line has fuse settings, and would generate an error from the bootloader program. These fuse settings are set in the bootloader program. If you want, or need to change them, you will have to re-flash the bootloader using a PIC programmer.

The line usually looks similar to this:

:02400E00323F3F

Find it, and delete the line. Now you are ready to upload the hex file to the PIC.

If you are using the CCS C Compiler you don't have to edit any of the lines. The bootloader version that loads CCS compiler hex files automatically removes this line for you, so go to the next step.

4. In NotePad go to 'Edit', 'Select All', then Ctrl+C (read as control C), to copy the hex file into the clipboard buffer.

HyperTerminal is up and running. Turn ON the main PIC board(not the bot!)...you have 3 seconds to hit a capital 'Z' if you are using the MPLAB, PicBasicPro version of bootloader..or hit any key if you are using the CCS version.

You should get a command prompt that looks like PIC> . From the keyboard enter a ? followed by . This gives you a menu of options.

Enter a 'u' , it asks 'Are you sure?', answer 'Y' to the question. It will earse the code space in preparation to upload the new code. When it is finished it will disaplay 'Ready'. Now paste the hex file into HyperTerminal by entering Ctrl+V(read as control V). If all goes well you should not get any errors. The terminal should display 'Upload succesful', followed by a prompt 'Enter a rev string> ', which will be the name for the image you just uploaded. For MPLAB and PBP users the bootloader expects this input from you. For CCS users the the name of the image is embedded in the hex file.

CCS users: If you get the error ' 0002h != goto XX ' then you need to add the proper 'goto main' code in your program. So go back and fix that, recompile the program, then go back to step 3.

MPLAB/PBP users: If you get an error such as '....Memory protection error @ 2007h' .....

it's because you forgot to remove the line which has the fuse settings on it. Go back and redo step 3. You don't need to recompile...just delete the line from the hex file.

5. To try out your new code, turn the main PIC board Off, unplug the Serial cable, then turn the PIC On. If the program is to controll the robot, then turn the robot on too.... (3 seconds Bob!).

Of course you don't have to unplug the robot from the serial cable if you want to monitor information coming from the PIC to HyperTerminal. Just make sure you are around to keep the Walker from getting all tangled up in its leash. Sending data to HyperTerminal can be usefull for debugging purposes.

You can find more information on Rick Farmer's PicLoader here.

Back to PIC Interface.