AnsweredAssumed Answered

[error report] STM32F1 CAN HAL BUG in HAL_CAN_Transmit_IT

Question asked by riabovas.justas on Apr 20, 2016
Latest reply on Apr 20, 2016 by Nesrine M
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;   
}

Outcomes