1
\$\begingroup\$

I need a high frequency clock (16MHz or higher) to drive OV7670 camera module, and I want my ATmega328P to be source of that clock. I'm using the CLKO pin since I can't get such high frequencies from PWM.

I programmed the lower fuse bits (0xBF - 8MHz+ external crystal osc., PB0 used to output clock) so it outputs its clock from quartz on PB0 pin. The problem is that if I drive my ATmega with 16MHz quartz, I get 8MHz output. If I use 20MHz quartz, then I get 4MHz output on PB0. The highest clock I get is from 12MHz quartz - then I get 12MHz on PB0.

It's quite strange since frequency goes like opposite direction. Am I doing something wrong?

\$\endgroup\$

1 Answer 1

4
\$\begingroup\$

Verify your fuse bits settings:

  • You should choose full swing crystal oscillator, that is CKSEL3...1 should be 011.
  • Then you can choose "Crystal Oscillator, slowly rising power", that is CKSEL0 is 1 and SUT1..0 is 11.
  • You selected 8MHz - why? If you use 16 MHz thats not the right setting.
  • CLKO pin will output system clock - that can be divided by the prescaler.
  • See chapter 9.12.2 in the datasheet. Register CLKPR should have bits CLKPS3...0 set to 0, so it gives prescaler value of 1.
  • That is make sure the fuse bit CKDIV8 is not enabled, as this will divide the clock by 8.

So it is more probably that 0xB7 is the correct settings, not the 0xBF. See this calculator

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