2022-04-11 10:51 AM
I've been reading several forums posts about filtering, and other resources such as:
https://community.st.com/s/question/0D50X00009XkfSlSAJ/can-filters
https://blog.csdn.net/flydream0/article/details/52317532
I get the gist of this.
CAN_FilterIdHigh is the value to "compare" to.
CAN_FilterMaskIdHigh is the mask.
I wrote this small program to test this:
Using a range ox 0x2b0 - 02xbf
The program returns the values it should.
However, after setting it up, nothing is accepted:
void set_filter(void) {
CAN_FilterTypeDef sFilterConfig;
sFilterConfig.FilterBank = 0U;
sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
if (MYID == EJCC_UNASSIGNED) {
sFilterConfig.FilterIdHigh = (0x2b0 & 0x7F0) << 5;
sFilterConfig.FilterIdLow = 0x0000U;
sFilterConfig.FilterMaskIdHigh = 0x7f0 << 5;
sFilterConfig.FilterMaskIdLow = 0x0000U;
}
sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
sFilterConfig.FilterActivation = ENABLE;
HAL_CAN_ConfigFilter(&hcan1, &sFilterConfig);
}