cancel
Showing results for 
Search instead for 
Did you mean: 

CAN RECEIVE FILTER CONFIGURATION

akshayamk
Associate II
Posted on March 04, 2016 at 09:14

Hello!

I am using a custom made STM32F302RE board. I want configure the filter such that I would be able to receive all messages. I have coded it as follows:

int i; 
 for ( i=0 ; i<=14 ; i++ ){ 
/* Allow all messages to be received */ 
CAN_FilterConfTypeDef sFilterConfig; 
sFilterConfig.BankNumber = 0; 
sFilterConfig.FilterActivation = ENABLE; 
sFilterConfig.FilterNumber = i; 
sFilterConfig.FilterFIFOAssignment = 0; 
sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT; 
sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK; 
sFilterConfig.FilterMaskIdLow = 0; 
sFilterConfig.FilterMaskIdHigh = 0; 
sFilterConfig.FilterIdLow = 0; 
sFilterConfig.FilterIdHigh = 0; 
HAL_CAN_ConfigFilter(&hcan, &sFilterConfig); 
} 
HAL_CAN_Receive_IT(&hcan, CAN_FIFO0);

However, I do not receive all messages as I wanted. is there anything wrong in the filter configuration?? Any suggestions? Thanks! #can-
7 REPLIES 7
Posted on March 04, 2016 at 14:44

What exactly do you think it is missing?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
slimen
Senior
Posted on March 04, 2016 at 17:00

Hello mk.shasha,

 

 I suggest you to refer to this example: STM32Cube_FW_F3_V1.4.0\Projects\STM32303C_EVAL\Examples\CAN\CAN_Networking

 It help you to configure the CAN filter.

-ForumSTM32-

Posted on March 04, 2016 at 18:40

Yeah, I think we've both looked at CAN filtering before, perhaps you can be more specific about how the example you cited differs from the pass everything model used here?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
akshayamk
Associate II
Posted on March 07, 2016 at 10:53

Hello,

I have tried the codes you suggested but I am not able to receive all messages.

akshayamk
Associate II
Posted on March 07, 2016 at 10:57

Hi Clive,

I need to receive all messages from the controller to my module so that I can analyse the received messages. I suspect that my filter configuration is wrong. I have already enabled receive interrupt and coded HAL_CAN_RECEIVE_IT after filter configuration. Even when I used the example from ST Micro, I am unable to receive all messages. Any suggestions??

Posted on March 07, 2016 at 17:21

Ok, but what messages are you seeing, and which ones do you think you are missing, and what analysis leads you to believe you are missing messages on the wire?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
akshayamk
Associate II
Posted on March 08, 2016 at 01:46

Currently, the message receive is very unstable as I am receiving messages sometimes and other times, the codes go to error handler (CAN_SCE handler) after the filter configuration.

I have tried the same filter configuration on STM32F302R8 custom made board and I am receiving messages as codes go into receive handler and I observe messages such as 0x4b6 and 0x4b7 at CAN_RECEIVE_IT () function (called in HAL_CAN_IRQHANDLER function). This behaviour is consistent for STM32F302R8 board but very inconsistent for STM32F302RE board.

I am using the same codes for CAN for both boards and so I expect the same behaviour for both boards.