STM32L4 CAN bus clock issue

27 Aug 2019

I have a system with STM32L431KB MCU and ATA6561 CAN transceiver that is producing an incorrect clock for CAN bus. I've used a Nucleo board with STM32L432KC (and a TI transceiver) for development with no issues, but running the same mbed-os code on the final version with the 431KB variant results in wrong clock speed.

The difference seems to be exactly 1.4x, so if I set CAN bus speed to 350kbps, it actually works at 250kbps (and works fine with my Microchip CAN BUS analyzer running at 250kbps).

What might be the source of this 1.4x difference in CAN bus speed? I also have I2C bus connected to a LED controller at 400kbps, which is working just fine. Also the RTC seems to be working accurately.

We're using the internal MSI clock on STM32 (we have a 8MHz external crystal, but it doesn't seem to be working correctly when initializing the clocks, so it falls back to MSI).

29 Aug 2019

The problem was with LSE, which we don't have but it was configured as available. Adding "target.lse_available": 0 to mbed_app.json fixed the issue.