Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 8 months ago.
wake up from vllsx
i've a board frdm kl46z and i try to test the very low leakage.
the board exit from deep sleep but don't restart. It seems that it is not managed the correct interrupt. i tried too with the frdm-k46f with the same result.
the code is:
- OBJECTS DECLARATIONS -----------
(frdm-kl46z) led
DigitalOut obj_ledGre(LED1); PTD5
DigitalOut obj_ledRed(LED2); PTE29
----------------
LLW ISR
void LLW_IRQHandler(void) {
clear flag NVIC_ClearPendingIRQ(LLW_IRQn);
from reset if (RCM -> SRS0 & RCM_SRS0_WAKEUP_MASK){
clear flag module 0 if (LLWU->F3 & LLWU_F3_MWUF0_MASK) { write one to clear the flag LLWU->F3 |= LLWU_F3_MWUF0_MASK;
Enable clock peripheral SIM->SCGC5 |= SIM_SCGC5_LPTMR_MASK; Clear any pending interrupt LPTMR0->CSR |= LPTMR_CSR_TCF_MASK; write 1 to TCF to clear the LPT timer compare flag LPTMR0->CSR = ( LPTMR_CSR_TEN_MASK Turn on LPT and start counting
LPTMR_CSR_TIE_MASK LPT interrupt enabled |
LPTMR_CSR_TCF_MASK ); Timer Free running counter is reset |
}
acknoledge isolation if (PMC->REGSC & PMC_REGSC_ACKISO_MASK) { PMC->REGSC |= PMC_REGSC_ACKISO_MASK; reset up modules to wakeup up LLWU->ME &= LLWU_ME_WUME0_MASK; }
led on obj_ledGre = 0; }
}
----------------
main
----------------
int main(){
CME=0 clock monitor disable MCG->C6 &= MCG_C6_CME0_MASK;
--------------
init
----------------
init Led All Led's off obj_ledGre = 1; obj_ledRed = 1;
if (1) { led on obj_ledGre = 0; wait (2 seconds in run state) wait(2); led off obj_ledGre = 1; }
Enable clock peripheral SIM->SCGC5 |= SIM_SCGC5_LPTMR_MASK;
use the LPTMR to wake up LPTMR0->PSR = ( LPTMR_PSR_PRESCALE(0) 0000 is div 2
LPTMR_PSR_PBYP_MASK LPO feeds directly to LPT |
LPTMR_PSR_PCS(1)) ; use the choice of clock |
LPTMR0->CMR = LPTMR_CMR_COMPARE(2000); Set compare value (2000ms) Clear any pending interrupt LPTMR0->CSR |= LPTMR_CSR_TCF_MASK; LPTMR0->CSR =( LPTMR_CSR_TIE_MASK LPT interrupt enabled | LPTMR_CSR_TPS(0) TMR pin select |!LPTMR_CSR_TPP_MASK TMR Pin polarity
!LPTMR_CSR_TMS_MASK LPTMR0 as Timer |
!LPTMR_CSR_TFC_MASK Timer Free running counter is reset |
whenever TMR counter equals compare ); LPTMR0->CSR |= LPTMR_CSR_TEN_MASK; Turn on LPT and start counting
deep sleep (VLLS)
set vector interrupt NVIC_SetVector(LLW_IRQn, (uint32_t)&LLW_IRQHandler); NVIC_EnableIRQ(LLW_IRQn); Set up modules to wakeup up LLWU->ME = LLWU_ME_WUME0_MASK;
Reset flag if (LLWU->F3 & LLWU_F3_MWUF0_MASK) LLWU->F3 |= LLWU_F3_MWUF0_MASK;
disable all protections SMC->PMPROT = SMC_PMPROT_AVLLS_MASK; Select Mode 0 Normal Stop 1 Reserved 2 Very-Low_Power Stop 3 Low-Leakage Stop 4 Very-Low-Leakage Stop SMC->PMCTRL &= SMC_PMCTRL_STOPM_MASK; SMC->PMCTRL |= SMC_PMCTRL_STOPM(4); Set sub-stop mode 0 = VLLS0 1 = VLLS1 3 = VLLS3 SMC->STOPCTRL = SMC_STOPCTRL_VLLSM(3); wait for write to complete to SMC before stopping core int dummyRead = SMC->PMCTRL; dummyRead++; Entry in Stop mode (sleepDeep) SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; wait for interrupt asm("WFI"); WFI();
return from sleep
main loop while (true) {
toggle led obj_ledRed = !obj_ledRed; wait_ms(330);
} }