This USB example project implements a host that connects a keyboard through the USB interface of LPC1768. Here the LPC1768 act as a host where the keyboard is enumerated and the inputs from the keyboard are reflected to the UART which can be viewed in the terminal softwares.
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 Interfacing USB With LPC2148
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 With LPC1768 To Implement Host Keyboard
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.
Connecting the Keyboard to the LPC1768:
Disconnect the power cable from the board.
Wait 10 seconds.
Re-connect the power cable to the board.
Connect a USB-Serial between COM0 on the board and a PC running a terminal program. Baud rate = 9600
Plug a keyboard into the USB in the LPC1768 board.
Running the HOST Device:
Once the Keyboard is connected to the board the program will enumerate the keyboard with drivers and the characters pressed will be transmitted over the COM port connected to the PC, which is displayed in the terminal software.
Fig. 3: Host Keyboard Enumerated Using LPC1768