cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Discovery Filter configration

ninad911
Associate III
Posted on June 30, 2016 at 20:53

Hello,

   can any one please provide me with CAN Filter configuration of  'FilterIdHigh', ''FilterIdLow', 'FilterMaskIdHigh', 'FilterMaskIdLow', 'BankNumber' of STM32F4 Discovery board. i want to receive any frame on CAN1 Receiver. i am using HAL Library.

I have configured my CAN Filter as follows.

/*CAN1 filter function*/

void CAN_filter_init(void)

{

CAN_FilterConfTypeDef  sFilterConfig;

 /*♯♯-2- Configure the CAN Filter ♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯*/

sFilterConfig.FilterNumber = 0;

    sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;

    sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;

    sFilterConfig.FilterIdHigh = 0xFFFF;;

    sFilterConfig.FilterIdLow = 0x0000;

    sFilterConfig.FilterMaskIdHigh = 0xFFFF;

    sFilterConfig.FilterMaskIdLow = 0x0000;

    sFilterConfig.FilterFIFOAssignment = CAN_FILTER_FIFO0;

    sFilterConfig.FilterActivation = ENABLE;

    sFilterConfig.BankNumber =14;

    HAL_CAN_ConfigFilter(&CanHandle, &sFilterConfig);

}

with this CAN configuration i am trying to receive frame on CAN1 using the following 

/*CAN1 Receving function */

void CAN_Rx(void)

{

      HAL_CAN_Receive(&CanHandle,CAN_FILTER_FIFO0, 10);

           datarx[0]=CanHandle.pRxMsg->StdId ;

          datarx[1] =CanHandle.pRxMsg->DLC;

           datarx[2]= CanHandle.pRxMsg->RTR   ;

           datarx[3]= CanHandle.pRxMsg->DLC   ;

           datarx[4]= CanHandle.pRxMsg->Data[0] ;

          datarx[5]= CanHandle.pRxMsg->Data[1];

}

please provide me with the correct can filter configuration.

Thanks in advance!

 

#!stm32f4 #cubemx-stm32-hal
1 REPLY 1
Posted on June 30, 2016 at 21:22

Yours will accept pretty much nothing...

Accept Everything...

sFilterConfig.FilterIdHigh = 0x0000;

sFilterConfig.FilterIdLow = 0x0000;

sFilterConfig.FilterMaskIdHigh = 0x0000;

sFilterConfig.FilterMaskIdLow = 0x0000;

Google is your friend, use him, it saves me from having to keep re-litigating this.

[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/STM32F4%20-%20can%20bus%20Id%20filters%20configuration&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&currentviews=142]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Java%2FSTM32F4%20%2D%20can%20bus%20Id%20filters%20configuration&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21¤tviews=142

Here's one with a diagram from the manual

[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

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