求助!!!!!!我用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<NUMBER_CAN_MSG;j++) { if((liId == guCanMsgBuffer[j].Id) && (dlc == guCanMsgBuffer[j].Length)) { for(i=0;i<dlc;i++) { guCanMsgBuffer[j].Data[i] = CAN_GetReceivedData(i); } guCanMsgBuffer[j].UpdatedFlag = 1; } } } |
STM8S003F3U6 请求各位大佬支援,但是遇到如下问题。。。这样就一定是这颗芯片的问题吗?
STVD如何生成库文件
STM8 flash 库函数 startaddress = startaddress + ((uint32_t)BlockNum * FLASH_BLOCK_S
stm 8 flash 在RAM运行代码的问题,是不是库函数有问题 Library call (?sll32_l0_l0_a) from within a
STM 有能替代MCHC912B32CFUE8 / NXP的型号吗?
STM8S的CAN总线使用
STM8L151在使用DAC功能后严重发热
STM8 IIC SLAVE 400K
STM8S 定时器1互补输出pwm
STM8S003F3 NRST电压低,无法开机
评分
查看全部评分