USB Component  Version 6.17.0
MDK Middleware for USB Device and Host Communication
USB Host Mass Storage

The following example application shows how to access an USB memory stick from a microcontroller. This example will create or overwrite a file called Test.txt on the USB Stick with the content "USB Host Mass Storage!". The following picture shows an exemplary connection of the development board and an USB memory stick.

The Abstract.txt file contained in the Documentation group of the Project window gives you more information on the general setup and the available I/O of the development board.

Build the "USB Host Mass Storage" Project

Open the example project in MDK (the web page explains this). The µVision Project window should display a similar project structure:

USB Host Mass Storage Project Structure

Source Files

  • MassStorage.c contains the main C function that initializes the board hardware, the flash storage device and the USB Host Component. Also, it contains that code that will write a file with a message onto the attached USB stick.

If you are using RTOS other than CMSIS-RTOS2 RTX5 for your project please make sure to satisfy USB Host Resource Requirements.

You may now build and download the example project to the evaluation board using the µVision commands:

  • Project --> Build target (F7)
  • Flash   --> Download (F8)
  • Debug --> Start/Stop Debug Session (Ctrl + F5)
  • Debug --> Run (F5)

After these steps, the project should start executing on your evaluation kit. In case of errors, refer to the Evaluation Board User's Guide for configuration information.

Using the "USB Host Mass Storage" Project

Hardware Setup

The setup of the Evaluation Board hardware is described in the Abstract.txt file.

  • Verify all jumper settings on the target hardware.
  • Simply connect an USB memory stick to one of the development board's USB connectors and run the program.
  • Detach the USB memory stick again and check the availability of the Test.txt file.
  • A terminal interface can be shown via Debug(printf) Viewer if ITM trace is supported and enabled, or via serial interface.
    USB Host Mass Storage - Terminal Interface