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

usb-pic problems

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



Joined: 27 Sep 2006
Posts: 11
Location: ITHACA,NY

View user's profile Send private message

usb-pic problems
PostPosted: Wed Oct 18, 2006 12:03 pm     Reply with quote

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);

      }
  }
}
Ttelmah
Guest







PostPosted: Wed Oct 18, 2006 2:55 pm     Reply with quote

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
jmofthenorth



Joined: 27 Sep 2006
Posts: 11
Location: ITHACA,NY

View user's profile Send private message

PostPosted: Wed Oct 18, 2006 3:45 pm     Reply with quote

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.
peter.kinnear01
Guest







Usb issue with 18f65j50
PostPosted: Fri Sep 12, 2008 4:49 am     Reply with quote

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
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Sep 13, 2008 12:57 am     Reply with quote

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.
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