# Sending data from PIC to PC via USB with 18f2550

Status
Not open for further replies.

#### bayabi

##### Newbie level 6
Hey there I want to control my PIC from PC and send feedback from PIC. I can easily control my PIC, however; the pic to PC part does not work. I have defined a function named USB_DATA on C18 on pic side :

Code:
void USB_Data(void)
{
send_data[1] = 1;
if(!mUSBGenTxIsBusy() )
{
USBGenWrite(send_data[1],2);
}
}
and on my PC side I try to read my send_data[1] via :

Code:
	unsigned char Data = 0;

data_in[1] = Data;
while(1)
{
if(Data == 1)
{
cout << "Data_here";
}

if(MPUSBRead(inPipe , data_in, 2, &ActualLength, 1000));
}

Where do I do wrong? I guess I am sending the data right way. But due to the misusage of MPUSBRead function I cant read it on visual side.

Thanks for your helps
Best regards..

#### bayabi

##### Newbie level 6
Is there nobody that can help me? Even an example code for usage of MPUSBRead function would be helpful.

Thank you..

#### klystron

##### Advanced Member level 4
Take a look at this project and code **broken link removed**

electrodarkness

### electrodarkness

Points: 2

#### bayabi

##### Newbie level 6
thank you very much I overcome my problem.

#### PLAAHemantha

##### Newbie level 5
Hi everybody!
I'm also trying to send a numeric value from PIC and get and display it on PC But I can't to success. I want to send a numeric value from PIC and get and display it on PC, or send pulse from PIC then get and count pulses given time interval and display it on PC. Anyone can give schematic, C source code for PIC and VB source code.

Hemantha

Status
Not open for further replies.