I am trying to use the arduino mega2560 to drive a h-bridge at a 125kHz frequency. To do this I need two square wave outputs that are at 125kHz. Is this frequency achievable because I have tried looking on line to see examples, but even the examples I have seen on line have not worked correctly for me. I am testing these straight from the arduino to an ocilloscope. I keep ending up with up with a square wave at around 79kHz with low resolution. I am also later going to put a mppt for a solar panel on the arduino and adjust the duty cycle of one of the square waves. That is later though right now I would really just like to figure out how to adjust the frequency. Does all of this sound possible, and if so is there some example of code out there that will adjust my frequency correctly. Thanks in advance for any advice.
two different codes.txt (840 Bytes)