EEVblog Electronics Community Forum
Electronics => Projects, Designs, and Technical Stuff => Topic started by: JJalling on August 19, 2013, 08:02:42 pm
-
Hi all,
I can't figure out how many individual PWM channels (HW) the ATTiny25/45/85 has. In Atmels parametric search, the number is 4, but it seems like it's only 2 when i look in the datasheet [1].
IMO, Microchips solution on showing the available peripherals and what pins to use in a table, is WAY better.
[1]: http://www.atmel.com/Images/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf (http://www.atmel.com/Images/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf)
BR Jonas
-
Based on datasheet (Page 1.)
– 8-bit Timer/Counter with Prescaler and Two PWM Channels
– 8-bit High Speed Timer/Counter with Separate Prescaler
• 2 High Frequency PWM Outputs with Separate Output Compare Registers
• Programmable Dead Time Generator
Not sure how ever if you can use all 4 at same time. Haven't used Atmel parts that much myself.
-
Each timer has two output registers to control two output pins, i.e. one timer provides the clock for two output pins and the PWM ratio is defined by the dedicated output compare registers. Please read the sections for the timers very carefully, it will take some time to understand the concept. The nice thing is that all AVRs (Tiny and Mega) share the same concept with minor differences.
-
– 8-bit Timer/Counter with Prescaler and Two PWM Channels
– 8-bit High Speed Timer/Counter with Separate Prescaler
• 2 High Frequency PWM Outputs with Separate Output Compare Registers
• Programmable Dead Time Generator
So 2 PWM channels are generated from timer 0, and 2 PWM channels from timer 1. You need both timers for 4 PWM outputs.
However, because the device only has 8 pins, most functions are multiplexed. From pin table at page 2:
PB5 contains no PWM
PB4 contains OC1B
PB3 contains OC1B Inverted
PB2 contains no PWM
PB1 contains OC0B or OC1A
PB0 contains OC0A or OC1A inverted
So you can only get 3 PWM outputs from this chip at one time. PB4, PB0, PB1.
-
Thanks for sorting it out for me guys. I'll have to find another chip then.
bR Jonas
-
I use the ATtiny44A quite often for random stuff.
It's small, cheap and has all the general stuff... ADC, Serial (USI), 8bit timer, 16bit timer, analog comparator.
Both of the timers have 2x output compare units for PWM (4 channels total).
They're also on separate pins, so you can use them all at once.