2017-02-24 11:54 AM
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!
2017-02-25 06:41 AM
Enabling battery charge detection (BCD) causes this function to be defined.
2017-02-27 09:14 AM
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
2017-02-27 05:51 PM
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.
2017-02-28 07:25 AM
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.
2017-02-28 07:12 PM
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.
2017-03-02 08:08 AM
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?
2017-03-02 11:17 AM
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
2017-11-24 07:39 AM
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.