Depending what you are doing, the function, below, will have problems. To avoid false counts with mechanical jitter near the transition point you need to interrupt on both the leading and trailing edges with appropriate inc/dec logic depending upon the edge. All external interrupts and ICP and ACI interrupts have selectable leading/falling edge select, so even with a small chip you can get quite a few encoders going.
----------- Larry Barello www.barello.net | -----Original Message----- | Beside, do you really need two external interrupts ? | I use a quadrature encoder in my current project, and one interrupt pin | is enough and the code is ridiculously simple ! | | ------------------------------- | #include "encoder.h" | | static volatile int8_t encoder_count; | | //ISR to handle the rotary encoder | SIGNAL (SIG_INTERRUPT0) | { | if ( PIND & _BV(PD6) ) //if Channel B is high | encoder_count++; //then the knob has been turned clockwise | else | encoder_count--; //if not... then must have been CCW !! ;-) | } | --------------------------------- _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list