Task: Enable INT0 and set the device in sleep mode. Use INT0 to wake
up the device and turn ON the LED to indicate that the device is in active mode.
- Configure PORTB0 as output to drive
LED0.
- Enable pull-up on PORTC0 and PORTD2
to connect to switches SW0 and SW1 respectively.
- Configure INT0 (on PORTD2) to sense
level and enable INT0. Also, set the global interrupt enable bit.
- Set sleep mode to power-down mode and turn ON LED0.
- Wait until switch SW0 is pressed.
Once it is pressed, turn OFF LED0 (to indicate that the device enters sleep mode)
and enter into sleep mode.
- Inside the ISR (after wake-up) turn ON LED0 to indicate that the device is in active
mode now. Repeat steps 5 and 6.
Hardware Setup:- Connect a wire between pins PB0
and LED0.
- Connect a wire between pins PC0
and SW0 (this connection is to make the device enter sleep mode).
- Connect a wire between pins PD2
and SW1 (External Interrupt INT0 connection).
Without using STK600, connect one LED circuit as shown in Figure 1 at PB0 and two switch circuits; one at PC0 and another at PD2.
By executing the example code LED0 will be turned ON. Once SW0 is pressed
LED0 is turned OFF and the device enters sleep mode. Now a switch action on SW1 wakes up
the device and turns ON LED0.