Dear all;
I am looking for an example code for interfacing a 96AB2 keypad with a 9S12DP256B MCU.
Currently I am stuck with a nonworking code from an old book. I've connected pins of the keypad to PORT A and the code goes as follows
DDRA = 0xF8; // set PORTA[0:2] as input and PORTA[3:7] as output
PORTA = 0xBF; // assert row 0
keypress = PORTA;
if (keypress != 0xBF) // some key has been pressed
key = scan_key(keypress);
...
I've a similar block for every row but I'm not even sure if this is the correct way of doing that and unfortunately I am not getting any results with it. I would really appreciate if someone could give me some hints or pointers to a working code.
Thanks in advance.
Solved! Go to Solution.
1. First of all where's the url to 96AB2 datasheet?
2. Where's your circuit
Are there external pullup resistors? If not then PORTA weak pull up resistors should be enabled. And by default PUCR PUPAE bit is off. Try enabling pull ups. Then your code may work if you wired your keypad correctly.
1. First of all where's the url to 96AB2 datasheet?
2. Where's your circuit
Are there external pullup resistors? If not then PORTA weak pull up resistors should be enabled. And by default PUCR PUPAE bit is off. Try enabling pull ups. Then your code may work if you wired your keypad correctly.
Thanks a lot. PUCR turned out to be the problem. Sadly, the code in the book does not enable PUPAE.
Now, instead of polling I am looking for an interrupt driven keypad operation. Any pointers or hints are appreciated.