2026-06-02 11:09 AM
Hello,
I am using a STM32L431 microcontroller. Bare-metal application in C using STM32CubeIDE and HAL library.
I am trying to transmit an 8-byte CAN Message at 1Mbps baud rate every 1ms. The best I can do right now is successfully transmit one CAN message every 3ms (with every 13th or 14th message going out at 4ms interval.). Any transmission rate >3ms I do not have any issues.
The system Clock is set to 80Mhz, using external 8Mhz crystal. Every 1ms (based on 500us timer), I add a CAN message to a queue (size 128). I check for any available TxMailbox and try to transmit using HAL_CAN_AddTxMessage. I also have a CANTransmit function that calls HAL_CAN_AddTxMessage in the HAL_CAN_TxMailboxEmptyCallback in case all 3 mailboxes were full. At present, there are no other devices trying to send any CAN messages on the bus expect the STM32 microcontroller. The loop that does CAN message packing and queuing is ~ 330us. What am I missing?
My end goal is to transmit three 8-byte CAN messages every 1ms.
Thank you in advance for any pointers you may have.
Indy
2026-06-02 11:13 AM
Just to be clear, when I attempt to send a CAN message every 1ms, the fastest the message gets transmitted is 3ms. When I attempt to send a message every 2ms, the message gets transmitted every 2ms and 4ms alternating between these times after every message.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.