For the school project I must measure frequency with Arduino Atmega2560 (or some other microcontroller). The idea is to have timer interrupt set to 1 second and external square signal (frequency) connected to pin interrupt. Each interrupt on pin increment counter for 1. Every second (timer interrupt) the frequency is calculated and counter is reset to 0. The frequency I must measure vary from 2-11 kHz. Can this be done?


  • \$\begingroup\$ what is your clock frequency, and interrupt latency? \$\endgroup\$ Nov 2, 2016 at 7:54
  • 3
    \$\begingroup\$ Gut feeling: easily. For higher frequencies it might be better to use a counter/timer to count the pulses directly. \$\endgroup\$ Nov 2, 2016 at 8:03
  • \$\begingroup\$ I think the clock frequency is 12Mhz or 16Mhz (must verify).. \$\endgroup\$
    – Ferguson
    Nov 2, 2016 at 8:13
  • 2
    \$\begingroup\$ You can measure frequencies all the way up to 8 MHz (perhaps even up to 16 MHz, I can't remember) by using timer/counter 2 as an externally clocked counter. \$\endgroup\$
    – jms
    Nov 2, 2016 at 9:11

1 Answer 1


The Arduino ATMega2650 is listed as having a clock speed of 16MHz, meaning that it should be able to handle this at least in terms of instruction cycles. If you look at the datasheet (P.39) for the actual ATMega2650 chip it appears the I/O clock runs at the same speed as the CPU clock.

There is also this forum post where someone found the maximum digital write speed to be around 100kHz.

I'd say go for it. The chip should be able to handle this. The only place you might run into issues is if you try to do too much in your 1 second timer interrupt, but if all you are doing is returning the counter value then resetting you should be fine.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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