summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNitiKaur <nitikaur102@gmail.com>2021-11-05 15:46:35 +0530
committerDamien George <damien@micropython.org>2021-11-19 15:30:14 +1100
commite538d8a5a6d4c643b1bff41107062511b2e7f65a (patch)
tree9c30a29bb025039af0084e1f53d28b146c3911b4
parent01f1c3aac200fa33f981e0e53a20005e7ae3f6e8 (diff)
docs/rp2/quickref.rst: Add section on PIO.
-rw-r--r--docs/rp2/quickref.rst31
1 files changed, 31 insertions, 0 deletions
diff --git a/docs/rp2/quickref.rst b/docs/rp2/quickref.rst
index 63b892828..4824f390e 100644
--- a/docs/rp2/quickref.rst
+++ b/docs/rp2/quickref.rst
@@ -92,6 +92,37 @@ Use the :ref:`machine.Pin <machine.Pin>` class::
p4 = Pin(4, Pin.IN, Pin.PULL_UP) # enable internal pull-up resistor
p5 = Pin(5, Pin.OUT, value=1) # set pin high on creation
+Programmable IO (PIO)
+---------------------
+
+PIO is useful to build low-level IO interfaces from scratch. See the :mod:`rp2` module
+for detailed explaination of the assembly instructions.
+
+Example using PIO to blink an LED at 1Hz::
+
+ from machine import Pin
+ import rp2
+
+ @rp2.asm_pio(set_init=rp2.PIO.OUT_LOW)
+ def blink_1hz():
+ # Cycles: 1 + 7 + 32 * (30 + 1) = 1000
+ set(pins, 1)
+ set(x, 31) [6]
+ label("delay_high")
+ nop() [29]
+ jmp(x_dec, "delay_high")
+
+ # Cycles: 1 + 7 + 32 * (30 + 1) = 1000
+ set(pins, 0)
+ set(x, 31) [6]
+ label("delay_low")
+ nop() [29]
+ jmp(x_dec, "delay_low")
+
+ # Create and start a StateMachine with blink_1hz, outputting on Pin(25)
+ sm = rp2.StateMachine(0, blink_1hz, freq=2000, set_base=Pin(25))
+ sm.active(1)
+
UART (serial bus)
-----------------