Skip to main content
justas23
Associate II
April 19, 2016
Question

[error report] STM32F1 CAN HAL BUG in HAL_CAN_Transmit_IT

  • April 19, 2016
  • 2 replies
  • 571 views
Posted on April 20, 2016 at 00:03

hcan is locked permanently in HAL_CAN_Transmit_IT when all transmit boxes are full.

Bellow is compressed HAL_CAN_Transmit_IT function:

HAL_StatusTypeDef HAL_CAN_Transmit_IT(CAN_HandleTypeDef* hcan)

{

   uint32_t transmitmailbox = CAN_TXSTATUS_NOMAILBOX;

  /* Check the parameters */

  assert_param(IS_CAN_IDTYPE(hcan->pTxMsg->IDE));

  assert_param(IS_CAN_RTR(hcan->pTxMsg->RTR));

  assert_param(IS_CAN_DLC(hcan->pTxMsg->DLC));

  if((hcan->State == HAL_CAN_STATE_READY) || (hcan->State == HAL_CAN_STATE_BUSY_RX))

  {

 /* Process Locked */

    __HAL_LOCK(hcan); //Here process is locked

    /* Select one empty transmit mailbox */

    if(HAL_IS_BIT_SET(hcan->Instance->TSR, CAN_TSR_TME0))

    {

        .....

    }

    else

    {

      transmitmailbox = CAN_TXSTATUS_NOMAILBOX;

    }

    if(transmitmailbox != CAN_TXSTATUS_NOMAILBOX)

    {

        ...........

      /* Process Unlocked */

      __HAL_UNLOCK(hcan);

        ...........

    }

    //!!!!!!!!!!! when all mailboxes are full program goes here and exits with hcan no unlocked

  }

  else

  {

    return HAL_BUSY;

  }

  return HAL_OK;   

}

    This topic has been closed for replies.

    2 replies

    slimen
    Visitor II
    April 20, 2016
    Posted on April 20, 2016 at 12:50

    Hi riabovas.justas,

    Same issue is already reported and fixed for STM32F4.

    Refer to this [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/HAL_CAN_Transmit_IT%28%29%20Missing%20__HAL_UNLOCK%28%29&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&currentviews=117]thread.

    Regards

    Nesrine M_O
    Associate
    April 20, 2016
    Posted on April 20, 2016 at 12:52

    Hi riabovas.justas,

    Thanks for highlighting this issue.It is a known bug, but the fix has not yet been released on the web. 

    -Syrine-