![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
jmofthenorth
Joined: 27 Sep 2006 Posts: 11 Location: ITHACA,NY
|
usb-pic problems |
Posted: Wed Oct 18, 2006 12:03 pm |
|
|
I'm communicating with a pic via a usb virtual com port and the ccs usb driver (usb_cdc.h). After loading the following code the pc will recognise the pic (loading it as a com port with the correct driver etc, but I can't seem to communicate with it if I use hyperterminal to detect an ascii message. My question is - is something wrong with my circuit or code? If the usb driver is correctly loaded and enumerated then does that indicate that both my rx and tx lines are correctly wired?
Code: | #include <18F2455.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=20000000)
#include <usb_cdc.h>
void main() {
char c;
int16 delay=0;
usb_init();
while(TRUE){
if(usb_enumerated()) {
if (++delay>200) {
delay=0;
printf(usb_cdc_putc,"Hello?\n\r");
}
delay_ms(5);
}
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Wed Oct 18, 2006 2:55 pm |
|
|
The problem is that 'usb_enumerated', does not mean that you have a connection to a program at the other end. 'usb_enumerated', signifies the device is attached to a USB bus, which has a driver present for it.
In usb_cdc.h, you will find another call 'usb_connected', which reflects a program having opened the connection to the PC driver, which then means you can start sending data.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
jmofthenorth
Joined: 27 Sep 2006 Posts: 11 Location: ITHACA,NY
|
|
Posted: Wed Oct 18, 2006 3:45 pm |
|
|
Thanks Ttelmah but that doesn't seem to work. I think the chip may be locking up (although the com port is still initialised). Running a while loop toggling the output of an unused pin causes the pic to toggle the pin for a few seconds before it stops. |
|
![](templates/subSilver/images/spacer.gif) |
peter.kinnear01 Guest
|
Usb issue with 18f65j50 |
Posted: Fri Sep 12, 2008 4:49 am |
|
|
I am having the same issue from what i read, i have the device enumerated, (using usb_cdc) and windows recognized the device and i installed the driver, the funny thing is that every 10min or so the device restarts, i am also toggling a led to see if its alive, and that seems fine, but still cant get HyperTerminal communicating with the device
please tell me if you fix this and how
thanks |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sat Sep 13, 2008 12:57 am |
|
|
Basically, a periodical call to usb_task() is missing in the example. I think, that it should be called also during extended wait periods.
The other point has already been said, sending data without an application connection at the PC side apparently causes the driver to stop servicing the device. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|