 |
| Author |
Message |
|
|
Posted: Sep 18, 2011 - 09:02 PM |
|

Joined: Oct 29, 2007
Posts: 294
Location: Como, Italy
|
|
Hello,
I'm going to use an xmega128A4(U) and I need 8 counters.
I have eight "clocks" with a fixed Ton = 220 us and variable frequency. I need to measure that frequency.
The simplest way is to increment a counter on each rising edge and periodically reset it.
I RTFMs (datasheet of A/AU family, datasheet of 128A4(U) chip) but there are quite few points I don't understand.
Each TC0 has 4 CC channels. So with 2 TC0 I have 8 16-bit counters. Good.
In counter mode they count (towards up or down as bit DIR sets) every time they receive a clock input. I don't understand which pins may be used as clock inputs and how to set the edge polarity (if possible).
In the electrical characteristics I can't find neither the maximum frequency nor the minimum on-time for external clock inputs to TC0.
Perhaps I can't find the right chapter.
Thanks |
|
|
| |
|
|
|
|
|
Posted: Sep 19, 2011 - 11:39 AM |
|

Joined: Jul 19, 2011
Posts: 47
Location: Haifa, Israel
|
|
The CC register are unable to count. You can use them to capture the value of a timer when some event happens.
The A4s have 5 16-bit counters. If you want to use them to count events, or the CC registers to capture events then you need to read through the chapters describing the ports and the event unit.
If the frequencies that you want to measure are not too high then you may just use a pin interrupt handler to increment a variable. |
|
|
| |
|
|
|
|
|
Posted: Sep 19, 2011 - 05:33 PM |
|

Joined: Oct 29, 2007
Posts: 294
Location: Como, Italy
|
|
Thanks for the clarification. I miserunderstood the word "counter" used in the ds. I thought the "counter" may just counts the edges of an external clock.
I do need to count up to 8 signals. So I'm going to follow the poor man way: increment a variable in the isr.
I'm not worried about the frequency, because if it's too high I will place a divisor before.
Thanks
EDIT:
the "old" atmega can count from an external clock! For example ATmega324P has two pin (T0 and T1) that can feed clock into timer0 and timer1. xmega can't! bad news  |
|
|
| |
|
|
|
|
|
Posted: Sep 19, 2011 - 08:36 PM |
|

Joined: Jul 19, 2011
Posts: 47
Location: Haifa, Israel
|
|
| Xmegas can! You need to use the event system to route the signal from the pin into the counter. Still, you have only 5 counters and 8 events. |
|
|
| |
|
|
|
|
|
Posted: Sep 20, 2011 - 02:18 PM |
|

Joined: Oct 29, 2007
Posts: 294
Location: Como, Italy
|
|
| Ok, I got it. Anyway I need 8 counters, so I will try the interrupt way. |
|
|
| |
|
|
|
|
|
|
|