BL4S100 User’s Manual
40
Once the connections have been made, compile and run this sample program. Change
the offset and duty cycle for a given PPM channel via the Dynamic C
STDIO
window
and watch the change to the begin and end counts measured on the input capture inputs.
The PPM frequency can be changed in the
#define PPM_FREQ
line.
Rabbit recommends that you run and understand both the
INTERRUPTS.C
and the
PULSE_
CAPTURE.C
sample programs before looking at
PULSE_CAPTURE_IRQ.C
since
PULSE_CAP-
TURE_IRQ.C
uses concepts covered in the simpler sample programs.
•
PULSE_CAPTURE_IRQ.C
—Demonstrates the use of an advanced pulse capture
method using RIO interrupts.
IN0 is configured as the pulse capture input, and OUT0–
OUT7 are configured as PWM outputs of varying fre-
quencies and duty cycles that provide signals to test the
capture with. Connect IN0 and OUT0 together.
If an external signal source is available, connect it to
IN0 for capture.
If an external signal source is not available, connect IN0 on the BL4S100 to SW1.
Once you compile and run this sample program, press any key on your PC keyboard to
pause or unpause the display—the capture will continue in the background. Change the
IN0 connection to any of OUT0–OUT7 or an external source to capture a different signal.
This sample program will continuously capture single pulses in an interrupt service
request for display
•
PWM.C
—Demonstrates the use of the eight PWM channels on digital output pins
OUT0–OUT7. The PWM signals are set for a frequency of 200 Hz with the duty cycle
adjustable from 0 to 100% by the user. These pins can be connected to an oscilloscope
to view the waveform being generated. The overall frequency can be adjusted in the
#define PWM_FREQ
line. Follow these instructions when running this sample program.
1. The digital outputs on the BL4S100 do not have an internal pull-up resistor and will not register on
the oscilloscope without a pull-up resistor. The Demonstration Board has pull-up resistors—
connect OUT0–OUT3 on the BL4S100 to SW1–SW4 on header J1 of the Demonstration Board.
2. Connect the oscilloscope probe to digital output pins OUT0–OUT3 on headers J3 or J4. Remember
to connect the oscilloscope ground to GND on header J4.
Once you compile and run the sample program, change the duty cycle for a given PWM
output channel via the Dynamic C
STDIO
window and watch the change in waveforms
on the oscilloscope. Signals on the same RIO counter block (OUT0 and OUT1 for
example) will all be synchronized with each other. Different blocks may have a phase
shift from each other, but will run at the same frequency.
Global synchronization can be used to synchronize different block on the RIO, but this
is not demonstrated in this sample program.
J3
OUT2 OUT1 OUT0 IN3 IN2 IN1 IN0 +K GND
DEMO BOARD
SW1