Microchip pic16f877 to FTDI USB interface

Introduction
This is a simple design that interfaces a PIC 16F877 microcontroller to the USB bus using the FTDI FT245 USB FIFO device. It has been designed using a simple single sided PCB with only one surface mount device, the USB chip itself. All schematics, PCB layouts and software are available for download

Update, May 2nd 2011.
A datalogger design is in progress based around this PCB design is currently in development.
You can also use the FTDI UM245R USB to FIFO module and a breadboard to implement this design.

This design uses the old, FT245BM device, which has been surpassed by the newer FT245R device. The FT245R incorporates the
configuration EEPROM, oscillator and USB config/pullup resistors, thus simplifying the design. Any new designs should use the updated device.

As stated in the introduction the design uses the FTDI FT245BM USB FIFO device. This part handles all the details of
communicating via the USB bus, all it needs is a simple, 1KBit serial EEPROM to hold some USB configuration
information and you are ready to go.

The FT245 has the following interface to the microcontroller (taken from the databook)

D0 to D7 comprise the 8 bit data bus interface, in this design it connects to
PORT D of the PIC micro controller.

RD# and WR are the Read and Write pins of the device, they connect totwo
output pins on PORT C of the PIC microcontroller Both signals are active low.

Finally, RXF# is the RX FIFO flag, when logic 0, it indicates there is data to be
read from the device. TXE is used to indicate that it is possible to write to the FIFO
device, logic 0 indicates it is OK to write data. Both of these signals connect to input
pins of PORT C of the PIC microcontroller.

Accessing the USB device using the PIC

For the PIC to talk to this device is reasonably straightforward. To write data, you set PORTD as outputs,
present a byte of data on D0-D7, toggle WR from high to low, wait a bit then toggle WR high. The data gets
latched into the device on the rising edge of WR. Finally set PORT D as inputs (high impedance state)

To read data, set PORT D as inputs, toggle RD from high to low, wait then read the 8 bits of data presented on D0-D7. Toggle RD to high to
complete the cycle.

The FT245 data sheet provides the full timing for the device but even with a 20 MHz PIC, as used in my design, an external cycle takes 200ns,
4x the minimum 50ns cyles in the device data sheets, there will be no timing issues.

The hardware design

Before going into any further detail, I present the schematic of my design below, click to enlarge.

It is fairly straightforward, the USB interface is copied from one of the FTDI example designs and the PIC interface is straightforward enough.
Note: the FTDI USB to FIFO interface could also be implemented using the FTDI UM245R module, if you want to avoid any SMT soldering.

PCB layout

Note: The PCB design files in Eagle CAD and Gerber format are available for download

My principle design aims for this project were that the software is simple enough and that the hardware could be built on a single sided PCB.
The USB device is mounted on the solderside of the PCB and tracks very easily to the PIC microcontroller.