EasyManuals Logo

Raspberry Pi RP2040 User Manual

Raspberry Pi RP2040
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 RP2040 and is the answer not in the manual?

Raspberry Pi RP2040 Specifications

General IconGeneral
ProcessorDual-core Arm Cortex-M0+
Clock Speed133 MHz
SRAM264 KB
GPIO30
USBUSB 1.1 Host/Device
PWM16 channels
UART2
SPI2
I2C2
Temperature Range-20°C to +85°C
Operating Voltage1.8V to 3.3V
FlashExternal QSPI flash
I/O InterfacesSPI, I2C, UART, PWM
ADC4 × 12-bit ADC channels

Related product manuals