|
|
View previous topic :: View next topic |
Author |
Message |
Viotronics
Joined: 10 Oct 2009 Posts: 5 Location: Mexico
|
PIC18F2450 USB PROBLEM |
Posted: Sat Nov 14, 2009 11:06 am |
|
|
Hi there!
I'm trying to implement the ex_usb_serial.c with the PIC18F2450, but I'm getting the Windows error message that USB device unkown, if I try with the pic18F4550 it works just fine.
I know the PIC18F2450 it's working because I used a endless loop to blink a led to 1 Hz.
But I can't make it work with USB, it just hangs.
In advance thanks a lot, and Happy Thanks Givings Day.
Code: |
#include <18F2450.h>
#device adc=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HSPLL //Crystal/Resonator with PLL enabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES PUT //Power Up Timer
#FUSES VREGEN //USB voltage regulator enabled
#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 LPT1OSC //Timer1 configured for low-power operation
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOPBADEN //PORTB pins are configured as digital I/O on RESET
#FUSES BBSIZ2K //2K words Boot Block size
#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 NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES PLL3 //Divide By 3(12MHz oscillator input)
#FUSES USBDIV //USB clock source comes from PLL divide by 2
#FUSES CPUDIV2 //System Clock by 4
#use delay(clock=48000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
//#define USB_CON_SENSE_PIN PIN_B2
#include <usb_cdc.h>
/////////////////////////////////////////////////////////////////////////////
//
// Configure the demonstration I/O
//
/////////////////////////////////////////////////////////////////////////////
#define LED1 PIN_C1
#define LED2 PIN_C2
#define LED3 PIN_B0
#define LED_ON output_low
#define LED_OFF output_high
void main(void)
{
char c;
port_b_pullups ( TRUE );
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2|ADC_TAD_MUL_0);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
LED_OFF( LED1 );
LED_ON( LED2 );
usb_init();
LED_ON( LED1 );
LED_OFF( LED2 );
while (TRUE)
{
usb_task();
if (usb_cdc_kbhit())
{
c=usb_cdc_getc();
usb_cdc_putc( c );
}
}
} |
|
|
|
Ttelmah Guest
|
|
Posted: Sun Nov 15, 2009 3:23 am |
|
|
Did the LED actually flash at the frequency you programmed?. It shouldn't.....
Selecting CPUDIV2, gives the binary pattern '01', for the CPUDIV fuses. This gives 96MHz /3, for the CPU clock rate = 32MHz.
The CPUDIV 'numbers' for CCS, are the divisions when used directly from the master clock. These change when using the PLL.
You need to correct this.
Also, what capacitor have you got on the USB regulator pin?. Some versons of the 2550, seem 'fussier', than the 4550. Use a 470nF polyester, or a small Tantalum (1uF).
Final thing, triple check the bus connections....
Best Wishes |
|
|
Viotronics
Joined: 10 Oct 2009 Posts: 5 Location: Mexico
|
Thanks |
Posted: Mon Nov 16, 2009 9:50 am |
|
|
I'm using a 0.1 uF Tantalum capacitor and a 10 uF bypass electrolytic capacitor connected to VDD and GND.
I'm going to check my configuration fuses and measure the frequency.
Thank you!
Hasta la vista amigo |
|
|
Ttelmah Guest
|
|
Posted: Mon Nov 16, 2009 10:54 am |
|
|
Vdd to GND, is _not_ the Vusb connection. Vusb is a separate pin (Pin14 on the 2550), and requires it's _own_ decoupling capacitor to GND. You have the 'choice' of providing this capacitor, and enabling the internal regulator, or feeding your own regulated 3.3v supply into the Vusb pin. USB will not work without this. Your fuses have the internal regulator enabled.
Best Wishes |
|
|
Viotronics
Joined: 10 Oct 2009 Posts: 5 Location: Mexico
|
|
Posted: Tue Nov 17, 2009 12:12 pm |
|
|
I found the failure , it was the capacitor connected to Vusb!
I changed it and the PIC worked flawlessly
Thanks a lot! |
|
|
|
|
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
|