Link global struct variable into FlexRAM memory

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Link global struct variable into FlexRAM memory

604 Views
benjamin_doerne
Contributor I

Hi everyone,

In order to have a more human readable and also address care-free way to deal with the EEEPROM, my idea was as follows:

  • link a global struct variable into the FlexRAM memory area (starts at 0x14000000)
    __DATA(FLEX_RAM) MyStruct myStructVariable;

    Note: this is done above the main() function

  • read and write via the SDK function 
    writeToFlexRam((uint32_t)&myStructVariable.value1, (uint8_t*)&someValue, sizeof(someValue));

Unfortunately this leads to a hard fault. Whenever I link the variable to another RAM, let's say RAM2, no hard fault occurs.

What's wrong with my approach? Any ideas?

Thanks in advance

Benjo

Labels (1)
0 Kudos
4 Replies

519 Views
benjamin_doerne
Contributor I

Hi Kerry,

The chip I'm using is the MKE18F512VLL16 supporting both, the FlexNVM and FlexRAM.
To link the struct variable into a RAM other than RAM3 (aka FLEX_RAM) makes no sense because I want to use the variable instead of hard coded FlexRAM addresses (which is prone to errors, such as typos, miscalculations, etc.).

The section where I'd like to have the struct variable is

/* DATA section for FLEX_RAM */
.data_RAM3 : ALIGN(8)
 {
 FILL(0xff)
 PROVIDE(__start_data_RAM3 = .) ;
 *(.ramfunc.$RAM3)
 *(.ramfunc.$FLEX_RAM)
 *(.data.$RAM3)
 *(.data.$FLEX_RAM)
 *(.data.$RAM3.*)
 *(.data.$FLEX_RAM.*)
 . = ALIGN(8) ;
 PROVIDE(__end_data_RAM3 = .) ;
 } > FLEX_RAM AT>PROGRAM_FLASH

How I'd like to write to the EEEPROM:

writeToFlexRam((uint32_t)&myStructVariable.value1, (uint8_t*)&someValue, sizeof(someValue));

What I'd like to avoid:

writeToFlexRam((0x14000000, (uint8_t*)&someValue, sizeof(someValue));
writeToFlexRam((0x14000004, (uint8_t*)&someValue2, sizeof(someValue2));

 

Cheers, 

Benjo

0 Kudos

519 Views
benjamin_doerne
Contributor I

Hi all,

found the solution myself. Instead of

__DATA(FLEX_RAM) MyStruct myStructVariable;

I used

__NOINIT(FLEX_RAM) MyStruct myStructVariable;

Now it works as expected.

0 Kudos

519 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi  benjamin.doerner@tecan.com ,

  Thanks for sharing the solutions.

  If you have the new question in the future, welcome to create the new case.

 

Have a great day,
Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

519 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi  benjamin.doerner@tecan.com ,

   Please tell me your kineti chip partnumber, please make sure your chip contains the FLEXNVM or not?

   If it contains the FlexNVM, whether you already use your FlexRAM as the EEPROM.

   If your chip don't contains the FlexNVM, you can use your FlexRAM(make sure your chip has it).

   I think you also can define your structure code in the normal RAM address, whether it works or not, just make sure it is not the code problem.

Wish it helps you!

If you still have questions about it, please kindly let me know.

Have a great day,
Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos