Can't go to VLPS mode when using FreeRtos

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

Can't go to VLPS mode when using FreeRtos

979 Views
martir
Contributor III

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í.

Labels (1)
0 Kudos
2 Replies

694 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Marti:

I would suggest you narrow down this issue by disable some tasks. Each time let only one task run. Check which task results in this issue.

Please also be kindly noted that there is an errata related with VLPS for MKL82z128

pastedImage_1.png

Regards

Daniel

0 Kudos

694 Views
martir
Contributor III

Hi Daniel, thanks for answering.

The function gets called always by the same task.

Nevertheless, I have tried using vTaskSuspendAll() before entering VLPS, but same result: the program doesn't stop (sleep), it feels like it hasn't gone to sleep.

The NVIC table is literally 0, all 32 possible interrupts are disabled. 

So I have to asume one of these are generating an interrupt? If it's so, how could I know which one is triggering?

Captura2.JPG

Thanks again for your help.

Edit: I think I've found what was 'instantly' waking up the mcu: the debugger. I have to prove this deeply (can't test currents atm), but I'm almost 90% sure was that...

(I've tested it with a LED, getting it On when the mcu left VLPS and triggering the wakeup with a timer)

0 Kudos