2020-08-29 05:54 AM
I'm working on a project based on STM32l496rg and trying to send data from USB CDC to terminal. I`ve created a project in STM32CubeIDE (the latest version available), where I`ve set up clocks, enabled USB_FS_Device and USB CDC middleware and all the settings remained default.
After this, I`ve generated code in STM32 Cube IDE, compiled and run with making only one changes into the code which is in Write function in syscalls.c file.
if I try to call CDC_Transmit_FS through printf, then it returns USBD_OK on first few times calling and then after USBD_BUSY on all the next calls. However, I cannot receive anything on terminal.
So, what I`m doing wrong, how to troubleshoot USB CDC connection and why STM32CubeIDE generated code gives such error?
#STM32CubeIDE #[STM32 MCUs] #STM32L4 #USB #cdc
Solved! Go to Solution.
2020-08-30 07:48 AM
2020-08-29 07:49 AM
> because of connection error
Explain what you mean by this. Does an error message show up somewhere?
2020-08-29 08:44 AM
Thanks for reply, that means, I'm not receiving data on my terminal through usbcdc after some time. That means it's properly work 1 or 2 minutes(received proper data on terminal) and then stop working(not received any data on terminal). After I checked in my code i found the error occurred which is USBD_BUSY. And connection error that means it's return USBD_BUSY.
I'm also used one interrupt ( which is another sensor interrupt) in my project , when interrupt trigger on that time I'm send data on my terminal through usbcdc( for confirmation interrupt trigger or not), its work properly sometimes and then it stop working usb cdc that means stop receiving data on my terminal.
I also noticed one thing, when I use interrupt on that time it's stop working (stop receiving data on terminal)after some time interval.
2020-08-30 07:25 AM
Are you calling CDC_Transmit_FS in both the interrupt and in the main thread? That will cause issues eventually. It is not thread-safe.
2020-08-30 07:44 AM
Thanks for reply,
Yes I'm calling CDC_Transmit_FS in both main function and in interrupt function. Then tell me how to fix this. Is it possible or not.
>That will cause issues eventually. It is not thread-safe.
I didn't get you exactly. Please give me some explanation about it why is it not working. And what is the reason behind it.
2020-08-30 07:48 AM