cancel
Showing results for 
Search instead for 
Did you mean: 

FDCAN g431 doesn't filter

Tomuello
Associate II

Hello, i'm testing FDCAN in my stm32g431 and it doesn't work well. Messeges goes throught it, even if ID doesn't match (TxHeader.Identifier = 0x102 shouldn't pass, but it does!)

 

static void MX_FDCAN1_Init(void)

{

hfdcan1.Instance = FDCAN1;

hfdcan1.Init.ClockDivider = FDCAN_CLOCK_DIV1;

hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC;

hfdcan1.Init.Mode = FDCAN_MODE_EXTERNAL_LOOPBACK;

hfdcan1.Init.AutoRetransmission = DISABLE;

hfdcan1.Init.TransmitPause = DISABLE;

hfdcan1.Init.ProtocolException = DISABLE;

hfdcan1.Init.NominalPrescaler = 3;

hfdcan1.Init.NominalSyncJumpWidth = 1;

hfdcan1.Init.NominalTimeSeg1 = 2;

hfdcan1.Init.NominalTimeSeg2 = 2;

hfdcan1.Init.DataPrescaler = 1;

hfdcan1.Init.DataSyncJumpWidth = 1;

hfdcan1.Init.DataTimeSeg1 = 1;

hfdcan1.Init.DataTimeSeg2 = 1;

hfdcan1.Init.StdFiltersNbr = 1;

hfdcan1.Init.ExtFiltersNbr = 1;

hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;

 

if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK)

{

Error_Handler();

}

 

FDCAN_FilterTypeDef sFilterConfig;

sFilterConfig.IdType = FDCAN_STANDARD_ID;

sFilterConfig.FilterIndex = 0; // Use the first filter bank

sFilterConfig.FilterType = FDCAN_FILTER_MASK; // Specify the filter type

sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0; // Store matching messages in RX FIFO 0

sFilterConfig.FilterID1 = 0x103; // filter

sFilterConfig.FilterID2 = 0x103; // mask

 

if (HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig) != HAL_OK) {

// Handle error

}

}

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello,

You need to configure the global filter. For example:

  HAL_FDCAN_ConfigGlobalFilter(&hfdcan1,
			       FDCAN_REJECT,
			       FDCAN_REJECT,
			       FDCAN_REJECT_REMOTE,
			       FDCAN_REJECT_REMOTE);

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

2 REPLIES 2
Tomuello
Associate II

configurating global filter was a solution C:

SofLit
ST Employee

Hello,

You need to configure the global filter. For example:

  HAL_FDCAN_ConfigGlobalFilter(&hfdcan1,
			       FDCAN_REJECT,
			       FDCAN_REJECT,
			       FDCAN_REJECT_REMOTE,
			       FDCAN_REJECT_REMOTE);

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.