How to put s08 Microcontroller in sleep mode(stop3) and wakeup it?

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

How to put s08 Microcontroller in sleep mode(stop3) and wakeup it?

521 Views
mehdializadeh
Contributor II

Hi,
I am using mc9s08dz96 microcontroller with 8 MHz external clock osc. I have read This document and I have try to write a function, When the timer value reaches a certain value, the function is executed and I expect the microcontroller to go to stop3.
First I try to set this register:

 

 

void stop3(){
	setReg8(SPMSC1, 0x14U);
	setReg8(SPMSC2, 0x00U); 
	setReg8(SOPT1, 0x23U);
	setReg8(MCGC1, 0x04U);
	setReg8(MCGC2, 0x26U);
}

 

 

 With this function, the power consumption did not decrease. I tried to set the registers in more detail with the help of datasheet .

 

 

void stop3(){       
    MCGC1_IRCLKEN = 1;
	SPMSC1_LVDSE = 1;
	SPMSC1_LVDE = 1;
	SOPT1_STOPE = 1;
	SPMSC2_PPDC = 0;
	SPMSC1_LVDRE = 1;
	SPMSC1_LVWACK = 1;
	SOPT1_STOPE = 1;
	MCGC1_IREFS = 1;
	MCGC2_ERCLKEN = 1;
	MCGC2_EREFS = 1;
	MCGC2_HGO = 1;
	MCGC2_RANGE = 1;
}

 

 

But this code didn't work either. Does anyone have experience doing this?
Thank you in advance.

0 Kudos
2 Replies

498 Views
vicentegomez
NXP TechSupport
NXP TechSupport

To enter stop mode(stop2,stop3),just use the following instruction:

_asm stop;

You can place these to instruction at wherever you want.

The stop mode configuration is determined by SOPT1:STOPE ,this bit should be enabled to enable stop mode SPMSC2:PPDC,configure to enter stop2 or stop3

 

Notice:If you want to enter stop2,you should disable the LVD or you will enter stop3.After wake up from stop2,you shold clear the PPDF by write a one to PPDACK.

 

 

0 Kudos

485 Views
mehdializadeh
Contributor II

Thanks a lot for your reply,

I set this register:

 

 

void _EntryPoint(void)
{
  setReg8(SOPT1, 0x20U);                
  setReg8(SOPT2, 0x00U);                
  setReg8(SPMSC1, 0x1CU);               
  setReg8(SPMSC2, 0x00U);               

  if (*(uint8_t*)0xFFAFU != 0xFFU) {   
    MCGTRM = *(uint8_t*)0xFFAFU;   
    MCGSC = *(uint8_t*)0xFFAEU;       
  }

  setReg8(MCGC2, 0x26U);          
  setReg8Bits(MCGC3, 0x10U);            
  setReg8(MCGC1, 0x9AU);          
  setReg8(MCGC3, 0x14U);            
  setReg8(MCGT, 0x00U);             
  while(MCGSC_OSCINIT == 0U) {      
  }
  while(MCGSC_IREFST != 0U) {        
  }
  while((MCGSC & 0x0CU) != 0x08U) {  
  }

  setReg8(MCGC2, 0x2EU);  
  setReg8(MCGC1, 0x92U); 

  clrReg8Bits(MCGC3, 0x10U);            
  setReg8(MCGC3, 0x44U);              
  while(MCGSC_PLLST == 0U) {       
  }

  clrReg8Bits(MCGC2, 0x08U);            
  while(MCGSC_LOCK == 0U) {        
  }
  setReg8(MCGC1, 0x12U);     
  while((MCGSC & 0x0CU) != 0x0CU) {  
  }
  
  __asm   jmp _Startup ;       
}

 

 

But the command "__asm stop;" in main(), has no effects. The project file is attached. 
Thank you

0 Kudos