EasyManua.ls Logo

Raspberry Pi Pico User Manual

Raspberry Pi Pico
77 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #31 background imageLoading...
Page #31 background image
Chapter 8. Creating your own Project
Go ahead and create a directory to house your test project sitting alongside the pico-sdk directory,
$ ls -la
total 16
drwxr-xr-x 7 aa staff 224 6 Apr 10:41 ./
drwx------@ 27 aa staff 864 6 Apr 10:41 ../
drwxr-xr-x 10 aa staff 320 6 Apr 09:29 pico-examples/
drwxr-xr-x 13 aa staff 416 6 Apr 09:22 pico-sdk/
$ mkdir test
$ cd test
and then create a test.c file in the directory,
Ê1 #include <stdio.h>
Ê2 #include "pico/stdlib.h"
Ê3 #include "hardware/gpio.h"
Ê4 #include "pico/binary_info.h"
Ê5
Ê6 const uint LED_PIN = 25;
Ê7
Ê8 int main() {
Ê9
10 bi_decl(bi_program_description("This is a test binary."));
11 bi_decl(bi_1pin_with_name(LED_PIN, "On-board LED"));
12
13 stdio_init_all();
14
15 gpio_init(LED_PIN);
16 gpio_set_dir(LED_PIN, GPIO_OUT);
17 while (1) {
18 gpio_put(LED_PIN, 0);
19 sleep_ms(250);
20 gpio_put(LED_PIN, 1);
21 puts("Hello World\n");
22 sleep_ms(1000);
23 }
24 }
These lines
will add
strings to the
binary visible
using picotool,
see Appendix
B.
along with a CMakeLists.txt file,
cmake_minimum_required(VERSION 3.13)
include(pico_sdk_import.cmake)
project(test_project C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
pico_sdk_init()
add_executable(test
Ê test.c
)
Getting started with Raspberry Pi Pico
Chapter 8. Creating your own Project 30

Table of Contents

Question and Answer IconNeed help?

Do you have a question about the Raspberry Pi Pico and is the answer not in the manual?

Raspberry Pi Pico Specifications

General IconGeneral
MicrocontrollerRP2040
Clock Speed133 MHz
SRAM264 KB
Flash Memory2 MB
GPIO Pins26
Operating Temperature-20°C to +85°C
ArchitectureARM Cortex-M0+ (dual-core)
InterfacesI2C, SPI, UART, PWM
Operating Voltage1.8–5.5 V
Dimensions51 mm × 21 mm

Summary

1. Quick Pico Setup

2. The SDK

2.1. Get the SDK and Examples

Download and clone the SDK and example repositories for development.

2.2. Install the Toolchain

Install necessary tools like CMake and the ARM embedded toolchain.

3. Blinking an LED in C

3.1. Building 'Blink'

Compile the 'Blink' C example program for the Raspberry Pi Pico.

3.2. Load and Run 'Blink'

Load and execute the compiled 'Blink' program onto the Raspberry Pi Pico.

4. Saying "Hello World" in C

4.3. Flash and Run 'Hello World'

Load and execute the compiled 'Hello World' program onto the Raspberry Pi Pico.

5. Flash Programming with SWD

5.3. Loading a Program

Use OpenOCD to load .elf program binaries into flash memory.

6. Debugging with SWD

6.3. Use GDB and OpenOCD for Debugging

Combine GDB and OpenOCD to interactively debug the 'Hello World' example.

7. Using Visual Studio Code

7.3. Debugging a Project

Set up and perform debugging for a project using VS Code and OpenOCD.

8. Creating Your Own Project

8.1. Debugging Your Project

Debug a custom project using command line tools and OpenOCD.

Appendix A: Using Picoprobe

Related product manuals