cancel
Showing results for 
Search instead for 
Did you mean: 

USB CDC is sending bad data.

sagit
Associate II

Hello all,

 

currently I am facing next problem - I have STM32H743 with USB configured such as CDC Virtual port COM. Receiving data works very well. But I have a strange problem with sending data. Data I send are not correct received in case of using dynamic array:

sagit_0-1719851862363.png

If I use CDC_Transmit_FS(buffer, 5) are bad data received.

If I use CDC_Transmit_FS((char*)data, 5) all is good.

 

I have checked memory locations and both data pointers in function CDC_Transmit_FS have correct data, but on different memory address.  

I don't have idea why it is so behave. Can anybody help with this? CHATGPT failed, so I try live peoples.

 

sagit_1-1719852285037.png

 

 

sagit_2-1719852427013.png

 

Thank you very much.

1 REPLY 1

Please don't post code as images - see this for the proper tool:

https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/ta-p/575228

Presumably, CDC_Transmit_FS is non-blocking?

So it's not going to work for sending auto (ie, local non-static) variables - as your buffer.

When you use 

char* data[] = "Tesxt";

You get a pointer to a static location.