admin管理员组文章数量:1391937
Win10, STM32CubeMx ver. 6.5.0, STM32CubeIDE ver. 1.18.0, MCU - STM32F103C6
I'm creating a new project using either STM32CubeMX or STM32CubeIDE. In the Pinout & Configuration window, I configure USB for data transfer. Under the Middleware > USB_DEVICE tab, I select VPC mode. I leave other settings at their defaults. The clock is configured to use an external 8 MHz oscillator.
Next, I set up the microcontroller’s clock tree. In the Code generation settings, I enable the option Generate peripheral initialization as a pair of [...].
After generating the code, I notice that the GPIO pins PA11 and PA12 (USB D+ and D-) are not fully configured: no pull-up/pull-down resistors, no alternate function mode, etc. Here are examples of the generated code:
void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) {
if (pcdHandle->Instance == USB) {
/* USER CODE BEGIN USB_MspInit 0 */
/* USER CODE END USB_MspInit 0 */
__HAL_RCC_USB_CLK_ENABLE(); // Enable USB clock
HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn);
/* USER CODE BEGIN USB_MspInit 1 */
/* USER CODE END USB_MspInit 1 */
}
}
void MX_GPIO_Init(void) {
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
}
Other peripherals (e.g., timers) generate code correctly.
Question: Why are PA11 and PA12 not configured for USB, despite selecting USB_DEVICE in CubeMX?
I tried reinstalling the software, logging into the ST account, and testing different USB operation modes.
本文标签: stm32STM32CubeMx doesn39t generate whole code for USBStack Overflow
版权声明:本文标题:stm32 - STM32CubeMx doesn't generate whole code for USB - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744678884a2619276.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论