在FreeRTOS系统下,GPIO口已正确初始化,下面这段代码是初始化CAN0和CAN1的程序。
can_parameter_struct can_init_parameter;
can_filter_parameter_struct can_filter_parameter;
can_struct_para_init(CAN_INIT_STRUCT, &can_init_parameter);
can_struct_para_init(CAN_FILTER_STRUCT, &can_filter_parameter);
/* initialize CAN register */
can_deinit(CAN0);
can_deinit(CAN1);
/* initialize CAN parameters */
can_init_parameter.time_triggered = DISABLE;
can_init_parameter.auto_bus_off_recovery = DISABLE;
can_init_parameter.auto_wake_up = DISABLE;
can_init_parameter.auto_retrans = ENABLE;
can_init_parameter.rec_fifo_overwrite = DISABLE;
can_init_parameter.trans_fifo_order = DISABLE;
can_init_parameter.working_mode = CAN_NORMAL_MODE;
can_init_parameter.resync_jump_width = CAN_BT_SJW_1TQ;
can_init_parameter.time_segment_1 = CAN_BT_BS1_7TQ;
can_init_parameter.time_segment_2 = CAN_BT_BS2_2TQ;
/* 1MBps */
#if CAN_BAUDRATE == 1000
can_init_parameter.prescaler = 5;
/* 500KBps */
#elif CAN_BAUDRATE == 500
can_init_parameter.prescaler = 10;
/* 250KBps */
#elif CAN_BAUDRATE == 250
can_init_parameter.prescaler = 20;
/* 125KBps */
#elif CAN_BAUDRATE == 125
can_init_parameter.prescaler = 40;
/* 100KBps */
#elif CAN_BAUDRATE == 100
can_init_parameter.prescaler = 50;
/* 50KBps */
#elif CAN_BAUDRATE == 50
can_init_parameter.prescaler = 100;
/* 20KBps */
#elif CAN_BAUDRATE == 20
can_init_parameter.prescaler = 250;
#else
//#error "please select list can baudrate in private defines in main.c "
#endif
/* initialize CAN */
can_init(CAN0, &can_init_parameter);
can_init(CAN1, &can_init_parameter);
/* initialize filter */
can_filter_parameter.filter_number = 0;
can_filter_parameter.filter_mode = CAN_FILTERMODE_MASK;
can_filter_parameter.filter_bits = CAN_FILTERBITS_32BIT;
can_filter_parameter.filter_list_high = 0;
can_filter_parameter.filter_list_low = 0;
can_filter_parameter.filter_mask_high = 0;
can_filter_parameter.filter_mask_low = 0;
can_filter_parameter.filter_fifo_number = CAN_FIFO0;
can_filter_parameter.filter_enable = ENABLE;
can_filter_init(&can_filter_parameter);
can_filter_parameter.filter_number = 15;
can_filter_init(&can_filter_parameter);
/* enable can receive FIFO0 not empty interrupt */
can_interrupt_enable(CAN0, CAN_INT_RFNE0);
can_interrupt_enable(CAN1, CAN_INT_RFNE0);
使能中断
NVIC_SetPriority(CAN0_RX0_IRQn, 3);
NVIC_EnableIRQ(CAN0_RX0_IRQn);
NVIC_SetPriority(CAN1_RX0_IRQn, 4);
NVIC_EnableIRQ(CAN1_RX0_IRQn);
问题:CAN0的中断可以正常进入,CAN1的中断无法执行