cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 :: CAN filter not working in randomly?

jd kim
Associate II
Posted on April 23, 2018 at 02:46

hi, i'm builing my own motor driver communicating by CAN BUS

i belive my can filter code because i almost always use this code,

but what i found funny thing is when i power on the circuit, then can bus filter not be initialized super very occasionally.

here is my enviroment

1. using HAL DRIVER by CUBEMX

2. polling methode, not interrupt

3. 24V -> 3.3V voltage down (not important. maybe)

4. I have two machine, the one is fully connected which is not malfunction yet (about 3 month) , the other strange one has missing ID

- I mean, there are 4 IDs, the strange one has one missing id, and the other IDs are transmitting message to this

And this is what i found on this case

1. filter not working, so whole message in canbus can be recenved

2. actually, the malfunctioning part (ID) has no relation with part, the i had not checked other parts have same matter

2. NEVER filter worked unless power off - on 

- even if reset pin, and re-download program

3. filter totally work in power reset, definitely same program

4. very rarely occurred, maybe a tens of time 

is there any similar issue like this?

i think when stop transmitting massage to the missing ID i will become normal ( not tried yet ).

well, why this happen?

1 REPLY 1
jd kim
Associate II
Posted on April 23, 2018 at 07:17

i found bug on my code, so i gonna answer myself

when power on, stm32f1 and maybe other series will NOT CAN Bus filter. so there will be random value.

but CAN filter enable register such as CAN_FAxR value will be reset to 0 . so basically it would not make problem.

My big mistake is enable 11 bit ID and 2 filters. 2 filters can be able by 1 bit of

CAN_FAxR in same time, but i misunderstood as allocated 1bit per 1 filter.

so when using can bus, take care of filter number. not like me