The PWM Generator takes a clock and generates a PWM by comparating the selected bus against a counter. Another input is added to determine the maximum resolution for the counter (meaning high resolution requires more bits for counting, which results in an overall lower frequency). By dinamically changing the counter max it is easy to generate the new signal. Also a DFF is added to the output of the comparator in order to synchronize the signal and reduce the possible glitches that can arise by changing values mid-run.
To test, just connect the duty bus to the desired value at the output, while also setting the Maximum Bits in the bidirectional pins to the desired quantity (max - 111). After pressing restart the PWM should work as desired.
# | Input | Output | Bidirectional |
---|---|---|---|
0 | Duty[0] | PWM output | Bit selector [0] |
1 | Duty[1] | Bit selector [1] | |
2 | Duty[2] | Bit selector [2] | |
3 | Duty[3] | ||
4 | Duty[4] | ||
5 | Duty[5] | ||
6 | Duty[6] | ||
7 | Duty[7] |