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 CCS Technical Support

PIC18F2550 USB interface with PC

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








PIC18F2550 USB interface with PC
PostPosted: Mon Jan 25, 2010 11:38 pm     Reply with quote

I need an example code to interface 18F2550 to PC via USB port.
ELCouz



Joined: 18 Jul 2007
Posts: 427
Location: Montreal,Quebec

View user's profile Send private message

PostPosted: Mon Jan 25, 2010 11:44 pm     Reply with quote

http://lmgtfy.com/?q=pic18f2550+pc+ccs+usb
_________________
Regards,
Laurent

-----------
Here's my first visual theme for the CCS C Compiler. Enjoy!
bells_electronics



Joined: 05 Dec 2009
Posts: 40

View user's profile Send private message

PostPosted: Wed Jan 27, 2010 6:15 am     Reply with quote

i have burnt the example "ex_usb_serial" in PIC18F4550 now i want to know which crystall should i use.
do i need to install any driver in my windows so that it gona detect PIC
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Jan 27, 2010 6:18 am     Reply with quote

You don't need a driver, but cdc_NTXPVista.inf provided in the Drivers folder. If you use your own VID/PID codes,
you have to modify the *.inf file of course.
Ttelmah
Guest







PostPosted: Wed Jan 27, 2010 10:12 am     Reply with quote

ex_usb_serial, is setup to use the 20MHz crystal that comes on the demo board.

Best Wishes
Guest








PostPosted: Mon Feb 01, 2010 2:33 am     Reply with quote

Should I require 20Mhz or 48Mhz ??
Code:

#define __USB_PIC_PERIF__ 1

#if !defined(__PCH__)
 #error USB CDC Library requires PIC18
#endif

#if __USB_PIC_PERIF__
 #DEFINE LED1  PIN_A5

 #include <18F4550.h>
 #fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
 #use delay(clock=48000000)
#else //use the National USBN960x peripheral
 #DEFINE LED1  PIN_B3
 #include <18F452.h>
 #fuses HS,NOWDT,NOPROTECT,NOLVP
 #use delay(clock=20000000)
#endif   //endif check to see which peripheral to use

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
Ttelmah
Guest







PostPosted: Mon Feb 01, 2010 5:35 am     Reply with quote

It uses a 20MHz crystal, to clock the chip at 48MHz.
The USB 'clock source', always requires 4MHz. The 'PLL5' entry, says 'take the external oscillator, and divide this by 5, to get the required 4MHz'. Hence 20MHz must be used. This frequency is then multiplied internally by 24, to generate 96Mhz. This is then fed to the USB circuitry. Then the HSPLL setting says that the CPU should be fed from this source (rather than directly from the crystal), and the CPUDIV1 setting says to take this and divide it by 2 (totally confusing, but the same bit pattern is used to divide by 1, when feeding from the external clock, rather than the PLL).

So the code requires a 20MHz crystal, and the timings set to run at 48MHz.

Best Wishes
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