Bootloader For 18F4520


Closed Thread
Results 1 to 37 of 37

Hybrid View

  1. #1
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Isaac, e-mail sent.

  2. #2
    Join Date
    May 2004
    Location
    brighton
    Posts
    149


    Did you find this post helpful? Yes | No

    Default Bootloader For 18F4520

    Quote Originally Posted by rmteo View Post
    Isaac, e-mail sent.
    you r great man

    Isaac

  3. #3
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86


    Did you find this post helpful? Yes | No

    Default

    Anyone have any idea what needs to be done to modify either of the included files to run at 40 MHz instead of 4 or 20? I looked over both hex files and there are only a few lines difference between them, but I have no idea what I'm actually looking at.

    David

  4. #4
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Luckyborg View Post
    Anyone have any idea what needs to be done to modify either of the included files to run at 40 MHz instead of 4 or 20? I looked over both hex files and there are only a few lines difference between them, but I have no idea what I'm actually looking at.

    David
    MCS has not provided any source code (that I am aware of) for their bootloader, so I think it would be pretty hard to modify it to run at double the speed. If you don't mind it not working directly through the MCS interface, then you could modify the assembly source code given by the Tiny Pic Bootloader, located here: http://www.etc.ugal.ro/cchiculita/so...bootloader.htm

    And run it beside your MCS.

    .... But Maybe,
    To still use MCS's bootloader hex, you could think about switching PLL settings on the fly in your code. See: http://www.picbasic.co.uk/forum/showthread.php?t=4093
    Maybe you could set the low power interrupt to change it back to 20 mhz when it powers down? Kind of backwards, but might work.

    Walter

  5. #5
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86


    Did you find this post helpful? Yes | No

    Default

    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

  6. #6
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default 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
    Last edited by ScaleRobotics; - 20th March 2010 at 18:11.

  7. #7
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default 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.



    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
    Attached Images Attached Images  
    Last edited by ScaleRobotics; - 22nd March 2010 at 08:32.

Similar Threads

  1. PIC18F4680 bootloader
    By vinyl_theif in forum General
    Replies: 1
    Last Post: - 29th January 2009, 17:45
  2. 18F4550 Bootloader enter via eeprom setting
    By bradb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd November 2008, 23:51
  3. USBDemo with Bootloader
    By vacpress in forum USB
    Replies: 4
    Last Post: - 25th January 2007, 22:29
  4. Bootloader Problems
    By rossfree in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th February 2005, 17:51
  5. Replies: 3
    Last Post: - 26th January 2005, 13:41

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts