Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
raspberrypipico:raspberrypipico [2021/03/11 18:55] admin [Programmable I/O] |
raspberrypipico:raspberrypipico [2021/05/28 09:51] admin [WS2812] |
||
---|---|---|---|
Line 6: | Line 6: | ||
==== Pinout ==== | ==== Pinout ==== | ||
{{: | {{: | ||
+ | // schematic from [[https:// | ||
On ADC 04 is a temperature sensor.\\ | On ADC 04 is a temperature sensor.\\ | ||
Line 15: | Line 16: | ||
[[https:// | [[https:// | ||
- | Plug in the RP Pico with pressed BOOTESL button | + | |
- | Download | + | Plug in the RP Pico with pressed BOOTESL button.\\ |
- | wget " | + | Download the [[https:// |
+ | wget " | ||
Copy it to the RP Pico | Copy it to the RP Pico | ||
Line 68: | Line 70: | ||
More sound with [[https:// | More sound with [[https:// | ||
+ | |||
+ | ---- | ||
+ | ==== Power ==== | ||
+ | |||
+ | VBUS – USB power, 5V | ||
+ | VSYS – power in (2-5V) | ||
+ | 3V3 – power out 3.3V, 300mA | ||
+ | | ||
+ | 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 | ||
+ | GP28 - ADC2 | ||
+ | AGND (analog ground) | ||
+ | GP27 - ADC1 | ||
+ | GP27 - ADC0 | ||
+ | The fourth ADC is internally wired to a temperature sensor.\\ | ||
+ | [[https:// | ||
---- | ---- | ||
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, | + | ---- |
- | from machine import Pin | + | ==== Links & Projects ==== |
- | import utime | + | |
- | + | ||
- | led_onboard | + | |
- | 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, | + | |
- | + | ||
- | 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**\\ |
- | | + | [[https:// |
- | | + | |
- | | + | |
- | | + | |
- | * 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, | + | |
- | * wait – Pauses until a defined action happens | + | |
- | * label(" | + | |
- | ==Some more Instructions== | + | |
- | - nop () [] - no operations, delays 0 to 31 circles\\ | + | |
- | - wrap_target() and wrap () - resets program counter and starts over again\\ | + | |
- | - lable() | + | |
- | - jmp () - jumps conditions: | + | |
- | _ jump if zero: jmp(not_x, " | + | |
- | _ shift the register, jump if zero: jmp(not_osre, | + | |
- | _ decrements, jump if zero: jmp(x_dec," | + | |
- | + | **Usb Micro**\\ | |
- | See [[https:// | + | [[https:// |
- | + | ||
- | [[https:// | + | |
- | + | ||
- | ---- | + | |
- | ==== WS2812 ==== | + | |
- | + | ||
- | [[https:// | + | |
---- | ---- |