当前位置:网站首页>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);
}
边栏推荐
- DNS Optimization Practice of APP network optimization
- B_ QuRT_ User_ Guide(20)
- VMware virtual machine IP, gateway settings. The virtual machine cannot be pinged to the Internet
- Determine whether a string of numbers is the result of a quick sort
- Multivalued mapping: arraylistmultimap and hashmultimap
- Hough transform of image
- B_QuRT_User_Guide(18)
- Application of the remote acquisition IOT gateway of the Bashir trough flowmeter in open channel flow monitoring
- The two departments jointly issued the nine provisions on fire safety management of off campus training institutions
- How to state clearly and concisely the product requirements?
猜你喜欢

ArTalk | 如何用最小投入,构建国产超融合进化底座?

Wechat applet

Hqchart actual combat tutorial 55 area map of K line of ouyi.com

Solr import MySQL database report: Data config problem: invalid byte 2 of 2-byte UTF-8 sequence

postgresql源码学习(二十)—— 故障恢复①-事务日志格式

CPT 102_ LEC 17

B_QuRT_User_Guide(17)

GraphAcademy 課程講解:《Neo4j 圖數據科學基礎》

Niuke: two numbers that only appear once in the array

cv. Houghcircles: Circular Hough transform opencv
随机推荐
出栈序列是否是入栈序列
Location data fusion Table 3
词汇表的构建——代码补全快餐教程(3)-分词
OpenJudge NOI 1.13 18:Tomorrow never knows?
DNS Optimization Practice of APP network optimization
UBIFS FAQ and HOWTO
Pyqt5:slider slider control
Detailed explanation of unity project optimization (continuous supplement)
How to ensure reliable delivery of messages?
Will your company choose to develop data center?
. Net module and assembly - NET Module vs Assembly
Young people fleeing big cities: shouldering housing prices and pressure, but not epidemics
The solution of invalid @data annotation in idea2018
反射三种方式
sonarqube平台基础使用
Helm deploy traifik ingress
HQChart钉钉小程序教程1-创建K线图
R分析可视化实用数据(航班_教育_餐厅_租户_变迁_寿命_安全)
Why did those who left Beijing, Shanghai and Guangzhou with a smile cry in the end?
MySQL学习笔记:JSON嵌套数组查询