Cytron Maker Pi RP2040

Overview

The Cytron Maker Pi RP2040 [1] board is based on the RP2040 microcontroller from Raspberry Pi Ltd. The board has motor drivers, servo headers, Grove connectors and a micro USB connector.

Hardware

  • Microcontroller Raspberry Pi RP2040, with a max frequency of 133 MHz

  • Dual ARM Cortex M0+ cores

  • 264 kByte SRAM

  • 2 Mbyte QSPI flash

  • 17 GPIO pins

  • 3 ADC pins

  • Supply voltage measurement

  • I2C

  • UART

  • Micro USB connector

  • LiPo charger

  • Reset, boot and 2 user buttons

  • 2 RGB LEDs (Neopixels)

  • Piezo buzzer with mute switch

  • 4 servo ports

  • 2 Motor drivers, with 4 manual test buttons

  • 7 Grove connectors, of which one can be used as a Maker/Qwiic/Stemma QT/zephyr_i2c connector

  • 13 status indicators for digital pins

Default Zephyr Peripheral Mapping

Description

Pin

Default pin mux

Zephyr PWM name

RGB LEDs

GPIO18

PIO0

Buzzer

GPIO22

PWM3A

6

Button 1

GPIO20

(Alias sw0)

Button 2

GPIO21

(Alias sw1)

Voltage sense

GPIO29

ADC3, voltage divider

Servo header:

Label

Pin

Default pin mux

Zephyr PWM name

GP12

GPIO12

PWM6A

12

GP13

GPIO13

PWM6B

13

GP14

GPIO14

PWM7A

14

GP15

GPIO15

PWM7B

15

Motor drivers:

Label

Pin

Default pin mux

Zephyr PWM name

M1A

GPIO8

PWM4A

8

M1B

GPIO9

PWM4B

9

M2A

GPIO10

PWM5A

10

M2B

GPIO11

PWM5B

11

Grove connector 1:

Label

Pin

Default pin mux

GP0

GPIO0

UART0 TX

GP1

GPIO1

UART0 RX

Grove connector 2:

Use an adapter cable to connect Qwiic/Stemma QT sensors (that use I2C) to this connector, which is mapped to the zephyr_i2c devicetree node label.

Label

Pin

Default pin mux

GP2

GPIO2

I2C1 SDA

GP3

GPIO3

I2C1 SCL

Grove connector 3:

Label

Pin

Notes

GP4

GPIO4

Alias led0

GP5

GPIO5

Alias led1

Grove connector 4:

Label

Pin

GP16

GPIO16

GP17

GPIO17

Grove connector 5:

Label

Pin

Default pin mux

Notes

GP6

GPIO6

GP26

GPIO26

ADC0

Also in Grove 6

Grove connector 6:

Label

Pin

Default pin mux

Notes

GP26

GPIO26

ADC0

Also in Grove 5

GP27

GPIO27

ADC1

Grove connector 7:

Label

Pin

Default pin mux

GP7

GPIO7

GP28

GPIO28

ADC2

See also schematic [2].

Supported Features

The maker_pi_rp2040 board supports the hardware features listed below.

on-chip / on-board
Feature integrated in the SoC / present on the board.
2 / 2
Number of instances that are enabled / disabled.
Click on the label to see the first instance of this feature in the board/SoC DTS files.
vnd,foo
Compatible string for the Devicetree binding matching the feature.
Click on the link to view the binding documentation.

Programming and Debugging

The maker_pi_rp2040 board supports the runners and associated west commands listed below.

flash debug

By default programming is done via the USB connector. Press and hold the BOOT button, and then press the RST button, and the device will appear as a USB mass storage unit. Building your application will result in a build/zephyr/zephyr.uf2 file. Drag and drop the file to the USB mass storage unit, and the board will be reprogrammed.

It is also possible to program and debug the board via the SWDIO and SWCLK pins in the DEBUG connector. You must solder a 3-pin header to the board in order to use this feature. A separate programming hardware tool is required, and for example the openocd software is used. Typically the OPENOCD and OPENOCD_DEFAULT_PATH values should be set when building, and the --runner openocd argument should be used when flashing. For more details on programming RP2040-based boards, see Programming and Debugging.

Flashing

To run the Blinky sample:

# From the root of the zephyr repository
west build -b maker_pi_rp2040 samples/basic/blinky/
west flash

Try also the LED strip, Hello World, Button, Input dump and Analog-to-Digital Converter (ADC) with devicetree samples.

The use of the Maker/Qwiic/Stemma QT I2C connector (Grove 2) is demonstrated using the Generic Light Sensor Polling sample and a separate shield:

# From the root of the zephyr repository
west build -b maker_pi_rp2040 --shield adafruit_veml7700 samples/sensor/light_polling
west flash

Use the shell to control the GPIO pins:

# From the root of the zephyr repository
west build -b maker_pi_rp2040 samples/sensor/sensor_shell -- -DCONFIG_GPIO=y -DCONFIG_GPIO_SHELL=y
west flash

To set one of the GPIO pins high, use these commands in the shell, and study the indicator LEDs:

gpio conf gpio0 16 o
gpio set gpio0 16 1

Servo motor control is done via PWM outputs. The Servomotor sample sets servo position timing (via an overlay file) for the output GP12:

# From the root of the zephyr repository
west build -b maker_pi_rp2040 samples/basic/servo_motor/
west flash

It is also possible to control servos via the pwm shell:

# From the root of the zephyr repository
west build -b maker_pi_rp2040 samples/sensor/sensor_shell -- -DCONFIG_PWM=y -DCONFIG_PWM_SHELL=y
west flash

Use shell commands to set the position of the servo. Most servo motors can handle pulse times between 800 and 2000 microseconds:

pwm usec pwm@40050000 12 20000 800
pwm usec pwm@40050000 12 20000 2000

To use the buzzer, you must turn on the buzzer switch on the short side of the board. Then build using the same command as above for the sensor_shell. Use these shell commands to turn on and off the buzzer:

pwm usec pwm@40050000 6 1000 500
pwm usec pwm@40050000 6 1000 0

You can also control the motor outputs via the shell. To set the speed of motor 1 to 100%, 50%, 20% and 0% respectively, use these commands:

pwm usec pwm@40050000 8 1000 1000
pwm usec pwm@40050000 8 1000 500
pwm usec pwm@40050000 8 1000 200
pwm usec pwm@40050000 8 1000 0

To run the motor in the opposite direction at 80%:

pwm usec pwm@40050000 9 1000 800

The sensor_shell sample is used also to measure the supply voltage. This is the result when running on a Vin voltage slightly less than 6 Volt:

sensor get vbatt
channel type=33(voltage) index=0 shift=3 num_samples=1 value=32688380776ns (5.977999)

References