Using a K60 (bare metal board), I am looking for a good way to generate a simple 50% duty cycle square wave on an output pin at a rate from 0Hz to approx 20kHz, with (hopefully) 1Hz resolution or better. In essence, I'd like to create a function generator that can sweep from 0 to 20KHz.
I have experimented with examples of using EPWM mode, and I can see how to use the FTM0 module for varying pulse widths and frequencies, but the problem I am having is how best to do this at low frequencies (i.e. < 9Hz).
I'm assuming that with my system clock at 75Mhz, my lowest frequency achievable FTM frequency is (75Mhz / 128 / 65535) or about 8.9Hz? If so, what is the best way to control the channel outputs below 9Hz? Can this be done elegantly in hardware with just an FTM? Or do I need a combination of periodic timer + ISR code?
Any pointers would be greatly appreciated! Thanks,
-Bill