AnsweredAssumed Answered

Which function can detect STM32F413 USB(CDC) connected or disconnected

Question asked by June Zhou on Sep 26, 2017
Latest reply on Sep 28, 2017 by June Zhou



I use STM32F413ZG MCU and STM32CubeMx to create the Keil project.


Now, I need USB as communication Device Class(Virtual Port Com) to transmit data to computer(Master). But I do not know which function in USB library can detect USB cable plugged in the computer or unplugged in?  I tried to set up breakpoints in function  USBD_LL_DevConnected(USBD_HandleTypeDef *pdev)  and USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev)  in USB_core.c. but program never went to here when I plugging in USB or taking USB out.


Note, the computer can find USB in and get the serial port (COM6) and I can sending and receiving data via USB port (COM6).


Do you know the function or a interrupt can detect USB connection or disconnection?


Thanks a lot.