AnsweredAssumed Answered

Can't go to VLPS mode when using FreeRtos

Question asked by martir on Apr 12, 2018
Latest reply on Apr 23, 2018 by martir

Hi, I'm working with MKL82Z7 on a custom PCB. I'm using SDK_2.2_MKL82Z128xxx7

 

I'm able to go to sleep at the beginning of the code, but unable to do it when all Tasks have been started. The sleep function it's called from a Task.

And the program doesn't get stuck after WFI() (line 219 of fsl.smc.c *1), so I'm guessing an interrupt is waking up the uC just after it has gone to sleep.

*1: if (base->PMCTRL & SMC_PMCTRL_STOPA_MASK)

 

The function that calls the sleep is this one:

void SLEEP_EnterSleepMode(void)
{/* Disable interrupts */
//taskENTER_CRITICAL();
sleep_disableInterrupts();
sleep_disableClocks();

/* Enter VLPS Mode */
SMC_PreEnterStopModes();
SMC_SetPowerModeVlps(SMC);
SMC_PostExitStopModes();

/* Reenable interrupts */
sleep_enableClocks();
sleep_enableInterrupts();
//taskEXIT_CRITICAL();
}

In sleep_disableInterrupts / sleep_enableClocks, I'm disabling only the modules I've been using (USB, ADC, LPTMR, etc) and same with the interrupts with sleep_disableInterrupts (LPUART, USB, LPTMR, RTC...). 

Am I missing something? Some general clock maybe?

Or how can I know which interrupt is triggering? I was thinking about FreeRtos, then I've tried that critical section, but a HardFault occurs.

 

Any advice will much apreciated.

Thanks in advance.

Martí.

Outcomes