Would I create a PWM output with a 50% duty cycle and determine the frequency by how often I turn the PWM output on and off?
QuoteWould I create a PWM output with a 50% duty cycle and determine the frequency by how often I turn the PWM output on and off? No the PWM duty cycle is set by the value in the look up table. This in effect sets an analogue level after the PWM has been passed through a filter. At the next sample time you fetch the next entry in the table and set the PWM duty cycle with that.Think of the PWM duty cycle as being an analogue output (which it is).So set the sample time at your basic rate say every 100uS. This will give you a maximum frequency of 5KHz.Then at each sample time you increment the pointer into the lookup table by some value. This value determines the final frequency. As you only have a look up table of 32 entries you only need 5 bits to address this. Therefore use the top 5 bits of your pointer to actually address the look up table and output (set the duty cycle) the value.For a second frequency output use a different pointer a different increment, different PWM output but the same look up table.
couldn't I just turn one of the output lines on and off and change the frequency & duty cycle