Will libraries work if I move from 16Mhz to 8Mhz?

Hello everyone!

I've got a question, I've a project running on Arduino UNO (16Mhz), then I move it to a stand-alone board. I was still working with 16Mhz external crystal.

Now I need the ATmega to run at 8Mhz, I manage to bootload it and upload sketches using ProMini configurations. My question is: I'm using 3rd party libraries will they continue to work when I move from 16Mhz to 8Mhz? The libraries I'm using are:

I'm also working with SoftwareSerial.

Thank you in advance!

Never had any problems with libraries running at 8 MHz. Tried and trusted libraries will have coding to adapt to lower speeds if needed.

Thank you Martin-X!

I was afraid maybe some functionality would stop working.

Best Regards

It's too obvious, but keep in mind that the processor will be twice as slow.

thk aarg! I alreadry knew that, but it's always good to remember it!

What crystal are you going to use for the chip ? 8 MHz or retain the 16 MHz and simply set the relevant board.txt parameter build.f_cpu to 8000000L ? See: http://forum.arduino.cc/index.php?topic=271364.0 post #2

6v6gt: What crystal are you going to use for the chip ? 8 MHz or retain the 16 MHz and simply set the relevant board.txt parameter build.f_cpu to 8000000L ? See: http://forum.arduino.cc/index.php?topic=271364.0 post #2

Or F_CPU in Atmel Studio.

6v6gt, I haven't think of that (keep 16Mhz crystal and just reduce clock speed). I'm actually using and external 8MHz crystal.

I'm intrigued about the solution you propose. If I'd like to keep the 16MHz crystal, but run the MCU at 8MHz, I would just need to change f_cpu to 8000000L or I would have also need to set the prescaler to divide clock freq by 2? or maybe that are two different approach for the same result? I mean I can set f_cpu OR change prescaler, it would be the same.

Thanks!

I can't offer a better description than is the post http://forum.arduino.cc/index.php?topic=271364.0 #2

The only things to say are (1) he could have made better use of if-then-elseif (2) If you use a 16Mhz crystal and set f_cpu to 8000000L, you need the supplementary code to alter the clock pre-scaler, otherwise timing dependent things go wrong (even Serial.print) in your sketch.

Since you have an 8MHz crystal, simply use that. If you have only a 16 Mhz crystal and you need to run the chip at 8Mhz, then use the supplementary code. If you don't use the crystal at all, you can use the internal oscillator at 8MHz (no pre-scaler code then necessary)

sebasira: 6v6gt, I haven't think of that (keep 16Mhz crystal and just reduce clock speed). I'm actually using and external 8MHz crystal.

I'm intrigued about the solution you propose. If I'd like to keep the 16MHz crystal, but run the MCU at 8MHz, I would just need to change f_cpu to 8000000L or I would have also need to set the prescaler to divide clock freq by 2? or maybe that are two different approach for the same result? I mean I can set f_cpu OR change prescaler, it would be the same.

Thanks!

Just to be sure:

to make the processor run at a different speed, you need to set the fuses. :-)

All else is about making timed operations in your software work as before.