Hello.
>
>I would like to count n-coder`s ticks (channel A and B)
>by use of AVR processor.
>I think about that such variable is incrementing
>while rotation of n-coder`s shaft in the right, and variable is
>decrementing while rotation in the left.
>I think that counters implemented in AVR can count
>in one direction only.
As far as I know, when the counters are in "counting" mode, they will only count up. In PWM mode they do count in both directions but only in response to reaching an upper or lower count limit.
[snip...snip...]
The code shown above works well and I can achieve
>frequency of counting which suits me.
>I would like to get to know if there is better solution of
>my problem (counting n-coder`s ticks in both directions) ?
Only recommendation is to ensure that you have taken precautions regarding the case where the encoder stops right over an edge and fires off constant interrupts. Possibly a hysteresis setup (which may be already built into the encoder) or, instead of firing an interrupt on an encoder event, run a tight timing loop and read the A-B conditions as inputs to a state machine.