Question
STM32 CAN Filtering
Posted on January 20, 2016 at 01:53
Hello!
I have configured my filter banks. However, the standard ID that the receive FIFO0 register is reading after controller transmits a response to my module is not what I expect. Hence, I suspect this phenomenon is due to incorrect message filtering that causes an incorrect bit sequence to be stored in the receive FIFO0 register. The following is my code:CAN_FilterConfTypeDef CAN_FilterConfig[5] = {
{.BankNumber = 0, .FilterActivation = ENABLE, .FilterNumber = 0, .FilterFIFOAssignment = 0,
.FilterScale = CAN_FILTERSCALE_16BIT, .FilterMode = CAN_FILTERMODE_IDMASK,
.FilterMaskIdLow = (0x7FF << 5), .FilterMaskIdHigh = 0,
.FilterIdLow = (STID1 << 5), .FilterIdHigh = 0},
{.BankNumber = 0, .FilterActivation = ENABLE, .FilterNumber = 1, .FilterFIFOAssignment = 0,
.FilterScale = CAN_FILTERSCALE_16BIT, .FilterMode = CAN_FILTERMODE_IDMASK,
.FilterMaskIdHigh = (0x7FF << 5), .FilterMaskIdLow = 0,
.FilterIdHigh = (STID2 << 5), .FilterIdLow = 0},
{.BankNumber = 0, .FilterActivation = ENABLE, .FilterNumber = 2, .FilterFIFOAssignment = 0,
.FilterScale = CAN_FILTERSCALE_16BIT, .FilterMode = CAN_FILTERMODE_IDMASK,
.FilterMaskIdLow = (0x7FF << 5), .FilterMaskIdHigh = 0,
.FilterIdLow = (STID3 << 5), .FilterIdHigh = 0},
{.BankNumber = 0, .FilterActivation = ENABLE, .FilterNumber = 3, .FilterFIFOAssignment = 0,
.FilterScale = CAN_FILTERSCALE_16BIT, .FilterMode = CAN_FILTERMODE_IDMASK,
.FilterMaskIdHigh = (0x7FF << 5), .FilterMaskIdLow = 0,
.FilterIdHigh = (STID4 << 5), .FilterIdLow = 0},
{.BankNumber = 0, .FilterActivation = ENABLE, .FilterNumber = 4, .FilterFIFOAssignment = 0,
.FilterScale = CAN_FILTERSCALE_16BIT, .FilterMode = CAN_FILTERMODE_IDMASK,
.FilterMaskIdHigh = 0, .FilterMaskIdLow = (0x7FF << 5),
.FilterIdHigh = 0, .FilterIdLow = (STID5 << 5)},
};
HAL_CAN_ConfigFilter(&hcan, &CAN_FilterConfig[0]);
HAL_CAN_ConfigFilter(&hcan, &CAN_FilterConfig[1]);
HAL_CAN_ConfigFilter(&hcan, &CAN_FilterConfig[2]);
HAL_CAN_ConfigFilter(&hcan, &CAN_FilterConfig[3]);
HAL_CAN_ConfigFilter(&hcan, &CAN_FilterConfig[4]);
I have configured 5 messages in the filters using filter numbers 0 to 4.
Is this configuration correct?
Is this what determines what is stored in the can receive FIFIO 0 (CAN_RIXR) register?
FYI, I am using a STM32F302 custom made board.
Thank you!