User`s guide
www.ti.com
Software
CDC and HID-Datapipe provide the developer a simple data exchange interface. As a brief example of
this interface, a simple application follows.
VOID main(VOID)
{
// Init clocks, power, ports
WDT_A_hold(WDT_A_BASE);
PMM_setVCore(PMM_BASE, PMM_CORE_LEVEL_2);
initPorts();
initClocks(8000000); // CPU frequency, in Hz
initTimer(); // Set up one-second intervals to wake from LPM0
USB_setup(TRUE,TRUE); // USB API call; initializes USB and connects to the host
__enable_interrupt();
while (1)
{
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 sleep
if (cdcSendDataInBackground(helloWorldStr, 12, CDC0_INTFNUM, 1000))
{
handleFailedSend(); // Might fail if cable is disconnected, bus is
// busy, or host has become unresponsive
}
}
}
This application wakes up once per second (using a timer interrupt, not shown) and sends a string over
USB to a virtual COM port on the host.
To send data over a CDC interface (to a virtual COM port), you can simply build the interface with the
Descriptor Tool, prepare your data, and call the API construct function cdcSendDataInBackground(), which
accepts these parameters:
• Data buffer
• The buffer's size
• Which CDC interface
• The number of retries before the attempt is considered a failure.
This is only one simple example; much more is possible with the USB API. See the MSP430 USB API
Programmer's Guide and examples in the MSP430 USB Developers Package for more information.
9
SLAA457A–September 2013–Revised May 2014 Starting a USB Design Using MSP430™ MCUs
Submit Documentation Feedback
Copyright © 2013–2014, Texas Instruments Incorporated










