View previous topic :: View next topic |
Author |
Message |
dahli.llama
Joined: 26 May 2005 Posts: 5
|
Setting Configuration Bits on a PIC12F508 |
Posted: Wed Jan 25, 2006 1:46 pm |
|
|
Hello,
I need some help setting the configuration bits in the hex file on the PIC12F508. I am using the CCS C compiler for this and the #fuses directive that is supposed to set the correct bits for the configuration. I can get the device to work program correctly using MPLAB IDE and modifying the Oscillator to INTOSC configuration bit in the Configure menu, but no matter what I do using the #fuses directive, I cannot tell any other programmers to set that option correctly.
I am working with another group that only has access to the Baseline Flash Programmer, and that does not have the ability to manually change the configuration bits. When I load my .hex file with that, I get an incorrect configuration word, and these settings are not correctly programmed.
Can anyone give me any help on this matter?
Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jan 25, 2006 4:52 pm |
|
|
1. Post your #fuses statement.
2. Compile a program with that #fuses statement, and then post the
last few lines of the HEX file that is created by the compiler.
These lines will contain the fuses settings. The HEX file will be
in your project folder.
3. Post your version of the compiler. |
|
|
dahli.llama
Joined: 26 May 2005 Posts: 5
|
|
Posted: Thu Jan 26, 2006 3:25 pm |
|
|
1. Ok, the #fuses statement I am using is:
Code: |
//Configuration
//Format for CCS C Ver. 3.218
//Internal oscillator, Watchdog Enabled, Master Clear enabled, Code Protect off
#FUSES WDT,NOPROTECT,MCLR,INTRC
|
2. This is the last few lines of the .hex file.
Code: |
:0205FE00FE0FEE
:00000001FF
;PIC12F508
|
3. Compiler: CCS C Ver. 3.218
If you look in #2, the configuration bits look to be set at location 0x5FF and have a value of 0xFFE. The value is correct, but I believe the location is wrong and that it should be located at 0x3FF.
Thanks in advanced for the help. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 26, 2006 5:22 pm |
|
|
Hex files use byte addresses, so 0x05FE translates to 0x02FF.
That's wrong. The correct address of the Config Word is 0x03FF
for the 12F508, so it should be 0x07FE in the Hex file. I think
somebody at CCS probably just typed in the wrong value.
If you have PCW or PCWH, you can run the Device Editor, and
see if there is a entry for the Config Word address. If so, you
could fix the problem. If not, you could report the problem to
CCS and wait for a new compiler version, or you could get a
Hex file editor and fix it yourself.
Here's one Hex file editor. I haven't tried it.
http://www.betarun.com/Pages/HexEditor/ |
|
|
dahli.llama
Joined: 26 May 2005 Posts: 5
|
|
Posted: Fri Jan 27, 2006 9:22 am |
|
|
Thank you for the information.
I will be submitting a bug to them.
I will probably just use the hex editor for now.
Thanks again for the help. |
|
|
dahli.llama
Joined: 26 May 2005 Posts: 5
|
|
Posted: Fri Jan 27, 2006 10:35 am |
|
|
Ok, I have tried to manually edit the hex file, but no such luck.
I have changed the end of the .hex file to this:
Code: | :0207FE00FE0FEC
:00000001FF
;PIC12F508 |
Which should be the right location. But when I load this into MPLAB or the Baseline Flash Loader, I get the same checksum as before and the configuration bits are still being reported as 0xFFF and not 0xFFE like they are supposed to be.
Am I missing something else?
Thanks for the help so far. |
|
|
dahli.llama
Joined: 26 May 2005 Posts: 5
|
|
Posted: Fri Jan 27, 2006 10:58 am |
|
|
Ok, another thing. I just found this in the PIC12F508/12F509 Memory Programing Specification.
Code: | Note: By convention, the Configuration Word is
stored at the logical address location of
0xFFF within the hex file generated for the
PIC12F508/509. This logical address
location may not reflect the actual physical
address for the part itself. It is the responsibility
of the programming software to
retrieve the Configuration Word from the
logical address within the hex file and
granulate the address to the proper physical
location when programming. |
How would this affect the .hex file? Would doing this be correct?
Code: | :020FFF00FE0FE3
:00000001FF
;PIC12F508 |
Thanks again. |
|
|
dahli.llama
Joined: 26 May 2005 Posts: 5
|
SOLVED! |
Posted: Fri Jan 27, 2006 11:05 am |
|
|
Okay, I've solved it!!!
this is what the end of my hex file looks like:
Code: | :021FFE00FE0FD4
:00000001FF
;PIC12F508 |
Evidentally you need to tell the programmer that the config word goes to phisical location 0xFFF which translates to 0x1FFE in the .hex file.
Thanks for all the help. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 27, 2006 11:30 am |
|
|
OK, I didn't read that part. I just looked at the chart that shows
the physical address. Normally that works. |
|
|
|