|
|
View previous topic :: View next topic |
Author |
Message |
maissa
Joined: 17 Feb 2012 Posts: 8
|
Problem usb 18f2550 |
Posted: Tue Apr 10, 2012 11:23 am |
|
|
Hi everyone, I have to detect usb connection. I tried to simulate my program in Isis and it works very well but when I program my pic and connect the cable usb nothing happen. Will you help me please to configure fuses bits in the programmer ? I'm using pikprog2elnec and this is my ccs program:
Code: |
#include <18F2550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=20000000)
#define USB_HID_DEVICE TRUE
#define USB_EP1_TX_ENABLE USB_ENABLE_INTERRUPT
#define USB_EP1_TX_SIZE 8
#include <pic18_usb.h>
#include <usb_desc_mouse.h>
#include <usb.c>
#define LED1 PIN_B7
#define LED2 PIN_B6
#define LED_ON output_high
void main(void)
{
usb_init_cs();
LED_ON(LED2);
while (TRUE) {
usb_task();
if (usb_enumerated())
{
LED_ON(LED1);
}
}
}
|
and the Dns FILE
http://img546.imageshack.us/img546/5274/sanstitrejp.jpg |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Apr 10, 2012 12:11 pm |
|
|
What is the crystal frequency on your hardware board ? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19497
|
|
Posted: Tue Apr 10, 2012 12:50 pm |
|
|
Assuming it is 20MHz, then with the fuses posted, the CPU will be running at 48MHz, not 20MHz, so this might well cause problems....
Best Wishes |
|
|
maissa
Joined: 17 Feb 2012 Posts: 8
|
|
Posted: Tue Apr 10, 2012 4:08 pm |
|
|
Yes It s 20Mhz, but i ditn't understand, what do you mean "with the fuses posted, the CPU will be running at 48MHz and not 20MHz" |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
maissa
Joined: 17 Feb 2012 Posts: 8
|
|
Posted: Tue Apr 10, 2012 4:18 pm |
|
|
ok, thank you |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19497
|
|
Posted: Wed Apr 11, 2012 2:09 am |
|
|
Other things possibly wrong in the circuit:
Vusb, does _not_ want a resistor to D- on it. This may well cause problems. This pin is the _output_ of the internal voltage regulator, and you can use your own resistors, to signal to the USB master what type of device you have, _or_ use the internal ones. The standard code has the internal resistors enabled. Note 2, Fig 17-1 in the data sheet:
"The internal pull-up resistors should be disabled (UPUEN = 0) if external pull-up resistors are used.".
There is a further problem, that a pull up on D-, would signal a low speed device, and your code is setup to use full speed, so the device will not enumerate.
On the same pin, you show an electrolytic capacitor, and with the picture (difficult to see), it looks as if it is 470uF. If so, this is _too large_. Recommended capacitor is 200nF to 1uF. Preferably something like a polyester capacitor, not an electrolytic (the latter do not have the high frequency performance required).
Then you show the USB 5v, connected to Vcc , but do not show any decoupling components on this anywhere. You _need_ a small capacitor (perhaps 0.1uF ceramic), _immediately_ adjacent to the PIC, and something slightly larger on the rail (perhaps 4.7uF).
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
|