cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 doesn't receive data when using extended ID in CAN_FD

Choudharyas
Associate III

Hi everyone,

I am trying to send data from one STM32G0B1 MCU to another STM32G0B1 MCU. When i use standard ID it works perfectly but if i use Extended ID then the receiver interrupt doesn't fire.

I also checked it with logic analyzer. Transmitter sending the data but the receiver side is not receiving it. This happens only when i use extended ID.

2 REPLIES 2
Javier1
Principal

That is weird.

What kind of XTAL are you using in your STM32G0B1's?

we dont need to firmware by ourselves, lets talk
Choudharyas
Associate III

I am not using any external clock. I am also attaching the transmitter side and receiver side code snippets and also the logic analyzer data.

Transmitter side:

/* Prepare Tx message Header */
  TxHeader.Identifier = 0x19800540; 
  TxHeader.IdType = FDCAN_EXTENDED_ID;
  TxHeader.TxFrameType = FDCAN_DATA_FRAME;
  TxHeader.DataLength = FDCAN_DLC_BYTES_8;
  TxHeader.ErrorStateIndicator = FDCAN_ESI_ACTIVE;
  TxHeader.BitRateSwitch = FDCAN_BRS_ON;
  TxHeader.FDFormat = FDCAN_CLASSIC_CAN;
  TxHeader.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
  TxHeader.MessageMarker = 0;
 
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
	 
         HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &TxHeader, TxData);
	 HAL_Delay(1000);
  }
  /* USER CODE END 3 */
}

Receiver Side:

    //Configure reception filter to Rx FIFO 0 
  sFilterConfig.IdType = FDCAN_EXTENDED_ID;
  sFilterConfig.FilterIndex = 0;
  sFilterConfig.FilterType = FDCAN_FILTER_RANGE;
  sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;
  sFilterConfig.FilterID1 = 0x19800540; 
  sFilterConfig.FilterID2 = 0x19820540;
  if (HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig) != HAL_OK)
  {
    Error_Handler();
  }
 
  // Configure global filter:
    // Filter all remote frames with STD and EXT ID
    // Reject non matching frames with STD ID and EXT ID 
  if (HAL_FDCAN_ConfigGlobalFilter(&hfdcan1, FDCAN_REJECT, FDCAN_REJECT, FDCAN_FILTER_REMOTE, FDCAN_FILTER_REMOTE) != HAL_OK)
  {
    Error_Handler();
  }
 
  // Activate Rx FIFO 0 new message notification 
  if (HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0) != HAL_OK)
  {
    Error_Handler();
  }
 
 
void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs)
{
  if((RxFifo0ITs & FDCAN_IT_RX_FIFO0_NEW_MESSAGE) != 0)
  {
     //Retrieve Rx messages from RX FIFO0 
    if (HAL_FDCAN_GetRxMessage(hfdcan, FDCAN_RX_FIFO0, &RxHeader, RxData) != HAL_OK)
    {
      Error_Handler();
    }
}

I have connected logic analyzer on Receiver side and it shows the data on RX pin but Receiver FIFO is empty.0693W00000YAZaBQAX.png