完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
求助!!!!!!我用STM8S208C8做的程序,烧录以后接收不到报文,MCU的TX脚也一直为高。
如果在CAN总线上接入另外一个USBCAN, 调试的时候就可以进入接收中断了,但是发送还是不成功,而且用示波器看MCU的TX脚还是一直为高电平,有大佬知道是因为什么吗~~~ 以下为初始化代码: 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; /* CAN register init */ CAN_DeInit(); /* 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); /* CAN init */ CAN_MasterCtrl=CAN_MasterCtrl_AllDisabled; CAN_Mode = CAN_Mode_Normal; CAN_SynJumpWidth = CAN_SynJumpWidth_1TimeQuantum; CAN_BitSeg1 = CAN_BitSeg1_12TimeQuantum; CAN_BitSeg2 = CAN_BitSeg2_3TimeQuantum; CAN_Prescaler = 2; status = CAN_Init(CAN_MasterCtrl, CAN_Mode, CAN_SynJumpWidth, CAN_BitSeg1, CAN_BitSeg2, CAN_Prescaler); /* Enable Fifo message pending interrupt*/ /* Message reception is done by CAN_RX ISR*/ CAN_ITConfig(CAN_IT_FMP, ENABLE); } /***************************************************************************//** * @brief 外设初始化函数. * @return 无. * @param 无. * @warning 该函数将在进入主循环之前调用. * *************************************************************************** */ static void AppL_PeriphInit(void) { /*GPIO Init*/ GPIO_DeInit(GPIOE); GPIO_DeInit(GPIOD); GPIO_Init(GPIOD,GPIO_PIN_4,GPIO_MODE_OUT_PP_LOW_SLOW);/*Voice_Mute*/ GPIO_Init(GPIOE,GPIO_PIN_2,GPIO_MODE_OUT_PP_LOW_SLOW);/*Voice_PWM2*/ GPIO_Init(GPIOE,GPIO_PIN_3,GPIO_MODE_OUT_PP_LOW_SLOW);/*STB*/ GPIO_Init(GPIOD,GPIO_PIN_2,GPIO_MODE_OUT_PP_LOW_SLOW);/*LED*/ /*Clock module init*/ CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1); /*Can Controller Init*/ CAN_Config(); } /***************************************************************************//** * @brief CAN接收中断函数. * @return 无. * @param 无. * @warning 中断函数. * *************************************************************************** */ @far @interrupt void CAN_RX_IRQ(void) { /* In order to detect unexpected events during development, it is recommended to set a breakpoint on the following instruction. */ /* Receiver Receives Frame */ uint32_t liId = 0; CAN_Id_TypeDef ide; CAN_RTR_TypeDef rtr; uint8_t data[8]; uint8_t dlc,i,j; CAN_Receive();//读取缓存中的数据 giTest = CAN_GetReceivedData(0); liId = CAN_GetReceivedId(); //读取帧ID ide = CAN_GetReceivedIDE();//读取帧类型(标准或扩展) rtr = CAN_GetReceivedRTR();//读取帧类型(数据或远程) dlc = CAN_GetReceivedDLC();//读取接收到的数据字节数 for(j=0;j |
|
相关推荐
1个回答
|
|
在CAN总线两线并联一个120欧的匹配电阻
|
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
1627 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
1550 浏览 1 评论
984 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
688 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
1601 浏览 2 评论
1867浏览 9评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
651浏览 4评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
518浏览 3评论
537浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
506浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 00:27 , Processed in 0.918732 second(s), Total 83, Slave 65 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号