Bootloader and configs, EEprom


Closed Thread
Results 1 to 21 of 21
  1. #1
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219

    Default Bootloader and configs, EEprom

    I am using Melabs bootloader for the first time. I have been able to load and run my blinkLED programs fine. While reading post on loaders I have come across several items discussing configs can not be loaded with your program but must be loaded at Bootloader installation. Well at least that’s what is sounds like. I am not sure how to set the configs during the installation of the loader Hex file. Is this done using the Melabs programmer? If I click the “C” button and set configs will that program the PIC when I install the Bootloader? Once I Read after programing I am not sure if the PIC is now set with those config settings? Also, I am not sure if the Program hex file that contains “Data” instructions to load the on board EEprom are actually loading the EEprom? I am not sure how configs and on board EEprom should be handled using the Bloader. Comments please.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    The PIC configuration fuses are already embeded in the Bootloader .HEX file. So if your EPIC software is set to program the fuses, everything's fine.

    On some PIC18, you can change some config fuses on the fly but it doesn't make much sense to do so unless you have a really specific need.

    You could change some config fuses BEFORE dumping the Bootloader firmware (.HEX) to your PIC, as long as you don't touch the OSC one, it shouldn't cause much problems.

    Nothing is programmed to the PIC EEPROM unless your program use PBP EEPROM, DATA. I think you can also set the Bootloader to NOT refresh the EEPROM each time you update he PIC firmware.

    Clear as mud huh?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    If you are using MCLoader -

    You need to load the correct .HEX file into the PIC for the speed of your oscillator.

    The CONFIG files generally have lots of options. Set it for your oscillator type, for example INTOSC noclockout, or HS or PLL.

    Make certain that you have the WatchDog Timer turned OFF
    Make double-certain that you have LowVoltageProgramming (LVP) turned OFF.
    All the others (code protect, etc), will probably be fine with defaults.
    You may want to change some of those after you learn more.

    The configuration registers that you set at the time you load the bootloader will not be changed by your program or the bootloader.

    The DATA statements in your program WILL write into the selected EEPROM locations only once, during programming.

    You can change the config registers of an 18F series (only) at runtime, but PBP does not normally have this functionality. If you want to do that, see

    http://www.darreltaylor.com/RTconfig/RTconfig.inc.txt
    Charles Linquist

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Sounds like a broken record... but in real English
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Reply

    Mister_e, Charles thanks for responding.
    OK, it sounds like I’m covered on the EEprom.

    So back to configs. You say configs are set with the Bloader.Hex, so how do I know what the fusses in 16F876a_20.HEX are set to?

    You say I can “change some fuses BEFORE dumping the Bloader firmware (.HEX),” OK but how ?

    It sounds like I have to edit the HEX file. So there must be a specific location in the HEX file to find the fusses? And I suspect I will find a number for OSC nearby. I could edit the HEX file if I knew where to look. Am I on the right track?
    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    You can see which configs are set in the Hex by loading the hex file into your programmer. Then look at the config settings and see what they are.

    On a Melabs programmer and a Pickit2 programmer:

    Name:  configs.PNG
Views: 1968
Size:  88.5 KB

    Now if you mean the speed of the Osc, then you can modify it using this procedure:

    http://www.picbasic.co.uk/forum/cont...Bootloader-Hex
    Last edited by ScaleRobotics; - 30th January 2011 at 22:23.

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Within EPIC software menus, you should be able to see and modify the configuration fuses.

    If you want to edit them, well do it within EPIC software then save changes (make sure you made abackup of the file BEFORE)

    If you want to use another Crystal/OSC value, you'll also need to modify the Bootloader firmware, it use USART so you want to spot the related USART registers (SPBRG, RCSTA at least) to alway keep the same Baudrate.

    Scalerobotics did a short tutorial in the Wiki that show 1 method to deal with it.

    PS: broken record again...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Reply to the broken records

    Thanks mister_e, I'll give it a shot...

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Poor Walter, he got no love

    Come on everybody, say it loud and proudly :"We love you Walter!"
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Poor Walter, he got no love

    Come on everybody, say it loud and proudly :"We love you Walter!"
    And I thought NO one cared! Thanks Mr. E

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Life's so hard when you're managed by a garlic bulb buddy... I feel your pain
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  12. #12
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default OK boys, Back to the subject please!

    Mister_e, after doing my homework, it looks like the MCBloader 16F876a_20 uses the config word 3F72 after opening the Bloader with Mel Labs Programmer. ( I don’t have a Pickit2) This value will turn off WDT. This is what Charles suggests but my program uses the PBP SLEEP command. I need to change the config to 3F76. If I use Word Pad to open 16F876a_20 and look for “3F72” . Word Pad seems to invert the bytes of each word so I search for “723F”. I find in the next to the last line “:02400E0072EFFF”. The last three bytes are of interest. 72EFFF. “72EFFF” is actually “EF72” followed by byte “FF” I think. If I’m right, a change here should do the trick. Please give me your valued wisdom on this change before I destroy this file and perhaps a $5 part in the process.
    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    Hello Mountain747,

    It almost sounds do-able, but the sinker is, how are you going to add the clear wdt instructions for the bootloader code? Seems like you would need the bootloader source code for that. You might be able to do it with a PIC18 with changes to the configs on the fly, by leaving WDT off for the bootloader, and then turning it on for your PBP code.
    Last edited by ScaleRobotics; - 2nd February 2011 at 00:36.

  14. #14
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Boot Loader demystified, I wish

    Correct me if I’m wrong. The MCBootloader.hex is raw data. There’s no decompression or any further manipulation to be done. So how is the configs past to the programer from the compiler? I set the configs in our PBP and that tells the compiler what you want, the compiler passes this information to the programmer in the HEX file. I open the programer after compiling PBP and I open only a HEX file. So the information must be in the HEX file. Why do you need anything else to set configs? We just locate the config word within our HEX file and replace that word with the information we need and save the file. The config word %0011 1111 0111 0110 or $3F76 would just replace the current $3F72 (in the word pad form of 723F) in the hex file and save!!! Job complete! IF and only IF what appears to be the config word on the next to the last line of the loader is in fact IT. We think the Hex file has instructions for the programmer to write to 2007 (16F87x) so all we have to do is find the word it writes to 2007 and replace it. I know this sounds too easy. A test of Occam’s razor’s edge. OOPs, the checksum got me! Can't change the word in the file so easy. More brainstorming...
    Last edited by MOUNTAIN747; - 2nd February 2011 at 02:34.

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


    Did you find this post helpful? Yes | No

    Default

    My MeLabs programmer has this interface. Is yours different?:
    Name:  wdt.PNG
Views: 1110
Size:  20.3 KB

    With this one it is really easy to change the configs to WDT On. Just open the mcloader hex, then click on enable WDT, then program your chip.

    I tried turning WDT on, and it was still able to read and write through the serial port using MCLoader. So it looks like you are right.

  16. #16
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default

    The question of whether or not the MeLabs programmer config interface would set the configs while burning a Hex file (overriding the config information in the Hex file) is one of the questions I was trying to ask in my first post. Sorry for not making that more clear. I’ll have to do some kind of test to find out how the programmer config interface works. Thanks scalerobotics .

  17. #17
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default mister_e is right, BootLoader files configs a piece of cake

    Yep! That’s the config word in the Hex file. Open a MC Boot loader Hex file (16F87x a_20) with Word Pad and check byte 8 and 7 from the end of the file. This is the config word $3F72 ( in the Word Pad it is 72 3F). It looks like all 16F MCLoader files default to $3F72. If I want to turn WDT on I will have to change" 72 3F" in the Word Pad to "76 3F" and save the file. If you open a MC boot loader Hex with MelProgrammer after making these changes in Word Pad you will see the WDT is now turned ON. And yes, to change the configs in the file all you have to do is open the config interface and change settings in the dropdown menu and save. I think this is what mister_e was talking about yesterday but he closed shop for the day before explaining the details. You can also change the config word in Word Pad but when you save you will get a checksum error. Whoever, the checksum error seems to have no effect on the function of the file as you can load the file in MelProgrammer and see that you have made changes to the config settings. Not a big deal now that I know the programmer will make the changes I need, but it’s nice to know a little more about the structure of the BootLoader Hex file. So that brings me back to Charles Linquis statement “Make certain that you have the WatchDog Timer turned off”. OK Charles, WHY?
    Thanks!
    Last edited by MOUNTAIN747; - 2nd February 2011 at 18:25. Reason: clarify Word Pad file

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by MOUNTAIN747 View Post
    So that brings me back to Charles Linquis statement “Make certain that you have the WatchDog Timer turned off”. OK Charles, WHY?
    Thanks!
    Well, I would have said:

    Because with the WDT turned on, there are no WDT clear statements in the MCloader code, and no way to put them in, because all we have is the hex file. You would think that the 4 seconds or so it takes to load a program through the serial port would exceed the WDT setting.

    But, it works, so that's obviously not correct.

  19. #19
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default And the winner is!

    And the uncontested award goes to “scalerobotics”! And the answer is, There are WDT clear statements in the MCBootLoader.HEX file. This fact confirmed this morning off-line by DT after checking source code of MCBootLoader.Hex 16F876a_20. SLEEP and NAP commands can be used by serial port loaded programs using this file and you have plenty of time to load the program. Well at least that’s the story I get from the shop and until something contradicts this information I’m sticking with it!

    Mountain

  20. #20
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    If you program the WDT OFF, then you can turn it ON with the SWDTEN bit. If you program it ON, then you don't have that choice. It is good to have choices.
    Charles Linquist

  21. #21
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default

    SWDTEN bit! Good point Charles. I don't think that will help my 16F876a project but I will certainly keep it in mind for future projects. So do you have anymore good tips on using the Boot Loader? You've got my undivided attention.

Members who have read this thread : 1

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