Finding oscillator speed

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello people I've got I small question for you. I'm playing around with the MEGA1284P but can't find any documentation where the clock speed stands directly. The hardware documentations on the other hand shows a " 12Mhz XTAL" connected to the board controller. Is it so that the F_CPU is 12Mhz or is this used for other tasks?

Last Edited: Wed. Dec 27, 2017 - 12:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The datasheet tells you what the default settings are. If your hardware has an external 12MHz crystal, then the fuses need to be set correctly to enable this and turn off the div8 option. If this has been done correctly, then your F_CPU is 12000000

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Write code to pulse a pin at 1Hz (say) based on an assumption of 12MHz. If it pulses at 1Hz then the CUP is 12MHz. If not work out the relative scale and multiply to work out the ratio.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The micro typically has several options for the clock source.

These include an internal RC oscillator, an external crystal (and two caps), or an external clock signal (square wave).

Other clock options sometimes exist, such as a 32 kHz clock Xtal.

In addition to the above, many of the micros have an optional Divide Clock by 8 option, so if enabled an 8 MHz clock source would really be running the micro at 1 MHz.

 

The FUSES are what sets the clock source.

 

You can, depending upon your programmer, read and adjust the micro Fuse settings.

 

Be very careful when you adjust the clock fuses, if you are sure what you are doing, ask first.

 

JC 

 

Cross post with the above...

 

 

Last Edited: Wed. Dec 27, 2017 - 01:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

Write code to pulse a pin at 1Hz (say) based on an assumption of 12MHz. If it pulses at 1Hz then the CUP is 12MHz. If not work out the relative scale and multiply to work out the ratio.

 

Why not simply program the CKOUT fuse and put a scope on PORTB1 to see what the system clock is?  Of course, if you are programming fuses, one could simply read the fuses and see what the AVR is set up to run at.

 

Jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For that you'd need a scope ;-)

 

I generally assume most people have access to an LED but not necessarily a scope.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
For that you'd need a scope ;-)

Point taken.

 

Since the OP seems to allude that this is a board they are playing with, maybe they can post a picture of the board, and tell us what IDE and programmer they are using before this thread turns into another 100+ thread.

 

Then maybe we can provide practical suggestions instead a lot of guesses.  Just a thought

 

JIm

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user