Test one clear action that you can see on the PC. Keep the first test small so that you can tell whether the USB connection works before adding other hardware or application code.
Connect the programmed board to the PC. The computer reads the board's USB information, gives it an address and selects its configuration. This first connection process is called enumeration. When it finishes, USB_Configured becomes 1.
|
Class |
First useful test |
|
HID data |
Open the matching VID/PID in a HID test application, send a known byte, and return a known report. |
|
Keyboard |
Open an empty text document, give yourself time to select it, then send one key press followed by a release. |
|
Mouse/joystick/consumer |
Send a small known input and then its neutral/released state. |
|
CDC |
Open the new COM port, set DTR if required, send a short command, and return a short line ending in CR/LF. |
|
MSC |
Open the drive, read a fixed file, and compare its exact bytes with the handler's expected contents. |
|
Browser |
Wait for the USB adapter's IPv4 address, open the device's HTTP address, and inspect /status. |
Unplug and reconnect the board as part of your test. A plugged-in cable does not by itself mean the device is ready. Even after Windows recognizes it, your PC program may still need to open it. A successful USB_Write() means the library accepted the data to send; it does not tell you that the PC program has used it.
Keep the USB service running while you add displays, measurements, motors or storage. In polling mode, the main loop must return to USB often. MSC file handling still runs in the main loop when interrupts are selected. Browser mode also needs its network service in the main loop.
Avoid starting with long blocking delays or slow operations inside the USB interrupt routine. Make one change, repeat the basic transfer test, and then add the next feature. See Keep USB running, then open the guide for HID, CDC, MSC or browser mode.
Created with the Personal Edition of HelpNDoc: Easy Qt Help documentation editor