Page 1 of 1

[M453] Wakeup from Deep Sleep by GPIO Interrupt

Posted: 08 May 2017, 18:20
by lalit
Hi,
How can I configure the CPU to wake up from Deep Sleep mode using a normal GPIO interrupt? I have configured SCB->SCR and CLK->PWRCTL to configure deep sleep mode. It is mentioned in the TRM that only LIRC and LIXT clocks are enabled during deep sleep. How can I enable GPIO interrupts as well?

[EDIT]
Now I am having trouble using timers in deep sleep mode. Attached are the code snippets.

I am using Timer3 in through LIRC.

Code: Select all

/* Enable LIRC clock (Internal RC 10Khz) */
CLK_EnableXtalRC(CLK_PWRCTL_LIRCEN_Msk);

/* Wait for HIRC clock ready */
CLK_WaitClockReady(CLK_STATUS_LIRCSTB_Msk);

CLK_EnableModuleClock(TMR3_MODULE);
CLK_SetModuleClock(TMR3_MODULE, CLK_CLKSEL1_TMR3SEL_LIRC, 0);
My timer configuration is as follows:

Code: Select all

/* Open Timer3 in periodic mode, enable interrupt and 1 interrupt ticks per second */
TIMER_Open(TIMER3, TIMER_PERIODIC_MODE, 1);
TIMER_EnableInt(TIMER3);
NVIC_SetPriority(TMR3_IRQn, TMR3_PRIORITY);
NVIC_EnableIRQ(TMR3_IRQn);
In main where I am enabling deep sleep mode:

Code: Select all

if(u8_DEEPSLP == TRUE)
		{
			u8_DEEPSLP = FALSE;
			TIMER_Start(TIMER3);
			CLK_PowerDown();
		}
Timer3 IRQ Handler:

Code: Select all

void TMR3_IRQHandler(void)
{
	if(TIMER_GetIntFlag(TIMER3) == 1)
	{
		/* Clear Timer3 time-out interrupt flag */
		TIMER_ClearIntFlag(TIMER3);
		LED2 = ledState;
		ledState = !ledState;
	}
}
Regards

Re: [M453] Wakeup from Deep Sleep by GPIO Interrupt

Posted: 09 May 2017, 09:28
by Dylan Hsieh
Hi,

Have you downloaded the BSP of M451 from our website, the BSP have the sample code of how to use GPIO to wake-up the system from the power-saving mode.

Thanks

Re: [M453] Wakeup from Deep Sleep by GPIO Interrupt

Posted: 16 May 2017, 14:26
by lalit
Hi,
Yes I have looked at the example. The problem was that I was enabling Deep Sleep Mode inside an interrupt, which was causing problem. I moved the enabling interrupt to main, now its working fine. But now I am having problems with Timer in Deep Sleep Mode. I am adding code snippets to better describe my problem in the edit of the question.

Regards

Re: [M453] Wakeup from Deep Sleep by GPIO Interrupt

Posted: 16 May 2017, 18:52
by Dylan Hsieh
Hi,

It seems you miss to enable wake-up function of timer.

To enable wake-up function of timer, you need to set the bit [WKEN] in the [TIMERx_CTL] or you can just call the API function TIMER_EnableWakeup(TIMERX).

Re: [M453] Wakeup from Deep Sleep by GPIO Interrupt

Posted: 16 May 2017, 19:52
by lalit
Hi,
Thanks for pointing that out. Got it resolved.
Also on a side note, just a suggestion, if you guys can implement a resolved or not resolved tag in the forum, that would be great.

Regards

Re: [M453] Wakeup from Deep Sleep by GPIO Interrupt

Posted: 17 May 2017, 13:51
by Prima
Hi Lalit,

Thanks for your suggestion.
Would you please to write your suggestion by clicking Suggestions on NuForum on the corner left bottom of this forum page?
By clicking Suggestions on NuForum, you can write email to our forum administrator.

Thanks,
Prima