keypad interfacing example

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

keypad interfacing example

跳至解决方案
2,394 次查看
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.

标签 (1)
0 项奖励
回复
1 解答
1,230 次查看
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 项奖励
回复
2 回复数
1,231 次查看
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 项奖励
回复
1,230 次查看
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 项奖励
回复