-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
RP2 - PIO module #7496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RP2 - PIO module #7496
Conversation
This is a good start, and the general overview here is well suited to a tutorial or general introduction section. The specific commands and the details of their arguments are more of a reference and I think would be better placed in a new section at the end of |
docs/rp2/pio.rst
Outdated
|
||
irq(mod, index = None) | ||
index : IRQ (0-7) | ||
see sec 3.4.9 of RPi docs for details |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the following forms of this instruction (index
is an integer value):
irq(index)
irq(rel(index))
irq(block, index)
irq(block, rel(index))
irq(clear, index)
irq(clear, rel(index))
irq(block | clear, index)
irq(block | clear, rel(index))
That can be summarised as 2 forms:
- form 1:
irq(index)
- for
10000
m 2:
irq(mode, index)
where: index
can be an integer orrel(integer)
mode
can be:block
orclear
orblock | clear
.
Allowed IRQ numbers are 0-7 (0-3 are visible from to the processor, 4-7 are internal to the state machines).
docs/rp2/pio.rst
Outdated
index : IRQ (0-7) | ||
see sec 3.4.9 of RPi docs for details | ||
|
||
self(dest, data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be "set"
This is already of use and close to what we asked of you @NitiKaur. But the more I dig into the PIO programming (I'm quite new to it), the more I think we need more, of which, this reference will form a component. In particular:
In short, enough documentation so that all of the techniques used in the PIO examples are covered. We'll discuss this further at the next meeting. |
docs/library/rp2.rst
Outdated
@@ -71,6 +71,79 @@ For running PIO programs, see :class:`rp2.StateMachine`. | |||
This exception is raised from `asm_pio()` or `asm_pio_encode()` if there is | |||
an error assembling a PIO program. | |||
|
|||
Each state machine has a set of instructions- which allow for a wide range of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section could do with a heading, for example "PIO assembly language"
docs/library/rp2.rst
Outdated
see sec 3.4.3 of RPi docs for details | ||
|
||
in(src, data) | ||
src : pin, X, Y, ISR, OSR(all 0-31) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these all need to be lower case: x, y, isr, osr. also it's in_
to not clash with the in
keyword
docs/library/rp2.rst
Outdated
see sec 3.4.4 of RPi docs for details | ||
|
||
out(dist,data) | ||
dist : pin, X, Y, PINDIRS, AC, ISR, OSR(all 0-31) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dist should be dest, and lowercase for x, y, pindirs, isr, osr (AC is not supported I don't think)
docs/library/rp2.rst
Outdated
see sec 3.4.7 of RPi docs for details | ||
|
||
mov(dist, src) | ||
dist : pin, X, Y, ISR, OSR, PC (all 0-31) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dist should be dest (for destination), and lowercase for the options
docs/library/rp2.rst
Outdated
see sec 3.4.8 of RPi docs for details | ||
|
||
set(dest, data) | ||
dest : X, Y, PINS, PINDIRS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lowercase
docs/library/rp2.rst
Outdated
* irq(block, rel(index)) | ||
* irq(clear, rel(index)) | ||
* irq(block | clear, index) | ||
* irq(block | clear, rel(index)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either keep this set of possible ways of writing it, or the below set of 2 forms, but not both
docs/rp2/pio.rst
Outdated
help of jmp, go to the code part which has label as 'delay high' for the | ||
instruction offset. The next part of the code teaches us to turn the LED off | ||
by turning the LED off with the help of set instruction. Here the label is | ||
'delay_low' for the instruction offset part of the jmp instruction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to put the code for blink_1hz here in the docs so readers can easily see what is going on
docs/rp2/pio.rst
Outdated
@@ -0,0 +1,59 @@ | |||
.. _rp2_pio: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename this file to docs/rp2/tutorial/pio.rst
data : value (0-31) | ||
see sec 3.4.10 of RPi docs for details | ||
|
||
irq(mod, index = None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of this line, I'd suggest breaking this instruction into 2 parts:
irq(index)
index: <integer> or rel(<integer>)
irq(mode, index)
mode: block, clear, block|clear
index: <integer> or rel(<integer>)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or it might be clearer to just write out all 7 possible options explicitly, as done below
docs/library/rp2.rst
Outdated
language which is later used in a MicroPython program to perform specific | ||
tasks. These instructions are - | ||
|
||
jmp(cond, lebel=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jmp(label)
label: label to jump to unconditionally
jmp(cond, label)
cond: not_x, x_dec, not_y, y_dec, x_not_y, pin, not_osre
label: label to jump to if condition is true
docs/library/rp2.rst
Outdated
data : bit count(0-31) | ||
see sec 3.4.5 of RPi docs for details | ||
|
||
push(value = 0, value = 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
push()
push(block)
push(noblock)
push(iffull)
push(iffull, block)
push(iffull, noblock)
Also include There are also "meta instructions":
Then also
You can apply side or delay or both or neither. |
for PIO assembly language instructions
docs/rp2/tutorial/pio.rst
Outdated
any other process. However, PIO allows it to carry on with the bit banging | ||
process while the processor resources are used for executing some other work. | ||
|
||
Along with the two main cotex - MO+ processing cores, RP2040 has two PIO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sp: cortex
docs/rp2/tutorial/pio.rst
Outdated
process data in FIFO (First-In-First-Out) format. When these state machines | ||
are free, they will put in data from the queue and execute the instruction. | ||
This way, the PIO state machines and the main process works simultaneously | ||
without being much dependant on the other. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sp: dependent
The 4 directives that MicroPython supports are: |
Check commit message formatting / build (pull_request) Failing after 6s — build Our old friend:
rears it's head again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found some typos
@dpgeorge /home/runner/work/micropython/micropython/docs/rp2/tutorial/pio.rst: WARNING: document isn't included in any toctree I tried copying the ESP8266 file structure as suggested for the ESP32 but it didn't work out as desired. It will be great if you can tell me how I should include this index file. |
For now you have So I would suggest you create That should fix your warning and also include |
This was merged in baa5a76, with some improvements. |
…n-main Translations update from Hosted Weblate
1st draft for PIO module- brief overview with explanation of each command