Task 4: External interrupt for device wake-up

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.

  1. 1.Configure PORTA0 as output to drive LED0.
  2. 2.Enable pull-up on PORTB0 and PORTD0 to connect to switches SW0 and SW1 respectively.
  3. 3.Configure INT0 (on PORTD0) to sense rising edge and enable INT0. Also, set the global interrupt enable bit.
  4. 4.Set sleep mode to power-down mode and turn ON LED0.
  5. 5.Wait until the switch SW0 is pressed. Once it is pressed, turn OFF LED0 (to indicate that the device enters sleep mode) and enter into sleep mode.
  6. 6.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:
  1. 1.Connect a wire between pins PA0 and LED0.
  2. 2.Connect a wire between pins PB0 and SW0 (this connection is to make the device enter sleep mode).
  3. 3.Connect a wire between pins PD0 and SW1 (External Interrupt INT0 connection).

Without using STK600, connect one LED circuit as shown in Figure 1 at PA0 and two switch circuits; one at PB0 and another at PD0.

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.