Skip to main content
Visitor II
December 19, 2017
Question

HAL CAN transmit timeout bug?

  • December 19, 2017
  • 5 replies
  • 1683 views
Posted on December 19, 2017 at 12:24

Hi,

I'm using one STM32F2 board and two STM32F3 boards. The F2 is the CAN master and the F3 are slaves. Everything works fine if I use only one F3 board. If I add the other one, then after 30sec - 5min one of the F3 boards is going to always return HAL_TIMEOUT from HAL_CAN_Transmit.

This is the code from HAL_CAN_Transmit that always returns HAL_TIMEOUT.

 /* Check End of transmission flag */
 while(!(__HAL_CAN_TRANSMIT_STATUS(hcan, transmitmailbox)))
 {
 /* Check for the Timeout */
 if(Timeout != HAL_MAX_DELAY)
 {
 if((Timeout == 0U) || ((HAL_GetTick()-tickstart) > Timeout))
 {
 hcan->State = HAL_CAN_STATE_TIMEOUT;
 /* Cancel transmission */
 __HAL_CAN_CANCEL_TRANSMIT(hcan, transmitmailbox);
 /* Process unlocked */
 __HAL_UNLOCK(hcan);
 return HAL_TIMEOUT;
 }
 }
 }�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

I'm using STM32CubeF3 V1.9.0

Here is a snapshot of my CAN registers right before the return HAL_TIMEOUT;

0690X00000609BoQAI.png #can-bus #stm32-f3 #hal #can
    This topic has been closed for replies.

    5 replies

    Alex SAuthor
    Visitor II
    December 20, 2017
    Posted on December 20, 2017 at 08:52

    The bug gets triggert if there is a collision on the CAN bus. eg. if two devices send a frame with the same CAN priority at the same time. This will permanently lockup the TX of one of the devices.

    Technical Moderator
    December 27, 2017
    Posted on December 27, 2017 at 15:32

    Hello

    alexander.siebert

    ,

    The issue related to

    HAL_CAN_Transmitis

    already raised internally to our development team and we would inform you that there is a plan for 2018 to reworkHAL CAN driver.

    Thank you for your understanding.

    Kind Regards,

    Imen

    Visitor II
    December 28, 2017
    Posted on December 28, 2017 at 01:21

    How did you configure the CAN on the STM32F3s?  I've been trying to port the CAN networking sample code from the F3 eval board to the STM32F303re Nucleo board and have been having nothing but troubles.  I'm routing the CAN pins to PA11 and PA12.  It appears I can generate a packet on the bus but I've been unable to receive.  Also, the interrupts don't seem to be firing.  

    Any setup suggestions appreciated.  Also, what CAN bus analyzer are you using?  I have the Ginkgo USB-CAN Interface adapter and its software is very obtuse.

    Thanks

    Visitor II
    December 28, 2017
    Posted on December 28, 2017 at 21:57

    its the same message ID issue.

    different boards should use different message IDs

    after a bus error like that, you have to power cycle all the boards.

    Visitor II
    January 23, 2018
    Posted on January 23, 2018 at 13:09

    I have a similar problem too, CAN-TX-TIMEOUT always occurs on the client. I've replaced the Cube-HAL (2.7.0) with the Keil-HAL (2.7.0) problem solved.

    Graduate II
    October 17, 2024

    Is there a work around for this? Is it possible to detect if the CAN module is in a locked state and then free it?