cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Filters config for STM32F105 problems

Marco1
Associate II
Posted on February 19, 2016 at 12:32

HI, 

I try to config Filters for two can bus on STM32F105, but i have strange problems .

When i config filter with CAN2SB = 14 to specify start point of filters for CAN2, the interrupts RX0 and RX1, not work.

If i config Filters  with CAN2SB = 0, interrupts RX0 and RX1 work both.

Sorry for my english.

{

CAN_FilterConfTypeDef  sFilterConfig;

// CAN1 filter init 

sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;

sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;

sFilterConfig.FilterIdHigh = 0x0000;

sFilterConfig.FilterIdLow = 0x0000;

sFilterConfig.FilterMaskIdHigh = 0x0000;

sFilterConfig.FilterMaskIdLow = 0x0000;

sFilterConfig.FilterFIFOAssignment = CAN_FIFO0;

sFilterConfig.FilterActivation = ENABLE;

sFilterConfig.FilterNumber = 0;

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

{

Error_Handler();

}

// CAN2 filter init 

sFilterConfig.BankNumber = 14; // start bank filters for can2

sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;

sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;

sFilterConfig.FilterIdHigh = 0x0000;

sFilterConfig.FilterIdLow = 0x0000;

sFilterConfig.FilterMaskIdHigh = 0x0000;

sFilterConfig.FilterMaskIdLow = 0x0000;

sFilterConfig.FilterFIFOAssignment = CAN_FIFO0;

sFilterConfig.FilterActivation = ENABLE;

sFilterConfig.FilterNumber = 14;

if (HAL_CAN_ConfigFilter( &hcan2, &sFilterConfig ) != HAL_OK)

{

Error_Handler();

}

}

   
3 REPLIES 3
Posted on February 19, 2016 at 12:51

Perhaps you need to fully initialize the structure in the first instance, as the stacked local variable will contain random junk?

sFilterConfig.BankNumber = 0; // start bank filters for can1

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Marco1
Associate II
Posted on February 19, 2016 at 16:14

I have already tried, and CAN_FMR register is only one for two can, so it's enought configure it one time before tx or rx ! 

Posted on February 19, 2016 at 17:39

Sorry, I'm not a HAL user.

Perhaps you need to zoom out a level or two, and look at how the CAN controller is being initialized, the pins and the transceiver.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..