Re: Keypad data reception

From: terry (leonlai2k_at_yahoo.com)
Date: 11/06/04


Date: 5 Nov 2004 17:27:49 -0800


"j.b. miller" <invalidjbmiller@cogeco.ca> wrote in message news:<0WJid.3068$14.2457@read1.cgocable.net>...
> 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

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(bitcount<11&&bitcount>2)//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.