I'm working with the STM32L552ZEQ, and I'm noticing that it is sending duplicate CAN transmissions.
I have two threads, one that adds transmissions to a FreeRTOS queue, and one that spins and transmits enqueued messages.
The thread that enqueues a message, calls osDelay(1000), enqueues the exact same message again, and then calls osDelay(1000).
The other thread just spins and waits for a message to be enqueued. It dequeues it and then transmits.
The problem I'm having is that for some reason, the second message that is enqueued is transmitted 4 times instead of just 1. It's the exact same function and arguments as the first.
When I enqueue a different message each time, I was able to confirm that it wasn't just an issue of the second message getting enqueued 4 times. In other words, thread 1 enqueues message 1, sleeps, and then enqueues message 2 (repeating the process). Thread 2 gets message 1, transmits, sleeps, and then gets message 2, transmits, and then sleeps. Using the oscilloscope, I confirmed that the peripheral is literally transmitting 4 times.
I've also confirmed that in each case, HAL_OK is returned (and everything looks good when I step through the HAL code).
This will also happen even if auto retransmit is turned off.
Any idea what is going on?
TLDR: I have various modules that all need to use the CAN Bus. Rather than letting each one have access to the hardware, they all add messages to a queue, and then the transmit thread sends each over the bus. There's something going on timing wise that's causing the FDCAN peripheral to transmit the same message 4 times instead of just once. The same message printed twice in two seconds seems to do this.