HCS08 Stop Mode2: Problem restoring I/O pins after wake-up

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

HCS08 Stop Mode2: Problem restoring I/O pins after wake-up

Jump to solution
1,262 Views
patrickk
Contributor I

Hi, I'm working on a project with MC9S08QD2. The CPU awake from stop mode 2 from a free count RTI every 250ms. After waking up the processor should restore the output I/O pins and check input pins before going to sleep again. My problem is how I can restore the I/Os after waking up. I know that I have to store the I/O status in RAM before going to sleep. I added this code in .prm file:

SECTIONSSOME_CONSTANTS = READ_ONLY 0x1000 TO 0x1010; /* RAM area */ENDPLACEMENTMY_CONSTANTS INTO SOME_CONSTANTS;END

 and this in my .c file:

#pragma CONST_SEG MY_CONSTANTSvolatile int store_IO; /* place in global namespace */#pragma CONST_SEG DEFAULT

It seems that the the variable is not stored in RAM correctly. Can anyone help me out there? Some sample code would be help much. Thanks.

Labels (1)
0 Kudos
Reply
1 Solution
547 Views
CompilerGuru
NXP Employee
NXP Employee

I see two issues.

First in the PRM file the "SOME_CONSTANTS" segment is defined as READ_ONLY.

As it ends up in RAM I don't think this is what you want. Basically READ_ONLY means that it is programmed at flashing time (with a programmer, or even placed in a real ROM).

For content in RAM either user READ_WRITE if the content should be initialized by the startup code or 

NO_INIT if the startup code should not touch it.

E.g.:

SOME_CONSTANTS = NO_INIT 0x1000 TO 0x1010; /* RAM area */

The second issue is that a #pragma CONST_SEG applies to constants, but the variable shown is not const.

So use a #pragma DATA_SEG (or make the variable const if the variable really does not change) .

 

#pragma DATA_SEG MY_CONSTANTS

volatile int store_IO; /* place in global namespace */

#pragma CONST_SEG DEFAULT

 or

 

#pragma CONST_SEG MY_CONSTANTS
const volatile int store_IO = 0; /* place in global namespace */
#pragma CONST_SEG DEFAULT

 

 Daniel

View solution in original post

0 Kudos
Reply
3 Replies
547 Views
patrickk
Contributor I
Many thanks to you both for helping me out. I appreciate it. Sometimes the easiest things remain unnoticed. I've changed the constant to a data variable and changed the RAM adress. Now it is working perfectly.
0 Kudos
Reply
548 Views
CompilerGuru
NXP Employee
NXP Employee

I see two issues.

First in the PRM file the "SOME_CONSTANTS" segment is defined as READ_ONLY.

As it ends up in RAM I don't think this is what you want. Basically READ_ONLY means that it is programmed at flashing time (with a programmer, or even placed in a real ROM).

For content in RAM either user READ_WRITE if the content should be initialized by the startup code or 

NO_INIT if the startup code should not touch it.

E.g.:

SOME_CONSTANTS = NO_INIT 0x1000 TO 0x1010; /* RAM area */

The second issue is that a #pragma CONST_SEG applies to constants, but the variable shown is not const.

So use a #pragma DATA_SEG (or make the variable const if the variable really does not change) .

 

#pragma DATA_SEG MY_CONSTANTS

volatile int store_IO; /* place in global namespace */

#pragma CONST_SEG DEFAULT

 or

 

#pragma CONST_SEG MY_CONSTANTS
const volatile int store_IO = 0; /* place in global namespace */
#pragma CONST_SEG DEFAULT

 

 Daniel

0 Kudos
Reply
547 Views
bigmac
Specialist III

Hello,

 

For the 9S08QD2 device, the address range starting at 0x1000 is actually unimplemented.  You will need to place the RAM data somewhere within the range 0x0080 to 0x00FF, and possibly not too high within this range to allow sufficient room for the stack, with an upper address of 0x00FF.

 

Regards,

Mac

 

0 Kudos
Reply