ATTiny87 using all pwm channels

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

Hello everyone,

      I have been looking all over and reading the data sheet for information on how the "9" pwm channels work.  Sorry if this has been covered before but I didn't see anything that exactly stated what i'm trying to figure out.  

 

From what I understand the PWM pins are OC1AU, OC1BU, OC1AV, OC1BV, OC1AW, OC1BW, OC1AX, OC1BX, and ,OC0A;  I am just interested in the the first 4 listed (OC1AU -  OC1BV).  My biggest question, is can they all be set to a different duty cycle.  Frequency I am setting to around 36khz and fast PWM for motor control.  If they can be set to different duty cycles, how is this done with only two compare registers OCR1A and OCR1B.  I see in data sheet where TCCR1D is used to enable the output compare pins. 

 

The only thing I can think of is the compare registers would have to be constantly updated with a new value and the TCCR1D updated to which pin for that value would be associated too.

 

Thanks 

-Lee

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

Figure 12-5 on page 114 of the ATtiny87/ATtiny167 datasheet shows that the parts only have two PWM channels. The bits you mention select which pins the two channels will drive. (EDIT: That is for Timer 1. You can use Timer 0 to get a third, 8-bit PWM channel.)

- John

Last Edited: Mon. Dec 25, 2017 - 09:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jfiresto wrote:
datasheet shows that the parts only have two PWM channels.

Now y'all are going to make me look.  OP is asking about 9 channels.  John says 2.  My datasheet Feature list implies 5 ...

 

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.

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

According to Microchips website pragmatic compare it lists 9 under the column Stand Alone PWM.  So i'm confused.

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

. . .

- John

Last Edited: Tue. Dec 26, 2017 - 10:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Right. It was hard to find and very slow to load, but I may have generated the table you were looking at, here.

 

The column actually reads: "Max # PWM outputs (including complimentary outputs)" which already suggests you may get fewer PWM channels. Unfortunately, the table only suggests some upper bound on how many channels a part may have, which is probably not so helpful if there is a particular number you need.

 

You may find this peripheral integration document (352 Kbyte PDF), which does specify the tiny87's 1+2 PWM channels, to be more useful.

 

 

 

 

- John

Last Edited: Tue. Dec 26, 2017 - 12:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the help, I appreciate it.

 

I saw that column, I also saw the "Stand alone PWM column if you click on "Show all specs" at the top.  So apparently a little hyped advertising going on there.  The Peripheral integration document is very helpful and now makes since with what I was seeing in the data sheet.  Looks like I will be looking at a different chip to do what I want to do.  

 

Thanks again.

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

You are a more patient man than I am. It took 2 1/2 minutes and a couple "script is unresponsive" warnings to see what I saw, and that much again, to see all the columns, including "Stand alone PWM".

 

One thing I might suggest is to write and verify your timer code before you commit to a chip. The AVR timers have their quirks and you may need a bigger/"enhanced" part if you get caught out by one.

- John