cancel
Showing results for 
Search instead for 
Did you mean: 

F072 USB wont connect with CAN connected.

JWieb
Associate III

Struggling with a rather weird problem.

I am using the STM32F072 in an application that needs both USB CDC and CAN.

Currently the peripherals are working as expected. However, if the USB is connected after the CANBUS, USB wont initialize. If I connect USB first then CAN, both work fine.

USB has the higher priority (lower number) , interrupts all appear to be working. No hard faults. I know these devices share a buffer so I set the USB CDC buffer to half the default, 256B for each TX and RX.

Where do i start to debug this?

5 REPLIES 5
Karl Yamashita
Lead II

Is your software and firmware package all up to date?

I had a USB to CAN project that used the SMT32F042 several years ago. It used a Custom HID. It was working great.

Then I bought a new CAN bus adapter that uses a STM32F072. I just ported the old code to the new project. The only difference was the firmware package was a little newer. I could not get the USB to transmit at all but it would receive no problems. I even tried CDC and pretty much the same issue.

Then recently I've noticed there was a new firmware package so I updated to that newer version and now the USB works 100%.

If you find my answers useful, click the accept button so that way others can see the solution.
S.Ma
Principal

Stack size too short, as it grows with interrupts, max interrupt latency (WCET) maybe?

JWieb
Associate III

Thanks for the tips but no luck.

I am using the latest firmware package 1.11.4.

I tried increasing stack and heap to 0x1000

S.Ma can you explain more about max interrupt latency (WCET) ? is there anything i can configure with this?

JWieb
Associate III

Just adding more detail I tried changing the clock sources have tried all three combinations of

- Running the Core and USB from PLL

- Running the Core from PLL an USB from HSI48

- Running the Core and USB from HSI48

No change in results from these clock source changes.

I also tried starting a 10 second timer where i alternate between MX_USB_DEVICE_Init(); and USBD_Stop(&hUsbDeviceFS); just to see if it would re-initialize. Again no. This works without CAN, every 10 seconds i get a connect or disconnect. But with CAN connected, nothing..

Almost like whatever interrupt needs to happen for initialize/ connecting isn't happening with CAN, possible due to the shared buffer?

JWieb
Associate III

I did make a revelation. The USB peripheral is going into suspend mode which happens after 3 missed SOF frames.

My application relies on using an Android device and its Serial drivers. This is for a motorcycle application so having your phone for debug and configuration is a key feature.

I noticed the suspend problem after some power testing. Then i tried plugging the device into a windows PC.

This problem only occurs with Android and not Windows!

I can plug and unplug all I want with Windows. I suspect this has to do with how Android negotiates the Serial ports and USB-C Power delivery.

My board has the required 5.1k resistors to act as a power sink but not a full PD controller.

Not really sure how to proceed from here. It would be great to have the android connection so perhaps I needs to do a full reset of the USB peripheral on USB connect. I don't have a USB Voltage sense line on this PCB but the next version will.

Ill post an updated once we have an updated board.