2017-03-20 10:28 AM
Working with HAL_CAN over STM32L4 polatform and kvaser (can analyzer).
I have this functions implementing my bank filtering:
void DRV_CAN_configureFiltersBank(void)
{ HCANFilter_Struct.FilterNumber = 0; //0 - 27 HCANFilter_Struct.FilterMode = CAN_FILTERMODE_IDMASK; HCANFilter_Struct.FilterScale = CAN_FILTERSCALE_32BIT; /*iid mask = 0...0 --> 0=don't care --> se acepta id con cualquier valor de bit en ese lugar*/ HCANFilter_Struct.FilterIdHigh = 0x0000; //11-bit ID in top bits ;//MSB of 32b config HCANFilter_Struct.FilterIdLow = 0x1F;//LSB of 32b config HCANFilter_Struct.FilterMaskIdHigh = 0x0000; //MSB HCANFilter_Struct.FilterMaskIdLow = 0x11; //LSB HCANFilter_Struct.FilterFIFOAssignment = 0; HCANFilter_Struct.FilterActivation = ENABLE; HCANFilter_Struct.BankNumber = 13; if (HAL_CAN_ConfigFilter(&HCAN_Struct,&HCANFilter_Struct) != HAL_OK) { DrvCan_Error_Handler(); } }I would like to remark black letters. Since I have this configuration and I'm sending frames with different ID values and controller seems to get sometimes expected frames ID, but sometimes get non expected ones. Even sometimes ahs blocked correct IDs. If I understand correctly, with this configuration I have:
Is it?
The thing is that I send a frame with 10100 = ID, but this frame passes the filters and it is processed (with an eco transmition after being receiving).
Is something wrong at my configuration understanding?
Thanks in advance.
#mask #id-filters #hal_can_receive_it #can #can-filter2017-04-27 03:40 AM
I don't understand.. This 5 bit (RTR,IDE,EXID) in what register are they?
2017-04-27 03:58 AM
If I want that the filter 0 works on 4 ID of 16 bit, and for example I want to receive the following ID: 5,10,12,14.. How can I set the Filter bank register?
CAN_F0R1 = 5<<5 | 10<<16;
CAN_F0R2 = 12<<5 | 14<<16;
It's correct, I can receive the ID 5 but not the ID 10?
Thanks.
2017-04-27 08:13 AM
They are bits in the CAN packet headers, see a definition of the CAN standards.
You have to shift the pattern you want to match in to the bit fields that the comparison is occurring on
CAN_F0R1 = (5<<5) | (10 << (5 + 16));
CAN_F0R2 = (12<<5) | (14 << (5 +16));