2020-07-28 10:22 PM
2020-07-28 11:06 PM
Going to be a function of the bits you want to match. Place them in the bit positions described, construct a bit mask to extract them.
What IDs do you need to match?
2020-07-29 12:42 AM
I use stm32f446re. I want the processor to get the value 0x1405. Example: Processor light the led according to the value 0x1405.
Use only can2.
Apb1= 32Mhz
systemclock =64 Mhz
//can2 settings
void MX_CAN2_Init(void)
{
CAN_FilterTypeDef sFilterConfig;
hcan2.Instance = CAN2;
hcan2.Init.Prescaler = 8;
hcan2.Init.Mode = CAN_MODE_NORMAL;
hcan2.Init.SyncJumpWidth = CAN_SJW_1TQ;
hcan2.Init.TimeSeg1 = CAN_BS1_11TQ;
hcan2.Init.TimeSeg2 = CAN_BS2_4TQ;
hcan2.Init.TimeTriggeredMode = DISABLE;
hcan2.Init.AutoBusOff = DISABLE;
hcan2.Init.AutoWakeUp = DISABLE;
hcan2.Init.AutoRetransmission = DISABLE;
hcan2.Init.ReceiveFifoLocked = DISABLE;
hcan2.Init.TransmitFifoPriority = DISABLE;
if (HAL_CAN_Init(&hcan2) != HAL_OK)
{
Error_Handler();
}
sFilterConfig.FilterBank = 0;
sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
sFilterConfig.FilterIdHigh=
sFilterConfig.FilterIdLow=
sFilterConfig.FilterMaskIdHigh=
sFilterConfig.FilterMaskIdLow=
sFilterConfig.FilterFIFOAssignment = CAN_FILTER_FIFO0;
sFilterConfig.FilterActivation = CAN_FILTER_ENABLE;
sFilterConfig.SlaveStartFilterBank = 13;
HAL_CAN_ConfigFilter(&hcan2, &sFilterConfig);
HAL_CAN_Start(&hcan2);
HAL_CAN_ActivateNotification(&hcan2, CAN_IT_RX_FIFO0_MSG_PENDING);
}
2020-07-29 01:36 AM
.