FRDM-KL05z: after exit from VLLS3, execution starts with Reset_Handler as expected but execution fails when reaching main()

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FRDM-KL05z: after exit from VLLS3, execution starts with Reset_Handler as expected but execution fails when reaching main()

Jump to solution
655 Views
mjoa
Contributor II

Hi,

When running low_power_demo from official package KL05-SC.zip as well as FRDM-KL05Z Quick Start Package to test deep sleep/wakeup on FRDM_KL05z, I found this scenario.


From the following trace, after exit from VLLS3, execution starts with Reset_Handler (the instruction pointed to by the RESET vector address) as expected but execution fails when reaching main():

-------------------------------------------------------------------------------------------------

Enter the key number to choose one mode: 9LLWU PE1   = 0x00,    LLWU PE2   = 0x00

LLWU ME    = 0x01,    LLWU F1    = 0x00

LLWU F3    = 0x00

LLWU FILT1 = 0x00,    LLWU FILT2 = 0x00

enter into VLLS3 mode--.

[outSRS]Wakeup bit set from low power mode exit

[outSRS]SMC_PMPROT   = 0x02

[outSRS]SMC_PMCTRL   = 0x04

[outSRS]SMC_STOPCTRL   = 0x03

[outSRS]SMC_PMSTAT   = 0x01

[outSRS] VLLS3 exit

K05

Unrecognized Kinetis package code.      SRAM Size:  4 KB

Silicon rev 15

Flash size:  32 KB program flash, 1 KB protection region

[LLWU ISR]

[LLWU ISR] ****WUF3_MWUF0 IF  LPT0  *****

-------------------------------------------------------------------------------------------------

MCU just stuck there until Reset button is explicitly pressed. I would expect main() to be re-executed when running the Reset_Handler:

Reset_Handler   PROC

                EXPORT  Reset_Handler             [WEAK]

                IMPORT  SystemInit

                IMPORT  __main

                LDR     R0, =SystemInit

                BLX     R0

                LDR     R0, =__main

                BX      R0

                ENDP

Is there anything that is needed in order to have reset flow run properly and have main() reexecute?

Thanks for your help.

Labels (1)
Tags (1)
0 Kudos
1 Solution
445 Views
mjoa
Contributor II

By referring the code in KL25_SC, I have modified llwu_isr() as follows (pls check the tag CHANGE for my hack):

   if (LLWU_F3 & LLWU_F3_MWUF0_MASK) {

       printf("\n [LLWU ISR] ****WUF3_MWUF0 IF  LPT0  *****\r\n");

       SIM_SCGC5 |= SIM_SCGC5_LPTMR_MASK;   //CHANGE: 

       LPTMR0_CSR |=  LPTMR_CSR_TCF_MASK;   // write 1 to TCF to clear the LPT timer compare flag

//       LPTMR0_CSR = ( LPTMR_CSR_TEN_MASK | LPTMR_CSR_TIE_MASK | LPTMR_CSR_TCF_MASK  );

//       LLWU_F3 |= LLWU_F3_MWUF0_MASK;   //CHANGE by comment out: write one to clear the flag

It now seems to work now where main() could be re-executed after waking up from VLLS3.

View solution in original post

0 Kudos
1 Reply
446 Views
mjoa
Contributor II

By referring the code in KL25_SC, I have modified llwu_isr() as follows (pls check the tag CHANGE for my hack):

   if (LLWU_F3 & LLWU_F3_MWUF0_MASK) {

       printf("\n [LLWU ISR] ****WUF3_MWUF0 IF  LPT0  *****\r\n");

       SIM_SCGC5 |= SIM_SCGC5_LPTMR_MASK;   //CHANGE: 

       LPTMR0_CSR |=  LPTMR_CSR_TCF_MASK;   // write 1 to TCF to clear the LPT timer compare flag

//       LPTMR0_CSR = ( LPTMR_CSR_TEN_MASK | LPTMR_CSR_TIE_MASK | LPTMR_CSR_TCF_MASK  );

//       LLWU_F3 |= LLWU_F3_MWUF0_MASK;   //CHANGE by comment out: write one to clear the flag

It now seems to work now where main() could be re-executed after waking up from VLLS3.

0 Kudos