PDA

View Full Version : Debugging USB Project



Dave-S
25th June 2017, 20:17
Hi,

What is it best to use to debug USB code?
I have mainly used a serial output for debugging for other projects but it slows the USB code, I could only get serial to work at 9600 (TRUE) and that was only after adding "100" in "PACE" before that it was gibberish. Have tried at 57600 and 115200 with various Pace setting and get either nothing or gibberish. Calculating for True you get a negative figure, can you use this? or should I change to inverted?

Thanks David

hadv215
25th June 2017, 21:40
In the section User Files you can find two USB HID monitors (one by JohnGB, one by me). You can send to the device and, of course receive and monitor the bytes being transferred both binary and ascii.
There's also a Command And Record tool that allows you to specify commands and their parameters and build records for commands. These records can be 'played' using the monitors and, if you specify expected results, used to test the responses.

Regards
Harm

Dave-S
26th June 2017, 17:50
In the section User Files you can find two USB HID monitors (one by JohnGB, one by me). You can send to the device and, of course receive and monitor the bytes being transferred both binary and ascii.
There's also a Command And Record tool that allows you to specify commands and their parameters and build records for commands. These records can be 'played' using the monitors and, if you specify expected results, used to test the responses.

Regards
Harm

Have tried both of those but did not show my USB Device, so have been using the Advanced USB Monitor. It was to debug the Pic proton code I was looking for advice on.

Thanks David

towlerg
26th June 2017, 18:39
It was to debug the Pic proton code I was looking for advice on.

I think hadv215 coming from the perspective that USB comms are central to the project. If you have a situation (which sounds like yours) where USB is just a small part eg. a USB bootloader, then perhaps you could disable that sub-system and debug in whatever way suits you.

Of course, can use the USB port as a serial port, configure the USB as CDC and instead of doing Hserout or whatever, write to the USB buffer - the PC will see the data as if it came from a COM port.

hadv215
27th June 2017, 12:20
George, you're quite right. It is aimed at monitoring the, more or less continuous, exchange betweend PC and Pic.

Dave-S
27th June 2017, 21:44
USB is central to the project, a dual function Audio/Composite USB Device, a Midi Controller with a PC setup facility. The Advanced USB monitor works ok on the PC USB side but need something on the Pic Proton code side as the serial slows everything down and effects the timing.

towlerg
27th June 2017, 22:43
Well, if you're building a composite device, you can add a CDC or custom HID and use that for your debug.

hadv215
27th June 2017, 23:37
That explains why my monitor does not see your device, it's HID only.

towlerg
28th June 2017, 16:07
If it's not proprietary, I'd be very interested to see you're descriptor. BTW are you using native USB (USBin etc.) or Les's port of the MicroChip stack?

Dave-S
7th July 2017, 19:05
If it's not proprietary, I'd be very interested to see you're descriptor. BTW are you using native USB (USBin etc.) or Les's port of the MicroChip stack?

It uses Les's port of the MicroChip stack.
Descriptor attached.


3317

towlerg
9th July 2017, 19:06
Dave, thanks for the descriptor. Where did you get USB_Defs_Midi.inc and USB_MemAlloc2.inc?

towlerg
10th July 2017, 14:16
Dave, I did a little research (basically read, well skimmed actually) Gabi's thread "USB Midi Class Streaming".

I realised that Les's port does not support Midi, did you port that bit yourself? If so can you post an overview of what was involved, as I think it would be great to get CDC working.

Dave-S
10th July 2017, 14:33
Dave, thanks for the descriptor. Where did you get USB_Defs_Midi.inc and USB_MemAlloc2.inc?

From "Users/David/PDS/samples/new samples/Proton_USB_HID_Stack" adapted USB_Defs.inc

towlerg
10th July 2017, 16:01
Sorry Dave, I must be having a not very sharp day. In the HID examples that come with Les's port, "USB_System.inc" and "USB_UserHID.inc" are included at the end of the descriptor but you don't (obviously because you are using Midi not Hid). Do you not need some Midi equivalent?

Dave-S
13th July 2017, 21:43
Using information from the usb org.
http://www.usb.org/developers/docs/devclass_docs/midi10.pdf
In the appendix it gives examples.