0

I am considering switching from Arduino Pro Mini 5V 16MHz to Arduino Pro Mini 3.3V 8Mhz for some project because I would like to run it with a 4.5V input power.

Will the switch from 16 to 8Mhz double the cycle time of my loop() function ?

Edit -- adding precision: My loop function is simple: it's reading a couple of sensors with analogRead and setting a few pins to HIGH or LOW. It does not use delay().

Thanks.

3

The execution time of your loop() will be slightly longer when the CPU runs at 8 MHz v.s. 16 MHz, but I don't expect the difference to be significant. CPU-bound functions, such as digitalWrite(), will run at half the speed. These functions, however, are quite fast. In contrast, analogRead() is slow, as it takes roughly 110 µs to execute, so this is likely where your loop() spends most of its time.

The execution time of analogRead() does not depend significantly on the CPU speed. This function spends most of its time waiting from the analog-to-digital converter to do its conversion. When the CPU is clocked at either 1, 2, 4, 8 or 16 MHz, the Arduino core sets the ADC prescaler so that the ADC is clocked at 125 kHz. This means the conversion time will be the same irrespective of the CPU frequency.

Note: You may just use your Arduino Pro Mini 5V 16MHz. This board is based on the ATmega328P microcontroller, which is rated for frequencies up to 20 MHz when the supply voltage is between 4.5 and 5.5 V. According to the datasheet (see freq-Vcc graph), it should safely run at 16 MHz for any supply voltage between 3.78 and 5.5 V.

| improve this answer | |
0

It depends.

The loop function is handled like a while loop. This means, when the loop function finishes, some framework code is executed (very small) and the loop function is called again etc.

However, there are some calls that do not depend on the clock speed, the best example is the delay function, but also if you made your own check using e.g. millis this will not depend high likely on the clock speed.

Beyond that, there can be peripheral calls which are not related to the clock speed (although internally in libraries timing functions as above are used to manage this), but you don't see them when used from a library.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.