Skip to main content
mh2
Associate III
May 30, 2017
Solved

STM32 USB CDC problem

  • May 30, 2017
  • 2 replies
  • 1228 views
Posted on May 30, 2017 at 10:07

hi everybody

I'm using stm32l151 and I want to use usb peripheral in cdc mode. I used stm32 cubeMx to generate the project.

when I connect the boar to PC, I can see the VCP in device manager.however I can't sen any data to PC. The function CDC_Transmit_FS() always return USBD_BUSY.

can anyone help me?

Here is my code:

while (1) { CDC_Transmit_FS(Buffer, 6); HAL_Delay(2000); }

I only added the above code to the project created by STM32cubeMX but it didn't work.

Thanks

    This topic has been closed for replies.
    Best answer by mh2
    Posted on May 31, 2017 at 08:37

    I found the problem. It was my new terminal monitor software I used to monitor the serial port. it doesn't monitor the serial port unless the port to be read by a software. It just monitor when the port was opened by another software.

    Thanks

    2 replies

    Technical Moderator
    May 30, 2017
    Posted on May 30, 2017 at 12:51

    Hi

    Hosseinzadeh.Mohamma

    ,

    Are you using CDC example from CubeL1 package ?

    You can start with a working 'CDC_Standalone' example available under STM32CubeL1 v1.7.0 and get inspired from the functions used todevelop your application.

    Imen

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    mh2
    mh2Author
    Associate III
    May 30, 2017
    Posted on May 30, 2017 at 13:03

    Hi Imen

    Thanks for your attention.

    I don't use example project. I created a project using STM32CubeMX and then, I just used the function CDC_Transmit_FS() to send the word 'hello' to the PC, as in the example project of

    STM32CubeL1 v1.6.0

    . I checked in debug mode, and I understood that the first time

    C

    DC_Transmit_FS is called it does not return USBD_BUSY, but after that, it return USBD_BUSY.

    I think that the transmission of the data, didn't complete.

    mh2
    mh2AuthorBest answer
    Associate III
    May 31, 2017
    Posted on May 31, 2017 at 08:37

    I found the problem. It was my new terminal monitor software I used to monitor the serial port. it doesn't monitor the serial port unless the port to be read by a software. It just monitor when the port was opened by another software.

    Thanks