CAN环回模式正常,正常模式这种情况是咋回事啊?求助

2019-07-21 00:14发布

两块板子一个103,一个407,分别写了两套程序,一套寄存器,一套库函数,寄存器的通信时候直接就是发送失败,库函数的则是打印发送成功,但是总线上电压还是2.5V,压根没数据发送出来,怎么回事,求解?????
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
6条回答
蓝风3101
1楼-- · 2019-07-21 04:05
问题出来了。是硬件的问题,可能是TJA1051芯片收发器的问题,有两种可能,一种是芯片不兼容问题,再者就是芯片自身质量问题
yuanxinfei
2楼-- · 2019-07-21 06:02
本帖最后由 yuanxinfei 于 2016-1-14 11:03 编辑


中断部分:void CAN1_RX0_IRQHandler(void)
{
        uint8_t can;
  CanRxMsg RxMessage;
  CAN_Receive(CAN1, CAN_FIFO0, &RxMessage);
  if ((RxMessage.ExtId == 0x0202FE32)&&(RxMessage.IDE == CAN_ID_EXT) && (RxMessage.DLC == 8))
{}
}
f407接收配置部分
static void CAN_Config(void)
{
  RCC_APB1PeriphClockCmd(CAN_CLK, ENABLE);
  
  /* CAN register init */
  CAN_DeInit(CANx);

  /* CAN cell init */
  CAN_InitStructure.CAN_TTCM = DISABLE;
  CAN_InitStructure.CAN_ABOM = DISABLE;
  CAN_InitStructure.CAN_AWUM = DISABLE;
  CAN_InitStructure.CAN_NART = DISABLE;
  CAN_InitStructure.CAN_RFLM = DISABLE;
  CAN_InitStructure.CAN_TXFP = DISABLE;
  CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;
  CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
   
  /* CAN Baudrate = 1 MBps (CAN clocked at 30 MHz) */
  CAN_InitStructure.CAN_BS1 = CAN_BS1_12tq;
  CAN_InitStructure.CAN_BS2 = CAN_BS2_8tq;
  CAN_InitStructure.CAN_Prescaler = 8;
  CAN_Init(CANx, &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;   //((0x0202FE20<<3)&0xFFFF0000)>>16
  CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000;     //((0x0202FE20<<3)|CAN_ID_EXT)&0xFFFF
  CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000;
  CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000;
  CAN_FilterInitStructure.CAN_FilterFIFOAssignment = CAN_FIFO0;
  CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
  CAN_FilterInit(&CAN_FilterInitStructure);
  
  /* Transmit Structure preparation */
  
  
  /* Enable FIFO 0 message pending Interrupt */
  CAN_ITConfig(CANx, CAN_IT_FMP0, ENABLE);
}

/**
  * @brief  Configures the NVIC for CAN.
  * @param  None
  * @retval None
  */
static void NVIC_Config(void)
{
  NVIC_InitTypeDef  NVIC_InitStructure;

  NVIC_InitStructure.NVIC_IRQChannel = CAN1_RX0_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
}
yuanxinfei
3楼-- · 2019-07-21 09:35
 精彩回答 2  元偷偷看……
蓝风3101
4楼-- · 2019-07-21 09:40
用的就是探索者的例程啊
yuanxinfei
5楼-- · 2019-07-21 11:38
蓝风3101 发表于 2016-1-14 11:18
用的就是探索者的例程啊

硬件也是探索者吗,会不会是引脚配置错了,或者can芯片问题,原子的例程can配置不会错的
蓝风3101
6楼-- · 2019-07-21 16:41
yuanxinfei 发表于 2016-1-14 11:23
硬件也是探索者吗,会不会是引脚配置错了,或者can芯片问题,原子的例程can配置不会错的

对硬件就是探索者f4开发板,另外一个是自己的f103rc板子

一周热门 更多>