avr-chat
[Top][All Lists]
Advanced

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

Re: [avr-chat] ATXMega128A1: 32-bit quadrature decoder with compare matc


From: Stefan Schoenleitner
Subject: Re: [avr-chat] ATXMega128A1: 32-bit quadrature decoder with compare match ?
Date: Fri, 23 Sep 2011 10:47:24 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Thunderbird/3.1.13

Hi,

On 09/23/2011 09:26 AM, Stefan Schoenleitner wrote:
>     // set up compare matching in the middle of the period
>     TCC0.CCA = TCC0.PER/2;
>     TCC0.CTRLB |= TC0_CMPA_bm;                // enable compare match on 
> compare channel A
>     TCC0.INTCTRLB |= TC_CCAINTLVL_LO_gc;      // low level interrupt on 
> compare match

finding the culprit always happens after one has already sent out
the posts asking for help ;)

In the above code sample, you can see that I enabled compare matching on
channel A with
TCC0.CTRLB |= TC0_CMPA_bm;

However, a look into iox128a1.h reveals that is wrong.
Instead, the correct constant to enable compare matching on channel A is
TC0_CCAEN_bm.

Since I wrote the wrong bitmask to the TCC0.CTRLB register, it also
explains the weird behavior of the timer.
Using TC0_CMPA_bm, TC0_CMPB_bm, etc. actually wrote to the waveform
generation field, causing the timer to no longer run in normal mode.

Still, if other people try to set up quadrature 32-bit decoding, I think
my posts to this list might be helpful for them.

cheers,
Stefan



reply via email to

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