2024-06-24 12:03 PM
I followed This Youtube Video from ST for setting up USB CDC in the hopes I can pass data from a sensor through to my PC for processing. The video demonstrated how to echo back messages in the `usbd_cdc_if.c` file which worked and I could send and receive the same message using Hercules SETUP serial port monitor. I can't seem to get CDC_Transmit_FS() to send data other than echoing messages back. I've read that it could cause a USB lock as the device needs to be queried by the host but then This Video shows sending data straight from the Main loop. I'm new to STM32 but I feel like Transmitting bytes over Serial shouldn't be this mysterious and there isn't much content online for this board. Any suggestions or experience with this issue is welcome and thanks. I haven't included any files as I get no errors and haven't a clue what would be useful to include
Configuration:
STM32F746DISCO
Windows 11
2024-06-24 01:33 PM
@SerialIterator wrote:I can't seem to get CDC_Transmit_FS() to send data other than echoing messages back.
Of course it should be possible.
You'll need to show what you tried for people to be able to comment.
What problem(s), exactly, did you encounter?
What debugging did you do to find the issues?
@SerialIterator wrote:I'm new to STM32 :
Do you have experience with any other microcontroller(s)?
@SerialIterator wrote:I feel like Transmitting bytes over Serial shouldn't be this mysterious
But you're not just sending bytes over Serial; you're implementing USB - which is orders of magnitude more complicate than just a simple UART ...
2024-06-24 02:15 PM
What problem(s), exactly, did you encounter?
I didn't get any errors, it just doesn't transmit when using CDC_Transmit_FS() in the main.c file. Inside the usbd_cdc_if.c file, in CDC_Control_FS() I can set it to copy the RCV buffer and send it back out using CDC_Transmit_FS() and I witness it on the PC with port monitoring. So I know USB communication is working both ways but not when initiated by the device.
What debugging did you do to find the issues?
I started by testing two way communication described above to ensure USB communication worked. After putting a simple "hello" transmit in the main while loop with a 1 second delay, I tried to debug but I'm not used to STLink debugging. I put a breakpoint in the main loop on the transmit line but it appears to step into SystemClock_Config() then go through some interrupt code and loop back, never getting to the main function as if the system clock is not configured correctly and keeps interrupting itself. Seems odd to me as my clock settings are the same that worked with two way communication already but maybe I'm using the debugger wrong. But I never witness it get to the breakpoint I set in the main function
Do you have experience with any other microcontroller(s)?
I've made quite a few things with Arduino and RaspberryPi and made my own boards with atmel chips. I just normally expect USB libraries to do all the library-ing.