This USB example project implements a HID (Human Interface Device) that connects via the USB interface to the PC. This does not require any special USB driver, since the support is already built into Windows or Linux. The Human Interface Device (HID) program allows the LPC1768 to act as a Windows HID while attached to your PC using a USB interface. With this program and the HIDClient.exe program, you can:
Control the LEDs connected to the LPC1768.
Respond to presses of the button connected to the LPC1768.
Universal serial Bus (USB), a connection technology for attaching peripheral devices to a computer, providing fast data exchange. USB connects more than computers and peripherals. USB gives you a single, standardized, easy-to-use way to connect up to 127 devices to a computer.
Below figure shows how to interface the USB to microcontroller. The USB is a 4 wire bus that supports communication between a host and a number (127 max.) of peripherals. In USB data cable Data+ and Data- signals are transmitted on a twisted pair. No termination needed. Half-duplex differential signaling helps to combat the effects of electromagnetic noise on longer lines. Contrary to popular belief, D+ and D- operate together; they are not separate simplex connections.
Fig. 1: Block Diagram Of USb HID Interfacing Microcontroller
Interfacing USB with LPC2148:
The LPC1768 controller enables 12 Mb/s data exchange with a USB host controller. It consists of register interface, serial interface engine, endpoint buffer memory and DMA controller. The input, output signals and a USB Bus are used to connect with controller. The LPC2148 controller read the USB voltage as power supply for controlling peripherals without having an external voltage. The LPC1768 USB takes supply voltage either from USB or external power supply by using a Jumper connection.
Circuit Diagram to Interface USB 2.0 with LPC1768:
Fig. 2: Circuit Diagram To Interface USB 2.0 HID With LPC1768
Create a project using Keil uvision4 for LPC1768 Microcontroller:
In this section, we will start creating a project in Keil MDK we have already installed Keil µVision and Co-MDK Plug-in + CoLinkEx Drivers required for the CoLinkEx programming adapter. You can start by downloading the project files and kick start your practical experiment.
To build this example, first download and extract the quick start code base.
After downloading, upload the program to the LPC1768 Board, follow these steps to run the program.
Installing the USBHID Device:
Disconnect the USB power cable from the board.
Wait 10 seconds.
Re-connect the USB power cable to the board.
The Windows operating system displays a “Found New Hardware” message, but you don’t have to load any special drivers. Because support is built into Windows or Linux, HIDs do not require a custom USB driver.
Review the status of the USB Controllers using the Device Manager.
Right click on My Computer to open the System Properties – Hardware dialog.
Then click on Device Manager.
Right-click on the USB Human Interface Device to open the Properties dialog which contains the description and status of the HID device.
Installing the Application:
After installing the HID device, install the USB Client application.
Open the extracted folder.
Double click on HIDClient.EXE.
Select the Device: NXP LPC17XX USB HID from the drop-down list.
Fig. 3: Installing NXP LPC17XX USB HID Client Application For HID Interface With LPC1768
Running the HID Device:
The Inputs (Buttons) and Output (LEDs) groups represent the data input and output from the LPC1768 Board.
Fig. 4: Running The HID Device
Checking of the box in the Inputs (Buttons) group acts as pressing the buttons, and unchecking the box releases the button (clears the 0 bit).
Checking or unchecking the boxes in the Output (LEDs) group turns the LEDs connected to the LPC1768 on and off, respectively.
Fig. 5: Unchecked Buttons In HID Interface