CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

help required in usb to serial converter 18f4550

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
zeeshan ahmed



Joined: 02 Dec 2010
Posts: 22

View user's profile Send private message

help required in usb to serial converter 18f4550
PostPosted: Tue Feb 08, 2011 12:58 am     Reply with quote

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. Confused

Please help ASAP.
Thanks in Advance
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Tue Feb 08, 2011 9:46 am     Reply with quote

I'd say you're overflowing the PIC UART and it's locked up. Always add ERRORS to #use rs232!

I would also use interrupt-driven serial routines. See EX_SISR.C and EX_STISR.C in the CCS examples.
_________________
Andrew
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group