Skip to main content
alessandro2
Associate III
January 26, 2016
Question

STM32F4 - can bus Id filters configuration

  • January 26, 2016
  • 4 replies
  • 3409 views
Posted on January 26, 2016 at 12:04

Hello everyone, I'm working with STM32F415RGT6. I need to setup the can filtering so as to get all messages which source address (I need to work with extended IDs) is different from a given one, discarded (by hardware). I'm trying to do that using the CAN_FilterConfTypeDef structure. I've had a look at the documentation (API documentation and MCU user manual), but I don't understand how the incoming message filtering works. For instance, let's suppose I need to receive messages which source address is 0x33. How should I configure the FilterIdHigh, FilterIdLow, FilterMaskIdHigh, and FilterMaskIdLow fields of the CAN_FilterConfTypeDef structure? A broader explanation of how the filtering works would also be appreciated. Many thanks in advance.

#stm32f4 #id-filters #can
This topic has been closed for replies.

4 replies

Tesla DeLorean
Guru
January 27, 2016
Posted on January 27, 2016 at 01:19

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32%20CAN%20acceptance%20mask&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=79]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32%20CAN%20acceptance%20mask&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=79

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/CAN%20FILTERS%207831&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=53

[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/STM32%20CAN%20networking%20demo%20-%20filter%20to%20accept%20everything&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=91]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Discovery%2FSTM32%20CAN%20networking%20demo%20-%20filter%20to%20accept%20everything&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F¤tviews=91

clive1 CAN Filtering

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Tesla DeLorean
Guru
January 26, 2019
Tesla DeLorean
Guru
January 27, 2016
Posted on January 27, 2016 at 01:48

/* CAN filter init */
CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;
CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;
CAN_FilterInitStructure.CAN_FilterIdHigh = (0x033 << 5); // ID 11-bit in top bits
CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0xFFE0;// ID 11-bit in top bits, mask for comparison
CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000;
// if ((bitstream & CAN_FilterMaskId) == CAN_FilterId)

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
alessandro2
Associate III
February 1, 2016
Posted on February 01, 2016 at 15:36

Many thanks for your clear example!! I managed to get things up and running!

gkema
Associate
January 26, 2019

Is HAL_CAN_ERROR_PARAM about this configuration?

Tesla DeLorean
Guru
January 26, 2019

Probably not, but you have the library source, and can breakpoint or step that to understand what it is objecting too.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..