完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
我用的STM32F072的芯片,在调试CAN程序的时候,用JLINK仿真出来的发送状态永远不是CANTXOK。
CAN的寄存器显示为三个邮箱先后为Pending状态,之后就状态一直为无邮箱可用。芯片无法发出信号。求解啊,各位大神,难道是硬件的原因吗 int main(void) { CanTxMsg TxMessage,TxMessage1; GPIO_InitTypeDef GPIO_InitStructure; CAN_InitTypeDef CAN_InitStructure; CAN_FilterInitTypeDef CAN_FilterInitStructure; NVIC_InitTypeDef NVIC_InitStructure; //CAN¿ÚÏà¹ØʱÖÓ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE); //ʹÄÜGPIOAʱÖÓ RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN,ENABLE);//ʹÄÜCAN1ʱÖÓ //can1¿ÚÒý½ÅÅäÖà GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11|GPIO_Pin_12;//³õʼ»¯ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//¸´Óù¦ÄÜ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //ËÙ¶È GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //ÍÆÍ츴ÓÃÊä³ö GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; //ÉÏÀ GPIO_Init(GPIOA,&GPIO_InitStructure); GPIO_PinAFConfig(GPIOA,GPIO_PinSource11,GPIO_AF_0); GPIO_PinAFConfig(GPIOA,GPIO_PinSource12,GPIO_AF_0); //CAN1¿ÚµÄÏà¹ØÅäÖà CAN_InitStructure.CAN_TTCM=DISABLE; CAN_InitStructure.CAN_ABOM=ENABLE; CAN_InitStructure.CAN_AWUM=DISABLE; CAN_InitStructure.CAN_NART=DISABLE; CAN_InitStructure.CAN_RFLM=DISABLE; CAN_InitStructure.CAN_TXFP=ENABLE; CAN_InitStructure.CAN_Mode=CAN_Mode_Normal; CAN_InitStructure.CAN_SJW=CAN_SJW_1tq; CAN_InitStructure.CAN_BS1=CAN_BS1_10tq; CAN_InitStructure.CAN_BS2=CAN_BS2_7tq; CAN_InitStructure.CAN_Prescaler=4; // CAN_InitStructure.CAN_Mode = CAN_Mode_LoopBack; // »Ø»·²âÊÔģʽ CAN_Init(CAN,&CAN_InitStructure); /* CAN filter init */ CAN_FilterInitStructure.CAN_FilterNumber=0; CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask; CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit; CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000; CAN_FilterInitStructure.CAN_FilterIdLow=0x0000; CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000; CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000; CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_Filter_FIFO0; CAN_FilterInitStructure.CAN_FilterActivation=ENABLE; CAN_FilterInit(&CAN_FilterInitStructure); TxMessage.StdId = 0x12; TxMessage.ExtId = 0x12; TxMessage.RTR = CAN_RTR_Data; //0x00000000; TxMessage.IDE = CAN_ID_STD; //0x00000000; TxMessage.DLC = 8; TxMessage.Data[0] = 0x01; TxMessage.Data[1] = 0x00; TxMessage.Data[2] = 0x00; TxMessage.Data[3] = 0x00; TxMessage.Data[4] = 0x00; TxMessage.Data[5] = 0x00; TxMessage.Data[6] = 0x00; TxMessage.Data[7] = 0x00; while (1) { GPIO_WriteBit(GPIOB,GPIO_Pin_9,(BitAction)(1-GPIO_ReadOutputDataBit(GPIOB,GPIO_Pin_9))); ii = 0x3fffff; CAN_Transmit(CAN, &TxMessage); while(ii--); } } |
|
相关推荐
1个回答
|
|
回帖奖励 +1 分积分
顶上去,让更多人看到解决一下。。
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
飞凌嵌入式-ELFBOARD 硬件知识分享-ELF 2电源电路讲解
361 浏览 0 评论
1378 浏览 0 评论
飞凌嵌入式ElfBoard ELF 1板卡-mfgtools烧录流程介绍之烧写所需镜像
1312 浏览 0 评论
飞凌嵌入式ElfBoard ELF 1板卡-mfgtools烧录流程之烧写方法
743 浏览 0 评论
飞凌嵌入式ElfBoard ELF 1板卡-内核编译之初次编译
1139 浏览 0 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 03:09 , Processed in 1.426876 second(s), Total 75, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号