cancel
Showing results for 
Search instead for 
Did you mean: 

USB HS CDC_Receive_HS funtion

Vitor Pereira
Associate II
Posted on November 29, 2017 at 13:56

Hi, I'm trying to make a little project just to send an echo of what is received over USB. I have been able to do it, but there   s something I couldn't do yet.

My code in the USB callback function is as shown below:

0690X0000060918QAA.png

The problem is really simple to describe: when CDC_Receive_HS is called, it only transmits ONE message, and I just can't figure out what is wrong. The code above only sends ''Echo:'' to the terminal on PC. When I only send the data received (CDC_Transmit_HS(Buf, *Len)) it only sends it, even if I try to send it again immediately after.

0690X000006091DQAQ.png

Thanks in advance

V�tor Pereira

#usb-hs-vcp #use-stm32f769-discovery-board
3 REPLIES 3
Ant M
Associate II
Posted on November 29, 2017 at 14:16

See this thread:

https://community.st.com/0D50X00009XkXTsSAN

Ant

Ben K
Senior III
Posted on November 29, 2017 at 14:37

The USB transmit API is not buffered/queued, if you call CDC_Transmit_HS() you should wait for the transfer to be complete, before attempting to send anything again.

Vitor Pereira
Associate II
Posted on November 30, 2017 at 12:51

Thank you for the answers. I actually had used this ''

put the data into a buffer'' approach, and was trying to make a simpler code, but seems like it's not possible to do it the way I did, since the trasmission only occur after exiting the CDC_Receive_HS function.

I'm having another issue, though. My code is now as follows:

0690X0000060920QAA.png

   in CDC_Receive_HS, buf=Buf, e len=Len.

The problem is that without the 1 ms delay, it doesn't work. Even when *len has its value changed, the program doesn't enter the if statement. I first thought it was because it hadn't exited CDC_Receive_HS function, but even after a while the transmissions are still not executed. No idea why, I'm working on it.

Thanks again

 Vítor Pereira