Raspberry Pi Pico Python SDK
13
label("pwmloop")
14
jmp(x_not_y, "skip")
15
nop()
16
label("skip")
17
jmp(y_dec, "pwmloop")
18
19
20
class
21
def
22
23
24
25
26
27
28
29
30
def
31
32
33
34
35
36
37
# Pin 25 is LED on Pico boards
38 pwm = PIOPWM(0, 25,
39
40
while
41
for
42
43
3.9.6. Using
As well as writing PIO code inline in your MicroPython script you can use the
Python file.
$ pioasm -o python input (output)
For more information on
3.9. PIO Support
.side(1)
PIOPWM:
__init__(self, sm_id, pin, max_count, count_freq):
self._sm = StateMachine(sm_id, pwm_prog,
# Use exec() to load max count into ISR
self._sm.put(max_count)
self._sm.exec("pull()")
self._sm.exec("mov(isr,
self._sm.active(1)
self._max_count = max_count
set(self, value):
# Minimum value is -1 (completely turn off), 0 actually still produces narrow pulse
value = max(value, -1)
value = min(value, self._max_count)
self._sm.put(value)
max_count=(1
True:
i in range(256):
pwm.set(i ** 2)
sleep(0.01)
pioasm
pioasm
see the
Raspberry Pi Pico C/C++ SDK
freq=2
* count_freq, sideset_base=Pin(pin))
osr)")
<< 16) - 1, count_freq=10_000_000)
book which talks about the C/C++ SDK.
pioasm
tool from the C/C++ SDK to generate a
25
Need help?
Do you have a question about the Pico Python SDK and is the answer not in the manual?