2008-10-30 02:50 AM
CAN filtering
2011-05-17 03:50 AM
I am using the CAN on the stm32 to control a number of stepper motor drivers. Am able to send and recieve messages without may trouble. However I want to be able to filter the messages to look for range of IDs. I set the filtering set as shown:
CAN_FilterInitStructure.CAN_FilterNumber=0; CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask; CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit; CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000; CAN_FilterInitStructure.CAN_FilterIdLow=0x0000; CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000; CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000; CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_FIFO0; CAN_FilterInitStructure.CAN_FilterActivation=ENABLE; CAN_FilterInit(&CAN_FilterInitStructure); I can see now all the messages on the CAN bus, I want to used the CAN filters to look for a range of Extended IDs e.g. 0x1A8023XX. I have tried various combinations of masks in both Mask and List modes but am still having no success. Can anyone offer any help Thanks Ian2011-12-22 12:34 AM
I have the same problem with stm32f407. Reference manual says thant filter banks need to be in form STDID[10:0], EXTID[17:0], IDE bit, RTR bit, 0. I tried various filter modes and ID's, but worked only FilterIdHigh=0x0000 FilterIdLow=0x0000 FilterMaskIdHigh=0x0000 FilterMaskIdLow=0x0000. Even in mask mode , for example configured FilterID = ( (0xA<<3) | (CAN_RTR_DATA | CAN_ID_EXT) ) FilterMaskID = 0 CAN_FilterMode = CAN_FilterMode_IdMask - as far as I understand in this case all frames will received - mask = 0 all ID bits don't care. But does not have frame reception.
Where is problem?2011-12-22 07:28 AM
Sorry, I found a problem in can-init code. All works.
But I little confused with filter structure in documentation. As far as I understand FxR1[31:21] is STD[10:0] only if IDE=0 (standard ID), if IDE = 1 (extended ID) this bits EXT[28:18]2011-12-23 07:46 PM
Agree, the documentation is a little confusing. The short answer is that the FilterIDLow and FilterIDHigh as well as MaskIDLow and MaskIDHigh don't correspond exactly to the SID/EID. The bits need to be shifted depending on the type of ID you are trying to filter. It took me several weeks to find the answer on a German website that I used google to translate. Please look at my example code below, hopefully it will be clear then.
In this example four filters are created to receive only SID 123, 124, 125 and 126. They don't have to be in order, just happened to be the numbers I picked. For a SID the numbers for the Filter/Mask IDs need to be shifted to the left by 5 bits.CAN_FilterInitStructure.CAN_FilterNumber = 1;
CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdList; CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_16bit; // All filters are shifted left 5 bits CAN_FilterInitStructure.CAN_FilterIdHigh = 0x2460; // 0x123 CAN_FilterInitStructure.CAN_FilterIdLow = 0x2480; // 0x124 CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x24A0; // 0x125 CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x24C0; // 0x126 CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0; CAN_FilterInitStructure.CAN_FilterActivation = ENABLE; CAN_FilterInit(&CAN_FilterInitStructure);2011-12-24 07:28 AM
Here is the comment from my filter setup code:
/* CAN initialization. * It took experimentation to fill in the missing details of the manual, * especially with the Rx filter. * Each filter is 8 bytes, and can be configured in one of four ways. * Two 29 bit IDs w/ EID and RTR bits (presumably extended IDs) * One 29 bit ID with a 29 bit mask * Four 11 bit IDs, w/ EID and RTR bits. * The lower 3 bits are ignored * Two 11 bit IDs w/ EID and RTR bits, paired with two 16 bit masks */2012-02-21 05:15 AM
I am working on scan tool I am trying to get diagnostic response. I have configured filter as below. Could anyone help me why is it not filtering only 0x18DAF1XX. It is receiving all frames!
This problem is similar one mentioned in earlier discussions... /* CAN filter init */ #ifdef USE_CAN1 CAN_FilterInitStructure.CAN_FilterNumber = 1; #else /* USE_CAN2 */ /* CAN_FilterInitStructure.CAN_FilterNumber = 15;*/ #endif /* USE_CAN1 */ CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask; CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit; CAN_FilterInitStructure.CAN_FilterIdHigh = 0xC6D7; CAN_FilterInitStructure.CAN_FilterIdLow = 0x8804; CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0xFFFF; CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0xF804; CAN_FilterInitStructure.CAN_FilterFIFOAssignment = CAN_FIFO0; CAN_FilterInitStructure.CAN_FilterActivation = ENABLE; CAN_FilterInit(&CAN_FilterInitStructure);2012-02-22 07:22 AM
As far as I understand this code configure FilterBank 1 or 15. But there is FilterBank 0 - which may be configured to receive all frames.
2012-12-19 06:14 AM
2024-07-29 10:20 AM
Dear Geeta, 0x18DAF1XX seems to be connection to rfhub message. Can you help me finding the message sequence to send in order to reset any connection to rfhub in order to block the thief? I'm dealing with alfa romeo giulia.