Atmega4809 - TCB, pulse counting

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello
I am working with the arduino nano every (Atmega4809) and looking for a way to count input pulses using one of the TCB timers. Pulse frequency may be up to 500kHz.
By reading the datasheet I think I saw allusions that this is indeed possible but cannot find the way in the concerned configuration registers .
In particular, in Table 21-4. Event Users and Available Event Actions in TCB page 241, there would be 2 types of USER:

  • CAPT for 6 TCB timer working modes.
  • COUNT where it is said that an event can be used as the source of the clock.

In the text: COUNT: Event as clock source in combination with a count mode.
But, when I refer to paragraph 14.3.2.4 Event Users of chapter EVSYS - Event System (p.126) we are only talking about 6 users of the CAPT type, no more allusion to the COUNT type.
A little clarifying help would be welcome.
Thank you

Link for datasheet:

http://ww1.microchip.com/downloa...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Two thoughts:

 

1) application notes

 

2) http://start.atmel.com

 

Either may offer examples.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sdb wrote:
I am working with the arduino nano every (Atmega4809) and looking for a way to count input pulses using one of the TCB timers.

 

Sadly, the TCB version inside the Mega AVR-0 series can't count events. You are using an old version of the datasheet, here is the current one:  https://ww1.microchip.com/downloads/en/DeviceDoc/ATmega4808-09-DataSheet-DS40002173C.pdf

 

Interestingly, if you go to an even older version like this one:  http://ww1.microchip.com/downloads/en/DeviceDoc/megaAVR0-series-Family-Data-Sheet-DS40002015B.pdf

the event counting feature is also not present.

 

Now, the AVR-Dx series MCUs do have an upgraded TCB that can count events.

 

My conclusion is, the particular version of the datasheet you are using was created at the same time the datasheets for the AVR-Dx were being written, and someone did a copy/paste error. Happens all the time.

 

edit:

The problem remains, you still need those pulses to be counted. Your options are TCA (counting events) and RTC (using the EXTCLK pin). My guess is you need the TCA for other stuff since it's the most powerful timer on the Mega4809. That leaves the RTC, but IDK if the EXTCLK pin is available on the board you are using.

 

 

Last Edited: Tue. Jun 8, 2021 - 09:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


El Tangas wrote:
You are using an old version of the datasheet,

Always good to go straight to the manufacturer's  Product Page - to ensure latest info:

 

https://www.avrfreaks.net/commen...

https://www.avrfreaks.net/commen...

 

Also the place to find Application Notes - as clawson suggested

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, the "getting started with TCB" document also needs to be revised, it doesn't explain the extra features present on the AVR-Dx TCB, so a new user will get the (wrong) idea they are identical to the old TCB on AVR-0/1 chips.

In fact they are backwards compatible, but with nice extras.

 

edit:

The most important new features are actually things some people, including myself, have previously criticized on this forum (for their lack on the old TCB):

- interrupt on timer overflow

- event counting

 

So I guess they actually listen to user feedback smiley

Last Edited: Tue. Jun 8, 2021 - 10:23 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The most important new features are actually things some people, including myself, have previously criticized on this forum (for their lack on the old TCB):

- interrupt on timer overflow

- event counting

Maybe they were always there & forgot to tell us about it...hard to keep things straight with these nutty datasheets. 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

>looking for a way to count input pulses using one of the TCB timers. Pulse frequency may be up to 500kHz.

 

The rtc is also a 16bit counter, and it can be clocked from ext. It is an asynch counter, and from another thread is sounds like it can count higher freq clocks, even though the datasheet says you need a clock < 1/4 cpu freq to read the counter. The rtc is an overlooked peripheral, and is a big plus for the newer avr.