WikiHome :: PIC18Fxx5x familly :: 18Fusb Programmers :: USB speeds, sockets, spec, power
Bootload :: HID Mouse w/ Buttons&Wheel, Keyboard, GamePad :: COMx port :: HID, CDC, Custom com :: Mass Storage Drive
pic18Fusb Wiki > CdcCOMx

How To emulate a COMx port via USB using Microchip CDC Firmware

Start communicating with a PC.

Follow the Tutorial in a few steps:



Notice that most of these Steps are needed only for the 1st use !

Step 1: Requirements:
- have a USB devlopment board based on a PIC18F4550...
- have the device programmed with the USB boot firmware code,
- have already sucessfully used the USB Bootloader

That means you must follow the UsbBootload Tutorial before doing this one !
If you don't want to use the USB Bootloader, you must make some modifications in the CDC project (change the Linker Script file to a normal one, set all Conf Bits, export a complete hex file including Conf Bits...).

Step 2: Install needed softwares and get CDC Firmware Source Code
Microchip MPLAB 7.00+ available from http://www.microchip.com/ide/
Microchip C18 2.40+ available from http://www.microchip.com/c18/ (check all Config Options boxes when asked !)
Microchip CDC Firmware Source Code ("CDC_RS232_Emulation.EXE")

Step 3: Adapt the firmware to your board
With a PICDEM FS-USB board (or complete clone), nothing to change, go to next step.
With a simplified clone (without SELF_POWER_SENSE_IO nor USB_BUS_SENSE_IO), edit the firmware:
Open MPLAB project :C:\MCHPFSUSB\fw\Cdc\MCHPUSB.mcp .
In usbcfg, comment both lines (start with //):
#define USE_SELF_POWER_SENSE_IO
#define USE_USB_BUS_SENSE_IO
Rebuild the project. This will update .\_output\MCHPUSB.hex.
If you use another Full Speed USB PIC (like 2455), also think to select your Device & replace the Linker Scripts file.

Step 4: Bootload the CDC firmware in the PIC
Connect the USB cable. It powers the PIC (not visible at this time).
Enter Boot Mode by pressing [S1 Reset] while maintaining [S2 enter Boot].
Bootload the HEX firmware file located at:
C:\MCHPFSUSB\fw\Cdc\_output\MCHPUSB.hex

Step 5: 1st CDC detection
Restart the board in user mode (reset while not pressing [S2 enter Boot]).
Normally, Windows will start detecting a new USB unknow device.

Step 6: Manualy specify "Microchip CDC" INF driver to MSWindows
At this point, you must have a window asking a driver for the new USB device.
The procedure depends on your Operating System version.
Don't let Windows find automatically a driver, or you will have to suppress the bad driver fille manualy!
Specify the driver location : C:\MCHPFSUSB\fw\Cdc\inf\win2k_winxp (mchpcdc.inf)
Now it should be recognised as "Communications Port" (COMx, COM3 for ex.).
You can verify in Windows Device Manager.

Step 7: Hyperterminal communication
Run MSWindows Hyperterminal (or others like this one).
Start Menu:Programms/Accessories/Communications/HyperTerminal
Create a new connection on COM3 with 115200 bauds rate (this value comes from cdc.c).
In the Hyperterminal, click Connect (Call) !
Then (& only then), push S2.
It must print :
Microchip Technology Inc., 2004
PIC18F4550 Full-Speed USB - CDC RS-232 Emulation Demo
Close the connection in the Hyperterminal before unpluging USB (thus you can reconnect USB and reuse the same connection in Hyperterminal without having to close/restart it).

Next: Your own program
To go further, try to do the examples proposed in user.c .
See Microchip documentation : AN956 Migrating Applications to USB from RS-232 UART
Then, you can start writing your own PC Comm application.
 Comments [Hide comments/form]
thank you. Merci beaucoup. You saved me several hours of time.
-- Grateful in connecticut
-- 69.0.38.69.adsl.snet.net (2007-01-31 03:01:17)
It's a VERY nice tutoreal, after two months finally I can do it
Thank you!
-- Paul Baldenegro
-- 63.167.43.60 (2007-10-04 08:59:36)
Good tutorials - a great help.
I did have problems getting my pic18f2550 @ 20mHz to load up with the correct boot code. It is important to to get the config bits just right, but once booting all is good. Also, be aware that the interrupt vectors change, so read up on that!
-- BenMoyes (2007-10-29 10:33:20)
Excelente artigo. Ajudou imenso.

Obrigado. :)
_______________
Excelente work. It helped a lot.

Thank you. :)
-- Nuno Sousa
-- deec-lab-nasc-inf.fe.up.pt (2007-11-13 18:57:48)
nice tutorial!! tyvm!
-- andres
-- 200.3.154.120 (2008-01-29 16:40:00)
pic18Fusb Wiki > CdcCOMx
WikiHome :: PIC18Fxx5x familly :: 18Fusb Programmers :: USB speeds, sockets, spec, power
Bootload :: HID Mouse w/ Buttons&Wheel, Keyboard, GamePad :: COMx port :: HID, CDC, Custom com :: Mass Storage Drive
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.2
Page was generated in 0.1318 seconds