Are you trying to change the PWM parameters via APIs at run-time?
This can be implemented using a 16bit PWM component.
I'll upload a project shortly.
I've just done this using a counter (16-bit) producing 200Hz to 900KHz on a 24MHz clock. I know exactly what you mean about the non-linearity (f=1/T)!
The code I wrote for the loading of the conter is:
where "count" (uint16) is the number to load into the Counter
"counter" (uint16) is the value of your pot or encoder for inputting the frequency
"scale" is simply the range of frequency required.
I am using this to generate quadrature encoder output frequecy using a flag for direction change (hence the use of "abs" - as I'm generating the +/- elsewhere.
Hope it helps!
Generating square wave of increasing frequency from 0Hz to 50KHz in steps of 1Hz might not be possible in a straight forward manner.
For example, increasing the frequency in steps of 1Hz, that is, 0Hz, 1Hz, 2Hz - - - 49,998Hz, 49,999Hz and then 50,000Hz using only a single PWM looks quite tricky.
Can anyone come up with algorithm/ strategy to attain this?
How to do frequency sweeping on step 1 hz .sweeping from 1mhz on evert step 1 hz using AD9833.i am new to this.please help.