1
\$\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?

asked Nov 17, 2014 at 23:30
\$\endgroup\$

2 Answers 2

2
\$\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).

answered Nov 18, 2014 at 0:00
\$\endgroup\$
1
  • \$\begingroup\$ Thanks. Once I knew which mode to look at it was pretty straight forward to get it going. \$\endgroup\$ Commented Nov 18, 2014 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 :)

answered Nov 17, 2014 at 23:56
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.