|
|
View previous topic :: View next topic |
Author |
Message |
allenhuffman
Joined: 17 Jun 2019 Posts: 554 Location: Des Moines, Iowa, USA
|
PIC24 and getting the Configuration Bits address? |
Posted: Fri Dec 13, 2024 9:32 pm |
|
|
We use three different PIC24 chips on various boards. Our firmware has #defines for where the Configuration Bits/Fuses are located, like this:
Code: | #define START_ADDRESS_CONFIG 0xABFC // The start address of the configuration words |
Is there a way to obtain this in code, or is it just "look it up in the data sheet and hard code it"?
And here is why I ask... I am finally implementing a bootloader I wrote a few years ago. The bootloader contains the IVT, the bootloader code, and the #FUSES.
The application will have #FUSES none.
One of the options is to create a master .hex file that the factory can use to burn a fresh board -- this would have the bootloader and the application combined.
Using info from CCS support and others in this forum a few years ago, I use #import to pull in the bootloader to the application hex file:
Code: | #warning/information Including Bootloader in Application HEX file.
// Import the vector table and bootloader code.
#import(FILE=BOOTLOADER_HEX, HEX)
|
This produces the desired .hex, but it will give a warning about memory being used. Tonight I went searching and saw posts here where they said it was due to the bootloader.hex containing the FUSES, and import generates that warning. A suggestion was given to use two #imports, so I tested this tonight:
Code: | #warning/information Including Bootloader in Application HEX file.
// Import the vector table and bootloader code.
#import(FILE=BOOTLOADER_HEX, HEX, RANGE=0:BOOTLOADER_APP_ADDRESS-1)
// Import the configuration bits (fuses).
#import(FILE=BOOTLOADER_HEX, HEX, RANGE=START_ADDRESS_CONFIG:0xFFFFFF)
|
And no more warning.
However, while I had a #define for the start of the config bytes, I have not yet looked up our various PIC24s to see what the range should be.
Also, I was looking to see if there was a getenv("XXX") or something that would let me obtain the memory address instead of "just having to know" and hard code it in a #define.
Is there some way to get this value? _________________ 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 ? |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1354
|
|
Posted: Fri Dec 13, 2024 11:51 pm |
|
|
I think one of the parameters does, maybe PROGRAM_MEMORY. Should be easy to test |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sat Dec 14, 2024 3:53 am |
|
|
The address you are using is the flash config words address, which is
always at the top of the last page in the program memory. The
PROGRAM_MEMORY value should give this, since it is the address immediately
above the maximum value the program can use. However a quick check
shows this is giving the address of the top of this area, so will need to
have the size of the config area subtracted. If your chips are all similar this
will be the same on them all.
It would be quite nice to have this available, so I'd ask CCS for this. They
may say it is already available. |
|
|
|
|
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
|