RASPBERRY PI PICO 树莓派PICO开发板双核高性能低功耗RP2040芯片

举报
tsinghuazhuoqing 发表于 2021/12/26 23:23:02 2021/12/26
【摘要】   ▌01 RASPBERRY PICO 1.简介 RaspBerry Pi Pico是一款低价格、高性能的微控制器电路板,具有丰富灵活的数字接口,主要特点包括有: RP2040...

 

01 RASPBERRY PICO


1.简介

RaspBerry Pi Pico是一款低价格、高性能的微控制器电路板,具有丰富灵活的数字接口,主要特点包括有:

  • RP2040 microcontroller chip designed by Raspberry Pi in the United Kingdom
  • Dual-core Arm Cortex M0+ processor, flexible clock running up to 133 MHz
  • 264KB of SRAM, and 2MB of on-board Flash memory
  • Castellated module allows soldering direct to carrier boards
  • USB 1.1 with device and host support
  • Low-power sleep and dormant modes
  • Drag-and-drop programming using mass storage over USB
  • 26 × multi-function GPIO pins
  • 2 × SPI, 2 × I2C, 2 × UART, 3 × 12-bit ADC, 16 × controllable PWM channels
  • Accurate clock and timer on-chip
  • Temperature sensor
  • Accelerated floating-point libraries on-chip
  • 8 × Programmable I/O (PIO) state machines for custom peripheral support

▲ 管脚定义

▲ 管脚定义

▲ 不同种类管脚定义对应的颜色

▲ 不同种类管脚定义对应的颜色

  • 相关资料链接:
  1. RP2040 DataSheet
  2. Raspberry Pi Pico 数据手册
  3. Pico Python SDK

▲ PI PICO 电路图

▲ PI PICO 电路图

2.实验电路板

今天刚刚从 RASPBERRY淘宝购买(¥:44.99)的 RP2040刚刚到货了。

两个购买的连接:

▲ 购买到的RP2040

▲ 购买到的RP2040

相关的资料可以在 RaspBerry PI PICO官方网站 寻找。

 

02 初步测试


1.焊接排针

▲ 焊接排针之后的PICO

▲ 焊接排针之后的PICO

焊接之后,使用USB电缆连接到电脑,会出现一个名字为:RPI-RP2磁盘号码。其中包括有:

其中包括有两个文件:
F:\INDEX.HTM
F:\INFO_UF2.TXT

2.初步使用PICO

根据 Getting started with MicroPython 中的的Drag and Drop MicroPython的操作步骤,将下载 Download UF2 Filepico_micropython_20210121.uf2拷贝到RPI-RP2磁盘,对于PI PICO进行处世王MicroPython解释器。

RPII-RP2磁盘消失。不过计算器出现了一个初始化错误的USB设备:

▲ 下载UF2之后,设备出现了一个USB其它设备

▲ 下载UF2之后,设备出现了一个USB其它设备

3.供PICO 5V电源

根据PICO数据手册介绍,VSYS是供给电路板5V电源的引脚。按照下面连接方式在面包板上给PICO施加5V电源。

▲ 供电示意图

▲ 供电示意图

错误:在一开始的时候,给PICO出现正负极性相反。在限流DC+5V作用下,供电电流别限制在1A的幅值。

▲ 面包板上给PICO供电

▲ 面包板上给PICO供电

  • 静态电路板工作电流: 16.5mA。
  • 3V3 OUT(PIN36) : 3.258V
  • RUN(PIN30):3.3V
  • TX(PIN1) :0V 奇诡
  • RX(PIN2) : 0V 奇诡

注意: 既然已经初始化成立MicroPython工作的状态,为什么TX0,RX0初始化后的电压为0V?*

4.测试TX,RX

利用STM32的下载传宝连接PICO的 UART0的TX(PIN1),RX(PIN2)测试它对于外部发送的信号的相应。

▲ 测试串口

▲ 测试串口

在PICO上电过程中在TX没有测量到任何字符输出。

 

03 安装Board CDC 驱动


1.下载MicroPytho Firmware

MicroPython 网站下载 Firmware for Raspberry PI Pico 最新的UF2。根据前面的操作方式,按住BOOTSEL按键将RASPBERRY接入PC的USB(Mini-USB)。将下载的Firmware拷贝进入出现的新的U盘内。系统重新启动,出现新的设备。

但是在Win7下,CDC无法自动安装驱动。根据 树莓派 PI Pico 安装 MicroPython 后会出现 Board CDC 未知设备 的说法:

树莓派 PI Pico 安装 MicroPython 后会出现 Board CDC 未知设备的解决办法
https://files.cnblogs.com/files/czcbzc/Board_CDC_RP2_pico-serial.zip
然后在设备管理器中手动安装
自动安装不了

▲ 其它设备:Board CDC

▲ 其它设备:Board CDC

https://files.cnblogs.com/files/czcbzc/Board_CDC_RP2_pico-serial.zip下载: Board CDC Driver

▲ 安装驱动之后

▲ 安装驱动之后

2.测试串口

使用STM32Bootload界面测量Pi Pico Serial Port。但是并没有接收到任何对应的反馈响应信息。

3.使用Python测试

使用Python直接对串口进行操作,可以得到对应的结果。

#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# TEST1.PY                     -- by Dr. ZhuoQing 2021-02-24
#
# Note:
#============================================================

from head import *
import serial
from _ast import Or
from serial.serialutil import SerialException

#------------------------------------------------------------
sport = serial.Serial()
sport.baudrate = 115200
sport.timeout = 0.05
try:
    sport.port = 'COM6'
except:
    printf('Set sport port COM6 error. ')

try:
    sport.open()
except serial.serialutil.SerialException:
    printf('Open sport port COM6 error.')
else:
    printf('Open sport port COM6 Ok.')
#------------------------------------------------------------

sport.write(b"2**3\r\r\r")

printf(sport.read(100).decode('utf-8'))

#------------------------------------------------------------
#        END OF FILE : TEST1.PY
#============================================================

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37

输出结果:

Open sport port COM6 Ok.
2**3
8
>>> 
>>> 
>>> 

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

输入“help()”最终输出内容:


help()
Welcome to MicroPython!

For online help please visit https://micropython.org/help/.

For access to the hardware use the 'machine' module.  RP2 specific commands
are in the 'rp2' module.

Quick overview of some objects:
  machine.Pin(pin) -- get a pin, eg machine.Pin(0)
  machine.Pin(pin, m, [p]) -- get a pin and configure it for IO mode m, pull mode p
    methods: init(..), value([v]), high(), low(), irq(handler)
  machine.ADC(pin) -- make an analog object from a pin
    methods: read_u16()
  machine.PWM(pin) -- make a PWM object from a pin
    methods: deinit(), freq([f]), duty_u16([d]), duty_ns([d])
  machine.I2C(id) -- create an I2C object (id=0,1)
    methods: readfrom(addr, buf, stop=True), writeto(addr, buf, stop=True)
             readfrom_mem(addr, memaddr, arg), writeto_mem(addr, memaddr, arg)
  machine.SPI(id, baudrate=1000000) -- create an SPI object (id=0,1)
    methods: read(nbytes, write=0x00), write(buf), write_readinto(wr_buf, rd_buf)
  machine.Timer(freq, callback) -- create a software timer object
    eg: machine.Timer(freq=1, callback=lambda t:print(t))

Pins are numbered 0-29, and 26-29 have ADC capabilities
Pin IO modes are: Pin.IN, Pin.OUT, Pin.ALT
Pin pull modes are: Pin.PULL_UP, Pin.PULL_DOWN

Useful control commands:
  CTRL-C -- interrupt a running program
  CTRL-D -- on a blank line, do a soft reset of the board
  CTRL-E -- on a blank line, enter paste mode

For further help on a specific object, type help(obj)
For a list of available modules, type help('modules')
>>> 

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37

4.闪烁LED(PIN25)

sport.write(b"from machine import Pin\r")
sport.write(b"led = Pin(25, Pin.OUT)\r")

for i in range(100):
    sport.write(b"led.value(1)\r")
    time.sleep(.5)
    sport.write(b"led.value(0)\r")
    time.sleep(.5)

printf(sport.read(10000).decode('utf-8'))

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

▲ 闪烁PIN25

▲ 闪烁PIN25

5.上载完整程序

上载一个执行程序,需要将前面运行的程序中断,然后输入程序,最后执行。

下面给出了对应的过程:

#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# TEST1.PY                     -- by Dr. ZhuoQing 2021-02-24
#
# Note:
#============================================================

from head import *
import serial
from _ast import Or
from serial.serialutil import SerialException

#------------------------------------------------------------
sport = serial.Serial()
sport.baudrate = 115200
sport.timeout = 0.05
try:
    sport.port = 'COM6'
except:
    printf('Set sport port COM6 error. ')

try:
    sport.open()
except serial.serialutil.SerialException:
    printf('Open sport port COM6 error.')
else:
    printf('Open sport port COM6 Ok.')
#------------------------------------------------------------
sport.write(b'\x04')

sport.write(b"from machine import Pin, Timer\r")
sport.write(b"led = Pin(25, Pin.OUT)\r")
sport.write(b"tim = Timer()\r")
sport.write(b"def tick(timer):\r")
sport.write(b"global led\r")
sport.write(b"led.toggle()\r")

sport.write(b"\r")
sport.write(b"\r")
sport.write(b"\r")

sport.write(b"tim.init(freq=10, mode=Timer.PERIODIC, callback=tick)\r")

printf(sport.read(10000).decode('utf-8'))

#------------------------------------------------------------
#        END OF FILE : TEST1.PY
#============================================================

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49

程序执行后的结果返回:

Open sport port COM6 Ok.

MPY: soft reboot
MicroPython v1.14 on 2021-02-24; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>> from machine import Pin, Timer
>>> led = Pin(25, Pin.OUT)
>>> tim = Timer()
>>> def tick(timer):
...     global led
...     led.toggle()
...     
...     
... 
>>> tim.init(freq=10, mode=Timer.PERIODIC, callback=tick)
>>> 

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

 

▌结论


对于刚刚到货的Raspberry PI Pico 电路板焊接相关外接的引脚,并通过Micro USB 线缆对于电路板初始化成对应的MicroPython状态。

通过实验发现遇到了两个问题:
1) USB对应的CDC出现了初始化错误:这部分通过 第3部分,下载对应的Board-CDC驱动解决了。
2)电路板初始化对应的串口输出电平是低电平,说明电路板实际上并没有工作在MicroPython的 REPL状态。这部分根据手册给出,说明内核需要重新进行编译之后才能够将REPL落实在对应的串口上。

此时,这两个电路板还无法进行相应的实验。

■ 相关文献链接:

文章来源: zhuoqing.blog.csdn.net,作者:卓晴,版权归原作者所有,如需转载,请联系作者。

原文链接:zhuoqing.blog.csdn.net/article/details/113185532

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。