cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with CAN controller

SS.Sagar
Associate III
Posted on May 27, 2016 at 20:11

Hi,

i m using STM32F103 nucleo board. I m configuring CAN controller to receive particular message ID for Standard Identifier (CAN ID : 0x0212) Here is my configuration for acceptance filter.

CAN_FilterStruct.FilterIdHigh = 0x0000; /* Upper 16bit filter ID */
CAN_FilterStruct.FilterIdLow = 0x0123; /* Filter lower 16bit ID */
CAN_FilterStruct.FilterMaskIdHigh = 0x0000; /* Upper 16bit filter mask */
CAN_FilterStruct.FilterMaskIdLow = 0x0000; /* Lower 16bit filter mask */
CAN_FilterStruct.FilterFIFOAssignment = CAN_FILTER_FIFO0; /* Which FIFO will be assigned to filter */
CAN_FilterStruct.FilterNumber = 0;
CAN_FilterStruct.FilterMode = CAN_FILTERMODE_IDLIST; /* Identifier mask mode*/
CAN_FilterStruct.FilterScale = CAN_FILTERSCALE_32BIT; /* 32bit ID filter */
CAN_FilterStruct.FilterActivation = ENABLE; /* Enable this filter */
CAN_FilterStruct.BankNumber = 14; /* Start slave bank filter (?) */

Thanks in advance. #uart #bxcan #stm32 #nucleo
2 REPLIES 2
Posted on May 27, 2016 at 21:04

[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=111]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Java%2FSTM32F4%20-%20can%20bus%20Id%20filters%20configuration&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21¤tviews=111

You'll have to adapt to the syntax for your chosen library

/* CAN filter init */
CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;
CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;
CAN_FilterInitStructure.CAN_FilterIdHigh = (0x212 << 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 Venmo
Up vote any posts that you find helpful, it shows what's working..
SS.Sagar
Associate III
Posted on May 28, 2016 at 18:30

Hi,

Thank you.It is working !!!

I have small doubt. 

I m sending following three messages from controller A to Controller B. 

1.msg ID:212

2.msg ID:313

3.msg ID:212

But i configured different controller B for 212 only.

So, Controller B is receiving 1st msg only. Controller A is getting stuck at 2nd msg bcoz controller B is not configured for that.

So controller A is not able to send 3rd msg.

Is it expected?