How to set a NO-INIT var in C startup runtime?

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

How to set a NO-INIT var in C startup runtime?

2,209 Views
w_tension
Contributor III

I konw I can edit *.PRM file to do this.

Is there a way like ARM compiler using "__no_init" command?

Labels (1)
Tags (1)
0 Kudos
3 Replies

1,815 Views
mihir_rajput
Contributor III

@ZhangJennie your answer is helpful. I want to carve out a section of RAM with a NO_INIT qualifier for improved start up time.

How do I assign a variable to this particular segment? 

0 Kudos

1,798 Views
mihir_rajput
Contributor III

In a c file:

#pragma DATA_SEG restart_detection_ram_data
static RestartStruct_t restart;
#pragma DATA_SEG DEFAULT

In prm file:

SEGMENTS

/* RAM 8k */
STARTUP_RAM = NO_INIT 0x001000 TO 0x00103F; // 64 bytes

RAM = READ_WRITE 0x001040 TO 0x002DFF; // 8k - 64 - 512 bytes

PLACEMENT

SSTACK, /* allocate stack first to avoid overwriting variables on overflow */
DEFAULT_RAM INTO RAM;
restart_detection_ram_data INTO STARTUP_RAM;

0 Kudos

1,825 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi,

Thank you for posting your questions.

We can't do this for a specific variable but we can do it for a section. I suggest you use NO_INIT qualifier to the RAM section that you don't want be initialized.

NO_INIT: used for address ranges where read/write accesses are allowed. The linker does not initialize memory area defined with this qualifier at application startup. This is useful if your target has a battery-buffered RAM or to speed up application startup.

For example:

///////////////////////

SECTIONS

  ROM   = READ_ONLY  0x1000 SIZE 0x2000;

  CLOCK = NO_INIT    0xFF00 TO   0xFFFF;

  RAM   = READ_WRITE 0x3000 TO   0x3EFF;

  Page0 = PAGED      0x4000 TO   0x4FFF;

  Page1 = PAGED      0x4000 TO   0x4FFF;

END

/////////////////////////

The CLOCK section is a READ_WRITE memory area. It starts at address 0xFF00 and ends at 0xFFFF (size = 100 bytes). Variables allocated in this segment are not initialized at application startup.

Does this answer your questions?


Have a great day,
Jennie Zhang

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