View previous topic :: View next topic |
Author |
Message |
madeiras
Joined: 12 Feb 2008 Posts: 14
|
usb on pic18f4550 |
Posted: Wed Sep 03, 2008 3:59 pm |
|
|
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
|
|
Posted: Wed Sep 03, 2008 11:47 pm |
|
|
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. |
|
|
|