AnsweredAssumed Answered

STM32F302R6 and CAN

Question asked by barinov.denis on Oct 4, 2016
Latest reply on Dec 26, 2017 by David Pekin
Hello. After the initialization CAN interface and call HAL_CAN_Receive_IT function (& hcan, CAN_FIFO0) there is no interruption USB_LP_CAN_RX0_IRQ Handler (); when receiving the CAN package. And accordingly misses the HAL_CAN_RxCpltCallback function (CAN_HandleTypeDef * CanHandle).
Although the function HAL_CAN_Receive (& hcan, CAN_FIFO0, 100); It takes the parcel.


Transfer works fine.
What can be wrong?


void MX_CAN_Init(void)
{
 
  hcan.Instance = CAN;
  hcan.Init.Prescaler = 24;
  hcan.Init.Mode = CAN_MODE_NORMAL; //CAN_MODE_LOOPBACK CAN_MODE_NORMAL
  hcan.Init.SJW = CAN_SJW_1TQ;
  hcan.Init.BS1 = CAN_BS1_3TQ;
  hcan.Init.BS2 = CAN_BS2_4TQ;
  hcan.Init.TTCM = DISABLE;
  hcan.Init.ABOM = DISABLE;
  hcan.Init.AWUM = DISABLE;
  hcan.Init.NART = DISABLE; //ENABLE //DISABLE
  hcan.Init.RFLM = DISABLE;
  hcan.Init.TXFP = DISABLE;
  if (HAL_CAN_Init(&hcan) != HAL_OK)
  {
    Error_Handler();
  }
   
  // настраиваем фильтр — приём всех посылок
  CAN_FilterConfTypeDef canFilterConfig;
  canFilterConfig.FilterNumber = 0;
  canFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
  canFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
  canFilterConfig.FilterIdHigh = 0x0000;
  canFilterConfig.FilterIdLow = 0x0000;
  canFilterConfig.FilterMaskIdHigh = 0x0000 << 5;
  canFilterConfig.FilterMaskIdLow = 0x0000;
  canFilterConfig.FilterFIFOAssignment = CAN_FIFO0;
  canFilterConfig.FilterActivation = ENABLE;
  canFilterConfig.BankNumber = 0;
  HAL_CAN_ConfigFilter(&hcan, &canFilterConfig);
 
  if (HAL_CAN_Receive_IT(&hcan, CAN_FIFO0) != HAL_OK)
  {
    /* Reception Error */
    Error_Handler();
  }
 
}

Outcomes