Getting Started With RPi Pico Using C
Getting Started With RPi Pico Using C
The Raspberry Pi Pico series is a range of tiny, fast, and versatile boards built using RP2040,
the flagship microcontroller chip designed by Raspberry Pi in the UK.
• Dual-core Arm Cortex M0+ processor, flexible clock running up to 133 MHz
• 264kB of SRAM, and 2MB of on-board flash memory
• 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(General Purpose input-output) pins
• 2 × SPI(Serial Peripheral Interface), 2 × I2C(inter integragted Circuits), 2 × UART(Universal
Asynchronous Receiver/Transmitter), 3 × 12-bit ADC, 16 × controllable PWM channels
• 8 × Programmable I/O (PIO) state machines for custom peripheral support
Overview
Pinout
Getting Started
RPi Pico C/C++ SDK Documentation
1. Setup
To start working with the microcontroller, we can use
One Click Installer (Setup Video step by Step)(Recommended)
OR
manually configure each component needed for this (refer section 4 of this document).
To re-open the examples repository later, you can open the copy installed at
(default)`C:\Users\<user>\Documents\Pico-<version>\pico-examples`.
int main() {
const uint LED_PIN = 25;
//const uint LED_PIN = PICO_DEFAULT_LED_PIN;
gpio_init(LED_PIN);
gpio_set_dir(LED_PIN, GPIO_OUT);
while (true) {
gpio_put(LED_PIN, 1);
sleep_ms(200);
gpio_put(LED_PIN, 0);
sleep_ms(200);
gpio_put(LED_PIN, 1);
sleep_ms(500);
gpio_put(LED_PIN, 0);
sleep_ms(500);
}
• Open “Pico – VS Code” from Start Menu(not VSCode directly) and Goto->File->Open
Folder->(Your Project{Blink}) folder.
• If asked about selecting a kit, select “Pico ARM GCC”
• Press Ctrl+Shift+P to open command pallete in VSCode, Type CMake:Configure, let it
complete. It’ll generate a build directory.
• Press Ctrl+Shift+P to open command pallete in VSCode, Type CMake:Build, this will
generate map/bin/hex/uf2 files in build directory.
• The uf2 file generate is to be uploaded in Pico to dump code. For that, press boot
switch of pico and insert power cable to PC. It’ll get detected as flash drive, we need
to paste blink.uf2 file there and Pico will restart automatically and onboard LED will
blink.
Following are the component that needed to be configured separately, if One Click Installer is not
working.
For manually installing you can refer section 9.2.2(Alternative Manual Installation) of this or
follow this article.
5. Extra materials
1. https://github.com/raspberrypi/pico-examples
2. https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf
3. https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf
4. https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf
5. https://datasheets.raspberrypi.com/pico/pico-datasheet.pdf
6. https://datasheets.raspberrypi.com/pico/pico-product-brief.pdf
7. https://datasheets.raspberrypi.com/picow/pico-w-datasheet.pdf
8. https://datasheets.raspberrypi.com/picow/pico-w-product-brief.pdf