cancel
Showing results for 
Search instead for 
Did you mean: 

Which USB parameter in CubeMX cause generetion of HAL_GPIO_EXTI_Callback?

Julie Lambert
Associate II
Posted on February 24, 2017 at 20:54

Hi,

I have created a project in CubeMX 4.19.0 for the STM32L476JGY (Firmware package 1.6.0) in which I have a USB device in CDC mode. The code was generated for SW4STM32. Communication with a PC works fine for both RX and TX.

Now I added a GPIO in interrupt mode to my design and implemented HAL_GPIO_EXTI_Callback in my user code. Oups... The compiler says I have multiple definition of 'HAL_GPIO_EXTI_Callback'.

I found that CubeMX has generated some code for HAL_GPIO_EXTI_Callback in usbd_conf.c even though VBUS sensing parameter is set to DISABLED and no GPIO_PIN_9 is defined in my design. Here is the code generated by CubeMX:

/**

  * @brief  GPIO EXTI Callback function

  *         Handle USB VBUS detection upon External interrupt

  * @param  GPIO_Pin

  * @retval None

  */

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)

{

  if (GPIO_Pin == GPIO_PIN_9)

  {

    HAL_PCDEx_BCD_VBUSDetect (&hpcd_USB_OTG_FS);

  }

}

Which USB parameter setting should I change in CubeMX so that the HAL_GPIO_EXTI_Callback function is not generated in usbd_conf.c?

Thanks!

8 REPLIES 8
Rob.Riggs
Senior
Posted on February 25, 2017 at 15:41

Enabling battery charge detection (BCD) causes this function to be defined.

Posted on February 27, 2017 at 17:14

Thanks Rob but I can't find any configuration parameter to enable/disable the BCD in CubeMX. However, when CubeMX generates my project code, it sets the battery_charging_enable parameter to DISABLE in USBD_LL_Init (usbd_conf.c).

Here are my settings in CubeMX:

USB_DEVICE Configuration, Parameter Settings

Basic Parameters

VirtualMode                 Cdc

USBD_MAX_NUM_INTERFACES     1

USBD_MAX_NUM_CONFIGURATION  1

USBD_MAX_STR_DESC_SIZ       512

USBD_SUPPORT_USER_STRING    Disabled

USBD_SELF_POWERED           Disabled

USBD_DEBUG_LEVEL            0

USBD_LPM_ENABLED            0

Class Parameters

USBD_CDC_INTERVAL           1000

USB_OTG_FS Configuration, Parameter Settings

Speed                       Full Speed 12MBit/s

Endpoint 0 Max Packet size  64 Bytes

Enable internal IP DMA      Disabled

Low power                   Disabled

Link Power Management       Disabled

VBUS sensing                Disabled

Signal start of frame       Disabled

Can you help me find where the BCD parameter that causes the generation of HAL_GPIO_EXTI_Callback function by CubeMX is located?

Thanks,

Julie

Posted on February 28, 2017 at 01:51

How do you have PA9 configured on the PINOUT tab of STM32CubeMX?  Make sure that is not set to USB_OTG_FS_VBUS.  And make sure in the Peripherals section on that screen under USB_OTG_FS, Activate_VBUS is disabled.

Posted on February 28, 2017 at 15:25

There is nothing connected to PA9. It is in Reset_State. Under USB_OTG_FS, the Mode is set to Device_Only, Activate_VBUS is set to Disable and both check boxes are empty.

Posted on March 01, 2017 at 03:12

I have replicated the behavior.  Seems like a bug in STM32CubeMX.  Seems wrong to be putting the HAL_GPIO_EXTI_Callback() in usbd_conf.c under any circumstance (it belongs in stm32l4xx_it.c -- always).  But it should certainly not get created in usbd_conf.c if PA9 is not used for USB_OTGFS_VBUS.

Posted on March 02, 2017 at 16:08

Do ST staff members read this forum or should I report the bug elsewhere so they could fix this in the next CubeMX firmware package for STM32L4?

Imen.D
ST Employee
Posted on March 02, 2017 at 20:17

Hello,

Thanks for highlighting this Julie.

I will raise this issue internally to investigate and will post you as soon as we have an update.

Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on November 24, 2017 at 15:39

Any news here? Came here after having the same issue with CubeMX 4.23.0 and FW L4 1.10.0, doesn't seem to be solved.