2022-12-18 11:28 PM
I am trying to implement a cdc device and would also like to use the FreeRTOS. For code generation I use CubeMX. To keep the interrupt of the receives as short as possible I want to send the answer to the host using a task. But after a few seconds my host receive an invalid answer. Is there a simple example that shows how to combine the UBS Device library with FreeRTOS ?
Regards,
Lena
2022-12-19 12:34 AM
I have tried this before, handling the data to be sent via usb with freertos queues.
Creating a high priority not preemptable task, i still got missing USB frames ...
>>But after a few seconds my host receive an invalid answer
Sounds similar to what happened to me.
2022-12-19 12:55 AM
Either call Transmit only from the interrupt routine of the same priority as USB interrupt or at least disable the interrupts before calling Transmit an re-enable them immediately after.
2022-12-19 01:45 AM
Thanks for your answers!
I tried to start the receive in the transmit complete callback but this does not improve the behavior.
2022-12-19 05:40 AM
Hi @Community member
You Can use AzureRTOS USBX middleware it works in RTOS (Threadx) and standalone mode.
You can refer to this example:
2022-12-19 07:23 AM
@mohamed.ayed thank you for your answer.
Since my whole project is based on freeRTOS I don't want to change the operating system. Can the procedure be applied to freeRTOS ?
2022-12-19 04:27 PM
Use other vendor's USB library that can be ported to FreeRTOS natively or via CMSIS-RTOS wrapper. It likely costs something, but your time isn't free either.
2022-12-22 04:40 AM
Do you have an example of a good USB library I tried tinyusb but it doesnt work well
2022-12-22 08:30 AM
Segger?
2022-12-29 05:19 PM
> I tried tinyusb but it doesnt work well
It does work. Integrate and use it properly.