cancel
Showing results for 
Search instead for 
Did you mean: 

How to receive the data through the usb of USB_CDC_ receive function

RKUMA.2
Associate II

How to receive the commands through the usb of USB_CDC_ receive

Hello,

I am working on the stm32f070c6 USB_CDC virtual COMK port ,I am transmitting the data from stm32 mcu to serial monitor but when I am trying to receive the commands through usb from my pc to serial monitor, i used usbd_cdc_receive function but unfortunately I am not receiving any commands from the pc to select the different operations of stm32f070c6, I am taking the received data to the main program of switch cases but I am receiving the data at usb_cdc_receive function but im not getting the data in main file ,how we can receive the data from the pc using USB_CDC virtual COM port and also when i try to use ptintf and scanf functions in stm cube IDE , even printf scanf functions also not working to print the messages on serial monitor ,they are not working nothing to display on the serial monitor, how can I overcome this problems, if anyone have an idea about of these please give a reply

Thanks in advance

6 REPLIES 6
Ons KOOLI
Senior III

Hi @RKUMA.2​ ,

Please refer to the STM32CubeF0 Firmware Package, under directory: Projects\$Board_Name$\Applications\USB_Device\CDC_Standalone

Best Regards,

Ons.

Thanks for your reply@Ons​ KOOLI, I did per your suggestions but, I am unable receiving my data through the pc to usb

Ons KOOLI
Senior III

Hi @RKUMA.2​ ,

Did you try to run the example from the FW package ? Can you check if it is working, just to make sure that the problem is not in your HW setup.

Best Regards,

Ons.

RKUMA.2
Associate II

Hai @Ons KOOLI

Yeah, I took a reference from the FW package , and develop a code for USB CDC COM port and it was detected as COM port everything fine but the problem is when send the commands through my pc to MCU it is not receiving my commands , the usb _cdc_receive function not​ get my commands ,how can I receive the data from pc to MCU .

Ons KOOLI
Senior III

Hi @RKUMA.2​ ,

I wanted that you run the project of the FW on your custom board, because we know that this code works well. So we can conclude if there is an issue with your HW or not, or maybe that you have an issue with the USART settings. In fact, the CDC_Standalone application suits your need. It allows to send and receive data between your laptop and the MCU. Please read carefully the readme.txt file.

Now for the operating mode, and if the code you wrote is well, you succeeded on sending data and I suppose that you are using a kind of terminal. To receive data there are two modes that can be set. Either you receive data on normal mode so you will use another terminal and connect it to the ST-Link COM port and you will see the data received from the first to the second terminal. OR you can use the loopback mode by connecting USART_Tx to USART_Rx and you will see the sent data in the same terminal. If the reception does not work, so you have an issue with the USART settings and maybe you didn't use the "good" USART for your application. Generally, the USART used in the CDC_Standalone projects provided by ST, is the one which is connected directly to ST-Link.

You have to make the necessary changes, if you are using your custom board, and use the correspondent USART.

I really hope this is helpful.

Best Regards,

Ons.

How did you solve this problem?