Very good. Getting the bootloader up and running is a major part of the battle.
The next step is to get your project running on your PIC without the bootloader. If it doesn't work without the bootloader you have no hope of making it work with the bootloader.
For information on setting up the project see this link...
http://www.mikroe.com/forum/viewtopic.p ... =usb+clock
Since you are using an 8 MHz crystal you will need to use Set _PLL_DIV2_1L. This will divide your 8 MHz crystal down to the 4 MHz input required by the PLL.
You will need to load your hex code over the top of the bootloader at first until you know you have hex code that works. Don't worry it is easy to reload the bootloader once your projecct is working and you are ready for the next steps.
Once you have verified that your project hex code is good you will need to make a few simple changes so that your code will work with the bootloader.
First, at the top of your project rename your main function main_thread and add the following code so that it looks like this...
Code: Select all
void main() org 0x1000 {
main_thread();
}
void main_thread() {
INSERT YOUR CODE HERE
}
Then open the P18F4550.mlk file and edit the section under //ROM MEMORY so that it looks like this...
Code: Select all
//ROM MEMORY
#pragma SetRomSize(32767)
//#pragma SetPage(PAGE0, 0x000008, 0x7FFF)
//ROM MEMORY for Boot Loader
#pragma SetPage(PAGE0, 0x001008, 0x7FFF)
#pragma SetPage(PAGE1, 0x001000, 0x7FFF)
I commented out the original SetPage line rather than deleting it so that it is easy to revert back by simply un commenting the orginal line and commenting out the two new lines. That makes it easy to switch back and forth as needed.
With these changes made you are now ready to compile your project again. When you have compilied it open the code with a text editor and it will look like this at the top
Code: Select all
:1000000000EF08F0FFFFFFFFFFFFFFFFFFFFFFFF15
:10001000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0
:10002000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0
:10003000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD0
<lines deleted to keep down the size of the post no need to >
, actually delete them in your code >
:100FF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF01
:101000006FEC1CF0FFD7FFFF02C0DCF101C0DBF189
:1010100000C0DAF1E9CFCFF1EACFD0F1E1CFD1F1E1
:10102000E2CFD2F18CEC1DF0016AF2B4012A01503A
:10103000010A05E1010E246ECE0ED66EF294016A0D
:10104000A1B2012A0150010A0BE12550010A03E176
:1010500054EC14F005D0A60EB26E150EB36EA1922C
:10106000CFC1E9FFD0C1EAFFD1C1E1FFD2C1E2FFA8
:10107000DCC102F0DBC101F0DAC100F01100818CAB
Now you need to add the following line at the top of the hex file on a line by itself.
:020000040000FA so that your code looks like this...
Code: Select all
:020000040000FA
:1000000000EF08F0FFFFFFFFFFFFFFFFFFFFFFFF15
:10001000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0
:10002000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0
:10003000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD0
Save the modified hex and you are ready to load it onto your PIC with the bootloader.
And now for the final steps.
Reload the bootloader code onto your PIC, hold pin RA.6 low and then plug in the USB cable. Next run the bootloader program that Microchip included. It should be located here...
"C:\Microchip Solutions\USB Device - Bootloaders\HID - Bootloader\HIDBootLoader.exe"
If it says "Device Attached" you are ready to click the open Hex File button and navigate to your modified hex code and select your hex file. Then click "Program/Verify" and your code will be loaded onto the PIC. Remove your jumper and click "Reset Device" and your project should come up running.
Goog Luck, Terry
[/code]