cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 USB CDC not showing up as a port

AC3
Visitor

I'm trying to get a USB virtial COM Port working on the STM32 Nucleo-H745ZI-Q. I've generated some minimal code to initialize the device on PA11 and PA12 and have tried connecting a four pin USB-C breakout board to wire GND, DP, DM, and U5V, as well as simply using the provided user usb port, but no luck. My configurations are as follows in the screenshots and code.

My expected result is to view all COM ports connected to my computer and see this pop up, currently that is not happening.

- USB set to device only on CM7

- USB Clock source is from RC48

- USB device set to CDC with default settings

Any help would be appreciated, I am sure I am missing something minor here

int main(void) {
    /* USER CODE BEGIN 1 */

    /* USER CODE END 1 */
    /* USER CODE BEGIN Boot_Mode_Sequence_0 */
    int32_t timeout;
    /* USER CODE END Boot_Mode_Sequence_0 */

    /* MPU Configuration--------------------------------------------------------*/
    MPU_Config();

    /* USER CODE BEGIN Boot_Mode_Sequence_1 */
    /* Wait until CPU2 boots and enters in stop mode or timeout*/
    timeout = 0xFFFF;
    while ((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) != RESET) && (timeout-- > 0))
        ;
    if (timeout < 0) {
        Error_Handler();
    }
    /* USER CODE END Boot_Mode_Sequence_1 */
    /* MCU Configuration--------------------------------------------------------*/

    /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
    HAL_Init();

    /* USER CODE BEGIN Init */

    /* USER CODE END Init */

    /* Configure the system clock */
    SystemClock_Config();
    /* USER CODE BEGIN Boot_Mode_Sequence_2 */
    /* When system initialization is finished, Cortex-M7 will release Cortex-M4 by means of
    HSEM notification */
    /*HW semaphore Clock enable*/
    __HAL_RCC_HSEM_CLK_ENABLE();
    /*Take HSEM */
    HAL_HSEM_FastTake(HSEM_ID_0);
    /*Release HSEM in order to notify the CPU2(CM4)*/
    HAL_HSEM_Release(HSEM_ID_0, 0);
    /* wait until CPU2 wakes up from stop mode */
    timeout = 0xFFFF;
    while ((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) == RESET) && (timeout-- > 0))
        ;
    if (timeout < 0) {
        Error_Handler();
    }
    /* USER CODE END Boot_Mode_Sequence_2 */

    /* USER CODE BEGIN SysInit */

    /* USER CODE END SysInit */

    /* Initialize all configured peripherals */
    MX_GPIO_Init();
    MX_USB_DEVICE_Init();
    /* USER CODE BEGIN 2 */
    GPIO_InitTypeDef GPIO_InitStruct = {0};
    __HAL_RCC_GPIOE_CLK_ENABLE();
    GPIO_InitStruct.Pin = GPIO_PIN_1;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
    /* USER CODE END 2 */

    /* Infinite loop */
    /* USER CODE BEGIN WHILE */
    while (1) {
        /* USER CODE END WHILE */

        /* USER CODE BEGIN 3 */
        HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_1);

        HAL_Delay(1000);
    }
    /* USER CODE END 3 */
}

 

2 REPLIES 2
FBL
ST Employee

Hi @AC3 

Would you attach IOC file ?  Make sure that Boot_Mode_Sequence_2 is commented out to reach USB application. Try booting only Cortex M7 alone.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.


Hi @FBL !

 

Thank you for your reply. The provided user USB seems to work now! I would still like to get the USB FS and HS working, starting with FS, to validate prior to my custom board design. Using a USB breakout to PA 11 and 12 still seems to be unresponsive.

 

Thanks again!