AnsweredAssumed Answered

how to allocate an area from internal flash to store private user data in CodeWarrior2.x

Question asked by wang heng on Aug 24, 2015
Latest reply on Aug 27, 2015 by wang heng

Hi,

 

If my 'inernal_flash' length is 1M, i want to allocate 100K memory from 'internal_flash' to store private user data.

Complier and linker can't use the 100K area to store hardware initialization routines, application code, constants and so on.

how should i modify the .lcf file ?

I consider that whether only modify length of 'internal_flash' segment from 1M to 924K in .lcf file ?

The 'internal_flash' segment defined in a MEMORY directive is used to to store sections .init, .text, .rodata, .ctors, .dtors, extab, extabindex and so on.

what operation I need to carry out for .lcf file ?

1、whether i need use .lcf file's MEMORY directive to associate a name 'myrom' for the 100K area ?

2、And then whether i need use .lcf file's SECTIONS directive to define a section which will be loaded in the memory area named 'myrom' ?

3、Finally, using #pragma and __declspec() directives to specify private user data write to specific section in source file ?

The 100K area is used to store all global variable value of CW every 60 seconds by flash_write driver function. After power-on startup, using flash_read driver function to read these global variable value which are stored in the 100K area last time. After the reading of global variable value, respectively assigning these read vlaue to global variable of CW project in order.

Could you tell me how to implement the feature ?

 

PS:

flash_read and flash_write driver functions are linked into 'inernal_flash' segment.

The 100K area can only be used to store all global variable value of CW project, not object code or/and other data.

Outcomes