[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] ATmega644 pin-change interrupts

From: David Kelly
Subject: Re: [avr-gcc-list] ATmega644 pin-change interrupts
Date: Thu, 29 Nov 2007 10:31:38 -0600
User-agent: Mutt/

On Thu, Nov 29, 2007 at 09:25:12AM -0600, David Kelly wrote:
> I too have not found one. I snag a copy of the PINx and keep it in a
> static variable in my ISR() to compare for which pins changed. Something
> like this:
>       current = PINA & PCMSK0;        //  only the pins enabled
>       xor = previous ^ current;       //  pins changed since last time
>       ...
>       previous = current;
>       return;

For completeness ought to point out that PINA isn't read at the same
instant as the interrupt was dispatched so there may be discrepancies
and additional interrupts due to changes. Be very fault tolerant.

I used pin change interrupts to read an optical encoder whose output
signals bounced a lot when transitioning. To deal with that on change to
A it was masked off and B was masked in. But because A was bouncing I
might not see its change, or I might, no matter that it dispatched the
interrupt vector. If I caught the change I masked it off. If I didn't
catch it then it was still changing and I'd get it the next time.

To cut down on the spurious interrupts I used the pin change mask
register. But because pins were still changing I had to also mask in
software as shown above.

David Kelly N4HHE, address@hidden
Whom computers would destroy, they must first drive mad.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]