cancel
Showing results for 
Search instead for 
Did you mean: 

F407 USB HS host with internal PHY

jimmjimmshen
Associate III
Posted on November 13, 2014 at 10:19

I'm using USB HS host mode with internal PHY but get a problem that i can't enter the interrupt when i plug or unplug my usb device. my program code is modified from host_device_libV2.10-USB_host_example. i just modified some init code:

i already defined USE_EMBEDDED_PHY marco and there are init code:

 USBH_Init(&USB_OTG_Host,

USB_OTG_HS_CORE_ID, 

&USB_Host, 

&USBH_MSC_cb,

&USR_Callbacks);

void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev)

{

  GPIO_InitTypeDef GPIO_InitStructure;   

  RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOB , ENABLE);  

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15 | 

                                GPIO_Pin_14;

  

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;

  GPIO_Init(GPIOB, &GPIO_InitStructure);  

  

  GPIO_PinAFConfig(GPIOB,GPIO_PinSource15,GPIO_AF_OTG2_FS) ; 

  GPIO_PinAFConfig(GPIOB,GPIO_PinSource14,GPIO_AF_OTG2_FS) ;

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

  RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_OTG_HS, ENABLE) ;

}

 
1 REPLY 1
Posted on November 13, 2014 at 17:25

Make sure USE_USB_OTG_HS is defined, and that you're using the right IRQ

 NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_IRQn;

#ifdef USE_USB_OTG_HS

void OTG_HS_IRQHandler(void)

{

  USBD_OTG_ISR_Handler (&USB_OTG_dev);

}

#endif

The example code also uses PB12 (OTG_HS_ID) and PB13 (OTG_HS_VBUS)

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB , ENABLE);

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 |

                                GPIO_Pin_14 |

                                GPIO_Pin_15;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_Init(GPIOB, &GPIO_InitStructure);

  GPIO_PinAFConfig(GPIOB,GPIO_PinSource12, GPIO_AF_OTG2_FS);

  GPIO_PinAFConfig(GPIOB,GPIO_PinSource14, GPIO_AF_OTG2_FS);

  GPIO_PinAFConfig(GPIOB,GPIO_PinSource15, GPIO_AF_OTG2_FS);

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;

  GPIO_Init(GPIOB, &GPIO_InitStructure);

  RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_OTG_HS, ENABLE) ;

# global definitions for C++, C and ASM (e.g. ''symbol_with_value=0xDEAD symbol_without_value'')

GLOBAL_DEFS = USE_STDPERIPH_DRIVER STM32F429_439xx USE_STM32F429I_DISCO USE_USB_OTG_HS USE_EMBEDDED_PHY HSE_VALUE=8000000

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..