CW for MobileGT - Create a User Data Segment?

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

CW for MobileGT - Create a User Data Segment?

Jump to solution
854 Views
Tim562
Senior Contributor I

Hi All,

 

    Can anyone offer some guidance on how to create a user data segment and then load some variables into that data segment on an MPC5125 with CodeWarrior for MobileGT? I'm sticking an NVRAM on the LocalPlus bus and I need to store some global vars in it.

 

I assume I need to modify the LInker Control file to create the user data segment and then maybe use a "#pragma section" statement in the code module where the variables are declared? I'm just not able to find any documentation on how to modify the LCF for the MPC5125. Any guidance or reading suggestions would sure be appreciated. Thanks!

 

~Tim

Labels (1)
0 Kudos
1 Solution
367 Views
stanish
NXP Employee
NXP Employee

Hello Tim,

 

I'd suggest you to try to use the pragma below instead of __declspec (section ".nvram_data")

 

#pragma push   //store pragma context
#pragma section  data_type sdata_type ".nvram_data" ".nvram_data"unsigned int iTemp = 0xA5A5;#pragma pop  // restore pragma context

 Stanish

View solution in original post

0 Kudos
3 Replies
367 Views
Tim562
Senior Contributor I

As a follow up to my earlier post, this is my current attempt at locating a variable in a section of memory that I define. Not having a lot of luck.

 

 

1.  Added an entry to the default Linker Control File MEMORY directive to represent the NVRAM area as I need it like this:

 

 

MEMORY{   SDRAM: org = 0x00000000, len = 0x10000000 // 256 MB DDR SDRAM   NVRAM: org = 0x10000000, len = 0x04000000 // 64 MB NVRAM   SRAM:  org = 0x30000000, len = 0x00008000 // 32K Internal SRAM   IMMR:  org = 0x80000000, len = 0x00100000 // 1 MB   FLASH: org = 0xfff00000, len = 0x00800000 // 8 MB }

 

  Then I added an entry to the default Linker Control File SECTIONS directive to create a section name for my NVRAM area (note: several GROUP entries removed for clarity):

 

SECTIONS{   GROUP : {      .nvram_data : {}   } > NVRAM   GROUP : {      .rosdata : {}      .sdata : {}      .sbss : {}   } > ram}

 

Finally, when I declared a variable I use the __declspec (section ".nvram_data") tool like this in an attempt to locate an intiger variable (iTemp) in the NVRAM section of the address space.

 

__declspec (section ".nvram_data")unsigned int iTemp = 0xA5A5;

 

 When I try to build the project I get "ERROR   : unknown section name '.nvram_data'

 

I think I'm on the right track here but I'm obviously missing some step(s). By the way it looks like the

"#pragma section("NVRAM",read,write)" pragma has fallen out of favor (according to the CW help file) so I've not been trying to use that. Anyadvice or observations? Thanks!

 

~Tim

 

 

 

0 Kudos
368 Views
stanish
NXP Employee
NXP Employee

Hello Tim,

 

I'd suggest you to try to use the pragma below instead of __declspec (section ".nvram_data")

 

#pragma push   //store pragma context
#pragma section  data_type sdata_type ".nvram_data" ".nvram_data"unsigned int iTemp = 0xA5A5;#pragma pop  // restore pragma context

 Stanish

0 Kudos
367 Views
Tim562
Senior Contributor I

Ahhh Stanish, that was it!!

 

      I was kind of steering away from the "#pragma section" code because the CW help pages list it as "depreciated" and say that "__declspec(section)" should be used. I just couldn't figure out how to make it happen. Thank you for your help, I sure appreciate it.

 

Best Regards,

Tim

0 Kudos