Instructions

www.ti.com
User Experience Software
When data is sent over a UART, communication generally happens quickly, because it is low-level and
has essentially no overhead. After a byte is written to the TXBUF register, the time is very brief before
TXBUF is ready to send the next byte. Therefore, bcUartSend() does not return until all bytes are sent.
Hardware flow control could theoretically keep execution here indefinitely, but it is usually a safe
assumption that the eZ-FET lite's MSP430, which is at the other end of this hardware UART connection,
will quickly de-assert flow control and be ready to receive data.
Sending data over a USB interface is very different. Multiple communication layers, both hardware and
software, exist between the MSP430 application and the bus. There is a higher potential for the host and
bus to respond slowly. So, sending data over USB is an interrupt-driven process, involving multiple
interrupts over time. Polling in one place until all data is sent is possible but carries some risk of blocking
execution.
The USB API provides two construct functions for CDC interfaces. cdcSendDataWaitTilDone() waits until
the sending is complete before proceeding to the next line of code. cdcSendDataInBackground() only
initiates the sending operation and returns immediately while data is sent in the background behind
subsequent lines of code. However, cdcSendDataInBackground() always checks to ensure there is not a
previous send operation still open and polls until that operation is complete. Both functions have a retry
parameter, so they can only block for a limited amount of time.
This example of USB sending and receiving is sufficient for simple situations, but its handling of events
like surprise removal of the USB cable is simplistic. If USB is present, it sends data. If not, then it simply
returns an error (which is not even checked) and moves forward. More sophisticated applications may
need to pay attention to return codes and consider USB surprise removals. The emulStorageKeyboard
example in Section 3.5 demonstrates this.
3.6.7 Modifying to Use an HID-Datapipe Interface
This demo can be easily converted to use an HID-Datapipe interface instead of CDC (see Figure 34). The
advantage of the HID-Datapipe interface is that HID does not require the INF installation process on
Windows PCs that CDC does. In exchange for this, it operates with a 64-KB/s bandwidth limit.
HID also does not have the same host-side coding simplicity provided by virtual COM ports. For this
reason, TI provides the Java HID Demo App as an example. This demo app and its source code are
included in the MSP430 USB Developers Package.
HID-Datapipe is a special version of HID and is part of the MSP430 USB API. It allows communication
that is point-to-point, bidirectional, and unformatted, much like a virtual COM port. In contrast, traditional
HID relies on highly-formatted reports. HID-Datapipe abstracts the application from these reports and
presents an interface that is very much like the one used for CDC.
To convert the simpleUsbBackchannel example to use HID-Datapipe:
Use the Descriptor Tool to generate new output in the example's \USB_config directory. A Descriptor
Tool input file called simpleUsbBackchannel_HID.dat is provided in the project directory. Open this file
with the Tool, and then generate new output files into \USB_config. (For reverting to CDC, another file
that is named simpleUsbBackchannel_CDC.dat is provided.)
The code shown in Section 3.6.6 includes alternate calls for HID, which are symmetrical to the ones for
CDC. Comment out the CDC calls, and uncomment the ones for HID.
Now, build and run. Download the MSP430 USB Developers Package, and run the Java HID Demo App.
The app needs to know the VID and PID reported by the F5529; for the HID version of this example, these
are 0x2047 and 0x0404, respectively.
Instructions for using the Java HID Demo App are located in the Examples Guide PDF file in the MSP430
USB Developers Package.
47
SLAU533ASeptember 2013Revised January 2014 MSP430F5529 LaunchPad™ Development Tool (MSP
EXP430F5529LP)
Submit Documentation Feedback
Copyright © 2013–2014, Texas Instruments Incorporated