keypad interfacing example

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

keypad interfacing example

ソリューションへジャンプ
2,393件の閲覧回数
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,229件の閲覧回数
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,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 件の賞賛
返信
1,229件の閲覧回数
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 件の賞賛
返信