2020-01-20 07:11 AM
My project involves a STM32F1 interfacing with a Linux machine as a USB CDCACM device, where the Linux machine will send some packets that need to be received/parsed on the MCU. I'd like to configure an interrupt for when the MCU receives the data packets.
I haven't found much material on this, except for UM1734 where I wasn't able to find anything about interrupts for CDC. I also found functions for USB_LP_CAN1_RX0_IRQn interrupt configuration (HAL_NVIC_SetPriority, HAL_NVIC_EnableIRQ) in the HAL user manual which get auto generated by CubeMX, but I'm not sure how to make use of these.
Any code or pointers to relevant reference material will be helpful.
2020-09-14 08:31 AM
HI Anaik,
here is my lib based on the latest STM32F4 libs.
you have to gnerate the USB CDC via CubeMx and then set on top that lib.
A receiver should check using the usb_cdc_status if there is pending incomming data.
The needed patches to usbd_cdc_if.c are described in the usb_cdc_stm32.c file.
HTH, Adib.
--
2020-12-17 06:18 AM
Hi Adib,
Thank you very much. Can you explain the setting of cubemx. Timeout.h and watchdog...h are missing
2020-12-17 06:44 AM
2020-12-17 07:54 AM
Thank you a lot. I did the instructions in the "usb_cdc_stm32.c". I called in the main : usb_cdc_init instead of "MX_USB_DEVICE_Init(0)"
Can i send and receive data via UART and terminal?
Best regards
2020-12-17 08:04 AM
Hello Daisky, yes , in my functions MX_USB_DEVICE_Init() must be replaced by usb_cdc_init().
I append my complete example here.
It runs on Olimex STM32-E407 board that has STM32F407. Which CPU do you have?
Basically CubeMX generated code runs outofthebox. That means if you are able to identify your device using CubeMX then you put my functions on_top.
You must correctly set Frequency, clocktree, USBlibs, etc first and verify.
That gives you buffered communication in USB CDC.
But if something on your setup does not work then my functions can not help either.
Regards, Adib.
2020-12-17 08:11 AM
Thank you a lot. i will check it now.
Best regards,
2020-12-17 08:31 AM
Dear Adib,
I am trying to send from PC using terminal tools like realTerm via USB. Will this work?
Thanks in advance and sorry for my many questions
Best regards,
2020-12-17 08:47 AM
Yes that should work.
You have to go through all steps and check success.
For me it works like this. The driver also has no dependency on HANDSHAKE signals. (The NXP application driver depends on DTS)
Which part does not work for you?
HTH, Adib.
2020-12-17 10:17 AM
Hi,
Please refer to the STM32CubeF1 under Applications/USB_Device/CDC_Standalone directory.
Best Regards,
Ons.