STOP2 mode wakeup, restore register content issue

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

STOP2 mode wakeup, restore register content issue

跳至解决方案
1,125 次查看
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.

标签 (1)
0 项奖励
回复
1 解答
926 次查看
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 项奖励
回复
2 回复数
927 次查看
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 项奖励
回复
926 次查看
marmotte
Contributor I

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

0 项奖励
回复