<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>8-bit MicrocontrollersのトピックHow to put the S08DZ96 to sleep mode!?</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-put-the-S08DZ96-to-sleep-mode/m-p/1593489#M23643</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;SPAN&gt;I am using mc9s08dz96.&lt;BR /&gt;&lt;/SPAN&gt;This is the first time I want to put the MCU to sleep. I want to use STOP3 mode. So far I have found that I need to set some registers before issuing the STOP command. I have made these settings according to the datasheet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void _EntryPoint(void)
{
  /* ### MC9S08DZ128_64 "Cpu" init code ... */
  /*  PE initialization code after reset */
  /* Common initialization of the write once registers */
  /* SOPT1: COPT=0,STOPE=1,SCI2PS=0,IIC1PS=0,??=0,??=0,??=0 */
  setReg8(SOPT1, 0x20U);                
  /* SOPT2: COPCLKS=0,COPW=0,??=0,ADHTS=0,??=0,MCSEL=0 */
  setReg8(SOPT2, 0x00U);                
  /* SPMSC1: LVWF=0,LVWACK=0,LVWIE=0,LVDRE=1,LVDSE=1,LVDE=1,??=0,BGBE=0 */
  setReg8(SPMSC1, 0x1CU);               
  /* SPMSC2: ??=0,??=0,LVDV=0,LVWV=0,PPDF=0,PPDACK=0,??=0,PPDC=0 */
  setReg8(SPMSC2, 0x00U);               
  /*  System clock initialization */
  /*lint -save  -e923 Disable MISRA rule (11.3) checking. */
  if (*(uint8_t*)0xFFAFU != 0xFFU) {   /* Test if the device trim value is stored on the specified address */
    MCGTRM = *(uint8_t*)0xFFAFU;       /* Initialize MCGTRM register from a non volatile memory */
    MCGSC = *(uint8_t*)0xFFAEU;        /* Initialize MCGSC register from a non volatile memory */
  }
  /*lint -restore Enable MISRA rule (11.3) checking. */
  /* MCGC2: BDIV=0,RANGE=1,HGO=0,LP=0,EREFS=0,ERCLKEN=1,EREFSTEN=1 */
  setReg8(MCGC2, 0x23U);               /* Set MCGC2 register */ 
  /* MCGC3: DIV32=1 */
  setReg8Bits(MCGC3, 0x10U);            
  /* MCGC1: CLKS=2,RDIV=3,IREFS=0,IRCLKEN=1,IREFSTEN=1 */
  setReg8(MCGC1, 0x9BU);               /* Set MCGC1 register */ 
  /* MCGC3: LOLIE=0,PLLS=0,CME=0,DIV32=1,VDIV=4 */
  setReg8(MCGC3, 0x14U);               /* Set MCGC3 register */ 
  /* MCGT: ??=0,??=0,DMX32=0,??=0,??=0,??=0,??=0,DRST_DRS=0 */
  setReg8(MCGT, 0x00U);                /* Set MCGT register */ 
  while(MCGSC_IREFST != 0U) {          /* Wait until external reference is selected */
  }
  while((MCGSC &amp;amp; 0x0CU) != 0x08U) {    /* Wait until external clock is selected as a bus clock reference */
  }
  /* MCGC2: BDIV=0,RANGE=1,HGO=0,LP=1,EREFS=0,ERCLKEN=1,EREFSTEN=1 */
  setReg8(MCGC2, 0x2BU);               /* Set MCGC2 register */ 
  /* MCGC1: CLKS=2,RDIV=2,IREFS=0,IRCLKEN=1,IREFSTEN=1 */
  setReg8(MCGC1, 0x93U);               /* Set MCGC1 register */ 
  /* MCGC3: DIV32=0 */
  clrReg8Bits(MCGC3, 0x10U);            
  /* MCGC3: LOLIE=0,PLLS=1,CME=0,DIV32=0,VDIV=4 */
  setReg8(MCGC3, 0x44U);               /* Set MCGC3 register */ 
  while(MCGSC_PLLST == 0U) {           /* Wait until PLL is selected */
  }
  /* MCGC2: LP=0 */
  clrReg8Bits(MCGC2, 0x08U);            
  while(MCGSC_LOCK == 0U) {            /* Wait until PLL is locked */
  }
  /* MCGC1: CLKS=0,RDIV=2,IREFS=0,IRCLKEN=1,IREFSTEN=1 */
  setReg8(MCGC1, 0x13U);               /* Set MCGC1 register */ 
  while((MCGSC &amp;amp; 0x0CU) != 0x0CU) {    /* Wait until PLL clock is selected as a bus clock reference */
  }
  

  /*** End of PE initialization code after reset ***/
  /*lint -save  -e950 Disable MISRA rule (1.1) checking. */
  __asm   jmp _Startup ;               /* Jump to C startup code */
  /*lint -restore Enable MISRA rule (1.1) checking. */
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next, I put the "__asm stop;"&amp;nbsp;command in the main(),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void main(void)
{
  PE_low_level_init();
  while(1){
  __asm stop;
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I don't see any change that the power consumption has decreased.&amp;nbsp;In fact, I expect the device's consumption to reach microamps after the stop command, instead of the usual 30mA.&amp;nbsp;Is " __asm stop; " command correct?&amp;nbsp;Shouldn't I define it before this command?&lt;BR /&gt;Thank you for your help.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 05 Feb 2023 07:35:08 GMT</pubDate>
    <dc:creator>mehdializadeh</dc:creator>
    <dc:date>2023-02-05T07:35:08Z</dc:date>
    <item>
      <title>How to put the S08DZ96 to sleep mode!?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-put-the-S08DZ96-to-sleep-mode/m-p/1593489#M23643</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;SPAN&gt;I am using mc9s08dz96.&lt;BR /&gt;&lt;/SPAN&gt;This is the first time I want to put the MCU to sleep. I want to use STOP3 mode. So far I have found that I need to set some registers before issuing the STOP command. I have made these settings according to the datasheet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void _EntryPoint(void)
{
  /* ### MC9S08DZ128_64 "Cpu" init code ... */
  /*  PE initialization code after reset */
  /* Common initialization of the write once registers */
  /* SOPT1: COPT=0,STOPE=1,SCI2PS=0,IIC1PS=0,??=0,??=0,??=0 */
  setReg8(SOPT1, 0x20U);                
  /* SOPT2: COPCLKS=0,COPW=0,??=0,ADHTS=0,??=0,MCSEL=0 */
  setReg8(SOPT2, 0x00U);                
  /* SPMSC1: LVWF=0,LVWACK=0,LVWIE=0,LVDRE=1,LVDSE=1,LVDE=1,??=0,BGBE=0 */
  setReg8(SPMSC1, 0x1CU);               
  /* SPMSC2: ??=0,??=0,LVDV=0,LVWV=0,PPDF=0,PPDACK=0,??=0,PPDC=0 */
  setReg8(SPMSC2, 0x00U);               
  /*  System clock initialization */
  /*lint -save  -e923 Disable MISRA rule (11.3) checking. */
  if (*(uint8_t*)0xFFAFU != 0xFFU) {   /* Test if the device trim value is stored on the specified address */
    MCGTRM = *(uint8_t*)0xFFAFU;       /* Initialize MCGTRM register from a non volatile memory */
    MCGSC = *(uint8_t*)0xFFAEU;        /* Initialize MCGSC register from a non volatile memory */
  }
  /*lint -restore Enable MISRA rule (11.3) checking. */
  /* MCGC2: BDIV=0,RANGE=1,HGO=0,LP=0,EREFS=0,ERCLKEN=1,EREFSTEN=1 */
  setReg8(MCGC2, 0x23U);               /* Set MCGC2 register */ 
  /* MCGC3: DIV32=1 */
  setReg8Bits(MCGC3, 0x10U);            
  /* MCGC1: CLKS=2,RDIV=3,IREFS=0,IRCLKEN=1,IREFSTEN=1 */
  setReg8(MCGC1, 0x9BU);               /* Set MCGC1 register */ 
  /* MCGC3: LOLIE=0,PLLS=0,CME=0,DIV32=1,VDIV=4 */
  setReg8(MCGC3, 0x14U);               /* Set MCGC3 register */ 
  /* MCGT: ??=0,??=0,DMX32=0,??=0,??=0,??=0,??=0,DRST_DRS=0 */
  setReg8(MCGT, 0x00U);                /* Set MCGT register */ 
  while(MCGSC_IREFST != 0U) {          /* Wait until external reference is selected */
  }
  while((MCGSC &amp;amp; 0x0CU) != 0x08U) {    /* Wait until external clock is selected as a bus clock reference */
  }
  /* MCGC2: BDIV=0,RANGE=1,HGO=0,LP=1,EREFS=0,ERCLKEN=1,EREFSTEN=1 */
  setReg8(MCGC2, 0x2BU);               /* Set MCGC2 register */ 
  /* MCGC1: CLKS=2,RDIV=2,IREFS=0,IRCLKEN=1,IREFSTEN=1 */
  setReg8(MCGC1, 0x93U);               /* Set MCGC1 register */ 
  /* MCGC3: DIV32=0 */
  clrReg8Bits(MCGC3, 0x10U);            
  /* MCGC3: LOLIE=0,PLLS=1,CME=0,DIV32=0,VDIV=4 */
  setReg8(MCGC3, 0x44U);               /* Set MCGC3 register */ 
  while(MCGSC_PLLST == 0U) {           /* Wait until PLL is selected */
  }
  /* MCGC2: LP=0 */
  clrReg8Bits(MCGC2, 0x08U);            
  while(MCGSC_LOCK == 0U) {            /* Wait until PLL is locked */
  }
  /* MCGC1: CLKS=0,RDIV=2,IREFS=0,IRCLKEN=1,IREFSTEN=1 */
  setReg8(MCGC1, 0x13U);               /* Set MCGC1 register */ 
  while((MCGSC &amp;amp; 0x0CU) != 0x0CU) {    /* Wait until PLL clock is selected as a bus clock reference */
  }
  

  /*** End of PE initialization code after reset ***/
  /*lint -save  -e950 Disable MISRA rule (1.1) checking. */
  __asm   jmp _Startup ;               /* Jump to C startup code */
  /*lint -restore Enable MISRA rule (1.1) checking. */
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next, I put the "__asm stop;"&amp;nbsp;command in the main(),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void main(void)
{
  PE_low_level_init();
  while(1){
  __asm stop;
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I don't see any change that the power consumption has decreased.&amp;nbsp;In fact, I expect the device's consumption to reach microamps after the stop command, instead of the usual 30mA.&amp;nbsp;Is " __asm stop; " command correct?&amp;nbsp;Shouldn't I define it before this command?&lt;BR /&gt;Thank you for your help.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Feb 2023 07:35:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-put-the-S08DZ96-to-sleep-mode/m-p/1593489#M23643</guid>
      <dc:creator>mehdializadeh</dc:creator>
      <dc:date>2023-02-05T07:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to put the S08DZ96 to sleep mode!?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-put-the-S08DZ96-to-sleep-mode/m-p/1594889#M23648</link>
      <description>&lt;P&gt;I saw that you already solved&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;Vicente&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 16:29:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/How-to-put-the-S08DZ96-to-sleep-mode/m-p/1594889#M23648</guid>
      <dc:creator>vicentegomez</dc:creator>
      <dc:date>2023-02-07T16:29:03Z</dc:date>
    </item>
  </channel>
</rss>

