View previous topic :: View next topic |
Author |
Message |
kiewic
Joined: 24 Apr 2010 Posts: 10
|
18F2550 USB not working |
Posted: Sun Apr 25, 2010 10:48 pm |
|
|
Hi! I'm trying to connect my pic with my computer using the USB port. When I connect it, I get the following error:
Quote: |
USB Device not Recognized. One of the USB devices attached to this computer has malfunctioned, and Windows does not recognize it.
|
I'm using the following code:
Code: |
#include <18F2550.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC //Internal RC Osc INTRC
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //No brownout reset NOBROWNOUT
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES PUT //No Power Up Timer NOPUT
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES PBADEN //PORTB pins are configured as analog input channels on RESET
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES MCLR //Master Clear pin enabled
#FUSES LPT1OSC //Timer1 configured for low-power operation
#FUSES XINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode) NOXINST
#FUSES PLL5 //Divide By 12(48MHz oscillator input) PLL12
#FUSES CPUDIV1 //System Clock by 4 CPUDIV4
#FUSES USBDIV //USB clock source comes from PLL divide by 2
#FUSES VREGEN //USB voltage regulator enabled
#include <usb_cdc.h>
#use delay(clock=48000000)
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
output_high(PIN_C1);
// USB Port
usb_cdc_init();
usb_init();
usb_task();
if (usb_enumerated()) {
delay_ms(50);
printf(usb_cdc_putc,"\rHeeeeello!");
}
}
|
And the following circuit, with internal oscillator:
What could be wrong? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Apr 26, 2010 1:17 am |
|
|
You're trying to run the USB module from the internal oscillator.
Download the 18F2550 data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/39632e.pdf
Look at the block diagram of the 18F2550 oscillator on page 26.
I don't see any connection between the Internal Oscillator Block
and the USB Oscillator section. For comparison, look at the
18F26J50 data sheet. It does show a connection between the
internal oscillator and the USB section.
The standard way that all the CCS examples do it, is to use an
external 20 MHz crystal (with 22 pf caps). This is divided down
by 5 (with the PLL5 fuse) to create the 4 MHz input clock required
by the USB PLL section.
Here you're using the Extended Instruction set mode. But CCS doesn't
support it, and enabling it will crash the program. Change it to NOXINST. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Mon Apr 26, 2010 4:37 am |
|
|
Even on the 46/26J, there is a 'caveat', that you can only run the USB at low speed on the internal oscillator. For high speed operation, the oscillator doesn't meet the USB timing requirements...
The oscillator in the 4550, doesn't even get close, hence the lack of connection.
Best Wishes |
|
|
kiewic
Joined: 24 Apr 2010 Posts: 10
|
|
Posted: Tue Apr 27, 2010 8:58 pm |
|
|
I went to the electronics store and bought a crystal oscillator of 20 MHz and now everything works perfectly!
Thank you very much for your help. I thought the internal oscillator was fully equal to an external oscillator. |
|
|
Renjith_Beginow
Joined: 21 May 2014 Posts: 12
|
|
Posted: Wed May 21, 2014 5:37 am |
|
|
Hiii,
I am using 18F26J50, and i am trying implement USB, but its showing the device not recognized,
Can any one help with a working code and oscillator configuration, i think my oscs configuration is creating pblm |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Wed May 21, 2014 8:51 am |
|
|
#FUSES HSPLL, NOWDT, PLL3, NOXINST, NOCPUDIV, NOFCMEN, NOIESO, NOIOL1WAY
With a 12MHz crystal. CLOCK=48MHz.
Remember key differences on this chip, no USB regulator, so you need an external source of 3 to 3.6v fed into the Vusb pin. The chip can run off 2.35v to 3.6v, so simplest is to run off 3.3v, and connect Vusb to this as well. |
|
|
|