Zephyr Lab MCXN947 Hello World - nxp-mcuxpresso/vscode-for-mcux GitHub Wiki

Objectives

In this lab, you will learn:

  • How to import an example from the Zephyr Repo in the VS Code workspace
  • How to build, clean, debug, and run the example
  • How to connect the Serial Monitor for UART console
  • How to navigate and edit files in the Explorer view

Hello_World Lab

After successfully installing Zephyr and setting up the VS Code extension for MCUXpresso, let’s go through the detailed steps to run the Zephyr hello_world application on the FRDM-MCXN947.

1. Import hello_world sample

  1. To import the hello_world application from the Zephyr Repository, click Import example from Repository in the Quickstart Panel.

    Import example from repo


  1. Select the following board settings to import the example:
  • For selecting the board, type n947 to find the board target frdm_mcxn947/mcxn947/cpu0. Make sure that the board ends with cpu0.

  • For selecting the example, type hello to find the application zephyr/samples/hello_world

  • For application type, select Repository Application.

  • Click Create and the example should be added to the PROJECTS view.

    Import example project

2. Build the application

We need to build hello_world project to generate the application image. After the code builds without any errors, the application can be run on the board.

  1. Build the project by clicking the Build Selected icon.

    Build project

    After the build, the Terminal view displays the memory usage (or compiler errors if any).

    Build output

3. Connect Serial Monitor to the board

To use the Serial Monitor integrated into VS Code, connect the USB Type-C cable to J17 to power the board. The onboard debugger provides a USB-UART bridge to interface with the Serial monitor.

  1. Connect the Serial monitor to the board’s COM port and select the Baud rate. The screenshots show the board enumerates as COM15, but the COM port number may be different for you. To capture the data sent over UART, click Start Monitoring.

    It can be disconnected by clicking Stop Monitoring after debug.

    Serial Monitor


  1. If the serial monitor view is disabled, right-click on the panel and select the Serial Monitor option.

    Serial Monitor option


  1. Optional settings for the Serial Monitor:
    6.1. To add a monitor for another COM port select Open an additional monitor.
    6.2. Click the icon to clear the output terminal.
    6.3. Click the gear icon for additional settings (data bits, stop bits, parity, DTR, RTS).
    6.4. To send a message to the serial terminal, type the command in the text box.

    Settings for Serial Monitor

4. Debug the application

This section uses the GDB debugger to connect to the MCU, and program the flash.

  1. Click the play icon to Debug the application:

    Debug project


  1. The execution will pause, and a debugger toolbar pops up at the top of VS Code. To continue execution click Continue on the debug options.

    Continue debugging


  1. In the Serial Monitor view, the application prints the boot banner during the startup code and halts at main(). The boot banner also includes the version of Zephyr used in the build. In main(), the application prints hello world.

    Hello_World printed to Console


5. Clean up after lab

This lab is completed. But the following steps will clean up the VS Code workspace:

  1. Click Stop to end the debug session.

    Stop Debugger

  2. Close all Editor tabs. Right-Click on a tab, and select Close All.

  3. If this is the last lab and you are done using the board, you should disconnect the Serial Monitor. Find the Serial Monitor view, and click Stop Monitoring.

    Stop Serial Monitor


Lab completed. Return to the MCXN947 Zephyr Labs Overview Training Zephyr Getting Started MCXN947

⚠️ **GitHub.com Fallback** ⚠️