Keypad data reception

Hi,

I am doing a project which needs to interface a AT compatible keypad. I find somethimes the keys returned is wrong. I used external interrupt to obtain serial data from the PS2 interface. I suspect that during reception timer interrupt or other interruptes make the data conrrupted as some edges are missed.

What could I do? What is the usual method to do PS2-interface data reception? Use another delicated MCU to do the PS2 data reception?

Thanks!

Reply to
terry
Loading thread data ...

We'd need more info like which processor you used,language,power supply,etc.

I've used the PIC16F84 for years as 'keyboard convertors'. Gads, showing my age....

Jay

Reply to
j.b. miller

Hi, your method should work ok, you are useing the clock edge as the interrupt souce? If you have other higher priority interrups running that coould cause a problem if they are long routines, try to shorten them.

Reply to
CBarn24050

The problem still exists after I have disabled all interrupts except the external interrupt 0. The MCU used is ATMega32. The code is modified from appnote AVR313 to GCC. The following is the code:

SIGNAL(SIG_INTERRUPT0) { static unsigned char data;//Holds the received scan code if(edge)//Routine entered at falling edge { MCUCR=2;//Set interrupt on falling edge edge=0; if(--bitcount==0)//All bits received { decode(data); bitcount=11; } } else { //Routine entered at rising edge if(bitcount2)//Bit 3 to 10 is data. Parity bit, { //start and stop bits are ignored. data>>=1; if(PIN_KEY_DATA&Bit_KEY_DATA) data|=0x80;//Store a '1' } MCUCR=3;//Set interrupt on rising edge edge=1; } }

I found the problem happens more frequently when I typed fast.

Reply to
terry

I have disabled all other interrupts and found the code runs without problem.

Thanks!

Reply to
terry

A cynic is a man who knows the price of everything and the value of nothing.

-- Lady Chatterly

"Can a robot even be gay?" -- Starshine Moonbeam

Reply to
Lady Chatterly

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.