CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem usb 18f2550

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
maissa



Joined: 17 Feb 2012
Posts: 8

View user's profile Send private message

Problem usb 18f2550
PostPosted: Tue Apr 10, 2012 11:23 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 10, 2012 12:11 pm     Reply with quote

What is the crystal frequency on your hardware board ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19497

View user's profile Send private message

PostPosted: Tue Apr 10, 2012 12:50 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 10, 2012 4:08 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 10, 2012 4:15 pm     Reply with quote

Read the explanations in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=44817
And also here:
http://www.ccsinfo.com/forum/viewtopic.php?t=40078
maissa



Joined: 17 Feb 2012
Posts: 8

View user's profile Send private message

PostPosted: Tue Apr 10, 2012 4:18 pm     Reply with quote

ok, thank you
Ttelmah



Joined: 11 Mar 2010
Posts: 19497

View user's profile Send private message

PostPosted: Wed Apr 11, 2012 2:09 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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