18.11.2014 Views

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Switches and Keypads<br />

• A single capacitor adds debouncing. A capacitor connected at KBM (keybounce mask)<br />

sets the debounce period. With a 1-microfarad capacitor, the 74C922 ignores<br />

keypresses shorter than 10 milliseconds. Only when a keypress lasts longer than this<br />

does the chip latch the data and bring DA high. In a similar way, after the key opens, the<br />

debouncing must time out before a new key press is detected. <strong>The</strong> debounce period<br />

varies directly with capacitor size, with larger values increasing the time. By<br />

experimenting with different values, you can adjust the timing until all key bounces are<br />

ignored, yet no noticeable delay is required between key presses.<br />

Adding a Keypad<br />

Figure 7-9 shows the 74C922 connected to the 8052-BASIC system. <strong>The</strong> 74C922 interfaces<br />

the keypad to a 72LS244 buffer, as described in Chapter 6. <strong>The</strong> 74C922 is shown addressed<br />

at E000h, but you can use any available chip-select. Pin 13 of the 74C922 is tied low to<br />

permanently enable the data outputs. Keypresses are read by reading the buffer at E000h.<br />

<strong>The</strong> keypad’s X and Y lines connect to their corresponding pins on the 74C922. Data outputs<br />

A-D connect to D0-D3 on the 8052’s data bus. DA, which signals when a key has been pressed,<br />

connects to INT1 on the 8052-BASIC. If you want to use polling to detect keypresses, you<br />

can use any input port pin instead of INT1.<br />

Figure 7-9. Circuits for adding a matrix-encoded keypad to an<br />

8052-BASIC system.<br />

<strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong> 121

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!