cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429 Disco USB + CAN randomly not working

Felix Schneider
Associate
Posted on December 08, 2016 at 19:27

Hi everyone,

I'm trying to use the STM32F429-Disc0 board with CubeMX as a CAN to USB bridge but I'm running across very strange behaviour now.

I've made it to the point where the device gets enumerated correctly by setting heap and stack sizes. When I just use an infinite loop after MX_USB_DEVICE_Init(); then I can connect Hterm or any other serial program and it works. However, as soon as I run MX_CAN1_Init(); in my code, the USB becomes totally unreliable. It still enumerates correctly, but as soon as I want to open it in any serial program, I get an internal error. 10% of the times it just randomly works.

I tried connecting an external power supply, moving the CAN pins, playing around with interrupt settings and so on.

Right now I'm using the HS USB with internal FS Phy and CAN 1 with PinD0 PinD1.

Please, if anyone has a solution for this, I would be very grateful.

#stm32f4 #usb #can #usb-cdc
1 REPLY 1
Felix Schneider
Associate
Posted on December 09, 2016 at 12:59

Ok, so I traced the USB communication and got it working.

For some reason I can't explain, with CAN enabled, the USBD will return wrong stuff forCDC_GET_LINE_CODING.

I fixed the problem by changingCDC_Control_HS to:

case CDC_GET_LINE_CODING: 
 pbuf[0] = pbuf[3] = pbuf[4] = pbuf[5] = 0;
 pbuf[1] = 0xc2;
 pbuf[2] = 0x01;
 pbuf[6] = 0x08;
 break;�?�?�?�?�?�?�?�?�?�?�?�?

These are just values I sniffed from the same device running without CAN. Can someone explain to me what is happening here, is this a bug in the driver?