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
raspberrypipico:raspberrypipico [2021/03/11 18:51]
admin [Programmable I/O]
raspberrypipico:raspberrypipico [2021/06/07 18:07] (current)
admin [Links & Projects]
Line 6: Line 6:
 ==== Pinout ==== ==== Pinout ====
 {{:raspberrypipico:pico-r3-sdk11-pinout.jpg?600|}}\\ {{:raspberrypipico:pico-r3-sdk11-pinout.jpg?600|}}\\
 +// schematic from [[https://www.raspberrypi.org/documentation/rp2040/getting-started/#board-specifications|raspberrypi.org]]//\\
  
 On ADC 04 is a temperature sensor.\\ On ADC 04 is a temperature sensor.\\
Line 15: Line 16:
 [[https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-python-sdk.pdf|Raspberry Pi Pico Python SDK]]\\ [[https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-python-sdk.pdf|Raspberry Pi Pico Python SDK]]\\
  
-Plug in the RP Pico with pressed BOOTESL button + 
-Download Micro Python for the RP Pico: +Plug in the RP Pico with pressed BOOTESL button.\\ 
-  wget "https://www.raspberrypi.org/documentation/rp2040/getting-started/static/f70cc2e37832cde5a107f6f2af06b4bc/rp2-pico-20210205-unstable-v1.14-8-g1f800cac3.uf2"+Download the [[https://micropython.org/download/rp2-pico/|Pico Firmware]]:\\ 
 +  wget "https://micropython.org/resources/firmware/rp2-pico-20210510-unstable-v1.15-89-gd0de16266.uf2"
 Copy it to the RP Pico Copy it to the RP Pico
  
Line 68: Line 70:
  
 More sound with [[https://github.com/benevpi/pico_pio_buzz|PicoBuzz]] by benevpi.\\ More sound with [[https://github.com/benevpi/pico_pio_buzz|PicoBuzz]] by benevpi.\\
 +
 +----
 +==== Power ====
 +
 +   VBUS – USB power, 5V
 +   VSYS – power in (2-5V)
 +   3V3 – power out 3.3V, 300mA
 +   3V3_EN – disable internal voltage regulator
 +   RUN – enable, disable or reset
  
 ---- ----
Line 76: Line 87:
 one can change the duty cycle, 0 to 65535 one can change the duty cycle, 0 to 65535
   pwm.duty_u16(duty)   pwm.duty_u16(duty)
 +
 +----
 +==== ADC ====
 +The Raspberry Pi Pico has four 12bit analog to digital converter:
 +  ADC_VREF    (voltage reference)
 +  GP28 - ADC2
 +  AGND        (analog ground)
 +  GP27 - ADC1
 +  GP27 - ADC0
 +The fourth ADC is internally wired to a temperature sensor.\\
 +[[https://pico-adc.markomo.me/|Characterizing the Raspberry Pi Pico ADC]] by Mark Omo.\\
  
 ---- ----
Line 106: Line 128:
 ---- ----
 ==== Programmable I/O ==== ==== Programmable I/O ====
-The RP Pico has eight state machines (0-7) including these parameters:\\ +[[raspberrypipico:pico_pio|Programmable I/O]]\\
-- state machine number\\ +
-- PIO program\\ +
-- frequency (between 2000 and 125000000)\\ +
-- GPIO pin\\ +
-These mini programs run on the PIO state machines and run continuously.\\+
  
-  from rp2 import PIO, StateMachine, asm_pio +---- 
-  from machine import Pin +==== Links & Projects ====
-  import utime +
-   +
-  led_onboard machine.Pin(25, machine.Pin.OUT) +
-  led_onboard.value(1) +
-  utime.sleep(2) +
-  led_onboard.value(0) +
-   +
-  @asm_pio(set_init=PIO.OUT_LOW) +
-  def faint_led(): +
-    set(pins, 0) [20] +
-    set(pins, 1) +
-   +
-  sm1 StateMachine(1, faint_led, freq=10000, set_base=Pin(25)) +
-   +
-  while(True): +
-    sm1.active(1) +
-    utime.sleep(1) +
-    sm1.active(0) +
-    utime.sleep(1)+
  
-The commands set(pins, 0) and set(pins, 1) turns the GPIO pin on and off.\\ 
-In square brackets are numbers between 1 and 31 to pause this clock cycles\\ 
-The @asm_pio descriptor above the function takes the set_init parameters.\\ 
-To start and stop the state machine use the active method (1 or 0)\\ 
  
-==The Nine State Machine Instructions== +**WS2812**\\ 
-  in – Shifts 1 word of 32 bits at a time into the ISR from another location +[[https://makersportal.com/blog/ws2812-ring-light-with-raspberry-pi-pico]]\\
-  out – Shifts 1 word of 32 bits from the OSR to another location +
-  push – Sends data to the RX (input) FIFO +
-  pull() – gets data from the TX (output),e.g. sm1.put(1234) +
-  * mov() – moves data x or y in register, e.g. mov(y, osr) osr=output shift register +
-  * irq – Sets or clears interrupt flag +
-  * set() [] – Writes data to destination, 0=off, 1=on, delays 0 to 31 circles +
-  * wait – Pauses until a defined action happens +
-  * label("mylabel") and jmp (condition,"label") – Jumps to a different point in the code +
-==Some more Instructions== +
-- nop () [no operations, delays 0 to 31 circles\\ +
-wrap_target() and wrap () resets program counter and starts over again\\ +
-lable() sts a lable label("end")\\ +
-jmp () - jumps conditions:\\ +
-- _ empty: jmp(not_x, "end")\\ +
-- _ shift the register: jmp(not_osre, "lable1")\\ +
-- _ decrements jmp(x_dec,"label2")\\+
  
 +**Usb Micro**\\
 +[[https://www.hackster.io/sandeep-mistry/create-a-usb-microphone-with-the-raspberry-pi-pico-cc9bd5]]\\
  
-See [[https://datasheets.raspberrypi.org/rp2040/rp2040-datasheet.pdf|RP2040 Datasheet]], Chapter 30, page 330 following\\+---- 
 +==== License ====
  
-[[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]]\\+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> 
-==== WS2812 ==== +<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>
-[[https://makersportal.com/blog/ws2812-ring-light-with-raspberry-pi-pico]]\\+
  
 ---- ----