Escolar Documentos
Profissional Documentos
Cultura Documentos
WebSeminar
Welcome to Microchip Webseminar My name is Rawin Rojvanit and I am an applications engineer here at Microchip Technology. With the introduction of the PIC18F4550 family, which has a full-speed USB peripheral, many more USB applications have become possible. One such application is the emulation of RS-232 over USB.
Agenda
l
Brief overview of RS-232 emulation over USB PICDEM FS USB Demo Board
This presentation is only about 20 minutes long and not every thing can be explained here. The goal of this presentation is to describe what the RS-232 Emulation over USB is, what it is useful for, what Microchip is providing, and where to find more information.
USB Terminology
l
For those that are new to USB, I would like to introduce a few terminologies. USB stands for Universal Serial Bus. USB has literally become the standard peripheral interface for every personal computer.
USB Terminology
l l
CDC stands for Communication Device Class. This is a device level protocol specification defined by the USB association body. It defines the rules of how a USB host and a USB peripheral should communicate as a communication device. Specifically, the CDC specification defines a wrapper protocol layer around other communication protocols allowing them to be transported over the USB interface. A standardized specification also allows a USB host and a USB peripheral to be developed independently. As I will explained later on in this presentation, no work or modification is required on the PC side to implement the RS-232 emulation over USB. This is so because Windows 2000 and XP already come with a driver which provides the RS-232 emulation capability as defined in the Communication Device Class Specification. Therefore the only things left to do is for the embedded device to have the hardware and firmware supports that conform to the CDC specification.
USB Terminology
l l
USB Universal Serial Bus CDC Communication Device Class VID Vendor ID
VID stands for Vendor ID. Vendor ID is a 16-bit number assigned by the USB organization body. This number has to be purchased by each manufacturer in order to market and sell a product.
USB Terminology
l l
USB Universal Serial Bus CDC Communication Device Class VID Vendor ID PID Product ID
l l
PID stands for Product ID and it is also a 16-bit number. Therefore each manufacturer has 65,536 Product IDs to use.
USB Terminology
l l
USB Universal Serial Bus CDC Communication Device Class VID Vendor ID PID Product ID Every product is required to have a unique combination of VID and PID
l l l
USB Terminology
l l
USB Universal Serial Bus CDC Communication Device Class VID Vendor ID PID Product ID Every product is required to have a unique combination of VID and PID www.usb.org
Emulating RS -232 Over USB 8
l l l
RS-232
The emulation of RS-232 over USB provides an easy migration path for an embedded application. The serial communication has traditionally been the most common method of transferring data between a PC and an embedded device. This slide shows that traditional method of transferring data over the RS-232 interface. The top half represents a personal computer and the bottom half represents an embedded application. The HyperTermina l is a Windows program that is used here as an example of an end application. Many computers no longer have a serial port. This fact causes a headache for many embedded system designers and a new solution is needed. An answer is to use USB.
RS-232
USB
10
This slide shows the migration path from RS-232 to USB. The UART physical layer is replaced with the USB hardware layer. Since CDC is a standard USB class, Microsoft has implemented a driver which supports the RS-232 interface emulation. On the PC side, the CDC driver provides the linking layer between the USB hardware and the UART driver. This allows the end application to remain unchanged because from its perspective, it still sees the RS-232 interface. As for the embedded application side, the PIC18F4550 has a full-speed USB peripheral. In addition, Microchip also provides the CDC RS-232 Emulation Reference Project which provides necessary application programming interfaces.
10
Assume that the CDC RS-232 Emulation Reference Project is programmed on the microcontroller
Switch 2 & 3
S2 S3 Serial Port
RS232 RST
Reset Switch
18F4550
Power Connector
POT
Potentiometer
I would like to introduce you to the PICDEM FS USB Demo Board. This board can be purchased from buy.microchip.com or any Microchips distributors. It provides a hardware platform for demonstrating the USB capability of the PIC18F4550 family of devices. Assuming that the board has the CDC RS-232 Emulation Reference Project loaded, I will next show you how the demo board would be recognized by Windows Operating System.
11
Device Manager
l l
12
12
Connect the demo board to a PC Windows should detect a new USB device
13
13
C:\MCHPFSUSB\fw\CDC\inf\win2k_winxp
Emulating RS -232 Over USB 14
A standard INF file for the Communication Device Driver is not provided by Microsoft. One is provided by microchip. Example INF file is part of the CDC RS-232 Emulation Reference Project. Once installed, it can be found in directory listed on this slide. USB Product ID and Vendor ID are also contained in the INF file. This means when you use the reference project, you should change the IDs in both the firmware and INF files.
14
Installation Complete
l l
15
15
Using HyperTerminal
l l
16
16
HyperTerminal: Connect To
l
Select the new COM port that was added during USB CDC installation and hit OK
17
17
18
18
Now, hit switch S2 on the demo board, you should see the message below
19
19
Before physically disconnecting a USB device, you must hang up the connection first, otherwise, the program must be closed and opened again the next time a USB device is connected.
Lets take a look at the APIs provided by the CDC reference project.
20
CDC APIs
void putrsUSBUSART(const rom char *data); void putsUSBUSART(char *data); void mUSBUSARTTxRom(rom byte *pData, byte len); void mUSBUSARTTxRam(byte *pData, byte len); byte getsUSBUSART(char *buffer, byte len); byte mCDCGetRxLength(void);
2004 Microchip Technology Incorporated. All Rights Reserved. Emulating RS -232 Over USB 21
21
USBTasks()
ProcessIO()
22
22
Performance Analysis
l
Speed l 640 Kbits/s = 80 Kbytes/s l Faster than RS-232 (UART) l This solution is not possible with a lowspeed USB device because it does not have a bulk endpoint. Program Memory Usage: ~ 3 KB
23
23
24
24
25
25
CDC_RS232_Emulation.EXE
l
C:\MCHPFSUSB\
Workspace file: MCHPUSB.mcw Output file: MCHPUSB.hex INF file for Windows Installation
26
26
Emulates RS-232 over USB = Easiest Transition No change for the PC application l Continues using COM1, COM2, etc. CDC RS-232 Emulation Reference Project is freely downloadable from www.microchip.com
27
27
Thank You
28