Hello,
i have a problem using the sdk 1.3 and the lptmr. I set this for count 10sec (i will use this to wake up the micro) but this not count. I have attach the project, i don't understand.... i have check the clock source (LPO) and i think is set correctly. Thanks
Daniele
Original Attachment has been moved to: Lowpower.zip
Solved! Go to Solution.
Hi Daniele Cortellazzi,
If you want to use the LPTMR to wake up your VLLS1 mode, after wake up, the CPU will reset and wake up, you don't need to use the Cpu_SystemReset() function.
You means, the LPTMR can wake up your VLLS1 one time, but the second time, it can't work?
If yes, please clear the LPTMR flag and enable the LPTMR in your LLWU interrupt, just like this :
if (LLWU_F3 & LLWU_F3_MWUF0_MASK) {
// printf("****WUF3_MWUF0 IF LPTMR *****\r\n");
SIM_SCGC5 |= SIM_SCGC5_LPTMR_MASK;
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 );
}
Wish it helps you!
If you still have question, please contact me!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Daniele Cortellazzi,
Thank you for your interest in Freescale kinetis product, I would like to provide service for you!
Did you check it in the debug mode?
If you want to read the LPTMR0_CNR, you need to write a arbitrary value to this register, then you can get the CNR value correct. But it won't influence the function of the LPTRM.
I create a KDS KSDK LPTMR project based on KL25, it can realize the 1s LPTMR count, and when it reaches 1s, toggle PTB18, I already test it, please refer to my code.
When want to read CNR, you do it like this:
unsigned int i;
LPTMR0_CNR=0;
i= LPTMR0_CNR;
Then you will get the CNR value, and you can find it is really counting.
I hope it can help you!
If you still have quesiton, please contact me!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Many thanks for the reply.
Now it's work. I want to use the LPTMR to wake up the system from VLLS1. Now my problem is how handle the wake-up of the system, i need to reset the device when the system power on. With the old pex there was the function Cpu_SystemReset(), with the sdk 1.3 how can i do?
The device go in low power and wake up but it didn't enter the second time. I do this:
LPTMR_DRV_SetTimerPeriodUs(WakeUP_Timer_IDX, 10000000);
LPTMR_DRV_Start(WakeUP_Timer_IDX);
and in the loop
GPIO_DRV_ClearPinOutput(GREEN_LED);
Read_Sensors();
WAIT_Waitms(1000);
GPIO_DRV_SetPinOutput(GREEN_LED);
POWER_SYS_SetWakeupModule(kPowerManagerWakeupModule0, TRUE);
POWER_SYS_SetMode(1, kPowerManagerPolicyForcible);
and in the event
void pwrMan1_llwuIRQHandler(void)
{
POWER_SYS_ClearWakeupPinFlag(kLlwuWakeupModule0);
}
i reset the flag
Thanks
Hi Daniele Cortellazzi,
If you want to use the LPTMR to wake up your VLLS1 mode, after wake up, the CPU will reset and wake up, you don't need to use the Cpu_SystemReset() function.
You means, the LPTMR can wake up your VLLS1 one time, but the second time, it can't work?
If yes, please clear the LPTMR flag and enable the LPTMR in your LLWU interrupt, just like this :
if (LLWU_F3 & LLWU_F3_MWUF0_MASK) {
// printf("****WUF3_MWUF0 IF LPTMR *****\r\n");
SIM_SCGC5 |= SIM_SCGC5_LPTMR_MASK;
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 );
}
Wish it helps you!
If you still have question, please contact me!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
I have tried to use the sdk library for control the wake up.
I do this operation:
LPTMR_DRV_SetTimerPeriodUs(WakeUP_Timer_IDX, 10000000); | |
LPTMR_DRV_Start(WakeUP_Timer_IDX); |
for (;;) {
GPIO_DRV_ClearPinOutput(GREEN_LED);
Read_Sensors();
//Send_AllData();
WAIT_Waitms(5000);
GPIO_DRV_SetPinOutput(GREEN_LED);
//LPTMR0_CNR=0;
//i= LPTMR0_CNR;
DeInit_I2C1();
DeInit_I2C0();
POWER_SYS_SetWakeupModule(kPowerManagerWakeupModule0, TRUE);
POWER_SYS_SetMode(1, kPowerManagerPolicyForcible);
//LPTMR_DRV_SetTimerPeriodUs(WakeUP_Timer_IDX, 10000000);
//LPTMR_DRV_Start(WakeUP_Timer_IDX);
//WAIT_Waitms(1000);
}
so i enable the lptmr timer and put the device in vlls1.
void pwrMan1_llwuIRQHandler(void)
{
POWER_SYS_ClearWakeupPinFlag(kLlwuWakeupModule0);
POWER_SYS_SetMode(0, kPowerManagerPolicyForcible);
//if (PMC_REGSC & PMC_REGSC_ACKISO_MASK)
// PMC_REGSC |= PMC_REGSC_ACKISO_MASK;
//NVIC_SystemReset();
}
and with the event i delete the flag in llwu but always the system crush after the GPIO_DRV_ClearPinOutput(GREEN_LED); if i use the NVIC_SystemReset(); this not happen .... why? there other register to clear?
Thanks
Thanks for the support!!!
Nothing? Thanks