专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
STM32
STM32CAN常用波特率配置,从此不再为计算那该死的BS1,BS2而烦恼。
2019-07-20 23:08
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
STM32/STM8
21653
48
1449
RT。
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
48条回答
MIFANHTS
1楼-- · 2019-07-25 17:54
一直想找的。谢谢、
加载中...
STM32YZ
2楼-- · 2019-07-25 19:30
STM32YZ 发表于 2016-11-29 08:26
谢谢楼主分享
谢谢支持。
加载中...
stm32tag
3楼-- · 2019-07-25 19:56
[mw_shl_code=applescript,true]switch (iBaud)
{
case CAN_BAUD_5K: /* BAUD = 5kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_8tq; /* 时间段1 */
// TS1[3:0],定义时间段1占用了多少个时间单元
CAN_InitStructure.CAN_BS2 = CAN_BS2_7tq; /* 时间段2 */
// TS2[2:0],定义时间段2占用了多少个时间单元
CAN_InitStructure.CAN_Prescaler = 450; /* 波特率预分频 F/(BS1+BS2+1)/PRE */
break;
case CAN_BAUD_10K: /* BAUD = 10kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_8tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_7tq;
CAN_InitStructure.CAN_Prescaler = 225;
break;
case CAN_BAUD_20K: /* BAUD = 20kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 150;
break;
case CAN_BAUD_25K: /* BAUD = 25kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_8tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_7tq;
CAN_InitStructure.CAN_Prescaler = 90;
break;
case CAN_BAUD_30K: /* BAUD = 30kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_8tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_7tq;
CAN_InitStructure.CAN_Prescaler = 75;
break;
case CAN_BAUD_40K: /* BAUD = 40kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 75;
break;
case CAN_BAUD_50K: /* BAUD = 50kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_8tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_7tq;
CAN_InitStructure.CAN_Prescaler = 45;
break;
case CAN_BAUD_60K: /* BAUD = 60kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 50;
break;
case CAN_BAUD_80K: /* BAUD = 80kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_5tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_4tq;
CAN_InitStructure.CAN_Prescaler = 45;
break;
case CAN_BAUD_90K: /* BAUD = 90kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_5tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_4tq;
CAN_InitStructure.CAN_Prescaler = 40;
break;
case CAN_BAUD_100K: /* BAUD = 100kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 30;
break;
case CAN_BAUD_200K: /* BAUD = 200kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 15;
break;
case CAN_BAUD_300K: /* BAUD = 300kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 10;
break;
case CAN_BAUD_400K: /* BAUD = 400kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_5tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_4tq;
CAN_InitStructure.CAN_Prescaler = 9;
break;
case CAN_BAUD_500K: /* BAUD = 500kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_4tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_3tq;
CAN_InitStructure.CAN_Prescaler = 9;
break;
case CAN_BAUD_600K: /* BAUD = 600kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 5;
break;
case CAN_BAUD_800K: /* BAUD = 800kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_4tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_4tq;
CAN_InitStructure.CAN_Prescaler = 5;
break;
case CAN_BAUD_900K: /* BAUD = 900kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_5tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_4tq;
CAN_InitStructure.CAN_Prescaler = 4;
break;
case CAN_BAUD_1000K: /* BAUD = 1000kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 3;
break;
default: /* BAUD = 50kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_8tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_7tq;
CAN_InitStructure.CAN_Prescaler = 45;
break;
}[/mw_shl_code]
加载中...
a4615800
4楼-- · 2019-07-26 01:37
精彩回答 2 元偷偷看……
加载中...
MIFANHTS
5楼-- · 2019-07-26 03:13
精彩回答 2 元偷偷看……
加载中...
stm32tag
6楼-- · 2019-07-26 06:32
好东西!
加载中...
上一页
1
2
3
4
5
6
7
8
一周热门
更多
>
相关问题
STM32F4上I2C(在PROTEUS中模拟)调试不通的问题
6 个回答
芯片供应紧张,准备换个MCU,MM32L系列替换STM32L系列的怎么样?
7 个回答
STM32同时使用两个串口进行数据收发时数据丢包的问题
5 个回答
STM32F103串口通信死机问题
4 个回答
STM32WLE5CC连接SX1268在LoRa模式下能与 SX1278互通吗?
2 个回答
STM32开发板免费用活动
7 个回答
stm32 处理 DHT11占用太多时间,大家程序是怎么设计的
8 个回答
分享一个STM32单片机做的离线编程器代码
9 个回答
相关文章
ST公司第一款无线低功耗单片机模块有效提高物联网设计生产效率
0个评论
如何实现对单片机寄存器的访问
0个评论
通过USB用STM32片内自带Bootloader下载程序及注意事项
0个评论
欲练此功必先自宫之STM32汇编启动,放慢是为了更好的前行
0个评论
×
关闭
采纳回答
向帮助了您的网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
STM32
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
关闭
您已邀请
15
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
谢谢支持。
{
case CAN_BAUD_5K: /* BAUD = 5kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_8tq; /* 时间段1 */
// TS1[3:0],定义时间段1占用了多少个时间单元
CAN_InitStructure.CAN_BS2 = CAN_BS2_7tq; /* 时间段2 */
// TS2[2:0],定义时间段2占用了多少个时间单元
CAN_InitStructure.CAN_Prescaler = 450; /* 波特率预分频 F/(BS1+BS2+1)/PRE */
break;
case CAN_BAUD_10K: /* BAUD = 10kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_8tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_7tq;
CAN_InitStructure.CAN_Prescaler = 225;
break;
case CAN_BAUD_20K: /* BAUD = 20kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 150;
break;
case CAN_BAUD_25K: /* BAUD = 25kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_8tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_7tq;
CAN_InitStructure.CAN_Prescaler = 90;
break;
case CAN_BAUD_30K: /* BAUD = 30kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_8tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_7tq;
CAN_InitStructure.CAN_Prescaler = 75;
break;
case CAN_BAUD_40K: /* BAUD = 40kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 75;
break;
case CAN_BAUD_50K: /* BAUD = 50kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_8tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_7tq;
CAN_InitStructure.CAN_Prescaler = 45;
break;
case CAN_BAUD_60K: /* BAUD = 60kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 50;
break;
case CAN_BAUD_80K: /* BAUD = 80kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_5tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_4tq;
CAN_InitStructure.CAN_Prescaler = 45;
break;
case CAN_BAUD_90K: /* BAUD = 90kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_5tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_4tq;
CAN_InitStructure.CAN_Prescaler = 40;
break;
case CAN_BAUD_100K: /* BAUD = 100kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 30;
break;
case CAN_BAUD_200K: /* BAUD = 200kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 15;
break;
case CAN_BAUD_300K: /* BAUD = 300kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 10;
break;
case CAN_BAUD_400K: /* BAUD = 400kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_5tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_4tq;
CAN_InitStructure.CAN_Prescaler = 9;
break;
case CAN_BAUD_500K: /* BAUD = 500kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_4tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_3tq;
CAN_InitStructure.CAN_Prescaler = 9;
break;
case CAN_BAUD_600K: /* BAUD = 600kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 5;
break;
case CAN_BAUD_800K: /* BAUD = 800kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_4tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_4tq;
CAN_InitStructure.CAN_Prescaler = 5;
break;
case CAN_BAUD_900K: /* BAUD = 900kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_5tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_4tq;
CAN_InitStructure.CAN_Prescaler = 4;
break;
case CAN_BAUD_1000K: /* BAUD = 1000kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_6tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_5tq;
CAN_InitStructure.CAN_Prescaler = 3;
break;
default: /* BAUD = 50kbps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_8tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_7tq;
CAN_InitStructure.CAN_Prescaler = 45;
break;
}[/mw_shl_code]
一周热门 更多>