Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 08, 2024, 02:58:04 14:58


Login with username, password and session length


Pages: [1]
Print
Author Topic: Debugging USB on PIC32 (USB-host HID)  (Read 3801 times)
0 Members and 1 Guest are viewing this topic.
gurksallad
Newbie
*
Offline Offline

Posts: 27

Thank You
-Given: 12
-Receive: 6


« on: January 28, 2020, 08:23:50 08:23 »

I have made a small PCB with a PIC32 on it. Using MCC I configured my project to use USB-host with a HID TPL. Then I extracted the keyboard example from the latest Microchip MLA, and I'm basically using app_host_hid_keyboard.* right into my project, just for testing. I added a lot of debug-messages in the functions as well just to get a grasp of where the code is running. Using MCC I also added a UART, so I can print the debug-messages on there and watch on my PC.

When running the project and attaching a keyboard, I see this on the debug terminal:

Code:
HOST: Initializing DETACHED state.
app_host: Attach keyboard
[>HOST: Starting settling delay.

And then nothing happens. So obviously the code is running, the USB-stack is up, it recognizes a USB-device is inserted, but then goes dead. I have not changed anything in the USB-stack or in the example code from the MLA.

Any tips of where I should go from here?
Logged
UKFlyer
Newbie
*
Offline Offline

Posts: 25

Thank You
-Given: 41
-Receive: 17


« Reply #1 on: January 28, 2020, 11:34:50 11:34 »

If you are outputting the debug messages using polling I would remove them as they will disrupt the timings of the USB. For debugging this sort of thing I use LEDs that can be turned on to indicate progress. This can be done without impacting any timing critical activities.
Logged
towlerg
Senior Member
****
Offline Offline

Posts: 263

Thank You
-Given: 474
-Receive: 104

What is this for?


« Reply #2 on: January 28, 2020, 12:27:18 12:27 »

Join the Axelson (author of USB complete etc.) forum http://janaxelson.com/forum/.
Logged

Win 7 Ult x64 SP1 on HP2570p
gurksallad
Newbie
*
Offline Offline

Posts: 27

Thank You
-Given: 12
-Receive: 6


« Reply #3 on: January 28, 2020, 02:59:08 14:59 »

If you are outputting the debug messages using polling I would remove them as they will disrupt the timings of the USB. For debugging this sort of thing I use LEDs that can be turned on to indicate progress. This can be done without impacting any timing critical activities.

Hm, that's a good point. I do indeed use USB-polling, so maybe that's the problem here.

Unfortunately I cannot add LED's to the board as it's already fabricated, and hand-solder LEDs straight onto a TQFP-48 is a bit tricky. However, I did add a single "activity LED" on the board. Maybe I can bit-bang some binary numbers to that pin and measure with a logic analyzer to get a grasp of where the running code is at.
Logged
gurksallad
Newbie
*
Offline Offline

Posts: 27

Thank You
-Given: 12
-Receive: 6


« Reply #4 on: January 28, 2020, 07:50:35 19:50 »

I poked around a bit and it seems the stack is stuck in this case switch after the keyboard is attached:

Code:
                        case SUBSUBSTATE_WAIT_FOR_SETTLING:
                            // Wait for the timer to finish in the background.
                            LED_Toggle();
                            break;

So it seems that the USB-connection is never settling. Now I just have to find out what that means.
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC