cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 F103 - How to configure CAN filters in ID List mode?

jerzy
Associate II
Posted on February 23, 2017 at 10:31

Hello,

I can configure can filters using filter mask mode, but I have problem with configuring them in ID List mode.

There is a code for ID mask mode i used:

      sFilterConfig

.

BankNumber

=

0

;

      sFilterConfig

.

FilterNumber

=

0

;

      sFilterConfig

.

FilterMode

=

CAN_FILTERMODE_IDMASK

;

      sFilterConfig

.

FilterScale

=

CAN_FILTERSCALE_32BIT

;

      sFilterConfig

.

FilterIdHigh

=

0x10

<<

5

;

      sFilterConfig

.

FilterIdLow

=

0

;

      sFilterConfig

.

FilterMaskIdHigh

=

0xff

<<

5

;

      sFilterConfig

.

FilterMaskIdLow

=

0

;

      sFilterConfig

.

FilterFIFOAssignment

=

0

;

      sFilterConfig

.

FilterActivation

=

ENABLE

;

      HAL_CAN_ConfigFilter

(&

hcan

,

&

sFilterConfig

);

And it works fine. I tried to write analogous code for ID List mode:

    sFilterConfig

.

FilterMode

=

CAN_FILTERMODE_IDLIST

;

    sFilterConfig

.

FilterScale

=

CAN_FILTERSCALE_32BIT

;

    sFilterConfig

.

BankNumber

=

1

    sFilterConfig

.

FilterNumber

=

0

    sFilterConfig

.

FilterIdHigh

 

=

0x10

<<

5

;

    sFilterConfig

.

FilterIdLow

=

0

;

    sFilterConfig

.

FilterMaskIdHigh

=

0

;

    sFilterConfig

.

FilterMaskIdLow

=

0

;

    sFilterConfig

.

FilterFIFOAssignment

=

0

;

    sFilterConfig

.

FilterActivation

=

ENABLE

;

    HAL_CAN_ConfigFilter

(&

hcan

,

&

sFilterConfig

);

With that code I can't receive any frames via CAN. 

Where am I wrong? 

#can-filter #stm32-can-can-filter-list #can
1 REPLY 1
Imen.D
ST Employee
Posted on February 23, 2017 at 18:24

Hi www1,

I suggest you to refer to this HAL example with STM32CubeF1, this will help you to configure the CAN filter:

STM32Cube_FW_F1_V1.4.0\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking

You can get inspired from this example and re-use sections available to develop your project.

Refer to the related reference manual

http://www.st.com/content/ccc/resource/technical/document/reference_manual/59/b9/ba/7f/11/af/43/d5/CD00171190.pdf/files/CD00171190.pdf/jcr:content/translations/en.CD00171190.pdf

 in the Controller area network (bxCAN) section, this will help you.

Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen