Change_filter_CAN1(0x0280<<5, 0x0380<<5); //test
sprintf(str_print,"high filter: %x\r\n",hcan1Filter.FilterIdHigh);
HAL_UART_Transmit(&huart2,(uint8_t*)str_print,strlen(str_print),0x1000);
sprintf(str_print,"high mask: %x\r\n",hcan1Filter.FilterMaskIdHigh);
HAL_UART_Transmit(&huart2,(uint8_t*)str_print,strlen(str_print),0x1000);
void Change_filter_CAN1(uint32_t filter_high, uint32_t mask)
{
hcan1Filter.FilterIdHigh =filter_high;
hcan1Filter.FilterIdLow =filter_high;
hcan1Filter.FilterMaskIdHigh =mask;
hcan1Filter.FilterMaskIdLow =mask;
if(HAL_CAN_ConfigFilter(&hcan1, &hcan1Filter) != HAL_OK)
{
Error_Handler();
}
}
что-то снова с тэгом код.
void MX_CAN1_Init(void)
{
/* USER CODE BEGIN CAN1_Init 0 */
/* USER CODE END CAN1_Init 0 */
/* USER CODE BEGIN CAN1_Init 1 */
//hcan1.Init.Prescaler = prescaler1;//6;
/* USER CODE END CAN1_Init 1 */
hcan1.Instance = CAN1;
hcan1.Init.Prescaler = 6;
hcan1.Init.Mode = CAN_MODE_SILENT;
hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ;
hcan1.Init.TimeSeg1 = CAN_BS1_13TQ;
hcan1.Init.TimeSeg2 = CAN_BS2_2TQ;
hcan1.Init.TimeTriggeredMode = DISABLE;
hcan1.Init.AutoBusOff = DISABLE;
hcan1.Init.AutoWakeUp = DISABLE;
hcan1.Init.AutoRetransmission = DISABLE;
hcan1.Init.ReceiveFifoLocked = DISABLE;
hcan1.Init.TransmitFifoPriority = DISABLE;
if (HAL_CAN_Init(&hcan1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN CAN1_Init 2 */
hcan1Filter.FilterBank = 0;
hcan1Filter.FilterMode = CAN_FILTERMODE_IDLIST; //CAN_FILTERMODE_IDMASK;
hcan1Filter.FilterScale = CAN_FILTERSCALE_16BIT;
hcan1Filter.FilterIdHigh = 0;//0x0280<<5; // = 0x07E0<<5; // Ñòàðøàÿ ÷àñòü ôèëüòðà
hcan1Filter.FilterIdLow = 0;//x0280<<5;
hcan1Filter.FilterMaskIdHigh = 0;//x0380<<5; //0x07E0<<5; // Ñòàðøàÿ ÷àñòü ìàñêè
hcan1Filter.FilterMaskIdLow = 0;//x0380<<5;
hcan1Filter.FilterFIFOAssignment = CAN_RX_FIFO0;
hcan1Filter.FilterActivation = ENABLE;
//hcan1Filter.SlaveStartFilterBank = 14;
if(HAL_CAN_ConfigFilter(&hcan1, &hcan1Filter) != HAL_OK)
{
Error_Handler();
}