
123Experiment 7: Counting Pulses with a Pico
the next pulse. Each of the comparators compares the binary value from the
counter with the level value for each output. If the counter value is less than
the level value, the output is high. If not, the output is low. In other words, the
duty cycle of the output signal is set by the level value. The frequency of the
output signal is the system-clock frequency divided by wrap plus 1.
Lines 18–21 set up the test-signal output. Line 18 assigns the output
pin to its PWM block. Line 19 sets the output frequency using the divisor
constant, and line 20 sets the duty cycle to 50%. Finally, line 21 turns on ...