keypad interfacing example

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

keypad interfacing example

Jump to solution
1,671 Views
dipole
Contributor I

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

 

for (;:smileywink: {

  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.

Labels (1)
0 Kudos
1 Solution
507 Views
kef
Specialist I

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.

View solution in original post

0 Kudos
2 Replies
508 Views
kef
Specialist I

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.

0 Kudos
507 Views
dipole
Contributor I

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.

0 Kudos