PDA

View Full Version : Bootloader and configs, EEprom



MOUNTAIN747
- 30th January 2011, 19:59
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.

mister_e
- 30th January 2011, 20:57
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?

Charles Linquis
- 30th January 2011, 20:59
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

mister_e
- 30th January 2011, 21:03
Sounds like a broken record... but in real English :D

MOUNTAIN747
- 30th January 2011, 22:03
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

ScaleRobotics
- 30th January 2011, 22:20
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:

5122

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

http://www.picbasic.co.uk/forum/content.php?r=96-Mechanique-Bootloader-Hex

mister_e
- 30th January 2011, 22:21
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...

MOUNTAIN747
- 30th January 2011, 22:27
Thanks mister_e, I'll give it a shot...

mister_e
- 30th January 2011, 22:30
Poor Walter, he got no love :(

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

ScaleRobotics
- 30th January 2011, 23:30
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

mister_e
- 30th January 2011, 23:35
Life's so hard when you're managed by a garlic bulb buddy... I feel your pain ;)

MOUNTAIN747
- 1st February 2011, 19:47
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

ScaleRobotics
- 2nd February 2011, 00:24
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.

MOUNTAIN747
- 2nd February 2011, 01:37
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...

ScaleRobotics
- 2nd February 2011, 12:44
My MeLabs programmer has this interface. Is yours different?:
5131

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.

MOUNTAIN747
- 2nd February 2011, 15:29
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 .

MOUNTAIN747
- 2nd February 2011, 17:27
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!

ScaleRobotics
- 2nd February 2011, 18:23
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.

MOUNTAIN747
- 2nd February 2011, 21:08
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

Charles Linquis
- 3rd February 2011, 02:06
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.

MOUNTAIN747
- 3rd February 2011, 03:19
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.