|
|
View previous topic :: View next topic |
Author |
Message |
Zeipt Guest
|
#fuses for USB with 16Mhz external |
Posted: Thu Sep 10, 2009 5:51 am |
|
|
Anyone! Please! Help!
I saw datasheets and many forums, but i dont understand WHAT FUSES i must use((((
All clocks and pll dividers makes me crazy with #use_delay...
Can anyone give me any working fuses to start usb cdc serial with 16Mhz external clocks?
Great thanks forward!!! |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Sep 10, 2009 6:23 am |
|
|
I have these setting with PIC18F2455 and 16 MHz crystal
Code: | #FUSES HSPLL //High Speed Crystal/Resonator with PLL enabled
#FUSES PLL4 //Divide By 4(16MHz oscillator input)
#FUSES USBDIV //USB clock source comes from PLL divide by 2
#FUSES CPUDIV2 //System Clock by 3: 32 MHz
#use delay(clock=32000000,RESTART_WDT)
|
|
|
|
Zeipt Guest
|
thanks! i understand this! |
Posted: Thu Sep 10, 2009 6:58 am |
|
|
but my xp sp2 doesnt see pluged usb with my 18f4550(( |
|
|
Zeipt Guest
|
can this be problem? |
Posted: Thu Sep 10, 2009 7:15 am |
|
|
I power my device from usb bus... may be its bad idea and power up timer takes time and usb fails? |
|
|
Ttelmah Guest
|
|
Posted: Thu Sep 10, 2009 7:17 am |
|
|
Then look carefully at:
1) The USB connections. It is surprisingly common to get them reversed....
2) The connection sense pin. Is this enabled in the code?. Is it connected?.
3) The USB Vref connection. You e4ither need 'VREGEN' selected in the fuses, and a capacitor (470nF, seems to work best), on the Vref pin, or an external 3.3v feed to this pin.
4) Remember the PIC needs 5v, for USB applications. To run below this needs external USB Vref, and gices several problems on selecting timings etc..
5) Remember the fuses given here, are only the clock ones. You still need to select other stuff (turn off extended instructions, setup the brownout, watchdog, etc...).
At the end of the day, start by proving the chip is working (toggle a LED on a pin), and at the right CPU frequency (does the LED toggle at the right rate), _before_ getting involved in USB.
Best Wishes |
|
|
Zeipt Guest
|
Ok |
Posted: Thu Sep 10, 2009 7:23 am |
|
|
I`ll check all this and post later with my code... |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Sep 10, 2009 9:23 am |
|
|
Quote: | I power my device from usb bus... may be its bad idea and power up timer takes time and usb fails? |
Seems like you don't yet understand, how USB works. Enumeration of the USB slave doesn't start, before you enable the USB interface, in general by calling usb_init(). (Provided you are using the software controlled USB ident resistor inside the USB PIC).
If the host doesn't see at least an unknown device, the USB interface is either not connected to the bus or not activated.
As Ttelmah mentioned, there are many other possible ways to cause USB failure. So I assume, that you are using an CCS provided USB example and only modify the oscillator fuses according to your hardware.
The device may be recognized but deactived, you can check in system control manager. It's also a good idea to check USB activities on plug-in with a software USB monitor. |
|
|
Zeipt Guest
|
hm... |
Posted: Thu Sep 10, 2009 12:27 pm |
|
|
Thanks for all!
I checked debug rs232 port and with my current used fuses it works properly! And led blinks seconds well.
But there is one interesting thing - when I unplug my device from usb bus, I see
"USB connected Waiting for enumerating..." in RS232 output))
and this happens only on unplugging!
I think the problem is in that capacitor 470.
I ll post here when I check this one! |
|
|
Zeipt Guest
|
not works.. |
Posted: Tue Sep 15, 2009 2:32 pm |
|
|
my current code:
Code: |
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdlibm.h>
#include <string.h>
//set to 1 to use a PIC's internal USB Peripheral
//set to 0 to use a National USBN960x peripheral
#define __USB_PIC_PERIF__ 1
#if !defined(__PCH__)
#error USB CDC Library requires PIC18
#endif
#define USB_CON_SENSE_PIN PIN_B2
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,VREGEN,PUT
#FUSES PLL4 //Divide By 4(16MHz oscillator input)
#FUSES USBDIV //USB clock source comes from PLL divide by 2
#FUSES CPUDIV2 //System Clock by 3: 32 MHz
#use delay(clock=32000000,RESTART_WDT)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
/////////////////////////////////////////////////////////////////////////////
//
// If you are using a USB connection sense pin, define it here. If you are
// not using connection sense, comment out this line. Without connection
// sense you will not know if the device gets disconnected.
// (connection sense should look like this:
// 100k
// VBUS-----+----/\/\/\/\/\----- (I/O PIN ON PIC)
// |
// +----/\/\/\/\/\-----GND
// 100k
// (where VBUS is pin1 of the USB connector)
//
/////////////////////////////////////////////////////////////////////////////
#include <usb_cdc.h>
/////////////////////////////////////////////////////////////////////////////
//
// Configure the demonstration I/O
//
/////////////////////////////////////////////////////////////////////////////
#DEFINE LED1 PIN_B0
#define LED2 PIN_B1
#define LED3 PIN_B2
//#DEFINE BUTTON PIN_A0
#define LED_ON output_low
#define LED_OFF output_high
/////////////////////////////////////////////////////////////////////////////
//
// usb_debug_task()
//
// When called periodically, displays debugging information over serial
// to display enumeration and connection states. Also lights LED1 based upon
// enumeration and status.
//
/////////////////////////////////////////////////////////////////////////////
void usb_debug_task(void) {
static int8 last_connected;
static int8 last_enumerated;
int8 new_connected;
int8 new_enumerated;
static int8 last_cdc;
int8 new_cdc;
new_connected=usb_attached();
new_enumerated=usb_enumerated();
new_cdc=usb_cdc_connected();
if (new_enumerated)
LED_ON(LED1);
else
LED_OFF(LED1);
if (new_cdc)
LED_ON(LED2);
else
LED_OFF(LED2);
if (usb_cdc_carrier.dte_present)
LED_ON(LED3);
else
LED_OFF(LED3);
if (new_connected && !last_connected)
printf("USB connected, waiting for enumeration...\r\n\n");
if (!new_connected && last_connected)
printf("USB disconnected, waiting for connection...\r\n\n");
if (new_enumerated && !last_enumerated)
printf("USB enumerated by PC/HOST\r\n\n");
if (!new_enumerated && last_enumerated)
printf("USB unenumerated by PC/HOST, waiting for enumeration...\r\n\n");
if (new_cdc && !last_cdc) {
printf("Serial program initiated on USB<->UART COM Port\r\n\n");
printf(usb_cdc_putc, "\r\n\nCCS CDC (Virtual RS232) Example\r\n\n");
}
last_connected=new_connected;
last_enumerated=new_enumerated;
last_cdc=new_cdc;
}
void main()
{
char c;
unsigned int zd,zb;
char dirled;
set_tris_d(0);
output_d(0xff);
//set_tris_b(0);
//output_b(0xff);
zb=0x80;
zd=1;
dirled=0;
LED_OFF(LED1);
LED_OFF(LED2);
LED_OFF(LED3);
printf("\r\n\nCCS CDC (Virtual RS232) Example\r\n");
#ifdef __PCH__
printf("PCH: v");
printf(__PCH__);
#else
printf("PCM: v");
printf(__PCM__);
#endif
printf("\r\n");
#if !(__USB_PIC_PERIF__)
printf("USBN: 0x%X", usbn_get_version());
printf("\r\n\n");
#endif
/*LED_ON(LED1);
LED_ON(LED2);
LED_ON(LED3);*/
//delay_ms(1000);
usb_init();
//delay_ms(1000);
while (TRUE) {
ENABLE_INTERRUPTS(GLOBAL);
if(zd == 0x80 && dirled==0)dirled=1;
if(zd == 1 && dirled==1)dirled=0;
output_d(~zd);
//output_b(~zb);
zd=(dirled)? (zd>>1) : (zd<<1);
//zb=zb>>1;
if(zb==0)zb=0x80;
delay_ms(50);
usb_task();
usb_debug_task();
if (kbhit()) {
c=getc();
if (c=='\n') {usb_cdc_putc('\r'); usb_cdc_putc('\n');}
if (c=='\r') {usb_cdc_putc('\r'); usb_cdc_putc('\n');}
else {usb_cdc_putc(c);}
}
if (usb_cdc_kbhit()) {
c=usb_cdc_getc();
if (c=='\n') {putc('\r'); putc('\n');}
if (c=='\r') {putc('\r'); putc('\n');}
else {putc(c);}
}
}
}
|
but even without my leds on port d (which are working good) this code doesnt return me nothing but "usb connected.. waiting for enumerating..."
The capasitor 470nF was set. |
|
|
Ttelmah Guest
|
|
Posted: Tue Sep 15, 2009 2:53 pm |
|
|
Return to my earlier reply. Have you gt the USB VBUS line connected to pin B2 on the chip, with the two resistors as shown in the comments?.
You can get the response you are seeing, if B2 floats high, but is not properly connected...
Best Wishes |
|
|
Zeipt Guest
|
IT WORKS!!! |
Posted: Sat Sep 19, 2009 4:08 am |
|
|
Great thanks to all you!
I resolve my problem. My electric designer make a mistake in B-female on the board))) 3-d and 4-th pins were reversed))) Sorry, for this discussion!)) You said check all, and I`ve checked... and it helps))
GREAT THANKS!!!! |
|
|
Ttelmah Guest
|
|
Posted: Sat Sep 19, 2009 5:08 am |
|
|
He isn't alone!.
That is why I said getting the USB connections wrong is surprisingly 'common'. Unfortunately, the pin ordering on a PCB, seems to repeatedly give problems. I met it when USB was 'young', and one connector manufacturer in the UK, published the connections the opposite way round to another. Took some reseach to actually work out which was right....
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
|