Hi all, despite a lot of tries I am unable to set the VLLS0 mode of a KL03 mcu using the KSDK v1.2 peripheral drivers in KDS v3.0.
The attached project is reduced to a strict minimum for testing: only a led and a switch for awakening from VLSS0. When debugging, after the instructions:
POWER_SYS_ClearWakeupPinFlag(kPowerManagerWakeupPin4);
POWER_SYS_SetMode(0, kPowerManagerPolicyForcible);
the code execution can be followed till the mode switch of the "__WFI();" instruction in the HAL component, then the J-Link debugger is suspended at 0X0 but the current supply remains the same indicating that the internal osc is still running. This could mean that there is an interrupt loop, but the LLWu external pin has no influence on it nor the flag clear in the handler:
void LLWU_IRQHandler(void) {
/* Write your code here. For example clear LLWU wake up flags ... */
POWER_SYS_ClearWakeupPinFlag(kPowerManagerWakeupPin4);
I feel as if I am missing something, but unfortunately the AN and documentation I found were not very helpful. Can someone help me please?
Original Attachment has been moved to: KL03-VLLS0-test.zip
已解决! 转到解答。
Check the errata on the KL03.
On reset the TIF flag in the RTC is set indicating that the RTC has an invalid time. When this flag is set the part has issues entering low power mode.
Clearing this flag allowed my design to finally enter sleep mode.
Good Luck
Check the errata on the KL03.
On reset the TIF flag in the RTC is set indicating that the RTC has an invalid time. When this flag is set the part has issues entering low power mode.
Clearing this flag allowed my design to finally enter sleep mode.
Good Luck
Hello Michael,
I have found the problem on your project.
There is still left to enable VLLS modes on SMC_PMPROT register. (On reference manual, see section 15.4.1 Power Mode Protection register) and also, restore peripherals I/O (because there are latched when being in VLLS mode), this is done by clearing ACKISO flag in PMC_REGSC register (section 16.5.3 Regulator Status and Control register).
You should add fsl_pmc_hal and fsl_smc_hal components to your project:
Generate code for being able to use PMC_HAL_GetAckIsolation() and SMC_HAL_SetProtection() functions.
First, you need to recover the I/O peripherals when entering from RESET and after that, you need to allow VLLS mode, it is done just after entering main function:
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
/* Write your local variable definition here */
uint32_t timerDly;
if (PMC_HAL_GetAckIsolation(PMC_BASE_PTR) != 0) {
PMC_HAL_ClearAckIsolation(PMC_BASE_PTR);
}
SMC_HAL_SetProtection(SMC_BASE_PTR,kAllowPowerModeVlls);
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/
/* Write your code here */
/* For example: for(;;) { } */
for(;;) {
// led blink
GPIO_DRV_ClearPinOutput(GPIOledV); // on
timerDly = timerRef + 500;
while (timerRef < timerDly) ; // wait
GPIO_DRV_SetPinOutput(GPIOledV); // off
// go low power
POWER_SYS_ClearWakeupPinFlag(kPowerManagerWakeupPin4);
POWER_SYS_SetMode(0, kPowerManagerPolicyForcible);
}
After compiling and running your project, I could be able to switch to VLLS0 mode and then return to RUN mode by resetting the board using LLWU_P4.
I attach project that i used to test your code (to test in FRDM-KL03Z board) , it may be helpful for you.
Note: I needed to switch CPU to MKL03Z32VFK4 (and GPIO output) in order to be compatible with FRDM-KL03Z.
Could you please try adding these changes?
Best Regards,
Isaac Avila
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Isaac,
back at work and sorry for the long time elapsed.
Thanks for your answer, but unfortunately none of your VLLS0_... version and my KL03... version modified as suggested puts the mcu in deep sleep. The only difference I noted is you are using an external oscillator while I use the internal one.
When running, the WFI instruction is executed, at once debugger connection is lost and processor resets as if there was some interrupt pending and this cycle repeats for again (through reset). I also tried to disable the LLWU_P4, gòobaò interrupt and reset pin in PE component but without change.
Any idea? Thanks, Michael
Hi Michael,
I am still working on your issue.
It is hard to understand what is happening, I will try to modify my example project to use internal reference to verify if this is causing your issue.
I will thank your patience.
Best regards,
Isaac
Hello Michael
I wouldn't use the debugger when testing/developing low leakage modes since there are conflicts with the debugger; it is best to test such things on the stand-alone hardware.
Note that wake up from VLLS0 and a wakeup port is via a RESET so there is no interrupt that is handled at wake up - but the interrupt will be pending after the reset. The easiest way of detecting that it was a reset due to wakeup is to check the reset controller, which will signal it as a wakeup source.
I have attached the uTasker FRDM-KL03Z project build (with low power support) as reference. If you have this board you can load the binary to it and test low power modes in the "Administration" menu that appears on the virtual COM port at 19200 Baud (a low speed baud is used because there is a big capacitor on the Rx input).
There are some notes on LLWU at µTasker LLWU Support
Here is a test:
1. The Admin menu - "show_lp" shows the low power settings that can be commanded
Admin. menu
===================
up go to main menu
show_config Show configuration
show_time Display date/time
set_time Set time hh:mm:ss
set_date Set Date dd:mm:yyyy
show_alarm Display alarm d/t
set_alarm Set alarm (date)(+)[time]
del_alarm Delete alarm
show_lp Show low power mode and options
set_lp [option] Set low power mode
reset Reset device
last_rst Reset cause
help Display menu specific help
quit Leave command mode
show_lp
0 = RUN
1 = WAIT [active]
2 = STOP
3 = VLPR
4 = VLPS
5 = LLS
6 = VLLS0
7 = VLLS1
8 = VLLS3
2. Command the VLLS0 mode with "set_lp 6"
3. The LED will stop blinking and the LLWU switch can be pressed to cause awakeup via reset.
4. In the Admin menu the command "last_rsr" now shows the status
Last reset cause = Wakeup
showing that it was a wakeup reset.
Regards
Mark
Kinetis: µTasker Kinetis support
KL03: µTasker FRDM-KL03Z support
For the complete "out-of-the-box" Kinetis experience and faster time to market