Raspberry Pi Pico | RP2040 Introduction | PINOUT | Lighting Example

1. Introduction to Pico:

RP2040 is the first microcontroller for Raspberry Pi. It brings our hallmark values ​​of high performance, low cost and ease of use to the microcontroller world.
With large on-chip memory, symmetric dual-core processor complex, deterministic bus structure and rich peripheral set, and our unique programmable I/O (PIO) subsystem, it provides professional users with unmatched power and flexibility sex. With detailed documentation, a well-established MicroPython port, and a UF2 bootloader in ROM, it has the lowest possible barrier to entry for beginners and hobbyist users.
The RP2040 is a stateless device that supports in-place execution from an external QSPI memory cache. This design decision allows you to select the appropriate density of nonvolatile storage for your application and benefit from the low price of commodity flash devices.
Manufactured on a modern 40nm process node, the RP2040 offers high performance, low dynamic power consumption, and low leakage, with multiple low-power modes to support long battery-powered operation.

Key features: Key features:
• Dual ARM Cortex-M0+ @ 133MHz
Dual ARM Cortex-M0+ @ 133MHz
• 264kB on-chip SRAM in six independent banks

Support for up to 16MB of off -chip Flash memory via dedicated QSPI bus
supports up to 16MB off-chip flash memory via dedicated QSPI bus
. DMA controller DMA controller
. Fully-connected AHB crossbar.
Fully-connected AHB crossbar . Interpolator and integer
divider peripherals
Design
• On-chip programmable LDO to generate core voltage On -chip
programmable LDO to generate core voltage
• 2 on-chip PLLs to generate USB and core clocks
2 on-chip PLLs for generating USB and core clocks
• 30 GPIO pins, 4 of which can be used as analog inputs
30 GPIO pins, 4 of which can be used as analog inputs
Peripherals
o 2 UARTs 2 UART
o 2 SPI controllers 2 SPI controllers
o 2 I2C controllers 2 I2C controllers
o 16 PWM channels 16 PWM channels
o USB 1.1 controller and PHY, with host and device support
USB 1.1 controller and PHY, Support host and device
o 8 PIO state machines
Why
is the chip called RP2040?
Why is the chip called RP2040?
The post-fix numeral on RP2040 comes from the following
,
insert image description here

  1. Number of processor cores (2
    )
  2. Loosely which type of processor (M0+)
    loosely selects which type of processor (M0+)
  3. floor(log2(ram / 16k)) floor(log2(ram / 16k))
  4. floor(log2(nonvolatile / 16k)) or 0 if no onboard nonvolatile storage
    floor(log2(nonvolatile / 16k)) or 0 (if no onboard nonvolatile storage)

Second, several important git warehouses:

根仓库:https://github.com/raspberrypi/
git clone https://github.com/raspberrypi/pico-sdk.git
git clone https://github.com/raspberrypi/pico-examples.git
git clone https://github.com/raspberrypi/pico-micropython-examples.git

3. Must read before use:

After the USB cable is connected to the computer, the Pico motherboard will not have any indicator light on, and it will not turn on after installing the firmware. The light can only be executed through the program. In addition, Pico has high requirements for the data cable. Some data cables cannot be recognized. If your computer cannot detect it, please replace the data cable. Please read carefully and follow the steps below.

4. PINOUT

insert image description here

Fifth, lighting

1. How to install the firmware

Step 1: Press and hold the BOOTSEL button on the board first, then connect the Raspberry Pi Pico to the computer with a USB cable, and release the button after 3 seconds. (Refer to the picture below, PS: 1 press -2 plug in -3 release). At this time, the computer will recognize a storage device disk named: RPI-RI2
(Problem: Pico will not be recognized due to the difference in the data cable, if your computer fails to recognize the device, please replace the data cable to try. )
Firmware download address:
https://www.raspberrypi.com/documentation/microcontrollers/micropython.html#what-is-micropython
insert image description here
The current file is: rp2-pico-20230426-v1.20.0.uf2.

2. Install Thonny programming environment configuration

1. Download URL: https://thonny.org/, click the windows version to download.
insert image description here

This installation is: thonny-4.1.1 version.
2. The interface after the installation is complete:
Click here: Run—Configure Interpreter—Select Micro Python (Raspiberry Pi Pico)
insert image description here
insert image description here
to switch to professional mode, and display the top menu:
insert image description here

Restart Thonny and switch to professional mode. Adjust the view settings as desired, natively selected:
insert image description here

3. Light up the onboard LED lights

1. Input or copy and paste the following test program code in the code editing area of ​​the Thonny software window (as shown below)

The code for Pico to light up the onboard LED light:

from machine import Pin
from utime import sleep
import utime

led = Pin(25, Pin.OUT)

if __name__ == '__main__':
    while True:
        # led点亮
        led.value(1)
        utime.sleep_ms(1000)
        # led熄灭
        led.value(0)
        utime.sleep_ms(1000)

The code for PicoW to light up the onboard LED light:

import machine
import utime

led = machine.Pin("LED", machine.Pin.OUT)
while True:
    led.on()
    utime.sleep(1)
    led.off()
utime.sleep(1)

Click Run — and you'll see the Pico's onboard LED blink.
insert image description here

If you want to save the program, you can choose the save location:
insert image description here
save it as main.py, and it will run automatically after power-on. Running and stopping can also be controlled in software.
insert image description here

Guess you like

Origin blog.csdn.net/Medlar_CN/article/details/131368289