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:
And then the code generated was the following:
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.
已解决! 转到解答。
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.
-------------------------------------------------------------------------------
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.
-------------------------------------------------------------------------------
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.
-------------------------------------------------------------------------------