Mark Hahn

How can I set up a section that the initialization code leaves alone? (on MCF521100)

Discussion created by Mark Hahn on Mar 16, 2009
Latest reply on Mar 18, 2009 by CrasyCat

This is for a coldfile MCF52110 processor. Developing code with Codewarrior 5.9.0.


I figured out how to set up a section, by modifying the linker control file.


In memory section:


  interrupts  (RX) : ORIGIN = 0x20000000, LENGTH = 0x00000500
  code        (RX) : ORIGIN = 0x20000500, LENGTH = 0x00002754
  data        (RW) : ORIGIN = 0x20002C54, LENGTH = 0x0000139C
  Magic_mem   (RX) : ORIGIN = 0x20003FF0, LENGTH = 0x00000010  <== memory for my new section

  ipsbar      (RW) : ORIGIN = 0x40000000, LENGTH = 0x0




  .Magic : {
  } > Magic_Mem


and then use a statement like:


#pragma define_section _Magic ".Magic" far_absolute R
__declspec (_Magic) char magic_data[16];


to set up variables in my new section.


The whole reason I'm trying to do this is to try to set aside a small area of RAM that the compiler's initialization code doesn't clear to 0 or initialize to some value.


Why? I want to be able to save a few bytes of system status, so that after an unexpected reset, there is some way for the system to figure out what state it is supposed to be in.


But this all seems way too complicated. Is there an easier way to accomplish this?