STM32F769 CAN3的配置,能发送,接收不到,为什么?配置如下:
/* CAN3 init function */
static void MX_CAN3_Init(void)
{
CAN_FilterTypeDef sFilterConfig;
hcan3.Instance = CAN3;
hcan3.Init.Prescaler = 54000000ul / 250000 / 18;
hcan3.Init.Mode = CAN_MODE_NORMAL;
hcan3.Init.SyncJumpWidth = CAN_SJW_1TQ;
hcan3.Init.TimeSeg1 = CAN_BS1_11TQ;
hcan3.Init.TimeSeg2 = CAN_BS2_6TQ;
hcan3.Init.TimeTriggeredMode = DISABLE;
hcan3.Init.AutoBusOff = DISABLE;
hcan3.Init.AutoWakeUp = DISABLE;
hcan3.Init.AutoRetransmission = DISABLE;
hcan3.Init.ReceiveFifoLocked = DISABLE;
hcan3.Init.TransmitFifoPriority = DISABLE;
if (HAL_CAN_Init(&hcan3) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
//过滤器设置
sFilterConfig.FilterBank = 0; //过滤器组0
sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK; //工作在标识符屏蔽位模式
sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT; //滤波器位宽为单个32位
sFilterConfig.FilterIdHigh = 0; //(((unsigned int)0x1314<<3)&0xFFFF0000)>>16; //要过滤的ID高位
sFilterConfig.FilterIdLow = 0; //(((unsigned int)0x1314<<3)|CAN_ID_EXT|CAN_RTR_DATA)&0xFFFF; //要过滤的ID低位
sFilterConfig.FilterMaskIdHigh = 0; //0xffff;
sFilterConfig.FilterMaskIdLow = 0; //0xffff;
sFilterConfig.FilterFIFOAssignment = CAN_FILTER_FIFO0;//过滤器被关联到FIFO0;
sFilterConfig.FilterActivation = ENABLE; //使能过滤器
//sFilterConfig.BankNumber = 14;
if (HAL_CAN_ConfigFilter(&hcan3, &sFilterConfig) != HAL_OK)
{
/* Filter configuration Error */
Error_Handler();
}
/*##-3- Start the CAN peripheral ###########################################*/
if (HAL_CAN_Start(&hcan3) != HAL_OK)
{
/* Start Error */
Error_Handler();
}
/*##-4- Activate CAN RX notification #######################################*/
if (HAL_CAN_ActivateNotification(&hcan3, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK)
{
/* Notification Error */
Error_Handler();
}
Can_sendData(&hcan3);
} |