042CAN STM32cube配置无法进中断回调函数

硬件没有问题用标准库接收发送都是正常的,cube配置里中断也打开了,初始化也声明了启动中断,但是接收数据就是没有反应调试无法进入中断,cube昨晚升级到4.25.0 。不知道是不是其他什么地方的问题

  MX_GPIO_Init();

  MX_CAN_Init();

  MX_TIM3_Init();

  MX_USART2_UART_Init();

  /* USER CODE BEGIN 2 */

HAL_TIM_Base_Start_IT(&htim3);//???????ccc  

HAL_CAN_Receive_IT(&hcan, CAN_FIFO0);  //??can??



void MX_CAN_Init(void)

{


  hcan.Instance = CAN;

  hcan.Init.Prescaler = 6;

  hcan.Init.Mode = CAN_MODE_NORMAL;//CAN_MODE_NORMAL;

  hcan.Init.SJW = CAN_SJW_1TQ;

  hcan.Init.BS1 = CAN_BS1_13TQ;

  hcan.Init.BS2 = CAN_BS2_2TQ;

  hcan.Init.TTCM = DISABLE;

  hcan.Init.ABOM = DISABLE;

  hcan.Init.AWUM = DISABLE;

  hcan.Init.NART = DISABLE;

  hcan.Init.RFLM = DISABLE;

  hcan.Init.TXFP = DISABLE;

  if (HAL_CAN_Init(&hcan) != HAL_OK)

  {

    _Error_Handler(__FILE__, __LINE__);

  }


}


void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle)

{


  GPIO_InitTypeDef GPIO_InitStruct;

  if(canHandle->Instance==CAN)

  {

  /* USER CODE BEGIN CAN_MspInit 0 */


  /* USER CODE END CAN_MspInit 0 */

    /* CAN clock enable */

    __HAL_RCC_CAN1_CLK_ENABLE();

  

    /**CAN GPIO Configuration    

    PB8     ------> CAN_RX

    PA12     ------> CAN_TX 

    */

    GPIO_InitStruct.Pin = GPIO_PIN_8;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pull = GPIO_PULLUP;

    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

    GPIO_InitStruct.Alternate = GPIO_AF4_CAN;

    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);


    GPIO_InitStruct.Pin = GPIO_PIN_12;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pull = GPIO_PULLUP;

    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

    GPIO_InitStruct.Alternate = GPIO_AF4_CAN;

    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);


    /* CAN interrupt Init */

    HAL_NVIC_SetPriority(CEC_CAN_IRQn, 0, 0);

    HAL_NVIC_EnableIRQ(CEC_CAN_IRQn);

  /* USER CODE BEGIN CAN_MspInit 1 */


  /* USER CODE END CAN_MspInit 1 */

  }

}


void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle)

{


  if(canHandle->Instance==CAN)

  {

  /* USER CODE BEGIN CAN_MspDeInit 0 */


  /* USER CODE END CAN_MspDeInit 0 */

    /* Peripheral clock disable */

    __HAL_RCC_CAN1_CLK_DISABLE();

  

    /**CAN GPIO Configuration    

    PB8     ------> CAN_RX

    PA12     ------> CAN_TX 

    */

    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8);


    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12);


    /* CAN interrupt Deinit */

    HAL_NVIC_DisableIRQ(CEC_CAN_IRQn);

  /* USER CODE BEGIN CAN_MspDeInit 1 */


  /* USER CODE END CAN_MspDeInit 1 */

  }



实在不知道哪里出了问题,求帮忙看看

已邀请:

往事随风1995

赞同来自:

HAL_CAN_RxFifo0MsgPendingCallback  这个回调函数

dqzhao

赞同来自:

void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef* hcan)

要回复问题请先登录注册