0
\$\begingroup\$

I am using a 16-bit, 16Mhz ATmega328P microcontroller. I have set the output of the timer to toggle mode. Hence generating a square wave.

my question is, do I still get a maximum of (2^16-1) 65535 when the 16MHz clock has been prescaled by 8 (2MHz)?

I want to know so that I can work out the duty cycle, as the value of OC1A changes.

Thanks!

\$\endgroup\$
2
\$\begingroup\$

Yes, it will just take 8x as long to get there.

\$\endgroup\$
2
  • \$\begingroup\$ Could you explain what the Max frequency would be? I know that when 0 is reached, the output is toggled high or low. thus is would only be half the time period \$\endgroup\$ Mar 22 '18 at 22:56
  • \$\begingroup\$ Overflow frequency: \$\frac{f_\mathrm{scaled}}{2^{16}}=\$ 30.5 Hz, which is double the frequency (as you said). So, if you use the full depth of the timer (just letting it run from zero every time) at 2 MHz, your frequency will be ~15 Hz. \$\endgroup\$
    – awjlogan
    Mar 23 '18 at 10:09

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.