0
\$\begingroup\$

Ultimately I am trying to create a timer that interrupts on a 50kHz cycle. Using the equations in the ATMega128A datasheet, I've determined that I would have to scale down a 12.8MHz crystal.

In the datasheet I've found language like, "for resonators, the maximum frequency is 8MHz with CKOPT unprogrammed and 16MHz with CKOPT programmed ..." and also, "... Max operating frequency 16MHz ... " There is nothing in the datasheet that concisely tells me whether or not a 12.8MHz crystal will work.

Is there no minimum frequency? I just don't understand this, I guess I'd expect them to give me a range of working frequencies somewhere but I guess not. I would also like to add that I am relatively new to microcontrollers and this may be something I just don't understand in general.

\$\endgroup\$
2
  • \$\begingroup\$ Assuming you're looking at the original manufacturers data sheet the table you're expecting to see is at the bottom of page 56. You can go from 0.9 to 16MHz. \$\endgroup\$
    – Finbarr
    Commented Mar 16, 2017 at 11:44
  • \$\begingroup\$ @Finbarr Yes. I read right over that and missed it. In the very bottom row of the chart it states the frequency range where 12.8MHz would fit in, and lets you know how to configure CKSEL. Thank you. \$\endgroup\$
    – Snoop
    Commented Mar 16, 2017 at 14:22

2 Answers 2

3
\$\begingroup\$

You'll be fine with any crystal up to 16MHz according to that chip's spec (see page 56). Resonators are not the same as crystals and on some chips they need to be treated differently, always check the datasheet for any differences.

Table 13-3 in the datasheet (the last row in that table) shows what settings and caps you need for the 12.8MHz xtal.

Many microcontrollers will allow you to clock them at any speed down to zero Hz and up to whatever their maximum stated frequency is. Often a MCU will have a slow speed internal oscillator (typically 32768 Hz) for times when you want to go into a low-power mode.

One interesting example is the Parallax Propeller P8X32A chip which behaves well at any clock speed between "DC" (literally Direct Current - no oscillation = 0Hz) up to a nominal 80Mhz. If you're careful you can even vary this clock rate on the fly and still get correct operation as long as all your edges are clean.

Many MCUs will allow you to programatically change your clock source or the "PLL taps" at runtime, sometimes for power saving, sometimes for changing other properties such as baud rate of a UART for instance.

In 99% of applications though most people will use a MHz range clock simply because they are cheap, available and provide a lot of processing power per unit time.

Further info -- related topics...

  • Sinusoidal clock sources
  • Clipped-sine crystal output (which is quite common as it approximates a square wave).
  • Square-wave clock sources
\$\endgroup\$
1
  • \$\begingroup\$ This AVR can be clocked at any speed as well - it's just the crystal that needs to be above 1 MHz. E.g. using an external oscillator can be any speed. \$\endgroup\$
    – asdfex
    Commented Mar 16, 2017 at 11:58
0
\$\begingroup\$

The kind of clock speed you need will depend on the way you generate the desired interval. A typical approach is to utilize timer overflow. The duration there will depend on prescaler, timer length, and if it is auto reload.

Other approaches offer more flexibility, like via a pwm generator, or output compare...

You can generate 50khz output from a clock much lower than 12.8Mhz.

And the minimum frequency is zero+ Hz. The datasheetss usually has a few charts on that.

\$\endgroup\$

Your Answer

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

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