|
|
View previous topic :: View next topic |
Author |
Message |
allenhuffman
Joined: 17 Jun 2019 Posts: 601 Location: Des Moines, Iowa, USA
|
Fantastic PIC24 conmfiguration bytes and where to find them. |
Posted: Thu Jan 16, 2025 4:27 pm |
|
|
Some observations and a question or two about configuration bytes and how to find them...
A) The datasheet for the PIC24FJ256GA110 chip...
https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ProductDocuments/DataSheets/PIC24FJ256GA110-Family-Data-Sheet-DS30009905F.pdf
...has Table 2-51 listing the "Flash Configuration Word Locations."
It lists Word Addresses 1, 2 and 3. For the 256 part, they are:
Code: | 1) 2ABFE
2) 2ABFC
3) 2ABFA |
However, getenv("CONFIGURATION_ADDRESS") returns 350192 (0xff7f0). 0x2ABF8 is half of that. and this is the value we have in a #define in our code for the start of the bytes.
If I load one of the .hex files into ICD Interface, it shows Configuration as:
But the data sheet does not reference this address.
B) In the PIC24FJ64GA004 datasheet, it lists
ICD Interface shows ABFC-AABFF and that makes sense.
getenv() shows 88056 (0x157f8). ABFC is half of that, so that also matches.
C) For the PIC24EPXXXXGP datasheet, they list 10 configuration bytes. For the 256 part, they are:
Code: | 1) 02AFEC
...
10) 02AFFE |
This one has the lower numbers first, while the other two parts are backwards. This was something CCS support was explaining when I was asking them about getenv() recently.
ICD Interface confirms 2AFEC-2AFFF which makes sense.
getenv() reports 352216 (0x55FD8), and half of that is 2AFEC so that one works.
So...
For A, I see other PIC chips have "Reserved" bytes, so I wonder if there really are 4 bytes, and the last one is Reserved.
But how do you know if the address reported means the last byte of config bytes, or the first? It looks like making generic PIC24 code that uses getenv() needs more information.
For C, in the .lst file, the compiler seems to skip over the two Reserved words at the start (1 and 2) but includes the two at the end (9-10):
Code: | Configuration Fuses:
Word 3L: FF4D ICSP3 NOJTAG DEBUG
H: 0000
. . .
Word 10L: FFFF
H: 0000
|
This caused an issue with a loader program I am working on that was expecting to find the start of config bytes as reported by getenv(), which didn't exist in the .hex file:
Code: | Configuration Words
02AFF0: 00FFFF4D 00FFFFEF 00FFFF6D 00FFFF39
02AFF8: 00FFFFF8 00FFFFFF 00FFFFFF 00FFFFFF
|
Checking for an address greater than would work, but not on the ones where it gives me the last word (since nothing will be after that in the hex file).
I've spent too much time in datasheets today trying to genericize my code, but I may just hard code it and move on to the next task... _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
Using: 24FJ256GA106, 24EP256GP202 and 24FJ64GA002. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19605
|
|
Posted: Fri Jan 17, 2025 1:46 am |
|
|
Data sheet says _Word Locations_. Hence half the byte address value.
You do understand that the configuration on these chips is at two locations.
The chip has the physical ROM configuration data held at 0xF80000 and up.
It is this that has to be used to program the configuration. The data held
here is copied on boot, from the ROM to the RAM, and is copied into the
top locations in the RAM.
It is the _ROM_ configuration data that a loader would have to deal with,
not the RAM data.
It is the ROM data that the program listing shows, not the RAM copy.
The configuration data (as far as reading it is concerned), is the data in
RAM. For programming you need to be dealing with the ROM locations. |
|
|
allenhuffman
Joined: 17 Jun 2019 Posts: 601 Location: Des Moines, Iowa, USA
|
|
Posted: Fri Jan 17, 2025 8:34 am |
|
|
Datasheet says program those flash locations and they are loaded to the config area during boot, yes?
My question is how do you know where to put data if the CONFIGURATION_MEMORY is sometimes the first word and sometimes the last, and sometimes is a value that is one word past what the datasheet says?
Is there another thing that can be read to clarify that?
And thanks - perhaps the write configuration talks directly to that area rather than the flash area. If so, maybe code can just set them as desired in main and not worry about flash? _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
Using: 24FJ256GA106, 24EP256GP202 and 24FJ64GA002. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19605
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|