This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Push Button to wake up or sleep (idle mode)

Hi,

I am doing a small project where I would like to press a push button to wake my device up and if I press again to put to it to idle mode ('PCON=0x01').

Creating an interrupt is not difficult but I don't know how to make it sleep again using the same interrupt.

Push Button attached to P3.2

something similar to this:

void interrupt0() interrupt 0
{ beep; //beep and then wake up or sleep if it is already on.
} -----------------------------------------------*/

void main()
{

IT0 = 1; // Configure interrupt 0 for falling edge on /INT0 (P3.2)
EX0 = 1; // Enable EX0 Interrupt
EA = 1; // Enable Global Interrupt Flag
PCON=0x01;

while(1)
{ ...
}

Any ideas?

Thanks,

Ed.

0