Skip to content

Commit 6c1227e

Browse files
committed
add tests of pwm extremes
1 parent 8a1b3e7 commit 6c1227e

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

tests/circuitpython-manual/pwmio/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This directory contains tools for testing CircuitPython's PWM API. Running the tests involves three steps:
44

5-
1. [CircuitPython PWM test code `code.py`](code.py) is run on the board to be tested.
5+
1. [CircuitPython PWM test code `code_ramps.py`](code_ramps.py) is run on the board to be tested.
66
2. As the code runs, the state of the PWM signal is logged by a logic analyzer (I used a Saleae Logic Pro 8).
77
3. Data collected by the logic analyzer is analyzed and plotted into a PNG image by [CPython code `duty.py`](duty.py).
88

@@ -37,3 +37,9 @@ These tests can be used to assess how well the PWM API delivers expected behavio
3737
The plot at the top of this page depicts data PWM gathered from a device with an API that displays all of the expected behavior listed above. The plots below show how the tools reveal flaws in the behavior of PWM APIs that are not as complete.
3838

3939
<img src="pwm_flaw_explainer.png">
40+
41+
## Testing always-off and always-on PWM extremes
42+
43+
The procedure described above does not test item 2 above, i.e. the ability of the API to support duty cycles of 0% and 100%. A different code file, (code_extremes.py) provides for this. This code cycles through PWM duty cycles of 32767, 65535, 1, 65534, and 0, repeating the sequence at six frequencies from 100 Hz to 10MHz. When viewed on a logic analyzer, the PWM output should look like the figure below. 100% and 0% PWM result from duty cycle settings of 65535 and 0, (and only from those settings, in accordance with item 3 above.)
44+
45+
<img src="pwm_extremes_explainer.png">

tests/circuitpython-manual/pwmio/code.py renamed to tests/circuitpython-manual/pwmio/code_ramps.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
board_name = sys.implementation[2]
4040

4141
pins = {
42+
"Feather RP2040": (("D4", ""),),
4243
"RP2040-Zero": (("GP15", ""),),
4344
"Grand Central": (("D51", "TCC"), ("A15", "TC")),
4445
"Metro M0": (("A2", "TC"), ("A3", "TCC")),
Loading

0 commit comments

Comments
 (0)