I need to generate two PWM frequencies around 40Khz separated by about 32hz on a Teensy4. According to the PWM page, it seems I should choose:
Resolution = 11 bits
Ideal frequency = 73242 hz
This gives a frequency resolution: 73242/2048=35.76hz
This is close enough to 32hz to work.
Is this the correct way to calculate what frequencies are available? ie 35.76hz * n
AnalogWriteFrequency does some rounding etc to get the closest frequency to what was input, so I need another way to set the frequency so I know the exact PWM frequency I’m going to get. Is there an easier way to do this other than direct register manipulation?
Resolution = 11 bits
Ideal frequency = 73242 hz
This gives a frequency resolution: 73242/2048=35.76hz
This is close enough to 32hz to work.
Is this the correct way to calculate what frequencies are available? ie 35.76hz * n
AnalogWriteFrequency does some rounding etc to get the closest frequency to what was input, so I need another way to set the frequency so I know the exact PWM frequency I’m going to get. Is there an easier way to do this other than direct register manipulation?
Last edited: