About 2 years ago, I played around briefly with CubeMX generated custom HID code on STM32F042K6. D+/D- signals seemed to work fine, but my "custom" HID FW did not enumerate against Windows. I got too busy with a new job, and did not pursue the problem. This weekend, I picked up where I left off. This time, I am trying to understand the USB HID better, so I just tried the CubeMX generated HID example. Except for emitting a debug byte here and there, I ran the auto-generated code verbatim. The voltage on DP/DM (PA12/PA11 pins connected to the header D2/D10 on the Nucleo F042K6) seems to show a setup problem: the DP doesn't seem to rise to 3.3 V!
Another thing I changed is the bmAttribute to bus powered (default is 0xE0, which is bus + self powered + remote wakeup) and increasing the max power to 250 (which means 500 mA). I increased the current when I noticed the host complaining about over-current. Strangely, The only load I put on the USB VBus is an LED in series with a 220 Ohm; and I only measured 2 V drop across 220 Ohm, so I should only be pulling 10 mA. Anyway, I shouldn't think that the current load on VBus shouldn't affect the DP/DM voltages, so the above waveform looks strange to me.
2 years ago, I never understood the ST's USB stack. I just downloaded AN4711 and UM1717, to better understand. Right away, it seems strange that CubeMX did NOT generate the DCD_xxx files being discussed in UM1717, but I'll keep reading. If anybody knows right away anything I am doing wrong, I'd really appreciate a tip.
Thanks for reading!