I found out what was going wrong. It was a hardware problem. I did not turn on the USB Voltage Regulator in the melabs programmer. So now my PC is recognizing the USB HID.
The problem I’m having now is that I can’t seem to get any data from the PIC to the VB.Net application. My VB application is recognizing that the device is plugged in or unplugged but nothing else. The application never seems to jump into the OnRead event.
I must be missing something. What tells the VB aplication to jump to the OnRead event?
Any suggestions.
Thanks,
Matthew
This is what I have.
Code:
VB.Net----------------------------------------------------------------
'*****************************************************************
' on read event...
'*****************************************************************
Public Sub OnRead(ByVal pHandle As Integer)
' read the data (don't forget, pass the whole array)...
If hidRead(pHandle, BufferIn(0)) Then
' ** YOUR CODE HERE **
' first byte is the report ID, e.g. BufferIn(0)
' the other bytes are the data from the microcontrolller...
TextBox1.Text = Chr(Val(BufferIn(1)))
End If
End Sub
PICB----------------------------------------------------------------------
' ************************************************************
' * main program loop - remember, you must keep the USB *
' * connection alive with a call to USBService every couple *
' * of milliseconds or so... *
' ************************************************************
usbinit ' initialise USB...
ProgramStart:
gosub DoUSBIn
USBBuffer(0)=32
USBBuffer(1)=16
gosub DoUSBOut
goto ProgramStart
Bookmarks