Is it possible to obtain the rectangular pulse signals of freuency 10 MHz simultaneously at the GPIOs of arduino mega 2560?
-
If you ran it at 20 MHz clock speed, maybe. But it's quite a stretch.– toweCommented Nov 19, 2018 at 7:20
-
But in that case I am not getting perfect rectangular shape pulses. Please help me to solve the problem. Thanks in advance.– sujoyCommented Nov 19, 2018 at 9:07
-
Short of replacing the on-board resonator, the maximum you can get is 8 MHz. You can get that on any of the pins identified as “PWM” (i.e. pins 2 – 13).– Edgar BonetCommented Nov 19, 2018 at 9:27
-
You should learn something about "impulse response". There is nothing like perfect. You can get closer to it by reducing parasitic capacitances/inductances and by using stronger line driver.– KIIVCommented Nov 19, 2018 at 9:39
-
16 MHz is also possible if one of the fuses is changed to output the system clock. '2560 is only rated to 16 MHz as well, at 20 MHz you'd be overclocking it: ATmega2560/ATmega2561: • 0 - 16MHz @ 4.5V - 5.5V– CrossRoadsCommented Nov 19, 2018 at 14:48
1 Answer
The maximum fundamental frequency you can generate is fcpu/2 - or 8MHz with the default 16MHz resonator / crystal.
What shape the actual signal is, though, is very much dependant on the load on the IO pin. The IO pin has a specific drive strength which will provide limited current into a load. Any capacitance or inductance within that load causes a change in the slew rate (also known as the rise time or fall time) of the IO pin, which affects the shape of the signal by limiting the highest harmonic frequencies you observe. At the worst case scenario, you get an almost sine wave (only the fundamental frequency gets through). In general though you get more of a rounded-off square wave:
You can improve that slew rate by adding a buffer with a higher drive strength to the output (assuming your buffer has a high enough bandwidth). However, the IO pin itself will always have a certain amount of curvature to the signal due to its own internal capacitances.
For generating higher frequencies you are better off using a chip that is designed to operate at higher frequencies.