AnsweredAssumed Answered

USB_OTG_BSP_EnableInterrupt fails over to UsageFault_Handler

Question asked by Flawed Science on Apr 30, 2014
Latest reply on May 1, 2014 by Flawed Science
I'm trying to get a USB Host running using code from STM32_USB-Host-Device_Lib_V2.1.0 with openocd on an STM32f215rg board with FS USB using internal PHY. But it dies trying to enable the OTG_FS interrupt.

As in the examples, USBH_Init() calls USB_OTG_BSP_EnableInterrupt(), and that calls NVIC_Init() for OTG_FS_IRQn. But that ends up in UsageFault_Handler(). What does that suggest I'm missing? Thanks!

01.void USB_OTG_BSP_Init (USB_OTG_CORE_HANDLE *pdev)
02.{
03.    GPIO_InitTypeDef GPIO_InitStructure;
04. 
05.    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
06. 
07.    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;
08. 
09.    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
10.    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
11.    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
12.    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
13.    GPIO_Init(GPIOA, &GPIO_InitStructure);
14. 
15.    GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_OTG1_FS);
16.    GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_OTG1_FS);
17. 
18.    /* Configure ID pin as Host */
19.    GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_10;
20.    GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; // GPIO_OType_PP;
21.    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
22.    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
23.    GPIO_Init(GPIOA, &GPIO_InitStructure);
24.    GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_OTG1_FS);
25. 
26.    RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
27.    RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, ENABLE);
28.}
29. 
30.void USB_OTG_BSP_EnableInterrupt (USB_OTG_CORE_HANDLE *pdev)
31.{
32.    NVIC_InitTypeDef NVIC_InitStructure;
33.    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
34. 
35.    NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn;
36.    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
37.    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
38.    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
39.    NVIC_Init(&NVIC_InitStructure);
40.}
41. 
42.void USBH_Init(USB_OTG_CORE_HANDLE *pdev,
43.               USB_OTG_CORE_ID_TypeDef coreID,
44.               USBH_HOST *phost,
45.               USBH_Class_cb_TypeDef *class_cb,
46.               USBH_Usr_cb_TypeDef *usr_cb)
47.{
48. 
49.  /* Hardware Init */
50.  USB_OTG_BSP_Init(pdev);
51. 
52.  /* configure GPIO pin used for switching VBUS power */
53.  USB_OTG_BSP_ConfigVBUS(0);
54. 
55. 
56.  /* Host de-initializations */
57.  USBH_DeInit(pdev, phost);
58. 
59.  /*Register class and user callbacks */
60.  phost->class_cb = class_cb;
61.  phost->usr_cb = usr_cb;
62. 
63.  /* Start the USB OTG core */
64.   HCD_Init(pdev , coreID);
65. 
66.  /* Upon Init call usr call back */
67.  phost->usr_cb->Init();
68. 
69.  /* Enable Interrupts */
70.  USB_OTG_BSP_EnableInterrupt(pdev);
71.}




Outcomes