I've looked into this a little, but as I have never used mplab and try to avoid assembly my first attempts have failed. If no one has any better ideas, I'll try to look into it more next week. Thanks for the help
David
I've looked into this a little, but as I have never used mplab and try to avoid assembly my first attempts have failed. If no one has any better ideas, I'll try to look into it more next week. Thanks for the help
David
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
Last edited by ScaleRobotics; - 20th March 2010 at 19:11.
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.
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
Last edited by ScaleRobotics; - 22nd March 2010 at 09:32.
I ran into a couple little snags when attempting your solution. the first being the melabs programmer doesn't allow directly modifying the hex file, so I had to use notepad and discovered it is all stored in Little-Endian but I actually got to remember something from college after 10 yearsSo I think I did it correctly other than my check sum was no longer good, but hopefully it is OK.
My second problem is my chip doesn't use config1L so I got a bunch of errors and will have to compare data sheets later to figure out what you were doing in your example. Unfortunately I need to be productive for the next few hours and will have to get into this later today. I'll let you know if I have any luck
Thanks for your help
David
Hey David,
Well I was thinking of just trying the 10mhz part first, and trying to make a 10mhz bootloader hex. Let me modify it for you, and send it your way. That will be the first step. If we can get that going, we can try to do something similar to what was done on the 18F4550, only, yes, we would have to modify the config settings to match the 18f4520.
Walter
It looks to be pretty easy to modify the baud rate of the mcLoader hex files, at least with the PICkit2. I changed the CONFIG1H setting for HS 4x PLL, and also modified the 7D06 address with the SPBRG (BRGH=1) setting for 19,200 baud rate for my 8mhz x 4 crystal. I left address 7E70 at 0F, and it works with the loader program, while running at 32mhz. Should be able to do the same with a 10mhz crystal at 4x PLL.
David, I sent you a 40 mhz version to try.
Walter
Thanks for the solution it seems to be working great.
I know there have been a few announcements recently about copyright protections, does anyone know if it is legal to post the solution for others to use? Walter and I both seem that we should be able to, but I want to make sure I'm following the rules.
David
Bookmarks