Anda di halaman 1dari 12

PROJECT REPORT

MICRO COMPUTER SYSTEM

PROJECT TITLE

USB TO UART CONVERTER

SUBMITTED TO:

ENGR. AZHAR ZAIDI

GROUP MEMBERS:

Mian Rizwan 08-EE-26

M. Bilawal Abrar 08-EE-77

SECTION:

SUBMISSION DATE:

31 MAY 2011

ELECTRICAL ENGINEERING DEPARTMENT

UNIVERSITY OF ENGINEERING AND TECHNOLOGY TAXIL


PIC 18F4550

Microchip Technology’s PIC microcontrollers are popular due to their low cost, wide
availability, large selection, good performance, and low power consumption.
The PIC18F4550 contains a USB controller that can function at low and full speeds. Microchip
offers other variants with different combinations of features. The PIC18F4550 is a member of
Microchip’s high-performance, low-cost, 8-bit PIC18 series. Firmware resides in 32 KB of
flash memory. The chip has 2KB of RAM and 256 bytes of EEPROM. A boot loader routine
can upgrade firmware via the USB port.

Construction and Working:

The chip has 34 I/O pins that include a 10-bit analog-to-digital converter, a
USART, a synchronous serial port that can be configured to use I2C or SPI,
enhanced PWM capabilities, and two analog comparators. The USB module and CPU can use
separate clock sources, enabling the CPU to use a slower, power-saving clock.
The USB controller supports all four transfer types and up to 30 endpoint addresses plus the
default endpoint. The endpoints share 1 KB of buffer memory, and transfers can use double
buffering. For isochronous transfers, USB data can transfer directly to and from a streaming
parallel port. For each enabled endpoint address, the firmware must reserve memory for abuffer
and a buffer descriptor. The buffer descriptor consists of four registers. Firmware can access the
register’s contents as a structure, a single 32-bit value, or a byte array.
The status register contains status information and the two highest bits of the endpoint’s byte
count. The byte-count register plus the two bits in the status register contain the number of
bytes sent or ready to send in an IN transaction or the number of bytes expected or received in
an OUT transaction. The address-low and address-high registers contain the starting address for
the endpoint’s buffer in RAM. The microcontroller’s CPU and the USB SIE share access to the
buffers and buffer descriptors.
Clock diagram
INTERNAL OSCILLATOR BLOCK

The PIC18F4550 devices include an internal oscillator block which generates two different
clock signals; either can be used as the microcontroller’s clock source. If the USB peripheral is
not used, the internal oscillator may eliminate the need for external oscillator circuits on the
OSC1 and/or OSC2 pins.

OSCILLATOR SETTING FOR USB

When the PIC18F4550 is used 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.
This may require some forethought in selecting an oscillator frequency and programming the
device. The full range of possible oscillator configurations compatible with USB operation.

RUNNING DIFFERENT USB AND MICROCONTROLLER CLOCKS

The USB module, in either mode, can run asynchronously with respect to the microcontroller
core and other peripherals. This means that applications can use the primary oscillator for the
USB clock while the microcontroller runs from a separate clock source at a lower speed. If it is
necessary to run the entire application from only one clock source, full-speed operation
provides a greater selection of microcontroller clock frequencies.
COMPONENTS

 PIC18F4550
 MXX 232
 Universal Serial Bus (USB)
 Capacitors (10uF)
 Crystal Oscillator
 UART
 Resistors
 Wires

Working of USB to UART Convertor


PIC IC is used to interface between USB and UART serial port. PIC takes signals from one
computer using USB and transfer it through UART by using the MXX 232 . In the same way it
takes a signal from second computer using a UART and transfer it to first computer using USB.
We use HYPER TERMINAL software to write on both computers. MXX 232 is used to convert
the USB data into SERIAL data. And external oscillator is used to provide clock signal to PIC.
And resistors are used to limit the current which may burn the IC.
Source Code

#include <18F4550.h>

#fuses
HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL1,CPUDIV1,VREGEN

#use delay(clock=48000000)

#use rs232(UART1, baud=9600, errors)

#define USB_CON_SENSE_PIN PIN_D2

#include <usb_cdc.h>

void usb_debug_task(void)

usb_attached();

usb_enumerated();

usb_cdc_connected();

}
void main(void)

char c;

usb_init_cs();

while (TRUE)

usb_task();

usb_debug_task();

if (kbhit())

c=getc();

if (c=='\n') {usb_cdc_putc('\r'); usb_cdc_putc('\n');}

else if (c=='\r') {usb_cdc_putc('\r'); usb_cdc_putc('\n');}

else {usb_cdc_putc(c);}

if (usb_cdc_kbhit())

{
c=usb_cdc_getc();

if (c=='\n') {putc('\r'); putc('\n');}

else if (c=='\r') {putc('\r'); putc('\n');}

else {putc(c);}

Circuit Diagram

Anda mungkin juga menyukai