|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
PIC18F2550 USB interface with PC |
Posted: Mon Jan 25, 2010 11:38 pm |
|
|
I need an example code to interface 18F2550 to PC via USB port. |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
|
bells_electronics
Joined: 05 Dec 2009 Posts: 40
|
|
Posted: Wed Jan 27, 2010 6:15 am |
|
|
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
|
|
Posted: Wed Jan 27, 2010 6:18 am |
|
|
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
|
|
Posted: Wed Jan 27, 2010 10:12 am |
|
|
ex_usb_serial, is setup to use the 20MHz crystal that comes on the demo board.
Best Wishes |
|
|
Guest
|
|
Posted: Mon Feb 01, 2010 2:33 am |
|
|
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
|
|
Posted: Mon Feb 01, 2010 5:35 am |
|
|
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 |
|
|
|
|
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
|