wake on pushbutton

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
DaMe_598781
Level 1
Level 1

I am new to SLEEP modes. Using PSoC5LP, the product has four pushbuttons on it which fire an ISR.

When I put this thing to sleep, and a button is pressed, it goes to the ISR.

In that ISR, it's the same ISR that the project normally uses to interpret button presses - how do I determine that I am  waking up, versus normal operation?

I will be putting all peripherals (ADC, UART, SPIM, PMWs) to sleep before putting the PSoC itself into sleep mode. So when it wakes up,  I have to wake up everything else, restore clocks, etc.

Obviously I don't want to do all of that during normal use, when the PSoC is not sleeping.

Thanks in advance.

0 Likes
1 Solution
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hello Dan,

You can set a flag (FLAG =1) before putting the device to sleep in the main. Inside the ISR, you can check the flag status. If the flag is set (if (FLAG==1)) which means that the device was in sleep mode, you can wake up the peripherals else there is no need to do so. At the end of the  ISR you can again reset the flag (FLAG = 0) and clear the interrupt.

Regards

Ekta

View solution in original post

0 Likes
1 Reply
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hello Dan,

You can set a flag (FLAG =1) before putting the device to sleep in the main. Inside the ISR, you can check the flag status. If the flag is set (if (FLAG==1)) which means that the device was in sleep mode, you can wake up the peripherals else there is no need to do so. At the end of the  ISR you can again reset the flag (FLAG = 0) and clear the interrupt.

Regards

Ekta

0 Likes