STOP2 mode wakeup, restore register content issue

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

STOP2 mode wakeup, restore register content issue

Jump to solution
784 Views
marmotte
Contributor I

Hi,

 

I use a MC9S08QE16CLC mcu, CW10.6 and processor expert.

 

 

My goal is to make S08 to enter STOP2 mode and exit  by asserting IRQ pin ==> No problem to do that it works well

 

Before entering STOP2, I save to RAM the content of some registers I'd like to restore when MCU wakes up. This is where I get the issue.

 

in start08.c: The _Startup(void) is called after reset (and also wakeup) which itself call the Init(); function which ZERO-OUT all RAM content ==> the register content copy I stored in RAM before entering STOP2 is also initialized/erased.

 

 

Is there a way to prevent my stored datas to be initialized by Init() function in the StartUp code?

 

How can I proceed?

 

Thanks and Sorry for my poor english.

Labels (1)
0 Kudos
Reply
1 Solution
585 Views
kef2
Senior Contributor V

In PRM file you can replace READ_WRITE with NO_INIT. This will prevent initialization variables, which are placed in specified memory segments.

You can also split RAM segment into two segments, READ_WRITE part and NO_INIT part like below.

In PRM SEGMENTS:

    /*RAM                      =  READ_WRITE   0x0100 TO 0x047F;*/

    RAM                      =  READ_WRITE   0x0100 TO 0x037F;

    NIRAM                    =  NO_INIT      0x0380 TO 0x047F;

in PRM PLACEMENT add

    NOINITRAM                           INTO  NIRAM;

In C code:

#pragma DATA_SEG NOINITRAM

// data in NOINITRAM won't be initialized by startup code

int v1, v2, v3;

#pragma DATA_SEG DEFAULT

View solution in original post

0 Kudos
Reply
2 Replies
586 Views
kef2
Senior Contributor V

In PRM file you can replace READ_WRITE with NO_INIT. This will prevent initialization variables, which are placed in specified memory segments.

You can also split RAM segment into two segments, READ_WRITE part and NO_INIT part like below.

In PRM SEGMENTS:

    /*RAM                      =  READ_WRITE   0x0100 TO 0x047F;*/

    RAM                      =  READ_WRITE   0x0100 TO 0x037F;

    NIRAM                    =  NO_INIT      0x0380 TO 0x047F;

in PRM PLACEMENT add

    NOINITRAM                           INTO  NIRAM;

In C code:

#pragma DATA_SEG NOINITRAM

// data in NOINITRAM won't be initialized by startup code

int v1, v2, v3;

#pragma DATA_SEG DEFAULT

0 Kudos
Reply
585 Views
marmotte
Contributor I

Thanks a lot for your help, it now works as expected.

0 Kudos
Reply