EasyManuals 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 #14 background imageLoading...
Page #14 background image
The destination for stdout can be changed using CMake directives, with output directed to UART or USB CDC, or to both,
pico_enable_stdio_usb(hello_world 1)
pico_enable_stdio_uart(hello_world 0)
1.
Enable
printf output via USB CDC (USB serial)
2.
Disable
printf output via UART
This means that without changing the C source code, you can change the destination for
stdio from UART to USB.
Pico Examples: https://github.com/raspberrypi/pico-examples/tree/master/hello_world/usb/CMakeLists.txt Lines 1 - 20
Ê1 if (TARGET tinyusb_device)
Ê2 add_executable(hello_usb
Ê3 hello_usb.c
Ê4 )
Ê5
Ê6 # Pull in our pico_stdlib which aggregates commonly used features
Ê7 target_link_libraries(hello_usb pico_stdlib)
Ê8
Ê9 # enable usb output, disable uart output
10 pico_enable_stdio_usb(hello_usb 1)
11 pico_enable_stdio_uart(hello_usb 0)
12
13 # create map/bin/hex/uf2 file etc.
14 pico_add_extra_outputs(hello_usb)
15
16 # add url via pico_set_program_url
17 example_auto_set_url(hello_usb)
18 elseif(PICO_ON_DEVICE)
19 message(WARNING "not building hello_usb because TinyUSB submodule is not initialized in
Ê the SDK")
20 endif()
4.2. Build "Hello World"
As we did for the previous "Blink" example, change directory into the
hello_world directory inside the pico-examples/build
tree, and run make.
$ cd hello_world
$ make -j4
Scanning dependencies of target ELF2UF2Build
[ 0%] Creating directories for 'ELF2UF2Build'
Ê .
Ê .
[ 33%] Linking CXX executable hello_usb.elf
[ 33%] Built target hello_usb
Ê .
Ê .
[100%] Linking CXX executable hello_serial.elf
[100%] Built target hello_serial
This will build two separate examples programs in the
hello_world/serial/ and hello_world/usb/ directories.
Getting started with Raspberry Pi Pico
4.2. Build "Hello World" 13

Table of Contents

Questions and Answers:

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

Related product manuals