PWMOUT4 gives you four channels of 12 bit PWM output. You can set the PWM counter to one of eight different frequencies. When used with the quad open-drain driver card the PWMOUT4 peripheral can control the speed of four DC motors or the brightness of four strings of LEDs.
The PWMOUT4 peripheral puts a PWM output on four FPGA pins. Each PWM output can be on from 0 to 4096 counts of the PWM clock. The outputs are not synchronized in any way. That is, one output might, or might not, start at the same time as another output. Typically, the outputs all start at different times but there is no guarantee of this. The PWM total period is always 4096 counts long.
pwm : PWM pulse widths as four hex numbers.
Specify the PWM duty cycles as hex numbers in the range of 0 to 1000. A value of 800 is fifty percent duty cycle. The maximum is 1000 (100% on) and the minimum is 0 (entirely off).
The pulse widths are separated by spaces and terminated by a newline. Each of the four pulse widths can vary between 000 and 1000.
config : clock rate in Hertz.
This is the frequency at which the PWM counter is incremented. Valid frequencies include: 20 MHz, 10 MHz, 2 MHz, 1 MHz, 500 KHz, 200 KHz, 100 KHz, and 0. A clock frequency of zero turns off all PWM outputs. The frequency of the PWM pulses is config frequency divided by 4096. This resource works with dpset and dpget.
2000000 -- 2 MHz 1000000 -- 1 MHz 500000 -- 500 KHz 100000 -- 100 KHz 50000 -- 50 KHz 10000 -- 10 KHz 5000 -- 5 KHz 1000 -- 1 KHz 500 -- 500 Hz 100 -- 100 Hz 50 -- 50 Hz
Set the PWM counter frequency to 10 MHz. Set the PWM duty cycles to 25, 50, 75, and 100 percent. percent, and the two LSBs to 0 percent.
# Set the PWM clock to 20 MHz dpset pwmout4 config 20000000 # Set the PWM duty cycles to 25, 50, 75 and 100 percent dpset pwmout4 pwms 400 800 c00 1000