PWM problem with AtTiny25

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

Hello...

I succesfully got PWM working on my AtMega8, by doing the following:

Set DDB1,2,3
I set WGM10 and WGM12 for 8-fit fast PWM.
I set COM1A1 and COM1B1 to set on match.
I set CS10 for no prescaling.
WGM20,WGM21 for timer2 fast PWM
COM21 for clear on match.
CS20 for no prescale.

There I went, I could set OCR1A, OCR1B, and OCR2 and things worked well.

But, on a Tiny25, no worky. Here's what I've tried:

DDRB=0xff
set COM0A0, COM0A1, COM0B0,and COM0B1 for set on match.
Set WGM00 and WGM01 for fast PWM, 0-255
set CS00 for no prescaler.

Then I set OCR1A and OCR1B... but no output on pins 3 or 6.

I imagine that I've just missed something simple...any suggestions?

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

That should have said OCR0A and OCR0B at the end.

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

Make sure your CKSEL fuses are not written to 0011 unless you want them set this way. This is ATtiny15 compatibility mode, which changes how the timers work.

From your description, I assume your setup is something like this:
TCCR0A = 0xF3;
TCCR0B = 0x01;

I assume you are aware of this:

Quote:
The extreme values for the OCR0A Register represents special cases when generating a PWM waveform output in the fast PWM mode. If the OCR0A is set equal to BOTTOM, the output will be a narrow spike for each MAX+1 timer clock cycle. Setting the OCR0A equal to MAX will result in a constantly high or low output (depending on the polarity of the output set by the COM0A1:0 bits.)

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

Never mind...

I took a little time off, ate some food, and looked at it again. When setting the TCCR0B bits, I had accidentally typed...

GTCCR=_BV(CS00) ... etc..

I fixed that, and all is well. Sorry for wasting everyone's time. :(