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 support@ccsinfo.com

Problem with CDC driver

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



Joined: 24 Jun 2005
Posts: 206

View user's profile Send private message Send e-mail

Problem with CDC driver
PostPosted: Wed Jul 12, 2006 4:34 am     Reply with quote

Hi All, i have decided that my fish tank conntroller that i am building need to have USB support. Anyway, i am using a PIC18F4550 with the usb_serial example. When i plug the usb cable in, windows detects the device as unknown, and then fails to install saying that the device has malfunctioned. I then tired to install the cdc driver, but windows tells me that the file does not contan any information about my device. I have also tried to install the driver by right clicking on it, but it did not help.

I have three questions about the usb_serial example;
1. are the internal pullups enabled and
2. in the internal 3.3 regulator enabled and
3. I am using a 20MHz cryistal. Is this OK?

Can anybode shed some light on my problem??

Thanks, Mark
jspencer



Joined: 22 Dec 2003
Posts: 57
Location: Boise, ID USA

View user's profile Send private message

Re: Problem with CDC driver
PostPosted: Wed Jul 12, 2006 9:26 am     Reply with quote

Markdem wrote:


I have three questions about the usb_serial example;
1. are the internal pullups enabled and
2. in the internal 3.3 regulator enabled and
3. I am using a 20MHz cryistal. Is this OK?

Can anybode shed some light on my problem??

Thanks, Mark


1. I can't remember if the pullups are enabled by default or not, but if you want to be sure then in your main enable or disable them.

2. If you didn't mess with any of the code below, then yes the 3.3V internal regulator is enabled.

3. Again, if you didn't mess with the code below then the 20MHz crystal is fine. Because of the fuses that are set it uses the 20MHz input and the internal PLL to set the clock speed at: clock=48000000 (48MHz)

Code:

#define __USB_PIC_PERIF__ 1

#if !defined(__PCH__)
 #error USB CDC Library requires PIC18
#endif

#if __USB_PIC_PERIF__
 #DEFINE LED1  PIN_A5
 #include <18F4550>
 #fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
 #use delay(clock=48000000)

///  Ignore the code from here down as you are not using this chip
#else //use the National USBN960x peripheral
 #DEFINE LED1  PIN_B3
 #include <18F452>
 #fuses HS,NOWDT,NOPROTECT,NOLVP
 #use delay(clock=20000000)
#endif   //endif check to see which peripheral to use
Markdem



Joined: 24 Jun 2005
Posts: 206

View user's profile Send private message Send e-mail

PostPosted: Wed Jul 12, 2006 3:57 pm     Reply with quote

thanks jspencer. but i am still having problems. It almost looks like more of a windows issue then a pic issue. I have now tried installing it on 2 diffrent computers, and all of them tell me that the device has malfunctioned. Has anyone else had this problem or suggest what i can do to try to fix it.

Thanks, Mark
jspencer



Joined: 22 Dec 2003
Posts: 57
Location: Boise, ID USA

View user's profile Send private message

PostPosted: Wed Jul 12, 2006 4:38 pm     Reply with quote

One other thing, CCS uses the default product and vendor ids for both the two different types of USB devices that I've used (CDC and HID). If you have installed used the HID device and then try to use the CDC device without uninstalling the HID device or changing the Product ID (usb_cdc_desc file), windows thinks that it is still and HID device. Open your device manager, right click on My Computer and select properties, then select device manager. Under the device (HID or COM port) you can look at the VID and PID for the device. Since there is an error with the device you should have a device in the list with a yellow circle with a question mark in it. Try uninstalling it and then unplug the usb cable, wait a few seconds and then plug it back in and see if it fixes your problem.

This may not be the problem, but is something I ran into when we ported our product from an HID device to a CDC device.

One more note, make sure that the PID and VID values that are in the CDC driver match the values that are in the usb_cdc_desc file.h file.
Markdem



Joined: 24 Jun 2005
Posts: 206

View user's profile Send private message Send e-mail

PostPosted: Wed Jul 12, 2006 7:14 pm     Reply with quote

Thanks again for you suggestions. Should the cdc drivers just work without me changing them??

anyways, i have checked PID and VID of the driver and usb_desc_dcd. Can you please tell me if they are correct. it looks like they have to be read from left to right.

cdc_NTXP.inf

[ccs]
%CCS_CDC%=Reader, USB\VID_0461&PID_0033


usb_desc_cdc.h

0x61,0x04, //vendor id
0x33,0x00, //product id

Thanks again for your help

Mark
Markdem



Joined: 24 Jun 2005
Posts: 206

View user's profile Send private message Send e-mail

PostPosted: Thu Jul 13, 2006 5:40 am     Reply with quote

OK, i have done some more testing, and i think it may be my hardware.
When i look at device manager, the pid and vid are 0000, which i am going to guess is incorrect. Also, if i swap the d+ and d- pins on the pic, the PC will still see the device and give me the same error.

At this point I have two more questions..
1. I have looked at a lot of USB designs on the web, and all the connections between the PC and pic all seem to be diffrent. My connections looks like the following, is it correct??

Code:
USB Connector                  PIC
PIN1(5v)                           (This pin is not connected to anything on my PIC board)
PIN2(D-)                           PIN_C4
PIN3(D+)                          PIN_C5
PIN4(GRD)                        Device ground


2.How do I enable the internal pullups? I have read the dtasheet, and know the register i need to change, but i am new to this and have never changed a register myself. How do I go about it.

Thanks again

mark
Markdem



Joined: 24 Jun 2005
Posts: 206

View user's profile Send private message Send e-mail

PostPosted: Thu Jul 13, 2006 5:57 am     Reply with quote

One more problem, when i compile the code i get the following warning

Warning 202 "C:\PROGRA~1\PICC\drivers\usb_desc_cdc.h" Line 147(16,37): Variable never used: USB_CLASS_DESCRIPTORS

Is this somthing that i should care about??

Thanks, Mark
jspencer



Joined: 22 Dec 2003
Posts: 57
Location: Boise, ID USA

View user's profile Send private message

PostPosted: Thu Jul 13, 2006 11:04 am     Reply with quote

The PID and VID look good. The pin out looks good for the USB and since you do not have +5 connected to anything, I'm assuming that your board is self powered. As for the pullups the quote below was taken directly from the CCS manual. Replace x with the port that you need to pullup. Just make sure that the pullups are available for the port that you are using.

Quote:

PORT_X_PULLUPS

Syntax:
port_x_pullups (value)

Parameters:
value is TRUE or FALSE on most parts, some parts that allow pullups to be specified on individual pins permit an 8 bit int here, one bit for each port pin.

Returns:
undefined

Function:
Sets the port A input pullups. TRUE will activate, and a FALSE will deactivate.

Availability:
Only 14 and 16 bit devices (PCM and PCH). (Note: use SETUP_COUNTERS on PCB parts).

Requires
Nothing

Examples:
port_a_pullups(FALSE);

Example Files:
ex_lcdkb.c with kbd.c

Also See:
input(), input_x(), output_float()


What size cap do you have on the Vusb line? You should have a 0.47uF cap to ground on that line.

The warning you are getting I'm not sure about. What version of the compiler are you using? That might help. I used 3.239 and it is compiling fine.
Markdem



Joined: 24 Jun 2005
Posts: 206

View user's profile Send private message Send e-mail

PostPosted: Thu Jul 13, 2006 4:09 pm     Reply with quote

Thanks for your help jspencer, what do you mean Vusb. Do you mean the 5v+ line that is coming from my PC? I dont currently have any caps there. I will try tonight.

my compiler version is 3.236. Maybe there could be a problem there. Is it possible, if it is not too much hassle, that you could email me your hex file. That way, at least i will stop wasting time trying to fix this.

My address is markdem(at)optushome.com.au

thank you again for your help.

Mark
jspencer



Joined: 22 Dec 2003
Posts: 57
Location: Boise, ID USA

View user's profile Send private message

PostPosted: Thu Jul 13, 2006 4:19 pm     Reply with quote

C3/Vusb needs a 0.47uF cap on it. This is for the USB voltage regualtor.
Markdem



Joined: 24 Jun 2005
Posts: 206

View user's profile Send private message Send e-mail

PostPosted: Sun Jul 16, 2006 7:13 pm     Reply with quote

Thankyou so much jspencer, i dont know how i missed that. It all looks good now

Thanks, Mark
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