CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC24 and getting the Configuration Bits address?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
allenhuffman



Joined: 17 Jun 2019
Posts: 554
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PIC24 and getting the Configuration Bits address?
PostPosted: Fri Dec 13, 2024 9:32 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Dec 13, 2024 11:51 pm     Reply with quote

I think one of the
Code:
getenv()
parameters does, maybe PROGRAM_MEMORY. Should be easy to test
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Sat Dec 14, 2024 3:53 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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