STM32F4can调试CAN但是没输出

2019-07-14 17:46发布

[tr]本人最近在调试STM32f407的CAN,按照例程配置的,但是CAN没输出怎么回事?有人说是得两个节点接在一起才能有数据。。。有人调过么?能给点指导或者例程不,感激不尽
[/tr]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
4条回答
nyvvhxcs
1楼-- · 2019-07-14 21:46
 精彩回答 2  元偷偷看……
zhan198498
2楼-- · 2019-07-15 00:11
uuewuw2 发表于 2018-9-14 14:46
两个节点加120欧姆电阻。

这个电阻是加了的,但是还是不对,我的配置如下帮忙指教一下;
        GPIO_InitTypeDef       GPIO_InitStructure;
        CAN_InitTypeDef        CAN_InitStructure;
        CAN_FilterInitTypeDef  CAN_FilterInitStructure;
       
        RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
       
       
        GPIO_PinAFConfig(GPIOB,GPIO_PinSource8,GPIO_AF_CAN1);
        GPIO_PinAFConfig(GPIOB,GPIO_PinSource9,GPIO_AF_CAN1);
       
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
        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_UP;
        GPIO_Init(GPIOB, &GPIO_InitStructure);
       
       
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);
       
        //CAN_DeInit(CAN1);
        CAN_DBGFreeze(CAN1,DISABLE);
  CAN_InitStructure.CAN_TTCM = DISABLE;
        CAN_InitStructure.CAN_ABOM = 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_12tq;
  CAN_InitStructure.CAN_BS2 = CAN_BS2_8tq;
  CAN_InitStructure.CAN_Prescaler =2;
        CAN_Init(CAN1, &CAN_InitStructure);
       
       
        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 = 0x321;
  TxMessage.ExtId = 0x01;
  TxMessage.RTR = CAN_RTR_DATA;
  TxMessage.IDE = CAN_ID_STD;
  TxMessage.DLC = 8;  
cmh20
3楼-- · 2019-07-15 01:44
等大神出现
zhan198498
4楼-- · 2019-07-15 04:14
cmh20 发表于 2018-9-14 15:19
等大神出现

还没有大神出现。。。

一周热门 更多>