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

PIC18F4550 USB Unknown Device

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



Joined: 26 Oct 2011
Posts: 6

View user's profile Send private message

PIC18F4550 USB Unknown Device
PostPosted: Wed Oct 26, 2011 2:27 pm     Reply with quote

Hi! I'm using Proteus to connect by Virtual USB the PIC18F4550 to my PC (as a CDC). Using an example (compiled in PCWH 4.033) it works fine! But, using the PCWHD 4.120, when I compiled it, the COM doesn't appear any more in Device Manager, and appears like "Unknown Device". Looking for details, I see that PID and VID are zero (0x0000), when I configured into usb_desc_cdc.h. Does anybody know about this?

Code:

#include <18F4550.h>
#device adc=10
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)


 #define USB_CON_SENSE_PIN PIN_B2

 #include <usb_cdc.h>


void main() {
   BYTE i, j, address, value;

   int16 q,q1;
   float p;

   q1=0;
   
   setup_adc_ports(AN0|VSS_VDD);
   setup_adc(ADC_CLOCK_INTERNAL);
   set_adc_channel(0);

   usb_cdc_init();
   usb_init();

//      while(!usb_cdc_connected()) {}

   do {
      usb_task();
      if (usb_enumerated()) {

      delay_ms(500);
      q = read_adc();
      if (q!=q1){
      p = 5.0 * q / 1024.0;
      printf(usb_cdc_putc,"\r Voltage=%01.2fV", p);
      }
      q1=q;
   }
      } while (TRUE);
}

Thanks!
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Wed Oct 26, 2011 2:58 pm     Reply with quote

Are you sure the compiler is looking at the _right_ files. If you have both compilers installed, or the new one is in a different directory, and you are working from a 'project' (IDE, rather than command line), you have to manually update the file directories used from the project properties. The entire structure of the usb include files changed at about v4.100, and it sounds like you might be using at least one of the older files....

Best Wishes
pinomarcelo



Joined: 26 Oct 2011
Posts: 6

View user's profile Send private message

PIC18F4550 USB Unknown Device
PostPosted: Thu Oct 27, 2011 4:19 am     Reply with quote

Hello, thanks for answering! I have installed only PCWHD 4.120. I know the example was compiled with 4.033 because the *.lst file says. Using the original
HEX file, or an example from Proteus, works fine, but compiling the C file, I get "unknown device". i tried a lot of changes, but nothing. Could anybody send me the verified files involved in USB communication?
I will replace files, then will find wich file has the problem.

usb_desc_cdc.h
usb_desc_cdc.h
usb_cdc.h
pic18_usb.h
usb_hw_layer.h
pic18_usb.c
usb.c
usb.h

Thanks a lot!
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Oct 27, 2011 5:16 am     Reply with quote

I'm with 'T" on this, sounds like a bad/incorrect installation NOT your 4550 program.
Obvious place to start is to remove your current PCWHD totally, then do a fresh install into a new subfolder(say ....\4120\).Create a new project(the ex_usb_serial.c is a good choice) and see what happens.
It's always best to go back to known good code/setups/etc. thatn trying to 'change this, copy that' approach.
pinomarcelo



Joined: 26 Oct 2011
Posts: 6

View user's profile Send private message

PIC18F4550 USB Unknown Device
PostPosted: Thu Oct 27, 2011 10:25 am     Reply with quote

Nothing at all. Fresh install of PCWHD 4.120 and untouched drivers and libraries. I used the example included into CCS compiler "ex_usb_serial.c". I compiled without problems, but again: When I connect the PIC18F4550 to the PC, appears like "Unknown Device". The PID and VID remains "0x0000". So strange! Does the compiler or library have errors? Has somebody used the example "ex_usb_serial.c"? Did it work?
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Oct 27, 2011 11:31 am     Reply with quote

I've used the example for the past few days on my Windows XP Pro machine.
When you open up 'device manager' you should see a new comport( COM4 in my case).
If in yellow, you'll need to install the driver that CCS supplies(cdc_NTXP.inf) in the examples or driver folder.
pinomarcelo



Joined: 26 Oct 2011
Posts: 6

View user's profile Send private message

PIC18F4550 USB Unknown Device
PostPosted: Thu Oct 27, 2011 1:00 pm     Reply with quote

Hello. Thanks for the ideas. Based on the last comment, I edited the driver (X:\Program Files\PICC\Drivers\NT,2000,XP,VISTA,7\cdc_NTXPVista.inf) in the following lines:

[CCS]
%CCS_CDC%=Reader, USB\VID_0000&PID_0000
%CCS_CDCBOOT%=Reader, USB\VID_0000&PID_0000
[CCS.NTamd64]
%CCS_CDC%=Reader, USB\VID_0000&PID_0000
%CCS_CDCBOOT%=Reader, USB\VID_0000&PID_0000

Then, I forced Windows 7 to update the driver of the "Unknown Device" looking for this modified file. Found it, and generated a new COM port. I tried the program and communicates fine!!!
BUT (there is always a "but")
I can't leave it this way. It must work with the correct PID(000A or 0033) and VID(048D or 0461).

Why the PIC doesn't send the correct PID and VID to the PC?
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Oct 27, 2011 1:14 pm     Reply with quote

From what I've scanned in the file 'usb_desc_cdc.h', about 1/2 way down, just below 'start device descriptors' is the area with the VID and PID information.

Maybe your version of this file is corrupted, or maybe Windows 7 is reading the data wrong ?

All I know is that under XP PRO I get VID of 0461 and PID of 0033 when I open the properties of the USB-COM4 driver. And it works. This from an old DOS guy who hates Windows and wonders WHY it take 8500 lines of code to do serial communications these dayze !

Trying to help but don't have '7'. Maybe someone else has ?
pinomarcelo



Joined: 26 Oct 2011
Posts: 6

View user's profile Send private message

PIC18F4550 USB Unknown Device
PostPosted: Fri Oct 28, 2011 4:18 pm     Reply with quote

I'm going crazy! Win XP, new installation of PICC, compile ex_usb_serial.c, I connect USB and get again, VID=0000 and PID=0000 in the device manager. At least we know, the problem isn't the version of Windows.
PCWHD 4.120, Installed, compiling ex_usb_serial.c... desn't work, even windows 7 or XP.
rtrombetta



Joined: 14 Oct 2011
Posts: 8

View user's profile Send private message MSN Messenger

PostPosted: Fri Oct 28, 2011 4:35 pm     Reply with quote

Did you put a 470n cap between Vusb and GND ?
pinomarcelo



Joined: 26 Oct 2011
Posts: 6

View user's profile Send private message

PIC18F4550 USB Unknown Device
PostPosted: Mon Oct 31, 2011 5:26 am     Reply with quote

Yes sir! The same circuit, using a firmware compiled by the author of the book works 100%. The same circuit, using a firmware compiled by me (same source C file), doesn't work, until I set the PID and VID to zero in the driver inf file. Then it works, but the PID and VID zero is wrong, it can't stay that way. The problem is now centred only in the declaration of Vendor (VID) and Product (PID) from the PIC. Everithing else work fine. I'm thinking the string in usb_init() doesn't have the right parameters. I will get an USB scope, may be that way I can find where is the mistake.
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Oct 31, 2011 7:20 am     Reply with quote

Maybe try an older version of the compiler? I know 4.114 works fine using the ex_usb_serial.c from CCS as well as several 'homebrewed' test programs in the past week or so.

hmm.. do you have the 'connect sense ' resistor setup installed ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Mon Oct 31, 2011 9:48 am     Reply with quote

I'd put a USB bus monitor on the PC. There are several free ones that work well, and then 'watch' the enumeration transaction.
You should be able to view the entire transaction, and see what bytes actually transfer. I really have to suspect something like a timing error in the enumeration, but this doesn't seem to make sense when you say the example runs if you change the inf file to have VID/PID=0, since even if enumerated, I'd then expect the data to be corrupted.....
Triple check what the fuse settings are 'in the firmware compiled by the author of the book'. Load it into something like MPLAB, and compare every fuse with the ones you are using.

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