20mhz bootloader and 48mhz code
Ok, this works for me. I'm using microcode stuidios 18f4550 20mhz hex bootloader file, and change the speed to 48mhz on the fly using Darrel's RTconfig.inc file.
Will post code tonight for a 18f4520
Code:
DEFINE OSC 48 ' Lets work at 48 MHz with our 20mhz bootloader!
define LOADER_USED 1
@ #include "RTconfig.inc" ;Darrel's write to configs while running inc
tempbyte var byte
redled var PORTD.1
;----Change back to low speed for bootloader at reset
@ ReadConfig?CB _CONFIG1L, _tempbyte ; Read CONFIG1L
tempbyte.0=1
tempbyte.1=1
@ WriteConfig?CB _CONFIG1L, _tempbyte ; Write CONFIG1L
@ ReadConfig?CB _CONFIG1H, _tempbyte ; Read CONFIG1H
tempbyte.1=0
@ WriteConfig?CB _CONFIG1H, _tempbyte ; Write CONFIG1H
pause 1000 ; Give bootloader time to do it's thing
;----Accelerate up to 48mhz for your code
@ ReadConfig?CB _CONFIG1L, _tempbyte ; Read CONFIG1L
tempbyte.0=0
tempbyte.1=0
@ WriteConfig?CB _CONFIG1L, _tempbyte ; Write CONFIG1L
@ ReadConfig?CB _CONFIG1H, _tempbyte ; Read CONFIG1H
tempbyte.1=1
@ WriteConfig?CB _CONFIG1H, _tempbyte
main:
pause 500
high redled
pause 500
low redled
goto main
end
1 Attachment(s)
Using other than 4 and 20mhz for MCS bootloader hex
Well, the 18F4520 is a little harder, because it has a 4x pll with no pre/post scalers. Since your only external OSC options using the MCS bootloader hex files (as is) is either 4mhz, or 20mhz, that does not help.
So I wanted to try a 10mhz crystal. The closest I had was 8mhz. But I had some luck with that.
Checking the difference between the two hex files (4mhz and 20mhz) using the PicKit2, there were two addresses that differed. The first one (7D06) is where the baud speed is set. For a 4mhz crystal, this should be set to 0E0C hex, with 0E as an assembly command, and the last 0C as the SPBRG setting. To change this for a 10mhz chip (without 4xpll for now), should be 0E20.
http://www.picbasic.co.uk/forum/atta...1&d=1269246294
Setting this to 0E19 was correct for my 8mhz crystal, and allowed me to use the MCS bootloader hex at 8mhz. That's promising.
Now here is where it gets a little fuzzier. The only other address that changes from 4mhz to 20mhz is 7E70. For a 4mhz, it is set to 0F, for a 20mhz it is set to 1F. It looks like it sends this to the serial port, from what I can make out of the disassembler I used. Not sure what it does with this info.....
I tried setting everything for 8mhz with 4xpll directly using the PicKit2, but the bootloader would not work. I have not tried doing it with run time configs. And I may well be missing a setting.
I have a little more playing to do. Maybe you can test it running at 10mhz as a first step. If that worked, we could try to do something like I did above with the 18f4550, and switch speeds using Darrel's run time config include file.
Walter