Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
raspberrypipico:pico_pio [2021/03/13 19:28]
admin
raspberrypipico:pico_pio [2021/06/07 18:05]
admin [Knowledge]
Line 51: Line 51:
 **frequency** the frequency of the state machine, should be between 1000 and 125000000\\ **frequency** the frequency of the state machine, should be between 1000 and 125000000\\
  
-**GPIO pin** depending on the first on all following pins will be mapped (up to 32)\\+**GPIO pin** depending on the first one, all following pins will be mapped (up to 32)\\
 INPUT: in_base (sets input pins) INPUT: in_base (sets input pins)
    sm = StateMachine(0, do_something, freq=1000, in_base=pin10)    sm = StateMachine(0, do_something, freq=1000, in_base=pin10)
Line 152: Line 152:
    wait(0, pin, 0)    wait(0, pin, 0)
  
-====wait()====+====wait(option)====
 **wait(//polarity//, gpio, //num//)**\\ **wait(//polarity//, gpio, //num//)**\\
 It will waits until the specified GPIO has the specified polarity.\\ It will waits until the specified GPIO has the specified polarity.\\
Line 161: Line 161:
 It does the same like before, but it uses the pin mapping.\\ It does the same like before, but it uses the pin mapping.\\
    wait(1, pin, 0)    wait(1, pin, 0)
-**wait (//polarity//, irq, //num(rel)//)\\**+**wait (//polarity//, irq, //num(rel)//)**\\
 It will wait for an irg to be set.\\ It will wait for an irg to be set.\\
 - polarity (1 clears the interrupt flag, 0 won't)\\ - polarity (1 clears the interrupt flag, 0 won't)\\
-- num (number of interrupt, with rel the relative interrupt numbers could be used)\\  +- num (interrupt number, with rel the relative interrupt numbers could be used)\\  
  
 +   wait(1, irq, rel(0))
  
-====in(source, bitcount)====+====in(source, bits)====
 The IN instructor shifts data from the source into the input shift register (ISR).\\ The IN instructor shifts data from the source into the input shift register (ISR).\\
 **source:**\\ **source:**\\
Line 175: Line 176:
 - status (from special register could e.g. indicate FIFO empty or full)\\ - status (from special register could e.g. indicate FIFO empty or full)\\
 - osr (from output shift registers)\\ - osr (from output shift registers)\\
-**bitcount:**\\+**bits:**\\
 - 0-31 bits\\ - 0-31 bits\\
  
-====out(destination, bitcount)====+====out(destination, bits)====
 The OUT instructor shifts data from the output shift register (OSR) to the destination.\\ The OUT instructor shifts data from the output shift register (OSR) to the destination.\\
 **destination:**\\ **destination:**\\
Line 188: Line 189:
 - pc (shifts an instruction into the program counter)\\   - pc (shifts an instruction into the program counter)\\  
 - isr (into the input shift registers)\\ - isr (into the input shift registers)\\
-**bitcount:**\\+**bits:**\\
 - 0-31 bits\\ - 0-31 bits\\
  
Line 234: Line 235:
   mov(osr, x) #copy the x scratch register to the output shift register    mov(osr, x) #copy the x scratch register to the output shift register 
  
-====irq(option, irq_num, rel)====+====irq(option, num(rel))====
 The IRQ instruction sets or clears an interrupt flag.\\ The IRQ instruction sets or clears an interrupt flag.\\
 **option**\\ **option**\\
Line 240: Line 241:
 - wait (wait until the flag is zero before setting it)\\ - wait (wait until the flag is zero before setting it)\\
 - clear (clears the flag)\\ - clear (clears the flag)\\
-**irq_num**number of the interrupt 0-7\\ +**num** number of the interrupt 0-7\\ 
-**rel** relative IRQ number, can set different IRQ per StateMachine, ([1:0]+sm_number)%4 \\+**rel** relative IRQ number\\
 In the StateMachine In the StateMachine
    irq(block, rel(0))    irq(block, rel(0))
Line 278: Line 279:
    set(pins, 1) [31] #drive first mapped pin high and delay 31 cycles    set(pins, 1) [31] #drive first mapped pin high and delay 31 cycles
 ====nop()==== ====nop()====
-The NOP instruction stands for no operations. It can delays to 31 cycles.\\ +The NOP instruction stands for no operations. In combination with the delay function one can create delays between 1 to 31 cycles.\\ 
-   nop (31   #delay 31 cycles+   nop () [31]   #delay 31 cycles
  
 ====wrap()==== ====wrap()====
Line 324: Line 325:
  
 ---- ----
-===== Simple Audio Out===== 
  
-   GPIO03----4k--- 
-                  | 
-   GPIO04----2k---- 
-                  |------ Audio Out 
-   GPIO05----1k---- 
-                  | 
-   GPIO06----500--- 
  
----- 
-==== Resistor DAC ==== 
- 
- 
----- 
 ===== Knowledge ===== ===== Knowledge =====
 [[https://www.youtube.com/watch?v=yYnQYF_Xa8g|In-depth: Raspberry Pi Pico's PIO - programmable I/O!]] by stacksmashing\\ [[https://www.youtube.com/watch?v=yYnQYF_Xa8g|In-depth: Raspberry Pi Pico's PIO - programmable I/O!]] by stacksmashing\\
Line 347: Line 335:
  
 [[https://www.seeedstudio.com/blog/2021/01/25/programmable-io-with-raspberry-pi-pico/|Seeedstudio: Programmable I/O with Raspberry Pi Pico by Jonathan Tan]]\\ [[https://www.seeedstudio.com/blog/2021/01/25/programmable-io-with-raspberry-pi-pico/|Seeedstudio: Programmable I/O with Raspberry Pi Pico by Jonathan Tan]]\\
 +
 +----
 +==== License ====
 +
 +This manuals is made by **Wolfgang Spahn** 2021.\\
 +Except where otherwise noted, content on this wiki is licensed under the following license: [[http://creativecommons.org/licenses/by-nc-sa/4.0/"|Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License]].\\
 +
 +<html>
 +<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a> 
 +</html>
  
 ---- ----