专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
STM32
求大神告知,有关STM32F429的CAN时钟是多少,从哪里看
2019-07-21 00:57
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
STM32/STM8
14873
9
1087
求大神告知,STM32F429 CAN的时钟具体是多少?从哪里获悉?由下图知道,tq=1/CAN时钟
由RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);知CAN1在APB1时钟线上,那APB1的时钟具体是多少M?
另外,CAN1的时钟可以通过扎波形获悉吗?波特率可以扎出来吗?从哪里扎?
谢谢!
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
9条回答
墨染卿卿
2019-07-21 12:29
回复【3楼】正点原子:
---------------------------------
u8 CAN1_Mode_Init(u8 tsjw,u8 tbs2,u8 tbs1,u16 brp,u8 mode)
{
GPIO_InitTypeDef GPIO_InitStructure;
CAN_InitTypeDef CAN_InitStructure;
CAN_FilterInitTypeDef CAN_FilterInitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
//?????à???±??
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);//????PORTA?±??
RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);//????CAN1?±??
//??????GPIO
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8| GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//????????
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//???ì????
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//????
GPIO_Init(GPIOB, &GPIO_InitStructure);//??????PA11,PA12
//????????????????
GPIO_PinAFConfig(GPIOB,GPIO_PinSource8,GPIO_AF_CAN1); //GPIOA11??????CAN1
GPIO_PinAFConfig(GPIOB,GPIO_PinSource9,GPIO_AF_CAN1); //GPIOA12??????CAN1
//CAN?????è??
CAN_InitStructure.CAN_TTCM=DISABLE; //·??±????·??¨??????
CAN_InitStructure.CAN_ABOM=DISABLE; //?í??×??????????í
CAN_InitStructure.CAN_AWUM=DISABLE;//?????????¨???í??????(????CAN->MCR??SLEEP??)
CAN_InitStructure.CAN_NART=ENABLE; //????±¨??×???????
CAN_InitStructure.CAN_RFLM=DISABLE; //±¨???????¨,????????????
CAN_InitStructure.CAN_TXFP=DISABLE; //????????±¨??±ê??·????¨
CAN_InitStructure.CAN_Mode= mode; //?????è??
CAN_InitStructure.CAN_SJW=tsjw; //?????????????í??(Tsjw)??tsjw+1???±?????? CAN_SJW_1tq~CAN_SJW_4tq
CAN_InitStructure.CAN_BS1=tbs1; //Tbs1·??§CAN_BS1_1tq ~CAN_BS1_16tq
CAN_InitStructure.CAN_BS2=tbs2;//Tbs2·??§CAN_BS2_1tq ~ CAN_BS2_8tq
CAN_InitStructure.CAN_Prescaler=brp; //·???????(Fdiv)??brp+1
CAN_Init(CAN1, &CAN_InitStructure); // ??????CAN1
//?????????÷
CAN_FilterInitStructure.CAN_FilterNumber=0; //?????÷0
CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;
CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit; //32??
CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000;////32??ID
CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000;//32??MASK
CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_Filter_FIFO0;//?????÷0??????FIFO0
CAN_FilterInitStructure.CAN_FilterActivation=ENABLE; //?¤???????÷0
CAN_FilterInit(&CAN_FilterInitStructure);//???¨?÷??????
CAN_ITConfig(CAN1,CAN_IT_FMP0,ENABLE);//FIFO0???????????????í.
NVIC_InitStructure.NVIC_IRQChannel = CAN1_RX0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; // ?÷????????1
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; // ??????????0
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
调用为CAN1_Mode_Init(CAN_SJW_1tq,CAN_BS2_4tq,CAN_BS1_6tq,2,CAN_Mode_Normal);?
配置程序如上,这样配扎TX脚波形为下图,大概1M,反推出CAN时钟为1*(1+4+6)*(2+1)=33M
?不是您说的45M表示非常迷茫,需要大神解答。
?也许您要说,是否是再看tsjw要加1,计算的时候已经按加1算了
?如下
?#define CAN_SJW_1tq ((uint8_t)0x00) /*!< 1 time quantum */
#define CAN_SJW_2tq ((uint8_t)0x01) /*!< 2 time quantum */
#define CAN_SJW_3tq ((uint8_t)0x02) /*!< 3 time quantum */
#define CAN_SJW_4tq ((uint8_t)0x03) /*!< 4 time quantum */
?所以,较郁闷。求解答。
?另,CAN2用与CAN1相同的配置,但是不能通信,真是一件非常伤心的事。同求大神解答。
加载中...
查看其它9个回答
一周热门
更多
>
相关问题
STM32F4上I2C(在PROTEUS中模拟)调试不通的问题
6 个回答
芯片供应紧张,准备换个MCU,MM32L系列替换STM32L系列的怎么样?
7 个回答
STM32同时使用两个串口进行数据收发时数据丢包的问题
5 个回答
STM32F103串口通信死机问题
4 个回答
STM32WLE5CC连接SX1268在LoRa模式下能与 SX1278互通吗?
2 个回答
相关文章
ST公司第一款无线低功耗单片机模块有效提高物联网设计生产效率
0个评论
如何实现对单片机寄存器的访问
0个评论
通过USB用STM32片内自带Bootloader下载程序及注意事项
0个评论
欲练此功必先自宫之STM32汇编启动,放慢是为了更好的前行
0个评论
×
关闭
采纳回答
向帮助了您的知道网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
STM32
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
×
付费偷看金额在0.1-10元之间
确定
×
关闭
您已邀请
0
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
---------------------------------
u8 CAN1_Mode_Init(u8 tsjw,u8 tbs2,u8 tbs1,u16 brp,u8 mode)
{
GPIO_InitTypeDef GPIO_InitStructure;
CAN_InitTypeDef CAN_InitStructure;
CAN_FilterInitTypeDef CAN_FilterInitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
//?????à???±??
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);//????PORTA?±??
RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);//????CAN1?±??
//??????GPIO
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8| GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//????????
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//???ì????
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//????
GPIO_Init(GPIOB, &GPIO_InitStructure);//??????PA11,PA12
//????????????????
GPIO_PinAFConfig(GPIOB,GPIO_PinSource8,GPIO_AF_CAN1); //GPIOA11??????CAN1
GPIO_PinAFConfig(GPIOB,GPIO_PinSource9,GPIO_AF_CAN1); //GPIOA12??????CAN1
//CAN?????è??
CAN_InitStructure.CAN_TTCM=DISABLE; //·??±????·??¨??????
CAN_InitStructure.CAN_ABOM=DISABLE; //?í??×??????????í
CAN_InitStructure.CAN_AWUM=DISABLE;//?????????¨???í??????(????CAN->MCR??SLEEP??)
CAN_InitStructure.CAN_NART=ENABLE; //????±¨??×???????
CAN_InitStructure.CAN_RFLM=DISABLE; //±¨???????¨,????????????
CAN_InitStructure.CAN_TXFP=DISABLE; //????????±¨??±ê??·????¨
CAN_InitStructure.CAN_Mode= mode; //?????è??
CAN_InitStructure.CAN_SJW=tsjw; //?????????????í??(Tsjw)??tsjw+1???±?????? CAN_SJW_1tq~CAN_SJW_4tq
CAN_InitStructure.CAN_BS1=tbs1; //Tbs1·??§CAN_BS1_1tq ~CAN_BS1_16tq
CAN_InitStructure.CAN_BS2=tbs2;//Tbs2·??§CAN_BS2_1tq ~ CAN_BS2_8tq
CAN_InitStructure.CAN_Prescaler=brp; //·???????(Fdiv)??brp+1
CAN_Init(CAN1, &CAN_InitStructure); // ??????CAN1
//?????????÷
CAN_FilterInitStructure.CAN_FilterNumber=0; //?????÷0
CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;
CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit; //32??
CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000;////32??ID
CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000;//32??MASK
CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_Filter_FIFO0;//?????÷0??????FIFO0
CAN_FilterInitStructure.CAN_FilterActivation=ENABLE; //?¤???????÷0
CAN_FilterInit(&CAN_FilterInitStructure);//???¨?÷??????
CAN_ITConfig(CAN1,CAN_IT_FMP0,ENABLE);//FIFO0???????????????í.
NVIC_InitStructure.NVIC_IRQChannel = CAN1_RX0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; // ?÷????????1
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; // ??????????0
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
调用为CAN1_Mode_Init(CAN_SJW_1tq,CAN_BS2_4tq,CAN_BS1_6tq,2,CAN_Mode_Normal);?
配置程序如上,这样配扎TX脚波形为下图,大概1M,反推出CAN时钟为1*(1+4+6)*(2+1)=33M
?不是您说的45M表示非常迷茫,需要大神解答。
?也许您要说,是否是再看tsjw要加1,计算的时候已经按加1算了
?如下
?#define CAN_SJW_1tq ((uint8_t)0x00) /*!< 1 time quantum */
#define CAN_SJW_2tq ((uint8_t)0x01) /*!< 2 time quantum */
#define CAN_SJW_3tq ((uint8_t)0x02) /*!< 3 time quantum */
#define CAN_SJW_4tq ((uint8_t)0x03) /*!< 4 time quantum */
?所以,较郁闷。求解答。
?另,CAN2用与CAN1相同的配置,但是不能通信,真是一件非常伤心的事。同求大神解答。
一周热门 更多>