USB to Serial Converter using PIC

Introduction

This is a microprocessor based project created to emulate a serial communication over full-speed Universal Serial Bus (USB). When the hardware is connected to a host with an USB cable, a new device interface is created by the operating system. An application running on this host and using serial communication can use this new interface exactly like it was doing before with legacy serial communiction.

The Microchip PIC 18f2550 is used as microprocessor. One of its features is to implement an USB Peripheral that contains a full-speed and low-speed compatible USB Serial Interface Engine (SIE) that allows fast communication between any USB host and the PIC microcontroller. The software performs the CDC (Communication Device Class) serial connection on the microprocessor usart.

Features

Here are the main features:

Schematics

The schematics is microprocessor centric. A 12 MHz crystal is connected to the internal oscillator and provides the reference, after division by 3, to the 96 MHz PLL necessary for the USB subsystem. CPU clock is also derived from the PLL and is set to 24 MHz.

The DB25 connector is wired to the unused ports and is intended to provide a parallel port interface or others if needed, but is not implemented at the moment.

Note: the rs232 interface is not part of the schematics to allow low level interfaces. Consider add an external one when connecting the serial interface to a PC, for example.

Hardware

Here is a picture of the board:

Software

The software is simple. After initialization, the program copies bytes received by the usart interface to an Usb In packet for the host and copies data received in an Usb Out packet in a buffer for the usart to transmit. Data to or from usart is buffered and sending or receiving is done on interrupt request.

Initialization consists on replying to the host requests about enumeration and endpoints configuration.

The usb stack is heavily based on the PIC USB Framework [1], written by Pierre Gaufillet, a pretty good example on how to start with USB.

The Pic bootloader program [2] is embedded in the software and let you re-flash the application from the serial line.

Tools

The software is developed on a Linux system with SDCC - Small Device C Compiler, see SDCC for download and documentation.

SDCC itself requires the gputils package for gpasm and gplink, the assembler and linker for PIC software, see gputils package.

Schematics are created with gschem from the gEDA suite see [3]. You could need it to edit, print, view or, why not, create other schematics.

Compiling the firmware

You need to have the tools installed, and next run the following commands.

tar zxvf picusb-yyyymmdd.tar.gz
cd picusb-yyyymmdd
make

References

  1. [1] PIC USB Framework.
  2. [2] An Pic Avr bootloader program.
  3. [3] my gEDA symbols.

LICENSE

The Picusb softwares is licensed under the terms of the GNU General Public License as published by the Free Software Foundation. See the file "COPYING" in the download directory.

Download