atmel单片机at89c51ic2键盘接口连接

来源:百度知道 编辑:UC知道 时间:2024/06/07 08:00:01
我想用at89c51ic2的P1口的键盘接口功能,连接4 x 4的矩阵键盘,我应该如何连接才能使用该单片机的键盘接口功能?
我就是想用at89c51ic2这个单片机的P1端口的Keyboard功能,我想接一个4 x 4的矩阵键盘,该如何将4 x 4的矩阵键盘连到单片机上?并且如何设置,能够用单片机的Keyboard功能,在有按键时能在中断服务程序中直接读出按键的键值。要是不用该单片机的Keyboard功能,直接用I/O扫描的话,会浪费很多的CPU时间。

Keyboard Interface The AT89C51IC2 implements a keyboard interface allowing the connection of a
8 x n matrix keyboard. It is based on 8 inputs with programmable interrupt capability on
both high or low level. These inputs are available as alternate function of P1 and allow to
exit from idle and power down modes.
The keyboard interface interfaces with the C51 core through 3 special function registers:
KBLS, the Keyboard Level Selection register (Table63), KBE, The Keyboard interrupt
Enable register (Table62), and KBF, the Keyboard Flag register (Table61).
Interrupt The keyboard inputs are considered as 8 independent interrupt sources sharing the
same interrupt vector. An interrupt enable bit (KBD in IEN1) allows global enable or dis-
able of the keyboard interrupt (see Figure33). As detailed in Figure34 each keyboard
input has the capability to detect a programmable level according to KBLS.x bit value.
Level detection is then