cancel
Showing results for 
Search instead for 
Did you mean: 

How to enable all CAN filterbanks/Specific # of CAN filterbanks?

WNguy.1
Associate II

Hi,

I know Mask/ID list modes use different amount of filter banks, How do I configure each bank and enable all of them? If i recall, 32 bit/16 scales also change the amount of filter banks per mask mode or Id mode. The filterbank # is what defines which one is being modified. I'm using an STM32F413- Nucleo F413Zh board and the following approach of using multiple banks is a for loop like this:

// for (filterNo = 0; filterNo < CAN1_FILTER_CNT; filterNo++){

//   sFilterConfig.FilterBank = filterNo;

//   sFilterConfig.FilterMode = CAN1_FilterMode[filterNo];

//   sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;

//   sFilterConfig.FilterIdHigh = CAN1_ID_HiWord[filterNo];

//   sFilterConfig.FilterIdLow = CAN1_ID_LoWord[filterNo];

//   sFilterConfig.FilterMaskIdHigh = CAN1_FilterMaskHiWord[filterNo];

//   sFilterConfig.FilterMaskIdLow = CAN1_FilterMaskLoWord[filterNo];

//   sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;

//   sFilterConfig.FilterActivation = ENABLE;

//   sFilterConfig.SlaveStartFilterBank = 14;

//

//   if(HAL_CAN_ConfigFilter(&hcan1, &sFilterConfig) != HAL_OK)

//   {

//    // Filter configuration Error

//    Error_Handler();

//   }

//  }

Where the variable arrays "CAN1_ID_HiWord[filterNo]", etc.... has different ID masks. within the CAN1_init function. The problem I'm facing is that the CAN controller is only using the last filter-bank configuration called in the "for loop" and not taking account for the previous filter-banks that were changed. I'm not sure where to go about this or how it works in enabling all can filter-banks.

For a start, say I'd like to implement only two ID lists (each having two unique IDS) = 4 IDS total, the for loop will limit two loops for the filter banks.

1 REPLY 1
WNguy.1
Associate II

I've found the solution! It was the "CAN1_FILTER_CNT" not being set to the appropriate amount of bytes!