I am trying to use the following code to put the chip in deep sleep mode to save current.
these few lines is copied from low power demo
PORTA_PCR7 = PORT_PCR_MUX(1); //p3
// llwu_configure(1<<3, LLWU_PIN_RISING, 0);
SMC_PMPROT = SMC_PMPROT_AVLLS_MASK;
SMC_PMCTRL = SMC_PMCTRL_STOPM(4);
SMC_STOPCTRL = SMC_PMCTRL_STOPM(0) | SMC_STOPCTRL_PORPO_MASK; // disable POR circuit
the PTB3 toggle before this code, I expected the PTB3 will not toggle after above code, but seems to me the above code won't set the chip in low power mode.
I am a hw engineer. with limited program knowledge. could any one give me some detail instruction to set this chip in deep sleep mode, I don't need to wake it up. this is just a back up chip. when I need it, I will reload the flash.
sincerely.
David
/* ###################################################################
** Filename : ProcessorExpert.c
** Project : ProcessorExpert
** Processor : MKL04Z8VFK4
** Version : Driver 01.01
** Compiler : IAR ARM C Compiler
** Date/Time : 2014-05-27, 10:23, # CodeGen: 0
** Abstract :
** Main module.
** This module contains user's application code.
** Settings :
** Contents :
** No public methods
**
** ###################################################################*/
/*!
** @file ProcessorExpert.c
** @version 01.01
** @brief
** Main module.
** This module contains user's application code.
*/
/*!
** @addtogroup ProcessorExpert_module ProcessorExpert module documentation
** @{
*/
/* MODULE ProcessorExpert */
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "GPIO1.h"
/* Including shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
//#include "llwu.h"
/* User includes (#include below this line is not maintained by Processor Expert) */
LDD_TDeviceData *MyGPIO1Ptr;
/*lint -save -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
/* Write your local variable definition here */
unsigned int i,j, k;
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/
MyGPIO1Ptr = GPIO1_Init((LDD_TUserData *)NULL);
/* Write your code here */
/* For example: for(;;) { } */
PORTB_PCR6 |= PORT_PCR_MUX(0x01);
PORTB_PCR6 |= 0x03;
GPIOB_PDDR |= 0X40;
for(k=0;k<10;k++)
{
for(j=0;j<2;j++)for(i=0;i<6553;i++);
GPIO1_ToggleFieldBits(MyGPIO1Ptr, PTB3, 0x1U); // this code works
GPIOB_PTOR |= 0x40;
//GPIOB_PTOR |= 0x40;
}
// the following 4 lines is I copied from low power demo program provide by Freescale. I don't know what this means, all I need to do is put the chip in sleep mode and I may use them later.
PORTA_PCR7 = PORT_PCR_MUX(1); //p3
// llwu_configure(1<<3, LLWU_PIN_RISING, 0);
SMC_PMPROT = SMC_PMPROT_AVLLS_MASK;
SMC_PMCTRL = SMC_PMCTRL_STOPM(4);
SMC_STOPCTRL = SMC_PMCTRL_STOPM(0) | SMC_STOPCTRL_PORPO_MASK; // disable POR circuit
for(k=0;k<10;k++)
{
for(j=0;j<2;j++)for(i=0;i<655;i++);
GPIO1_ToggleFieldBits(MyGPIO1Ptr, PTB3, 0x1U); // I still can see the signal toggle, which is not expected. I hope the chip in sleep mode
GPIOB_PTOR |= 0x40;
//GPIOB_PTOR |= 0x40;
}
// printf("\n enter into VLLS0_2 mode--.\n");
// SMC_PMPROT = SMC_PMPROT_AVLLS_MASK;
// SMC_PMCTRL = SMC_PMCTRL_STOPM(4);
// SMC_STOPCTRL = SMC_PMCTRL_STOPM(0) | SMC_STOPCTRL_PORPO_MASK; // disable POR circuit
/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;){}
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
/* END ProcessorExpert */
/*!
** @}
*/
已解决! 转到解答。
Hi Davidson,
Thank you for your question in our community.
I add the lowpower code based on KL04Z8VFK4_toggle_PTB3 project which I give you at the last time, please find the attached project.
The project function is after PTB3 toggle 50 times, the CPU will enter into VLLS3 mode, the power consumption will very low, my consumption is about 1.17uA.
You can use the falling edge of PTA5 as the wake up source, after wakeup, it will enter into VLLS3 again.
For details, please refer to the attached code.
Wish it helps you!
If you still have question, please contact with me!
Have a great day,
(Jingjing)
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Davidson,
Thank you for your question in our community.
I add the lowpower code based on KL04Z8VFK4_toggle_PTB3 project which I give you at the last time, please find the attached project.
The project function is after PTB3 toggle 50 times, the CPU will enter into VLLS3 mode, the power consumption will very low, my consumption is about 1.17uA.
You can use the falling edge of PTA5 as the wake up source, after wakeup, it will enter into VLLS3 again.
For details, please refer to the attached code.
Wish it helps you!
If you still have question, please contact with me!
Have a great day,
(Jingjing)
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
I am using this example to get a KL04 into low power mode. I have copied relevant portions of the code into my project but the following lines do not compile:
SCB_SCR &= (uint32_t)~(uint32_t)(SCB_SCR_SLEEPONEXIT_MASK);
/* SCB_SCR: SLEEPDEEP=1 */
SCB_SCR |= SCB_SCR_SLEEPDEEP_MASK;
I'm using KDS 3.0. It is complaining that the SCB_* registers and constants are not defined. I have found SCB_SCR_SLEEPONEXIT_Msk in the core_cm4.h header file, but still no mention of SCB_SCR.
Thanks for the reply. I'm back on this project again, but I've switched back to CodeWarrior since 10.6.3 supports the KL04 -- so the missing register isn't affecting me anymore. In case it's a bug, I've attached the file you mentioned. I can't find the register in it. The project was created with KDS 3.0 (as I remember, I don't have it installed anymore).
Hi Jingjing
in English, they never say, No thanks in this situation, they always say "you are welcome".
No thanks 要翻译成,“不用了,谢谢” 而不是“不用谢”。
of cause, we are all Chinese. so I understand what you mean.
I am not going to debug this time, all I need is to put it in to sleep mode. is it possible for me to rewrite the flash with new image later when I want make it work.
thanks,
David Sun
Hi David,
Of course you can rewrite the flash with new image, you can download it to your flash, then power off and power on again, the low power code will run, MCU will enter into vlls3 mode!
If your test has any quesiton, please let me know(both community or SR is ok!).
Best regards!
Jingjing
Hi,
I attach a simple code compiled in CodeWarrior with Processor Expert to put the device in VLLS3 (Very Low Leakage Stop3) mode which is a Sleep Deep mode.
The code just to that and nothing more as you told in your requirements.
I hope this information can help you.
Regards,
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. It would be nice!
-----------------------------------------------------------------------------------------------------------------------
Hi ,
if I remember correctly, CPU bean of processor expert allows you to configure low power features and provides the functions to do the low power mode entry and curing the state after wake up
Pavel