I think that most of my USB problems are solved now!
I rewrote the USB Out routine as such:
Code:
'*******************************************************
'Writing data to USB port
'*******************************************************
DoUSBOut:
USBBufferSizeTX = 0
FOR Counter = 1 TO USBBufferSizeMax 'Calculate number of valid bytes within the string
IF USBBuffer [Counter - 1] > 0 THEN USBBufferSizeTX = USBBufferSizeTX + 1
NEXT Counter
IF TX_READY THEN 'USB data can be transmitted
TX_READY = 0 'Clear USB data send flag
USBOUT 3, USBBuffer, USBBufferSizeTX, DoUSBOut
ENDIF
FOR Counter = 1 TO USBBufferSizeMax 'Clear the USB buffer after data has been sent
USBBuffer [Counter - 1] = 0
NEXT Counter
RETURN
- Fist step is to calculate how many bytes are used in the string (not = 0)
- Second, sending data
- third, blanking the data buffer for next operation
I have no more garbage data in my strings, and I was able to remove the Pause without any data loss. Transmission is very fast now, with over 10kB/s (I have large conversion routines between my DoUSBOut, could even be faster without these).
Now onto other problems, especially getting all the interrupts to work together,and implementing ADC and ultra-low power routine.
What about publishing the generic code for CDC? I'll let you decide since it is actually minor modification to code you have written.
Bookmarks