What is correct way to declare an array of pointers in flash (ROM)?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

I would like to generate a pointer array in flash (ROM) initialized with the addresses of tool generated variables (G4 CapSense data from the structure) for tuning and general debugging.  This way I'm able to use a loop to index the data without using the macro "CapSense_BUTTON0_SNS0_RAW0_VALUE".  I've tried named areas and assigned the area to flash in the build settings for the linker. 

   

I understand

   

const uint8 Variable = 0x12;  // Put in flash.

   

needs an initializer to put it into flash.  Otherwise the compiler create a RAM variable.

   

const uint8 Variable;              // Put in RAM.

   

 

   

Here is a snippet of the declaration.  The comments added are what I've determine by using the debugger to confirm the compiler's placement in memory.  I have successfully used a struct in a named area in flash with initializers before, so I'm puzzled why the declaration and initialization does not work.

   

uint16 * const VariableCapSense_sensorRaw4[] = // INCORRECT array in FLASH of random? addresses.

   

{

   

&CapSense_BUTTON0_SNS0_RAW0_VALUE,

   

&CapSense_BUTTON1_SNS0_RAW0_VALUE,

   

&CapSense_BUTTON2_SNS0_RAW0_VALUE,

   

&CapSense_BUTTON3_SNS0_RAW0_VALUE

   

};

   

 This should be the correct construction - VariableCapSense_sensorRaw4[] is an array in const memory of pointers to uint16's in RAM.

   

But my results placed this array at address 0 according to the debugger.

0 Likes
1 Solution
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received


This Application Note properly defines the step needed to place code and variables in custom locations.Please go through page#23 & #29(section9.3 &9.4)- http://www.cypress.com/file/46521/download This is a KBA for placing functions. http://www.cypress.com/knowledge-base-article/locating-object-files-specific-memory-section-psoc-cre...
 

View solution in original post

0 Likes
1 Reply
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received


This Application Note properly defines the step needed to place code and variables in custom locations.Please go through page#23 & #29(section9.3 &9.4)- http://www.cypress.com/file/46521/download This is a KBA for placing functions. http://www.cypress.com/knowledge-base-article/locating-object-files-specific-memory-section-psoc-cre...
 

0 Likes