__WFI() will not sleep even with all interrupts disabled and pending cleared - LPC18XX Series

cancel
Showing results for 
Search instead for 
Did you mean: 

__WFI() will not sleep even with all interrupts disabled and pending cleared - LPC18XX Series

597 Views
Contributor I

Background: I am trying to make my embedded application go to sleep when there is no CAN activity with the __WFI() and then wake up whenever a CAN interrupt is received. Before enterring sleep mode, I disable all interrupts and clear their pending states in the NVIC registers.

To start, right now I'm just trying to make sure that I can sleep forever when I have all interrupts disabled.

for(int i = 0; i < IRQ_MAX; i++)
{   
    IRQ_ClearPending((IRQ)i);
    IRQ_Disable((IRQ)i);
}
__DSB();
__ISB();
__WFI();
MCU_Reset();

I checked the NVIC registers, and they are all set to 0, which should mean that all interrupts are disabled and there are no pending interrupts. However, everytime I execture the WFI (Wait for interrupt) instruction, it will just NOP on me.

Why can I not enter sleep mode? Do I actually have to somehow disable all of my peripherals and disable the interrupts at their source or is there a way to just mask all interrupts minus the CAN?

I have tried this with the debugger both connected and disconnected.

Thank you for your time. Let me know if there is anything I can do to clarify the question.

Labels (1)
Tags (3)
0 Kudos
6 Replies

20 Views
NXP TechSupport
NXP TechSupport

HI Lane,

The example have two interrupts as a wakeup source, one with the RTC as you say, and the other with the wake-up pin, you could try using the second one.

Or if you not have routed this you could try checking directly with the CAN interrupt as a source for the router event.

Please let me know if this helped you.

Best Regards,

Alexis Andalon

0 Kudos

20 Views
NXP TechSupport
NXP TechSupport

Hi Lane Lutgen,

If you want to test if your MCU is going to Sleep Mode, I suggest to see the example misc_pmc_states, in the code bundle of the MCU.

Also please check the initialization of the Event Router, there you can set the CAN interrupt as a wake up source.

I hope this will help you.

Best Regards,

Alexis Andalon

0 Kudos

20 Views
Contributor I

Thanks Alexis I did try this. However, my custom board does not have the 32 kHz clock source from the RTC that is required for the Event Router and the Alarm Timer in that example project. 

0 Kudos

20 Views
Senior Contributor III

How do you know WFI is not doing anything? What is it you are observing that indicates that the WFI has not slept?

0 Kudos

20 Views
Contributor I

After initialization, I call the sleep code after 30 seconds. After the __WFI() call, I do a reset. The device has an LCD screen and I can observe the device doing the reset every 30 seconds both with and without the debugger. I'm starting to suspect that maybe it is the SysTick interrupt that is preventing the hang, but I thought that the __WFI() call only cared about NVIC interrupts.

0 Kudos

20 Views
Senior Contributor III

It’s WFI (wait for interrupt) not WFNVIC! So a SysTick interrupt will certainly break the WFI. #

0 Kudos