当前位置:网站首页>GD32 can发送报no mailbox 故障
GD32 can发送报no mailbox 故障
2022-06-11 03:04:00 【NULL_1969】
1、问题描述
在使用GD32can通信时,发现如果can线断开了,再把can线连上,用can分析仪监测不到总线数据,调试后发现can发送没有成功,通过串口打印出错误,显示是没有邮箱。
2、问题解决
这个问题的原因是没有没有使能重新上线自动连接的功能。
can_parameter.auto_bus_off_recovery = ENABLE;
打开这个功能后,就正常。
另外,要使用can1,必须要初始化can0才行。
GD307的can初始化代码如下:
void init_can0(void)
{
can_parameter_struct can_parameter;
can_filter_parameter_struct can_filter;
init_can_gpio();
/* initialize CAN register */
can_deinit(CAN0);
/* initialize CAN */
can_parameter.time_triggered = DISABLE;
can_parameter.auto_bus_off_recovery = DISABLE;
can_parameter.auto_wake_up = DISABLE;
can_parameter.no_auto_retrans = DISABLE;
can_parameter.rec_fifo_overwrite = DISABLE;
can_parameter.trans_fifo_order = DISABLE;
can_parameter.working_mode = CAN_NORMAL_MODE;
can_parameter.resync_jump_width = CAN_BT_SJW_1TQ;
can_parameter.time_segment_1 = CAN_BT_BS1_6TQ;
can_parameter.time_segment_2 = CAN_BT_BS2_3TQ;
/* baudrate 1Mbps */
can_parameter.prescaler = 6;
can_init(CAN0, &can_parameter);
/* initialize filter */
/* CAN0 filter number */
can_filter.filter_number = 0;
/* initialize filter */
can_filter.filter_mode = CAN_FILTERMODE_MASK;
can_filter.filter_bits = CAN_FILTERBITS_32BIT;
can_filter.filter_list_high = 0x0000;
can_filter.filter_list_low = 0x0000;
can_filter.filter_mask_high = 0x0000;
can_filter.filter_mask_low = 0x0000;
can_filter.filter_fifo_number = CAN_FIFO0;
can_filter.filter_enable = ENABLE;
can_filter_init(&can_filter);
nvic_irq_enable(CAN0_RX0_IRQn, 10, 0);
/* enable CAN receive FIFO0 not empty interrupt */
can_interrupt_enable(CAN0, CAN_INTEN_RFNEIE0);
}
/** * @description: ӫƁĻǽ¶¯°卨Ѕ * @param {*} * @return {*} */
void init_can1(void)
{
can_parameter_struct can_parameter;
can_filter_parameter_struct can_filter;
init_can_gpio();
/* initialize CAN register */
can_deinit(CAN1);
/* initialize CAN */
can_parameter.time_triggered = DISABLE;
can_parameter.auto_bus_off_recovery = ENABLE;
can_parameter.auto_wake_up = DISABLE;
can_parameter.no_auto_retrans = DISABLE;
can_parameter.rec_fifo_overwrite = DISABLE;
can_parameter.trans_fifo_order = DISABLE;
can_parameter.working_mode = CAN_NORMAL_MODE;
can_parameter.resync_jump_width = CAN_BT_SJW_1TQ;
can_parameter.time_segment_1 = CAN_BT_BS1_6TQ;
can_parameter.time_segment_2 = CAN_BT_BS2_3TQ;
/* baudrate 1Mbps */
can_parameter.prescaler = 6;
can_init(CAN1, &can_parameter);
/* initialize filter */
/* CAN0 filter number */
can_filter.filter_number = 14;
/* initialize filter */
can_filter.filter_mode = CAN_FILTERMODE_MASK;
can_filter.filter_bits = CAN_FILTERBITS_32BIT;
can_filter.filter_list_high = 0x0000;
can_filter.filter_list_low = 0x0000;
can_filter.filter_mask_high = 0x0000;
can_filter.filter_mask_low = 0x0000;
can_filter.filter_fifo_number = CAN_FIFO1;
can_filter.filter_enable = ENABLE;
can_filter_init(&can_filter);
nvic_irq_enable(CAN1_RX1_IRQn, 5, 0);
/* enable CAN receive FIFO0 not empty interrupt */
can_interrupt_enable(CAN1, CAN_INTEN_RFNEIE1);
}
边栏推荐
- VMware virtual machine IP, gateway settings. The virtual machine cannot be pinged to the Internet
- Error excluded identifier before '(' token, grpc enumeration class compilation error
- 出栈序列是否是入栈序列
- The two request sessionids of the same user are inconsistent ----- record the problem
- B_QuRT_User_Guide(19)
- 近期学习和更新计划
- JS memory leak
- intXX_ T and int_ fastXX_ T what is the difference- What is the difference between intXX_ t and int_ fastXX_ t?
- MySQL学习笔记:JSON嵌套数组查询
- Graphacademy course explanation: Fundamentals of neo4j graph data science
猜你喜欢
![[long time series prediction] aotoformer code detailed [3] model overall architecture analysis](/img/77/30215c363ae8a1324db1cbcaa5324b.png)
[long time series prediction] aotoformer code detailed [3] model overall architecture analysis

Android P SoftAP start process

【大咖秀】博睿数据眼中的AIOps,选择正确的赛道正确的人

CocosCreator原生二次开发的正确姿势

ASLR

postgresql源码学习(十七)—— MVCC②-快照与隔离级别简介

Cygwin reports an error child_ info_ fork::abort: XXX. dll: Loaded to different address: parent(XXX) != child(XXX)

Arduino使用NRF24L01模块进行无线通信

org. apache. solr. common. SolrException:Could not load core configuration for core hotel

巴歇尔槽流量计远程采集物联网关在明渠流量监测的应用
随机推荐
Fuluo classic source code Fuluo classic system development principle sharing
DNS Optimization Practice of APP network optimization
富络经典源码富络经典系统开发原理分享
【长时间序列预测】Aotoformer 代码详解之[3]模型整体架构分析
出栈序列是否是入栈序列
第七章 常用的协议简介(1)
Longest increasing subsequence
Go quick start of go language (I): the first go program
How to state clearly and concisely the product requirements?
org. apache. solr. common. SolrException:Could not load core configuration for core hotel
Three ways of reflection
Cmake common commands
2022年6月中国数据库排行榜:TiDB卷土重来摘桂冠,达梦蛰伏五月夺探花
Hqchart actual combat tutorial 55 area map of K line of ouyi.com
023 MySQL索引优化口诀-索引失效的常见情况
MySQL学习笔记:JSON嵌套数组查询
Pyqt5: button control
Wechat template message errCode ": 40165," errmsg ":" invalid web pagepath
ThoughtWorks.QRCode功能齐全的生成器
Construction of Flink development environment and wordcount