AN980
APPLICATION NOTE
ST7 KEYPAD DECODING TECHNIQUES,
IMPLEMENTING WAKE-UP ON KEYSTROKE
by 8-Bit Micro Application Laboratory
INTRODUCTION
The goal of this application note is to present an example of the use of the HALT mode.
In this application, the MCU (here a ST72F264) is waked up by an external interrupt caused by
someone pressed a key on the 4x4 matrixed keypad.
AN980/0802 1/8
1
ST7 KEYPAD DECODING TECHNIQUES, IM PLEMENTING WAKE-UP ON KEYSTROKE
1 ST7 / KEYBOARD INTERFACE
Rows are connected to inputs with p u ll-up and interrupts (Por t C). Columns are connected to
Port A configured as output. The result of the interrupt (the value of the pr essed key) is sent on
LEDS (Port B) and stored into the X register. In our configuration, we have to add 4 pul l-up r esistors on Port A (from PA0 to PA3) to be able to appl y a high level on the corresponding pads.
Figure 1. ST7 / keypad interface set-up
4x100k
8x560
V
DD
PC0
PC1
PC2
PC3
ST7
PA0
GND
PA1
PA2
PA3
2/8
2
ST7 KEYPAD DECODING TECHNIQUES, IMPLEMENTING WAKE-UP ON KEYSTROKE
2 ST72F264 CONFIGURATION
The application has been validated with a ST72F264. Its configuration i s described in this part.
Refer to your datasheet for more details.
2.1 I/O CONTROL
Rows are connected to pins configured as inputs (Port C as input with pull up and interrupts).
Columns are connected to pins configured as outputs (Port A).
External interrupts are caused by a low level applied to a pin of Port C (caused by a key
pressed), they wake up the MCU which was in HALT mode.
Port B is configured as outputs to send the value of the pressed key on LEDS.
Please, refer to the Data Book to configure pins properly.
2.2 MISCELLANEOUS REGISTER
Bits 7 and 6 have to be set to configure events correctly: the external interrupt (EI1) has here
to be caused by a falling edge only.
Please, refer to the datasheet for more details.
2.3 HALT MODE
The HALT instruction places the ST72F264 in its lowest power consumption mode. The core
and all peripherals are frozen. In this mode, the internal oscillator is turned off, causing all internal processing to be halted. The data remain unchanged. During the HALT mode, external
interrupts are still enabled. The MCU stays in this state until an external interrupt or a reset occurs. Then the internal oscillator is restarted and the core waits for 4096 CPU clock cycles
(512 µs for a f
= 8MHz) before running the extern al interrup t subroutine . Then the MCU
CPU
comes back to the main program (in our application to the HALT state).
Please, refer to the datasheet for more details.
3/8