Compiling or running the USB stack and examples

Note: The USB example may not support all compilers. The steps below describes how to compile and run on all compilers. Check the specific MCUXpresso SDK documentation to know about the supported compilers for the USB example.

Step-by-step guide for MCUXpresso IDE

  1. Prepare a compressed release package, such as SDK_2.0_FRDM-K64F.zip.

  2. Open MCUXpresso IDE and drag and drop the MCUXpresso SDK (zip file/folder) into the “Installed SDKs”. The MCUXpresso SDK should install.

    |

|

  1. To select an example, select the “Import SDK example(s)” button. Click the “Next” button after selecting the available board.

    |

|

|![](../images/select_boards.jpg "Select boards")

|

  1. To import one example, click the “Finish” button after selecting the available example.

    |

|

  1. After importing, the window should look like the below figure.

    |

|

  1. Choose the appropriate build target, “Debug” or “Release”, by left-clicking the build configuration icon as show in the below figure.

    |

|

  1. If the project build does not begin after selecting the desired target, left-click the build icon to start the build.

    |

|

  1. To check debugger configurations, click the down arrow next to the green debug button and select “Debug Configurations”.

    |

|

  1. After verifying the debugger configurations are correct, click the “Debug” button.

    |

|

  1. The application is downloaded to the target and automatically runs to main():

  2. Run the code by clicking the “Resume” button to start the application:

    |

|

  1. See the example-specific document for more test information.

Parent topic:Compiling or running the USB stack and examples

Step-by-step guide for IAR

This section shows how to use IAR. Open IAR as shown in this figure:

  1. Open the worksace corresponding to different examples.

    For example, the workspace file is located at: <install_dir>/boards/twrk22f120m/usb_examples/usb_host_hid_mouse/bm/iar/host_hid_mouse_bm.eww.

    |

|

  1. Build the host_hid_mouse_bm example.

  2. Connect the micro USB cable from a PC to the J25 of the TWR-K22F120M Tower System module to power on the board.

  3. Click the “Download and Debug” button. Wait for the download to complete.

  4. Click the “Go” button to run the example.

  5. See the example-specific readme.pdf for more test information.

Parent topic:Compiling or running the USB stack and examples

Step-by-step guide for Keil µVision5

This section shows how to use Keil µVision5. Open Keil µVision5 as shown in this figure:

  1. Open the workspace corresponding to different examples.

    For example, the workspace file is located in <install_dir>/boards/twrk22f120m/usb_examples/usb_host_hid_mouse/bm/mdk/host_hid_mouse_bm.uvmpw.

    |

|

  1. Build the host_hid_mouse_bm example.

  2. Click the “Start/Stop” debug session button. Wait for the download to complete.

  3. Click the “Go” button to run the example.

  4. See the example-specific readme.pdf for more test information.

Parent topic:Compiling or running the USB stack and examples

Step-by-step guide for ARMGCC

Setup tool chains

Parent topic:Step-by-step guide for ARMGCC

Install GCC Arm embedded tool chain

Download and install the installer from www.launchpad.net/gcc-arm-embedded.

Parent topic:Step-by-step guide for ARMGCC

Install MinGW

  1. Download the latest mingw-get-setup.exe.

  2. Install the GCC Arm Embedded toolchain. The recommended path is C:/MINGW.

    Note: The installation path should not contain a space.

  3. Ensure that the mingw32-base and msys-base are selected under basic setup.

  4. Click “Installation” and “Apply changes”.

    |

|

  1. Add paths C:/MINGW/msys/1.0/bin;C:/MINGW/bin to the system environment. If the GCC Arm Embedded tool chain was not installed at the recommended location, the system paths added should reflect this change else the tool chain will not work. An example using the recommended installation locations is shown below.

    |

|

Parent topic:Step-by-step guide for ARMGCC

Add new system environment variable ARMGCC_DIR

Create a new system environment variable ARMGCC_DIR. The value of this variable should be the short name of the Arm GCC Embedded tool chain installation path.

|

|

Parent topic:Step-by-step guide for ARMGCC

Install CMake

  1. Download CMake 3.0.1 from www.cmake.org/cmake/resources/software.html.

  2. Install CMake 3.0.1 and ensure that the option “Add CMake to system PATH” is selected.

    |

|

Parent topic:Step-by-step guide for ARMGCC

Build the USB demo

  1. Change the directory to the project directory:<install_dir>/boards/twrk22f120m/usb_examples/usb_host_hid_mouse/bm/armgcc.

  2. Run the build_all.bat. The build output is shown in this figure:

    |

|

Parent topic:Step-by-step guide for ARMGCC

Run a demo application

This section describes steps to run a demo application using J-Link GDB Server application.

  1. Connect the J-Link debug port to the SWD/JTAG connector of the board.

  2. Open the J-Link GDB Server application and modify your connection settings as shown in this figure.

    |

|

**Note:** The target device selection should be MK22FN512xxx12. The target interface should be SWD.
  1. After the connection is estabilished, the screen would resemble the figure below:

    |

|

**Note:** The CPU selection should be CPU to: MK22FN512xxx12.
  1. Open the Arm GCC command prompt and change the directory to the output directory of the desired demo. For this example, the directory is:

    <install_dir>/boards/twrk22f120m/usb_examples/usb_host_hid_mouse/bm/armgcc/debug.

  2. Run the command “arm-none-eabi-gdb.exe <DEMO_NAME>.elf”. Run these commands:

    • “target remote localhost: 2331”

    • “monitor reset”

    • “monitor halt”

    • “load”

    • “monitor reset”

  3. The application is downloaded and connected. Execute the “monitor go” command to start the demo application.

  4. See the example-specific document for more test information.

Parent topic:Step-by-step guide for ARMGCC

Parent topic:Compiling or running the USB stack and examples

Parent topic:Build the USB examples in MCUXpresso SDK