OK, so obviously nobody has any thoughts so far but I have done a little more investigation and found out the probem lies with me using an interrupt to perform the reads...
I started from scratch using Darrells BasicUSB.pbp test program adapted for pic18f2550 4MHz. I wrote a very simple loop that checks for Rx data then sends out the RX buffer straight back to the PC. It sits there quite happily spewing out whatever the last RX data was, everytime I send a new set of data it updates correctly and everything works as expected.
I started adapting this simple routine to become more like my original (faulty) code. The first step was to take the DoUSBIn out of the main loop and into an interrupt driven by TMR2. So now the program runs the main loop where it echoes whatever is in the RX buffer, pauses for 100ms and repeats, whilst TMR2 interrupts when it overflows (no preload, it just keeps running) and checks for received data using the @ ON_USBRX_GOSUB macro. This is where it seems to fail. Basically the data I send the device does not get copied over into the Tx buffer. I also get the same effect as before where after a reset the TX buffer contains whatever the previous RX data was.
I have confirmed that the PC end is working as expected by using a variety of different methods of communicating the device. It is definately the PIC that is not operating as expected.
So I think there is something funny going on with the interrupts, either I am missing some statements somewhere or DT_HID is doing something funny.
Does anybody have any thoughts?
Thanks
Andy
Bookmarks