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

usb on pic18f4550

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



Joined: 12 Feb 2008
Posts: 14

View user's profile Send private message

usb on pic18f4550
PostPosted: Wed Sep 03, 2008 3:59 pm     Reply with quote

I need to use usb with pic, i use this code:
Code:
#include <usb_cdc.h>
...
void usb_string(void){
   int i;
   for(i=0;;i++){   
      if(string[i]!='\0'){  //se a posição não estiver vazia
         usb_task();
         if(usb_enumerated())
            usb_cdc_putc(string[i]);
      }
      else
         return;
   }
}

.....

void main()
{
....
usb_cdc_init();
usb_init_cs();
...
sprintf(string,"%lu",value);          //send a value to pc
usb_string();
...
}

I need some help, it doesn't send any value to pc.
I use the program rogercom, to receive in pc.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Sep 03, 2008 11:47 pm     Reply with quote

I doubt, that it can work to call the work function usb_task() only when sending data. I suggest to setup your application close to the provided CDC examples. I can confirm, that they are basically operational.

This implies servicing usb_task() continuously and unconditionally during application lifetime and sending data on demand.

Another point, I'm not yet sure about. You can apparently manage to lock the CDC driver when sending data without an application connected to it at the PC side. usb_enumerated() doesn't signal a connected application. One suggestion is to utilize usb_cdc_connected() no know the connection status.
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