AnsweredAssumed Answered

STM32H7 FDCAN FILTER

Question asked by mendes.ari.001 on May 23, 2018
Latest reply on May 24, 2018 by Imen D

Hi,

I tested the example FDCAN_Com_IT. FDCAN configuration copied below.

 

When I transmit a frame from another board with the ID different from 0x111, the message is received in the "HAL_FDCAN_RxFifo0Callback" function anyway. I suppose that this configuration should only accept frames with the ID = 0x111.

 

I did verify that the FDCAN1->GFC = 0x00. When I forced FDCAN1->GFC = 0x3F inside the  "HAL_FDCAN_Init " function, I could receive frames only with the ID = 0x111.

 

Is that a bug in the HAL?  Or this configuration is wrong?

 

How can I change the configuration below for the extended ID = 0x011111111 and with the mask to receive only this ID?

 

Ari.

 hfdcan.Instance = FDCANx;
hfdcan.Init.FrameFormat = FDCAN_FRAME_FD_BRS;
hfdcan.Init.Mode = FDCAN_MODE_NORMAL;
hfdcan.Init.AutoRetransmission = ENABLE;
hfdcan.Init.TransmitPause = DISABLE;
hfdcan.Init.ProtocolException = ENABLE;
hfdcan.Init.NominalPrescaler = 0x1; /* tq = NominalPrescaler x (1/fdcan_ker_ck) */
hfdcan.Init.NominalSyncJumpWidth = 0x8;
hfdcan.Init.NominalTimeSeg1 = 0x1F; /* NominalTimeSeg1 = Propagation_segment + Phase_segment_1 */
hfdcan.Init.NominalTimeSeg2 = 0x8;
hfdcan.Init.DataPrescaler = 0x1;
hfdcan.Init.DataSyncJumpWidth = 0x4;
hfdcan.Init.DataTimeSeg1 = 0x5; /* DataTimeSeg1 = Propagation_segment + Phase_segment_1 */
hfdcan.Init.DataTimeSeg2 = 0x4;
hfdcan.Init.MessageRAMOffset = 0;
hfdcan.Init.StdFiltersNbr = 1;
hfdcan.Init.ExtFiltersNbr = 0;
hfdcan.Init.RxFifo0ElmtsNbr = 2;
hfdcan.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8;
hfdcan.Init.RxFifo1ElmtsNbr = 0;
hfdcan.Init.RxBuffersNbr = 0;
hfdcan.Init.TxEventsNbr = 0;
hfdcan.Init.TxBuffersNbr = 0;
hfdcan.Init.TxFifoQueueElmtsNbr = 2;
hfdcan.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
hfdcan.Init.TxElmtSize = FDCAN_DATA_BYTES_8;
HAL_FDCAN_Init(&hfdcan);

/* Configure Rx filter */
sFilterConfig.IdType = FDCAN_STANDARD_ID;
sFilterConfig.FilterIndex = 0;
sFilterConfig.FilterType = FDCAN_FILTER_MASK;
sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;
sFilterConfig.FilterID1 = 0x111;
sFilterConfig.FilterID2 = 0x7FF; /* For acceptance, MessageID and FilterID1 must match exactly */
HAL_FDCAN_ConfigFilter(&hfdcan, &sFilterConfig);

/* Configure Rx FIFO 0 watermark to 2 */

HAL_FDCAN_ConfigFifoWatermark(&hfdcan, FDCAN_CFG_RX_FIFO0, 2);

/* Activate Rx FIFO 0 watermark notification */
HAL_FDCAN_ActivateNotification(&hfdcan, FDCAN_IT_RX_FIFO0_WATERMARK, 0);

/* Prepare Tx Header */
TxHeader.Identifier = 0x111;
TxHeader.IdType = FDCAN_STANDARD_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_FD_CAN;
TxHeader.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
TxHeader.MessageMarker = 0;

/* Start the FDCAN module */
HAL_FDCAN_Start(&hfdcan);

Outcomes