User manual
GPIO Expander Keypad and LCD Demo Board User’s Guide
DS51636A-page 12 © 2006 Microchip Technology Inc.
FIGURE 2-4: KEYPAD SCAN
One nibble is set to input and
the other nibble is output (to
read the columns) (already
configured before entering
function).
Read INTCAP and place in a
variable.
To read the rows.
Merge with variable
containing INTCAP value.
The result can be looked up
in a table (switch statement)
to determine which key was
pressed.
Scan_Buttons
Read INTCAP
Read GPIO
Set I/O back to
default so it is
correct the next
time the function is
called
END
Swap inputs and
outputs
Determine key
press from lookup
table