we have an application that sends data to a pic then forwards it to another then the result is copied back to the usb port, we found that generally we had problems and that the data would be missed or corrupt if we sent to much data in one go.
it turned out that we could simulate the same problem with the code below on the pic18f4550 by using realterm and sending the following in a text file (there are cr and lf added to the ends)
12345678
12345678
12345678
12345678
12345678
12345678
12345678
123
one char less and it works just fine
the code is same as in the sample provided by SF
Code: Select all
/ device and clock...
Device = 18F4550
Clock = 48
// 20Mhz crystal, 48Mhz internal (FS USB)
Config
PLLDIV = 5,
CPUDIV = OSC1_PLL2,
USBDIV = 2,
FOSC = HSPLL_HS,
VREGEN = ON
// import modules...
Include "usbcdc.bas"
// this event will fire if the DTR line
// from the PC is set or cleared...
Event OnControl()
Output(PORTD.0)
PORTD.0 = DTR
End Event
// assign event handler...
CDC.OnControl = OnControl
// main program loop - this just simply reads a byte from a
// terminal window (for example, SerialCommunicator) and then
// echo it back...
While true
If DataAvailable Then
WriteByte(ReadByte)
EndIf
Wend
firstly, is this a bug?
secondly is there any way round this problem at the pic end?
i was hoping i could flag back to the usb that the buffer is full, like flow control over usb
any help would be great
Richard