AnsweredAssumed Answered

Bug in CAN_TransmitStatus function?

Question asked by martin.ray on Jun 10, 2013
Latest reply on Feb 13, 2014 by gonzalez.laurent

I noticed something strange with the CAN_TransmitStatus function in the stm32f10x_can.c (V3.1.2) peripheral driver code. Most of the time it works fine but occasionally it returns the wrong status. The root cause is it’s reading the CANx->TSR register multiple times when updating “state”. If that register changes between reads, the logic based on “state” becomes corrupt. The correct way to do this is to first capture CANx->TSR in a local variable then test that value.

Outcomes