2020-03-10 02:10 AM
Hi is it possible to use in the same time can and USB CDC because i need to receive message from can and then transmit over usb to PC?
2020-03-10 05:21 AM
I can transmit over USB message using CDC_Transmit and i can send CAN message but dont get interrupt for receiving CAN message. Interrupt occurs that can message is received only when i dont initialize USB_CDC
2020-03-11 01:09 AM
anyone?
2020-03-11 02:04 AM
Should be possible, or atleast the reference manual did not tell anything else when i fast looked at it.
How did observe that receive can rx interrupt is not called when USB is initialised? Have you looked at the can register values before and after USB init? Have you tried different order of init, ie. If USB is now first, init can first etc.
There are quite alot of discussion about the USB cdc within these forums with many mcu's, maybe you can find something related from there.
I myself have custom board with stm32f446 and have no proplems with USB cdc and can simultaneously, thought i haven't really pushed it more than ~40kb/s rate from can to PC.
2020-03-11 02:22 AM
I have debugging and put that in interupt when can rx occurs it should toggle led. When i dont call MX_USB_DEVICE_INIT led has toggled when i send from can device message and during debug session i get data and everything what i have sent from another device over CAN. But when i call MX_USB_DEVICE_INIT led doesnt turn on and in debug session breakpoint doest hit in interrupt. I have configured in CUBE_MX usb_FS as device only and CDC class
2020-03-12 05:50 AM
I have also tried different order of init and also doest helps. Are you using CAN1_RX0_IRQHandler for getting RX message over CAN or?
2020-03-12 06:19 AM
Yes, I use interrupts for can receive.
One thing came to my mind, have you inchereased heap and stack size? It's quite common that you have to do that when using the STM provided USB middleware driver. I think you can do it via STM32cube before you generate the code.
2020-03-12 06:33 AM
I have tried to decrease usb_tx and rx bufffer to 64 and it didnt help. Where in cubeMX and how much to put for a size of heap and stack (stm32f407 DISC1) ?
2020-03-12 06:56 AM
Atleast double the default value, I can't remember the exact place since I haven't used cubemx for sometime, but I believe it was near the settings where you can select if you want hal or ll driver periephals.
2020-03-12 07:14 AM
I have found and double values for heap and stack but system have the same behavioral . :S