21ic问答首页 - GD32A503 CAN FIFO
GD32A503 CAN FIFO
hgt1232023-05-16
本帖最后由 tyw 于 2023-5-16 18:57 编辑
GD32A503 的CAN fifo 和滤波器怎么用,求大神指点
GD32A50x_User_Manual_Rev1.0_CN.pdf
(11.03 MB)
tyw 注
GD32A503 的CAN fifo 和滤波器怎么用,求大神指点
tyw 注
赞0
评论
2023-09-14
赞0
评论
2023-09-06
赞0
评论
2023-09-05
赞0
邮箱和FIFO共用一个特定的RAM,我用的邮箱模式收,不知道怎样以邮箱模式做滤波器。
我看你用的FIFO模式,能滤波成功吗?
评论
2023-08-04
请问下CAN验证好了吗,我用A503的DEMO初始化一直进入暂停状态,退不出来
赞0
{
/* enable CAN clock */
rcu_can_clock_config(CAN1, RCU_CANSRC_PCLK2_DIV_2);
rcu_periph_clock_enable(RCU_CAN1);
can_parameter_struct can_parameter;
/* initialize CAN register */
can_deinit(CAN1);
/* initialize CAN */
can_struct_para_init(CAN_INIT_STRUCT, &can_parameter);
/* initialize CAN parameters */
can_parameter.internal_counter_source = CAN_TIMER_SOURCE_BIT_CLOCK;
can_parameter.self_reception = DISABLE;
can_parameter.mb_tx_order = CAN_TX_HIGH_PRIORITY_MB_FIRST;
can_parameter.mb_tx_abort_enable = ENABLE;
can_parameter.local_priority_enable = DISABLE;
can_parameter.mb_rx_ide_rtr_type = CAN_IDE_RTR_FILTERED;
can_parameter.mb_remote_frame = CAN_STORE_REMOTE_REQUEST_FRAME;
can_parameter.rx_private_filter_queue_enable = DISABLE;
can_parameter.edge_filter_enable = DISABLE;
can_parameter.protocol_exception_enable = DISABLE;
can_parameter.rx_filter_order = CAN_RX_FILTER_ORDER_MAILBOX_FIRST;
can_parameter.memory_size = CAN_MEMSIZE_32_UNIT;
/* filter configuration */
can_parameter.mb_public_filter = 0x0;
can_parameter.resync_jump_width = 1;
can_parameter.prop_time_segment = 2;
can_parameter.time_segment_1 = 4;
can_parameter.time_segment_2 = 3;
/*baudrate =fCANCLK/prescaler/(1+PTS+PBS1+PBS2)
=50M/40/(1+2+4+3)=125K
*/
can_parameter.prescaler = 50000/Bps/(1+2+4+3); //分频系数
/* initialize CAN */
can_init(CAN1, &can_parameter);
/* configure CAN0 NVIC */
nvic_irq_enable(CAN1_Message_IRQn,6, 0);
/* enable CAN MB0 interrupt */
// can_interrupt_enable(CAN1, CAN_INT_MB0); //邮箱0 接收、发送中断
can_interrupt_enable(CAN1, CAN_INT_FIFO_AVAILABLE); //FIFO 非空中断
// can_interrupt_enable(CAN1, CAN_INT_RX_WARNING); //接收错误中断
// can_interrupt_enable(CAN1, CAN_INT_TX_WARNING); //发送错误中断
// can_interrupt_enable(CAN1, CAN_INT_ERR_SUMMARY); //错误集合中断
CAN1_FIFO_Config();
can_operation_mode_enter(CAN1, CAN_NORMAL_MODE);
}
static void CAN1_FIFO_Config(void)
{
/*
00:格式A:每个标识符过滤表元素包含一个完整标识符(标准格式和扩展格式)
01:格式B:每个标识符过滤表元素包含两个完整标准格式标识符或者两个扩展格式标识符其中14位
10:格式C:每个标识符过滤表元素包含四个标准格式标识符其中8位或者四个扩展格式标识符其中8位
*/
// //3xx;
can_fifo_parameter_struct can_rx_fifo_config_struct;
can_rx_fifo_config_struct.dma_enable = DISABLE;
can_rx_fifo_config_struct.filter_format_and_number = CAN_RXFIFO_FILTER_A_NUM_8;// 8个过滤器
can_rx_fifo_config_struct.fifo_public_filter = FIFO_FILTER_ID_EXD_A(0xFFFFFF00);//0xFFFFF00; //bit1 的是完全匹配 0是不关心
can_rx_fifo_config(CAN1,&can_rx_fifo_config_struct);
can_rx_fifo_id_filter_struct rx_fifo_id_filter_config[8];
for(int i = 0 ; i < 8; i++)
can_struct_para_init(CAN_FIFO_ID_FILTER_STRUCT, &rx_fifo_id_filter_config[i]);
rx_fifo_id_filter_config[0].remote_frame = CAN_DATA_FRAME_ACCEPTED;//远程针不要
rx_fifo_id_filter_config[0].extended_frame = CAN_EXTENDED_FRAME_ACCEPTED; //只要扩展帧
rx_fifo_id_filter_config[0].id = 0xA101;
rx_fifo_id_filter_config[1].remote_frame = CAN_DATA_FRAME_ACCEPTED;//远程针不要
rx_fifo_id_filter_config[1].extended_frame = CAN_EXTENDED_FRAME_ACCEPTED; //只要扩展帧
rx_fifo_id_filter_config[1].id = 0xB101;
can_rx_fifo_filter_table_config(CAN1,rx_fifo_id_filter_config);
}
评论
2023-06-19
大佬,可否发一下CAN发送的代码参考一下,现在我遇到一个问题,就是can能中断收到数据,发不出数据
您需要登录后才可以回复 登录 | 注册