Summary of PIC USB HID (Human Interface Device) Interfacing
This article explains interfacing PIC18F2550/4550 microcontrollers with PCs via USB using MikroC Pro. It highlights the critical role of correct microcontroller configuration and USB device descriptors for successful communication. The text details USB speed standards (Low, Full, High, Super) and specifies that Full Speed (12 Mb/s) requires a 48 MHz clock source.Parts used in the PIC Microcontroller USB Interfacing:
- PIC18F2550 microcontroller
- PIC18F4550 microcontroller
- MikroElektronika's MikroC Pro for PIC software
- 48MHz crystal oscillator
Introduction
The purpose of this article is to explain how to interface a PIC microcontroller to a PC via the USB port. Although the concepts are universal, the examples are specifically for use with MikroElektronika’s ‘MikroC Pro for PIC’. PIC18F2550 and PIC18f4550 are famous for their USB Module. To stay ahead you can start with their datasheets.

USB Speed
The original USB 1.0 specification, defined data transfer rate of 1.5 Mbit/s "Low Speed" and 12 Mbit/s "Full Speed". The 12 Mbit/s data rate was intended for higher-speed devices such as disk drives, and the lower 1.5 Mbit/s rate for low data rate devices such as joysticks. The USB 2.0 specification has 480 Mbit/s data transfer rate, which is also known as “High Speed”. The new USB 3.0 specification has up to 5 Gbit/s data transfer rate, known as “Super Speed”.
P18F2550/4550 supports low speed (1.5 Mb/s) and Full Speed (12 Mb/s). So the first thing you have to know is how to set desired clock for USB.
Clock setting
I’ll show you how to configure ‘Full Speed’ i.e. 12 Mb/s. When you use mcu for USB connectivity, it must have either a 6 MHz or 48 MHz clock for USB operation, depending on whether Low-Speed or Full-Speed mode is being used. The first thing you can do is, use a 48MHz crystal (for full speed). But there are two drawbacks:
For more detail: PIC USB HID (Human Interface Device) Interfacing
- What is the primary purpose of this article?
To explain how to interface a PIC microcontroller to a PC via the USB port. - Which microcontrollers are famous for their USB Module?
PIC18F2550 and PIC18f4550 are famous for their USB Module. - What are the two most important things required for USB communication?
The microcontroller configuration and the USB device descriptor must be absolutely correct. - What data transfer rate does USB 2.0 offer?
USB 2.0 has a 480 Mbit/s data transfer rate known as High Speed. - Does P18F2550/4550 support Low Speed mode?
Yes, P18F2550/4550 supports low speed at 1.5 Mb/s. - What clock frequency is needed for Full Speed USB operation?
A 48 MHz clock is required for Full Speed mode which uses 12 Mb/s. - Can you use a 6 MHz clock for Full Speed USB?
No, a 6 MHz clock is only for Low-Speed mode; Full Speed needs 48 MHz. - What software examples are specifically mentioned in the article?
The examples are specifically for use with MikroElektronika's MikroC Pro for PIC.
Related projects
PICDEM FS USB CDC Evaluation Board using PIC18F4550 with Proteus Simulation
Introduction The PICDEM FS USB CDC Evaluation Board is a practical microcontroller project built around the PIC18F4550, designed to demonstrate USB communication...
Peripheral Tutorials · PIC18F4550PICDEM FS USB Mass Storage Device using PIC18F4550 with Proteus Simulation
Introduction This microcontroller project demonstrates how to simulate a USB Mass Storage Device (MSD) using the PIC18F4550 in a Proteus simulation environment....
Development Boards & Kits · PIC18F2550Pinguino Project: A PIC Microcontroller Based Arduino
This is a complete tutorial to make a PIC Microcontroller based Arduino. This is a complete tutorial to make PIC microcontroller based...
Communication & Interfacing · PIC18F4520CAN FD Node based on a PIC18 Microcontroller
The introduction sets the stage for an embedded systems project that involves developing a Embedded C CAN FD project using the MCP2517FD...
Communication & InterfacingLAN9662 Gigabit Switch: Optimized for Industrial Ethernet
Introduction It should come as little surprise therefore that one element of what is now more commonly referred to in some circles...
Communication & InterfacingPIC Microcontroller: Fundamentals & Applications for Students
Introduction Microcontrollers are the key components in the embedded systems market. A variety of embedded systems was formed and developed after the...