In previous project I have created USB 2.0 device which can communicate with computer via HID device class. I decided to add to USB device function which will allow it to display received data on LCD display. Main reason why I did it was that I wanted to prove to unfaithful people that my device really works online. Idea was quite simple. After enumeration process of USB device, we switch on HID terminal. HID terminal is a software created by Mikroelektronika company. HID terminal is a one of tools from toolsuite environment MikroC Pro. It is possible to download demo version of mentioned software. This software gives us possibility to send information to chosen USB device. LCD display (LCD → Liquid-Crystal Display) which was chosen to project is based on HITACHI HD44780 chip. LCD display allows displaying two lines with sixteen characters. So as you can see it’s the first limitation. My USB device supports two endpoints. Endpoint 0 (EP0) and Endpoint 1 (EP1) both are bidirectional. If you are familiar with USB you probably know that every USB device has to support bidirectional endpoint 0, because it is used during device’s enumeration process at first connection to USB Host. After successful configuration of device we are able to send data via terminal to device. Microcontroller has reserved in its RAM memory four banks as a USB RAM. USB RAM is 1024 bytes long. Microcontroller shares its USB RAM with Serial Interface Engine (SIE) which is directly connected to USB bus. After receiving packet from endpoint 1 microcontroller’s firmware checks data consistency and immediately display it on LCD. To communicate with LCD display ten bits are used. Eight bits are data bits (D7..D0), two bits serve as control signals E and RS. LCD display has also signal R/notW which toggles between read/write mode of HD44780 chip. In my project only writing mode is used. LCD display’s control signal R/notW is permanently connected to the ground. HD44780 has also option to use four bits data transfer mode which is very useful if we don’t have enough port bits in microcontroller to perform eight bit data transfer or if we would to save some port bits for other functions.
When device is connected to USB port and installation process has succeeded, it is possible to send data to USB device via HID terminal. When device receives data packet from USB host, it immediately displays it on LCD and send in return the same data packet to the host. When USB host receives data from USB device it displays it on HID terminal.
When USB device receives data from computer then it immediately displays it on LCD.
USB device returns the same data packet to USB host after displaying it on LCD.