Skip to main content

Control RP2040 on Windows

Introducts relationship between Intel N100,RP2040 and 40-PIN GPIO

The Radxa X2L integrates an Intel J4125 CPU and a RP2040 MCU, which communicate with each other via USB and UART. The RP2040 exists as a USB memory device in the system, and the program can be burned by dragging and dropping the files to the USB device. In addition, they share the same UART communication interface, which enables Intel J4125 to control the RP2040 through UART, for example, to realize the control of RP2040 GPIO through the UART interface. The relationship between the two is shown in the following figure:

40 PIN Usage

In order to operate the IO resources on RP2040, we need a complete software environment, such as MicroPython or C/C++ SDK, here we mainly introduce a set of C/C++ SDKs, namely pico-sdk and pico-examples. pico-sdk mainly provides some APIs to operate the RP2040, while pico-examples provides a compilation framework for us to add our own programs according to the compilation framework provided by pico-examples. pico-sdk provides some APIs to operate the RP2040, while pico-examples provides a compilation framework for us to add our own programs according to the compilation framework provided by pico-examples.

Install necessary Tools

Set Environment Variables

  • Search for ‘Edit the system environment’ in the search bar.

  • Click "Environment Variables"

  • Add system or user variables

    • Add variables PICO_INSTALL_PATH and PICO-SDK_PATH
    pico install path pico sdk path
  • Ads PATH

    pico path env

Build

Open git bash, go to the pico-examples/build directory, and execute the following command to build the system

cmake -G "Ninja" ..

ninja
cmake ninja ninja build

Flash

Press the BOOTSEL key and a USB device will pop up. Copy the compiled .uf2 file to the USB device of RP2040 and wait until the USB device disappears, then the programme will start to execute.

Examples

GPIO
1. Preparation
  • One Radxa X2L
  • One LED
2. Connection
Radxa X2L<-->LED
PIN_5<-->LED
PIN_1<-->VCC
PIN_9<-->GND
tip

Here PIN_5 corresponds to GPIO29 in the following code, please refer to GPIO Definition for details.

3. Test
  • Replace pico-examples/blink/blink.c with the following code

    blink.c

    #include "pico/stdlib.h"
    #define BLINK_PIN 29 // GPIO29

    int main() {

    gpio_init(BLINK_PIN);
    gpio_set_dir(BLINK_PIN, GPIO_OUT);

    while (true) {
    gpio_put(BLINK_PIN, 1);
    sleep_ms(250);
    gpio_put(BLINK_PIN, 0);
    sleep_ms(250);
    }
    }

  • Compile

    cd pico-examples/build/
    rm -rf *
    cmake -G "Ninja" ..
    ninja

    After successful compilation, a file named blink.uf2 will be created in the pico-examples/build/blink/ directory.

  • Flash

    • Reboot RP2040
    • Drag the blink.uf2 file into the RP2040, and when the RP2040 disappears, the LED will start blinking.