PWM - Which timer to use? [ATtiny817]

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

Hi,

 

Just wanted to ask (sorry if this is a simple question), but what exactly is the difference between timer A and timer B in terms of just making a simple PWM signal (for example, for dimming / setting brightness of LED)?

 

A search in the AVRFREAKS search box on top right lead me to this link:

https://www.avrfreaks.net/forum/...

 

And in that topic, I see Timer B was the original timer that was to be used, but ultimately Timer A became the timer that was used. So what's the difference now?

 

Thanks,

 

~mc0134

Last Edited: Tue. Mar 6, 2018 - 07:16 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

All the information that you are asking about is contained in the datasheet.  The author of that thread opted to use TCA possibly out of convenience?

 

For generating PWM either Timer/Counter can be used.

 

ATtiny417/817 - Complete Datasheet

 

20. TCA - 16-bit Timer/Counter Type A

 

20.1 Features
• 16-bit timer/counter
• Three compare channels
• Double buffered timer period setting
• Double buffered compare channels
• Waveform generation:
– Frequency generation
– Single-slope PWM (pulse width modulation)
– Dual-slope PWM
• Count on event
• Timer overflow interrupts/events
• One compare match per compare channel
• Two 8-bit timer/counters in Split Mode​

 

20.2 Overview

 

The flexible 16-bit PWM Timer/Counter type A (TCA) provides accurate program execution timing,
frequency and waveform generation, and command execution.

 

A TCA consists of a base counter and a set of compare channels. The base counter can be used to count
clock cycles or events, or let events control how it counts clock cycles. It has direction control and period
setting that can be used for timing. The compare channels can be used together with the base counter to
do compare match control, frequency generation, and pulse width waveform modulation.

 

Depending on the mode of operation, the counter is cleared, reloaded, incremented, or decremented at
each timer/counter clock or event input.

 

A timer/counter can be clocked and timed from the peripheral clock with optional prescaling or from the
event system. The event system can also be used for direction control or to synchronize operations.
By default, the TCA is a 16-bit timer/counter. The timer/Counter has a Split mode feature that splits it into
two 8-bit timer/counters with three compare channels each.

 

A block diagram of the 16-bit timer/counter with closely related peripheral modules (in grey) is shown
below.

21.      TCB - 16-bit Timer/Counter Type B

 

21.1      Features
•      16-bit counter operation modes:
–     Periodic interrupt
–     Timeout check
–     Input capture
•     On event
•     Frequency measurement
•     Pulse width measurement
•     Frequency and pulse width measurement
–     Single shot
–     8-bit Pulse Width Modulation (PWM)
•      Noise canceler on event input
•      Optional: Operation synchronous with TCA

 

21.2 Overview

 

The capabilities of the 16-bit Timer/Counter type B (TCB) include frequency and waveform generation,
and input capture on Event with time and frequency measurement of digital signals. The TCB consists of
a base counter and control logic which can be set in one of eight different modes, each mode providing
unique functionality. The base counter is clocked by the peripheral clock with optional prescaling.

EDIT: Bolded text, See post#6 below

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

Last Edited: Tue. Mar 6, 2018 - 07:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Larry,

 

I see. Guess I gotta just review the datasheet some more! But thanks for replying, I appreciate it.

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

mc0134 wrote:
but what exactly is the difference between timer A and timer B i

There was a fairly recent thread on distilling the datasheet to compare the capabilities of Type A, Type ... timers in that family.  I'll see if I can find it.

 

This one:  https://www.avrfreaks.net/forum/... Not too definitive but might help.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

Last Edited: Tue. Mar 6, 2018 - 07:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mc0134 wrote:
I see. Guess I gotta just review the datasheet some more!
I added a bit more to the post for completeness.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

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

This sticks out like a sore thumb; TCA has 16-bit or 8-bit PWM capability with caveats, read the datasheet for more information.

 

21. TCB - 16-bit Timer/Counter Type B

 

21.1 Features
• 16-bit counter operation modes:
– Periodic interrupt
– Timeout check
– Input capture
• On event
• Frequency measurement
• Pulse width measurement
• Frequency and pulse width measurement
– Single shot
– 8-bit Pulse Width Modulation (PWM)
• Noise canceler on event input
• Optional: Operation synchronous with TCA0

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

Last Edited: Tue. Mar 6, 2018 - 08:12 PM