2019-12-31 08:51 PM
I'm using an STM32F411RET6 MCU to make a keyboard. Attached is the full schematic. Using CubeMX to generate the USB code. I'm a hobby-ist and I apologize in advance if there's a very basic issue that I've overlooked.
The problem is it works sometimes but most times it doesn't. I get the error in Windows "USB Device has malfunctioned". Looking in USB Device Viewer, i see the following error:
[Port2] FailedEnumeration : Unknown USB Device (Device Descriptor Request Failed)
Is Port User Connectable: yes
Is Port Debug Capable: no
Companion Port Number: 0
Companion Hub Symbolic Link Name:
Protocols Supported:
USB 1.1: yes
USB 2.0: yes
USB 3.0: no
---===>Device Information<===---
ConnectionStatus: FailedEnumeration
Current Config Value: 0x00 -> Device Bus Speed: Low
Device Address: 0x00
Open Pipes: 0
*!*ERROR: No open pipes!
===>Device Descriptor<===
*!*ERROR: bLength of 0 incorrect, should be 18
bLength: 0x00
bDescriptorType: 0x00
bcdUSB: 0x0000
bDeviceClass: 0x00
*!*ERROR: Device enumeration failure
A few points about the setup:
void SystemClock_Config(void) {
RCC_OscInitTypeDef RCC_OscInitStruct = { 0 };
RCC_ClkInitTypeDef RCC_ClkInitStruct = { 0 };
/** Configure the main internal regulator output voltage
*/
__HAL_RCC_PWR_CLK_ENABLE()
;
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/** Initializes the CPU, AHB and APB busses clocks
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 4;
RCC_OscInitStruct.PLL.PLLN = 96;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV6;
RCC_OscInitStruct.PLL.PLLQ = 4;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
Error_Handler();
}
/** Initializes the CPU, AHB and APB busses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV2;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) {
Error_Handler();
}
}
Any suggestions will be greatly appreciated!
Solved! Go to Solution.
2020-01-02 06:55 AM
Okay found the issue. The problem is with the location of the standoff. It is too close to the USB connector. So every time I tighten the screws the leads either come out or get shorted and it stops working.
I re-soldered the usb connector leads and made sure to not tighten the screws and just let them gently stop in place. I'll fix this in the next design. Thanks for your help Barry! :)
2020-01-01 01:59 AM
A follow up question - I just noticed that I'm completely ignoring the VBUS pin (PA9). But I found this attached image which says VBUS needs to be connected to the 5V from the connector. Does a HID qualify as a peripheral-only connection?
2020-01-01 02:52 PM
I worked on a USB keyboard emulator and also had very intermittent results, mostly not working.
The design was on a 2 layer board and the power trace to the VDD pin that was closest to the USB + and - signals was very far from the power source. I increased the capacitor size on that VDD pin and it started working without any problems.
Probably not your problem but it might be worth trying a larger cap close to the USB signals.
2020-01-01 06:32 PM
Thanks for the suggestion! I'll give that a try. Right now I have 400nF close to the pins on the MCU, but really far from the USB connector. I'll try bumping it up to 1uF and see if that helps. I'm also wondering if there's some loose connection on the micro-usb connector, will try re-soldering the leads again.
2020-01-02 06:55 AM
Okay found the issue. The problem is with the location of the standoff. It is too close to the USB connector. So every time I tighten the screws the leads either come out or get shorted and it stops working.
I re-soldered the usb connector leads and made sure to not tighten the screws and just let them gently stop in place. I'll fix this in the next design. Thanks for your help Barry! :)