zeeshan ahmed
Joined: 02 Dec 2010 Posts: 22
|
help required in usb to serial converter 18f4550 |
Posted: Tue Feb 08, 2011 12:58 am |
|
|
Hi all, I'm new to ccs. I need help regarding USB to UART converter. I'm using pic18f4550 usb microcontroller. I setup my controller as CDC usb Device. Have a look at my simple code.
For testing purpose I am just sending characters to see what happens.
Code: |
#include <18F4550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)
#use rs232(baud=38400,xmit=PIN_C6, rcv=PIN_C7 )
#include <usb_cdc.h>
#define LED1 PIN_A5
#define LED2 PIN_B4
#define LED3 PIN_B5
#define LED_ON(x) output_high(x)
#define LED_OFF(x) output_low(x)
#define PBTN() !input(PIN_D6)
void main(void)
{
char c;
LED_OFF(LED1);
LED_OFF(LED2);
LED_OFF(LED3);
usb_init();
while (TRUE)
{
usb_task();
if (kbhit())
{
c=getc();
usb_cdc_putc(c);
}
if (usb_cdc_kbhit())
{
c=usb_cdc_getc();
putc(c);
}
}
}
|
Actually it works fine but when I input plenty of characters (data) my PC hangs up.
Please help ASAP.
Thanks in Advance |
|