嗨,我想用
STM32F4 在 2 个 CAN 总线之间架起一座桥。我试图在 HAL_CAN_RxFifo0MsgPendingCallback 上监听两个 CAN 的中断并接收消息并将其发送到另一个 CAN,但似乎我只收到 CAN1 中断。CAN2 不触发中断。
我对两个总线使用相同的过滤器配置:
- //hcan - CAN1 and CAN2
- CAN_FilterTypeDef sFilterConfig;
- sFilterConfig.FilterBank = 0;
- sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
- sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
- sFilterConfig.FilterIdHigh = 0x0000;
- sFilterConfig.FilterIdLow = 0x0000;
- sFilterConfig.FilterMaskIdHigh = 0x0000;
- sFilterConfig.FilterMaskIdLow = 0x0000;
- sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
- sFilterConfig.FilterActivation = ENABLE;
- sFilterConfig.SlaveStartFilterBank = 14;
- if (HAL_CAN_ConfigFilter(hcan, &sFilterConfig) != HAL_OK)
- {
- Error_Handler();
- }
- if (HAL_CAN_Start(hcan) != HAL_OK)
- {
- Error_Handler();
- }
- if (HAL_CAN_ActivateNotification(hcan, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK)
- {
- Error_Handler();
- }
为什么 CAN2 没有按预期工作?