cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Cube FW_L4 V1.11.0 Bug in new CAN driver?

Till Rachow
Associate III
Posted on May 18, 2018 at 17:37

Hi,

in the HAL_CAN_IRQHandler, the checks for ALST and TERR errors are only done if RQCP is Set, meaning successful transmission:

The hardware indicates a successful transmission by setting the RQCP and TXOK bits in the CAN_TSR

register.

If the transmission fails, the cause is indicated by the ALST bit in the CAN_TSR register in

case of an Arbitration Lost, and/or the TERR bit, in case of transmission error detection.

(reference manual page 1359)

So no error can be detected, if they are only checked when transmission was successful..

Is that right?

Please fix if neccessary!

Thanks.

#stm32cube-fw_l4-v1.11.0
1 REPLY 1
Amel NASRI
ST Employee
Posted on May 23, 2018 at 11:49

Hi

‌,

Checking both reference manual and the CAN driver in STM32CubeL4 package, I don't agree with you that there is a bug in

HAL_CAN_IRQHandler and mainly when managing transmission end.

In fact,RQCP is set when the hardware consider that the transmission request is completed (successful or with error).

The result of the transmission is indicated in the CAN_TSR register by the TXOK, ALST and TERR bits:
  • TXOK: This bit is set by hardware when the transmission request on mailbox has been completed successfully

  • ALST:This bit is set when the previous transmission failed due to an arbitration lost

  • TERR: This bit is set when the previoustransmission failed due to an error

And this is exactly what we implement:

 /* Transmit Mailbox 0 management *****************************************/ if ((tsrflags & CAN_TSR_RQCP0) != RESET) { /* Clear the Transmission Complete flag (and TXOK0,ALST0,TERR0 bits) */ __HAL_CAN_CLEAR_FLAG(hcan, CAN_FLAG_RQCP0); if ((tsrflags & CAN_TSR_TXOK0) != RESET) { /* Transmission Mailbox 0 complete callback */ /* Call weak (surcharged) callback */ HAL_CAN_TxMailbox0CompleteCallback(hcan); } else { if ((tsrflags & CAN_TSR_ALST0) != RESET) { /* Update error code */ errorcode |= HAL_CAN_ERROR_TX_ALST0; } else if ((tsrflags & CAN_TSR_TERR0) != RESET) { /* Update error code */ errorcode |= HAL_CAN_ERROR_TX_TERR0; } else { /* Transmission Mailbox 0 abort callback */ /* Call weak (surcharged) callback */ HAL_CAN_TxMailbox0AbortCallback(hcan); } } }�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.