2

I am moving my Arduino Uno project from Uno to Bread and as we know, this requires two 22 pf capacitors and 16 MHz on the breadboard (and the other things too like the power-but my question is about the crystal frequency so I'll focus on that).

If I replace the 16 MHz crystal with a 12 MHz crystal then the project will work as expected on a breadboard-is that correct?

It seems that the fuse setting to use 16 MHz crystal is the same as for the 12 MHz crystal for Arduino Uno-so I guess a change to the fuse setting or bootloader is not required. Am I missing anything?

I guess it's as simple as replacing a 16 MHz crystal by a 12 MHz crystal.

asked Oct 20, 2016 at 16:57
4
  • 4
    You will need to change your compile settings so that baud rates and delays are calculated for 12 MHz. This used to require a unique entry in the boards file but it can possibly now also be supported as a menu choice, you may have to do some research on your own to find the current state of things, but I bet a web search will find you an example boards file entry for 12 MHz, too. Commented Oct 20, 2016 at 17:00
  • You can also program the ATmega using ISP, and thus not needing a bootloader at all. Commented Oct 20, 2016 at 18:29
  • @Gerben So how would that differ (versus using a bootloader) for setting up a 12 Mhz crystal? Commented Oct 21, 2016 at 20:58
  • @yabbadabba you don't need to burn a 12MHz version of the arduino bootloader. Your code still needs to set the correct F_CPU so delay etc. work correctly. Commented Oct 22, 2016 at 14:40

2 Answers 2

2

Some of the code running on the microcontroller needs to know the clock speed it's running at for correct timing. For this reason the macro F_CPU is set with this value. In the Arduino IDE this value is commonly defined in the boards.txt build.f_cpu property. If you're using a bootloader(which is used for uploading sketches over serial) it also needs to know the clock speed so that it can get the baud rate of the upload correct. The bootloader is not compiled in the Arduino IDE so it is not affected by your setting in boards.txt. You can recompile the bootloader with the correct clock speed setting and then install the compiled file on your microcontroller using an ISP.

There is a much more simple solution. All the hard work has already been done for you in MiniCore: https://github.com/MCUdude/MiniCore

You only need to:

  1. Install MiniCore following the instructions at https://github.com/MCUdude/MiniCore
  2. Tools> Board> ATmega328
  3. Tools> Variant> 328P / 328PA
  4. Tools> Clock> 12 MHz external
  5. Tools> Burn Bootloader
answered Dec 20, 2016 at 22:42
0

Yes it will work correctly IF you change the compile setting so that everything is in sync. This is because when you select an Arduino UNO from the IDE, it will process that as if your Arduino has 16Mhz. Here is a link for more information..

answered Oct 20, 2016 at 17:03
2
  • Im going to leave in the 16 MHz crystal upon to the very last moment Ive got everything on breadboard working (so the baud rate isnt affected when downloading a sketch). And for the compiler setting-I looked up the code-I think you mean change FCPU then it will define the real world time correctly from the frequency. Is that all that required for the changes? Commented Oct 20, 2016 at 17:09
  • at the last moment ill plug out the 16mhz crystal and replace it with the 12mhz Commented Oct 20, 2016 at 17:12

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.