cancel
Showing results for 
Search instead for 
Did you mean: 

USB OTG FS Problem: Infinite Loop at USB_OTG_GCCFG_PWRDWN

miracaydogan
Associate II

Hello masters,

I am trying USB_OTG_FS application with STM32f401VE MCU on own designed board.

Program going infinite loop at startup _stm32f401xe.s file . I traced to where the problem occurs.

It seems;

    /* Deactivate the power down*/
    USBx->GCCFG = USB_OTG_GCCFG_PWRDWN;

line in the stm32f4xx_ll_usb.c .

I insert handler lines in stm32f4xx_it.c file :

void OTG_FS_WKUP_IRQHandler(void)
 
{
   /* USER CODE BEGIN OTG_FS_WKUP_IRQn 0 */
 
CONSOLE_PRINT("OTG_FS_WKUP_IRQHandler");
 __HAL_GPIO_EXTI_CLEAR_IT(EXTI_PR_PR18);
 
  HAL_NVIC_ClearPendingIRQ(OTG_FS_WKUP_IRQn);
 
 
}

But nothing happened. When i comment USBx->GCCFG = USB_OTG_GCCFG_PWRDWN; line, the error doesn't happen but transmitting doest not start.

Is there any fixing way? I will be glad with your helps. I am hanging for 2 week with this problem

Sincerely.

1 REPLY 1

The GCCFG.PWRDWN has a very misleading name, in fact, setting it enables the USB PHY, which is what you want. And setting it does not cause the fault directly, it just may start a sequence of other USB events which eventually lead to the fault. I guess it's the hardfault handler where it ends up, in the startup file. It is always a good idea to learn how to debug faults - start maybe with searching here - but debugging other's code is not that much fun.

You might want to start with getting some of the "known good" boards (Disco, Nucleo) and trying some of the example codes there.

JW

PS. It's unlikely you want to use the USB wakeup handler.