Hardware Reference
In-Depth Information
A few more statements check for errors and reset if necessary (these may not be
strictly necessary). Then the following two statements provide a short pause and re-enable
the PWM peripheral:
usleep(10); /* Pause */
pwm_ctl->PWEN1 = 1; /* Enable */
That covers the interesting aspects of the hardware PWM control.
Hardware PWM Set Command
When program pwm is provided with command-line arguments, it simply sets up and
starts the PWM peripheral. The command takes up to three arguments:
$ ./pwm N [M] [ F ]
where:
N is the N in the PWM ratio.
M is the M in the PWM ratio.
F is the frequency required.
Once the command is started with these parameters, the PWM peripheral is started
and the program exits:
$ . /pwm 40 100 1000
PWM set for 40/100, frequency 1000.0
$
If you have an oscilloscope available, you can attach probes to GPIO 18 and the
ground to see a 40% PWM signal. If you attach the meter circuit of Figure 9-1 , it should
read near 40% of the full deflection. Figure 9-2 shows my milliampere meter showing
nearly 40% (the deflection reading is nearly 0.4). The DMM in the background is
measuring the +3.3 V supply voltage, which is showing good voltage regulation.
 
Search WWH ::




Custom Search