MKE04Z8 Stop Mode

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

MKE04Z8 Stop Mode

跳至解决方案
1,398 次查看
pauvilanova
Contributor III

Hi,

I'm trying to make the MKE04Z8 enter STOP mode. I'm working with MCUXpresso IDE and I am not able to find the register to toggle to make the cpu enter stop mode when the WFI rutine is called. In the manual reference stop mode is only mentioned to explain functionalities and not how to really implement it.

In KDS there was an option on processor expert:

pastedImage_1.png

And then the code generated was the following:

pastedImage_2.png

This SCB_SCR des not exist in MCUXpresso nor it's mentioned on the manual reference. If I dont activate this deepsleep bit the __WFI(); rutine, it just puts my microcontroler in wait mode and that's not acceptable in my case, for consumption reasons.

I would like to know how to implement the STOP mode, using the clock tool in MCUXpresso or directly with baremetal.

Also if its possible, i would like to know if there are any interrupts enabled by default that could wake my mcu appart from the ones that I work with (just the RTC) 

Thanks.

标签 (1)
标记 (2)
1 解答
1,242 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Pau Vilanova,

  About the SCB register, you need to find it in the ARM cortexM0+ core document, not the KE04 reference manual.

  About the ARM core document, you can go to the ARM official website to find it.

  The register code, normally, you can find it in the core_cm0plus.h, I already attach it.

/* Memory mapping of Cortex-M0+ Hardware */
#define SCS_BASE            (0xE000E000UL)                            /*!< System Control Space Base Address */
#define SysTick_BASE        (SCS_BASE +  0x0010UL)                    /*!< SysTick Base Address */
#define NVIC_BASE           (SCS_BASE +  0x0100UL)                    /*!< NVIC Base Address */
#define SCB_BASE            (SCS_BASE +  0x0D00UL)                    /*!< System Control Block Base Address */

#define SCB                 ((SCB_Type       *)     SCB_BASE      )   /*!< SCB configuration struct */
#define SysTick             ((SysTick_Type   *)     SysTick_BASE  )   /*!< SysTick configuration struct */
#define NVIC                ((NVIC_Type      *)     NVIC_BASE     )   /*!< NVIC configuration struct */

#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U)
  #define MPU_BASE          (SCS_BASE +  0x0D90UL)                    /*!< Memory Protection Unit */
  #define MPU               ((MPU_Type       *)     MPU_BASE      )   /*!< Memory Protection Unit */
#endif

The stop mode code is:

void stop (void)
{
 /* Set the SLEEPDEEP bit to enable deep sleep mode (STOP) */
 SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; 

 /* WFI instruction will start entry into STOP mode */
#ifndef KEIL
        // If not using KEIL's uVision use the standard assembly command
 asm("WFI");
#else
        // If using KEIL's uVision, use the CMSIS intrinsic
 __wfi();
#endif
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍

*****************************************************************************/
void PMC_SetMode(PMC_Type *pPMC,uint8_t u8PmcMode)
{
    switch(u8PmcMode & 0x3) 
    {
        case PmcModeRun:    
            break;
        case PmcModeWait:
            wait();
            break;
        case PmcModeStop4:
            /* enable LVD in stop mode */
            pPMC->SPMSC1 |= (PMC_SPMSC1_LVDE_MASK | PMC_SPMSC1_LVDSE_MASK); 
            stop();   
            break;
        case PmcModeStop3: 
            /* disable LVD in stop mode */
            pPMC->SPMSC1 &= ~(PMC_SPMSC1_LVDE_MASK | PMC_SPMSC1_LVDRE_MASK | PMC_SPMSC1_LVDSE_MASK); 
            stop();  
            break;
        default: 
            break;
    }
 
}

You can add the baremetal code to your MCUXpresso project.

About the interrupt, it is totally determined by your own app code, if you enable the interrupt, when the interrupt happens, the STOP mode will be exit, you can your RTC code, whether enable the RTC interrupt or not.

The KE04 PMC sample code, you also can refer to the offical code, but it is the IAR and MDK project.

https://www.nxp.com/webapp/Download?colCode=FRDM-KEXX-Driver-Library-Package&appType=license 

Wish it helps you!

Have a great day,
Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

在原帖中查看解决方案

3 回复数
1,243 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Pau Vilanova,

  About the SCB register, you need to find it in the ARM cortexM0+ core document, not the KE04 reference manual.

  About the ARM core document, you can go to the ARM official website to find it.

  The register code, normally, you can find it in the core_cm0plus.h, I already attach it.

/* Memory mapping of Cortex-M0+ Hardware */
#define SCS_BASE            (0xE000E000UL)                            /*!< System Control Space Base Address */
#define SysTick_BASE        (SCS_BASE +  0x0010UL)                    /*!< SysTick Base Address */
#define NVIC_BASE           (SCS_BASE +  0x0100UL)                    /*!< NVIC Base Address */
#define SCB_BASE            (SCS_BASE +  0x0D00UL)                    /*!< System Control Block Base Address */

#define SCB                 ((SCB_Type       *)     SCB_BASE      )   /*!< SCB configuration struct */
#define SysTick             ((SysTick_Type   *)     SysTick_BASE  )   /*!< SysTick configuration struct */
#define NVIC                ((NVIC_Type      *)     NVIC_BASE     )   /*!< NVIC configuration struct */

#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U)
  #define MPU_BASE          (SCS_BASE +  0x0D90UL)                    /*!< Memory Protection Unit */
  #define MPU               ((MPU_Type       *)     MPU_BASE      )   /*!< Memory Protection Unit */
#endif

The stop mode code is:

void stop (void)
{
 /* Set the SLEEPDEEP bit to enable deep sleep mode (STOP) */
 SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; 

 /* WFI instruction will start entry into STOP mode */
#ifndef KEIL
        // If not using KEIL's uVision use the standard assembly command
 asm("WFI");
#else
        // If using KEIL's uVision, use the CMSIS intrinsic
 __wfi();
#endif
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍

*****************************************************************************/
void PMC_SetMode(PMC_Type *pPMC,uint8_t u8PmcMode)
{
    switch(u8PmcMode & 0x3) 
    {
        case PmcModeRun:    
            break;
        case PmcModeWait:
            wait();
            break;
        case PmcModeStop4:
            /* enable LVD in stop mode */
            pPMC->SPMSC1 |= (PMC_SPMSC1_LVDE_MASK | PMC_SPMSC1_LVDSE_MASK); 
            stop();   
            break;
        case PmcModeStop3: 
            /* disable LVD in stop mode */
            pPMC->SPMSC1 &= ~(PMC_SPMSC1_LVDE_MASK | PMC_SPMSC1_LVDRE_MASK | PMC_SPMSC1_LVDSE_MASK); 
            stop();  
            break;
        default: 
            break;
    }
 
}

You can add the baremetal code to your MCUXpresso project.

About the interrupt, it is totally determined by your own app code, if you enable the interrupt, when the interrupt happens, the STOP mode will be exit, you can your RTC code, whether enable the RTC interrupt or not.

The KE04 PMC sample code, you also can refer to the offical code, but it is the IAR and MDK project.

https://www.nxp.com/webapp/Download?colCode=FRDM-KEXX-Driver-Library-Package&appType=license 

Wish it helps you!

Have a great day,
Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

1,242 次查看
pauvilanova
Contributor III

Thanks for your fast response, now all makes more sense.

From 4mA to 0.2mA =).

0 项奖励
回复
1,242 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Pau Vilanova,

    Thank you for your updated information.

    So, now, do you still have any question about this topic?

    If you still have question about it, please let me know.

    If your question is solved, please help me to mark the correct answer, just to close this case, thank you!


Have a great day,
Kerry

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 项奖励
回复