Author Topic: PWM channels in ATTiny25/45/85  (Read 4693 times)

0 Members and 1 Guest are viewing this topic.

Offline JJalling

  • Supporter
  • ****
  • Posts: 238
  • Country: dk
PWM channels in ATTiny25/45/85
« 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

BR Jonas
 

Offline lapm

  • Frequent Contributor
  • **
  • Posts: 562
  • Country: fi
Re: PWM channels in ATTiny25/45/85
« Reply #1 on: August 19, 2013, 08:20:24 pm »
Based on datasheet (Page 1.)
Quote
– 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.
Electronics, Linux, Programming, Science... im interested all of it...
 

Online madires

  • Super Contributor
  • ***
  • Posts: 6194
  • Country: de
  • A qualified hobbyist ;)
Re: PWM channels in ATTiny25/45/85
« Reply #2 on: August 19, 2013, 08:31:07 pm »
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.
 

Offline hans

  • Super Contributor
  • ***
  • Posts: 1150
  • Country: nl
Re: PWM channels in ATTiny25/45/85
« Reply #3 on: August 19, 2013, 08:44:06 pm »
– 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.
« Last Edit: August 19, 2013, 08:47:22 pm by hans »
 

Offline JJalling

  • Supporter
  • ****
  • Posts: 238
  • Country: dk
Re: PWM channels in ATTiny25/45/85
« Reply #4 on: August 20, 2013, 09:07:56 am »
Thanks for sorting it out for me guys. I'll have to find another chip then.

bR Jonas
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 8112
  • Country: nz
Re: PWM channels in ATTiny25/45/85
« Reply #5 on: August 20, 2013, 10:35:23 am »
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.

« Last Edit: August 20, 2013, 10:40:26 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf