cembeddedstm32can-bus

STM32L552 CANFD Filter configuration


Im currently working with CANFD and have to set up the filters in my STM32L552. I need to get four IDs (0, 20, 10, 100). Currently I only get the two IDs 0 and 20.

  FDCAN_FilterTypeDef myFDCanFilter;
  myFDCanFilter.IdType=FDCAN_STANDARD_ID;
  myFDCanFilter.FilterType=FDCAN_FILTER_DUAL;
  myFDCanFilter.FilterIndex=0;
  myFDCanFilter.FilterConfig=FDCAN_FILTER_TO_RXFIFO0;
  myFDCanFilter.FilterID1=((uint32_t)0);
  myFDCanFilter.FilterID2=((uint32_t)20);

  if(HAL_FDCAN_ConfigFilter(&hfdcan1,&myFDCanFilter) != HAL_OK)
  {
      Error_Handler();
  }

I saw this:

DE : https://www.mikrocontroller.net/topic/543601

EN : https://www-mikrocontroller-net.translate.goog/topic/543601?_x_tr_sl=de&_x_tr_tl=en&_x_tr_hl=de&_x_tr_pto=wapp

Code should work when the StdFiltersNbr is set correctly:

 FDCAN_HandleTypeDef hfdcan1;
 ...   
 hfdcan1.Init.StdFiltersNbr = 4;
 ...

Set it to two, three and four via the .ioc file.

And addded this filter Configuration:

  myFDCanFilter.IdType=FDCAN_STANDARD_ID;   
  myFDCanFilter.FilterType=FDCAN_FILTER_DUAL;
  myFDCanFilter.FilterIndex=3;
  myFDCanFilter.FilterConfig=FDCAN_FILTER_TO_RXFIFO0;
  myFDCanFilter.FilterID1=((uint32_t)10);
  myFDCanFilter.FilterID2=((uint32_t)100);

  if(HAL_FDCAN_ConfigFilter(&hfdcan1,&myFDCanFilter) != HAL_OK)
  {
      Error_Handler();
  }

It still only allows the IDs 0 and 20 to pass the filter. The Error_Handler is not beeing called. I' ve allready tried usind different filterIndexs.

What am I missing?

Edit:

I've removed the second filter block and tried setting the Filtertype to rage 0-100 - nothing changes. Setting the range to 100-200, IDs 0 and 20 still activate the Interrupt. It seems as if the Filter is stuck / isn't correctly writen to the hardware?


Solution

  • Error 40 -

    Due to some custom functions CAN was manualy reinitializied and filters reset... Code workes when used in the right place.