完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
跑STM8的CAN例程,例程波特率为1M,接上CAN分析仪,可以收到数据.但是设置波特率500k,板子接上can分析仪却没有数据,大神门求救啊!
下面贴上代码 void CAN_Config(void) { CAN_InitStatus_TypeDef status = CAN_InitStatus_Failed; /* Filter Parameters */ CAN_FilterNumber_TypeDef CAN_FilterNumber; FunctionalState CAN_FilterActivation; CAN_FilterMode_TypeDef CAN_FilterMode; CAN_FilterScale_TypeDef CAN_FilterScale; uint8_t CAN_FilterID1; uint8_t CAN_FilterID2; uint8_t CAN_FilterID3; uint8_t CAN_FilterID4; uint8_t CAN_FilterIDMask1; uint8_t CAN_FilterIDMask2; uint8_t CAN_FilterIDMask3; uint8_t CAN_FilterIDMask4; /* Init Parameters*/ CAN_MasterCtrl_TypeDef CAN_MasterCtrl; CAN_Mode_TypeDef CAN_Mode; CAN_SynJumpWidth_TypeDef CAN_SynJumpWidth; CAN_BitSeg1_TypeDef CAN_BitSeg1; CAN_BitSeg2_TypeDef CAN_BitSeg2; uint8_t CAN_Prescaler; CLK_PeripheralClockConfig(CLK_PERIPHERAL_CAN, ENABLE); /* CAN register init */ CAN_DeInit(); /* CAN init */ CAN_MasterCtrl=CAN_MasterCtrl_AllDisabled; CAN_Mode = CAN_Mode_LoopBack; CAN_SynJumpWidth = CAN_SynJumpWidth_1TimeQuantum;//1 CAN_BitSeg1 = CAN_BitSeg1_8TimeQuantum;//8 CAN_BitSeg2 = CAN_BitSeg2_7TimeQuantum;//7 CAN_Prescaler = 2;//1 status = CAN_Init(CAN_MasterCtrl, CAN_Mode, CAN_SynJumpWidth, CAN_BitSeg1, CAN_BitSeg2, CAN_Prescaler); if(status ==CAN_InitStatus_Success) { printf("can init succeed!rn"); } else { printf("can init Failed!rn"); } /* CAN filter init */ CAN_FilterNumber = CAN_FilterNumber_0; CAN_FilterActivation = ENABLE; CAN_FilterMode = CAN_FilterMode_IdMask; CAN_FilterScale = CAN_FilterScale_32Bit; CAN_FilterID1=0; CAN_FilterID2=0; CAN_FilterID3=0; CAN_FilterID4=0; CAN_FilterIDMask1=0; CAN_FilterIDMask2=0; CAN_FilterIDMask3=0; CAN_FilterIDMask4=0; CAN_FilterInit(CAN_FilterNumber, CAN_FilterActivation, CAN_FilterMode, CAN_FilterScale,CAN_FilterID1, CAN_FilterID2, CAN_FilterID3, CAN_FilterID4,CAN_FilterIDMask1, CAN_FilterIDMask2, CAN_FilterIDMask3, CAN_FilterIDMask4); /* Enable Fifo message pending interrupt*/ /* Message reception is done by CAN_RX ISR*/ CAN_ITConfig(CAN_IT_FMP, ENABLE); } |
|
相关推荐
3个回答
|
|
你这样设置,波特率只有250K,你can采集器试试用250K
|
|
|
|
楼主的问题解决没?能否贴出来让学习一下。谢谢楼主
|
|
|
|
都不贴硬件电路吗?
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1492 浏览 1 评论
AD7686芯片不传输数据给STM32,但是手按住就会有数据。
1427 浏览 3 评论
3261 浏览 0 评论
如何解决MPU-9250与STM32通讯时,出现HAL_ERROR = 0x01U
1560 浏览 1 评论
hal库中i2c卡死在HAL_I2C_Master_Transmit
1995 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-4 22:14 , Processed in 0.578716 second(s), Total 76, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号