User manual
LPCXpresso Experiment Kit - User’s Guide
Page 128
Copyright 2013 © Embedded Artists AB
7.19 Extra: Work with USB Host
In this experiment you will learn how to work with an USB host interface. This experiment requires the
LPCXpresso LPC1769 board, which has an USB Host interface.
7.19.1 Lab 18a: USB Host
Using the USB Host interface of the LPC1769 it is possible to read/write from a USB Memory Stick.
This has a wide range of uses, including
Providing files for a web server
Data logging
Storing of initialization data
The data on the memory stick is persistent, allowing states and data to be kept between power cycles.
This experiment is based on the USBHostLite project that is part of the software package distributed
with the LPCXpresso IDE. It expects an msread.txt file (content not important) to be present in the
root of the memory stick's file system. The file will be copied into (possibly overwriting) mswrite.txt.
The memory stick should be formatted as FAT.
Note that an external +5V supply is needed, either via J1 or J17. Also note that two jumpers shall be
inserted in J11, pos 1-2 and 3-4.
This experiment is based on the code examples that are delivered with the LPCXpresso IDE. The code
is structured very differently (none of the code from the previous exercises is used). You have to create
a new workspace in LPCXpresso and then import the projects from Lab18a.zip.
Insert a USB memory stick in the J10 connector and then start the program. The program uses
semihosting so all printouts will be available in the LPCXpresso IDE. If the memory stick is found and
the file is copied the printouts should look like this:
Initializing Host Stack
Host Initialized
Connect a Mass Storage device
Mass Storage device connected
Copying from MSREAD.TXT to MSWRITE.TXT...
Copy completed
If the memory stick was not inserted before the program started it will look like this:
Initializing Host Stack
Host Initialized
Connect a Mass Storage device
ERROR: In Host_EnumDev at Line 407 - rc = -1
This is not very user friendly. Improve the implementation of main() to wait for the memory stick to be
inserted, copy the file, wait for the memory stick to be removed and then start over.