[M453] Wakeup from Deep Sleep by GPIO Interrupt

Post Reply
lalit
Posts: 8
Joined: 14 Apr 2017, 18:14

08 May 2017, 18:20

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
Last edited by lalit on 16 May 2017, 14:35, edited 1 time in total.

Dylan Hsieh
Posts: 31
Joined: 22 Mar 2017, 09:54

09 May 2017, 09:28

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

lalit
Posts: 8
Joined: 14 Apr 2017, 18:14

16 May 2017, 14:26

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

Dylan Hsieh
Posts: 31
Joined: 22 Mar 2017, 09:54

16 May 2017, 18:52

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

lalit
Posts: 8
Joined: 14 Apr 2017, 18:14

16 May 2017, 19:52

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

Prima
Posts: 109
Joined: 20 Mar 2017, 14:22

17 May 2017, 13:51

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

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests