Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

12 MHz crystal speed

So I just noticed that my Chinese Arduino Uno has a 12 MHz crystal instead of the original 16Mhz.

I made calculations and that turned out to be a quarter millisecond's difference.

My questions:

  1. Does this affect servos or tone(), or any other time sensitive hardware/library?
  2. Can I notify by code that "clock speed is 12,000"?
like image 393
Wadaane Avatar asked Dec 06 '25 05:12

Wadaane


1 Answers

The reduced clock speed will affect anything that uses a timer, unless that code can be altered to accommodate the slower clock. Delays, millis(), explicitly coded timer interrupts, etc. And one must remember that you'll get fewer overall instructions per second, so a fast interrupt that barely "fits" at 16MHz might not "fit" at all in the clock cycles available at 12MHz.

Hobby-level servos in particular are sensitive to timing...they depend on a pulse in the 0.5-2.0 millisecond range every 20 milliseconds or so. So if your project includes servos as so many hobby projects do, you'll want to be especially cognizant of timings.

In gcc-c programming the #define F_CPU = 12000000 directive would alert the compiler/preprocessor to compute delays with the 12 MHz clock in mind. Your toolset may vary.

like image 125
TomServo Avatar answered Dec 09 '25 06:12

TomServo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!