Tag archives for USB CDC
Many computers especially portable ones do not have a serial port (COM Port) anymore. When a connection to a Personal Computer (PC) is required, a USB is the choice. The Universal Serial Bus (USB) is the widely used interface in electronic consumer products today. Most of electronic devices have at least one USB port on them, this include PCs, cameras, GPS devices, printers and so on. Some PIC18 microcontrollers support USB interface directly. 16bits (PIC24) and 32-bits (PIC32) pic microcontrollers have also an embedded USB interface. In this article we will learn how a communication between a host PC and a microcontroller can be achieved with a USB bus.
Many computers especially portable ones do not have a serial port (COM Port) anymore. When a connection to a Personal Computer (PC) is required, a USB is the choice. The Universal Serial Bus (USB) is the widely used interface in electronic consumer products today. Most of electronic devices have at least one USB port on them, this include PCs, cameras, GPS devices, printers and so on. In this article we are going to learn how to set up a serial communication between a microcontroller and a PC using a USB port by creating a virtual COM Port. Some PIC18 microcontrollers support USB interface directly. For example, the PIC18F25K50, PIC18F4450 and PIC18F4550 microcontrollers just to name a few all have a full-speed compatible USB interface that allows communication between a host PC and the microcontroller. The USB bus is a very complex protocol. Flowcode provides a component for USB Serial ,The USB Serial device is used to stream data between a microcontroller and a PC.
The CDC device class code is "0x02, this class defines various communications over USB. The CDC class can be used to emulate the RS232 serial port (COM Port) and thus creating an easy solution to migrate the application from an old RS232 to the Universal Serial Bus (USB) interface without implementing many changes especially to the PC software. The device will create a virtual COM. The current MikroC Pro for PIC version 6.0.0 does not have a built in USB CDC library in the compiler, but you can download the USB Device Library from LIBSTOCK. This library supports the USB HID Class, the USB CDC Class and the USB Mass Storage Device Class. The file you are going to download has an .mpkg extension. You need the package manager to integrate this USB library into the MikroElekronika compilers. You can download the latest package manager from MikroElekronika website.
Microchip Libraries for Applications (MLA) is a collection of Microchip firmware libraries, drivers, demo projects, documentation and utilities for different type of applications including USB, Graphic displays, File I/O (Memory cards), TCP IP, Smartphone and many more. Not all firmware libraries and demo projects from Microchip are distributed in this package; rather, this package includes a few specific libraries that tend to be used together. By distributing libraries that are used often together, Microchip can provide example projects that integrate the use of multiple libraries.
The MPLAB® Code Configurator (MCC) is a user friendly Graphical User Interface (GUI) plug-in tool for MPLAB® X IDE which generates easy to understand C code that is inserted into an MPLAB® X project, based on the settings peripherals configurations and selections made in the Graphical User Interface (GUI). The generated code can be used in any application program. When starting out with a new project using Microchip 8-bit microcontrollers, setup of the configuration and all the peripherals can be time consuming, especially for new projects. The MPLAB® Code Configurator simplifies this down to a series of simple graphical selections from the menus within the MCC.