0
\$\begingroup\$

I'm trying to drive an LED at 38kHz with a low duty cycle like 10% from an Atmel ATTiny88. The chip is currently running at 8MHz, but could be adjusted for this portion of code, if need be.

Using the Timer1 with PWM I seem to either have the option to have decent control over the frequency, or I can only use the prescalers to adjust frequency and have control over the duty cycle. I have not found a way to have both the tight control over frequency and also be able to adjust the duty cycle.

Is there a solution that would allow for this, or is it not possible on these microcontrollers?

\$\endgroup\$
1
\$\begingroup\$

Wavegen mode 14 on timer 1 will allow you to control both frequency (via prescaler and ICR1) and duty cycle (via OCR1A and OCR1B).

\$\endgroup\$
  • \$\begingroup\$ Thanks. Once I knew which mode to look at it was pretty straight forward to get it going. \$\endgroup\$ – Jonathan Adams Nov 18 '14 at 23:49
0
\$\begingroup\$

Perhaps you could use an external clock source but I'm not sure how ATTiny reacts to variable frequency.

What exactly do you want to achieve? I hope you're not re-inventing Phase Correct PWM :)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.