2017-06-19 04:45 AM
Hi evryone, I'm using STM32f103rb card to communicate with another STM32f103rb thanks to STM32F103Rb CAN protocole, and I'm looking for using J1939.
I have parameter my identifier like that :hcan.pTxMsg->StdId = 0x01;
hcan.pTxMsg->ExtId = 0x01DAD4DC1;
hcan.pTxMsg->RTR = CAN_RTR_DATA;
hcan.pTxMsg->IDE = CAN_ID_EXT;
hcan.pTxMsg->DLC = 8;
and I'm trying to configurate my filter, but I've no idea of what could be the following configurations :
sFilterConfig.FilterIdHigh
sFilterConfig.FilterIdLow
sFilterConfig.FilterMaskIdHigh
sFilterConfig.FilterMaskIdLow
sFilterConfig.BankNumber
Anyone can help me ?
Thanks for your attention,
Regards,Nicolas.2017-06-19 05:44 AM
https://community.st.com/0D50X00009XkYJGSA3
You have to construct the mask and id so the comparator in the peripheral can recognize the specific bit pattern
The mask is ANDed with the bit stream and the ID is then compared.
https://community.st.com/0D50X00009XkXx6SAF
The EXID complicates the construction of the bit patterns, but look at the diagram of what the chip is looking for.
2017-06-19 11:37 AM
HCANFilter_Struct.FilterIdHigh = (EXTID >> 13) & 0xFFFF; // 29-bit EXTID
HCANFilter_Struct.FilterIdLow = ((EXTID << 3) & 0xFFF8) | 4;HCANFilter_Struct.FilterMaskIdHigh = 0xFFFF; // MSBHCANFilter_Struct.FilterMaskIdLow = 0xFFFC; //LSB2017-06-21 03:36 AM
thank you so much, but I need to know how you have doing this
2017-06-21 03:46 AM
I read the others link you send and I'm trying to understand but I don't really know how you have doing this
2017-06-21 10:40 AM
Don't over think the problem, silicon implementation tend to take the most simple and straight-forward design decisions.
The peripheral is processing a stream of bits, the filter is Masking the bits it wants to inspect with an AND, and then matching the bit pattern left with a comparator.
The manual describes the bit ordering of the data stream.
A critical skill to learn is to read the manual and understand the logic they describe. If it is too complex, go back to simpler concepts and understand binary representation, bits and logic operations (AND, OR, XOR, NAND, NOR, etc)
2017-06-22 03:49 AM
If I've understand,the filter bank scale configuration that we use is this one:
And you use :''HCANFilter_Struct.FilterIdHigh = (EXTID >> 13) & 0xFFFF;'' for go to EXID [17:13]
And ''HCANFilter_Struct.FilterIdLow = ((EXTID << 3) & 0xFFF8) | 4;'' for go just after IDE
am I right?Thanks for all your help
2017-06-22 09:41 AM
Yes, I'm manipulating the 29-bit ID into the pair of 16-bit registers, and also checking for the bit defining it as using the extended ID. Thus the patterns that match the comparison are posted to the FIFO, and the rest are ignored.
If you are looking to match a range of IDs then you'd adapt the mask to allow a bigger group of messages to be collected. If the bit positions don't fully accommodate this, then you can use multiple filters, or apply a fine grain filtering in software once you pull the message from the FIFO. The goal of the filters being to decimate the work load.