Skip to main content
Zek_De
Senior
August 17, 2018
Solved

Trying CAN and interrupt go in it just one time

  • August 17, 2018
  • 1 reply
  • 530 views

Hi guys, my codes go into interrupt function just one time.Could you offer me any solution?

  1. device clock 72 MHZ
  2. device clock 180 MHZ
CAN // 1. device
 
 hcan.Init.Prescaler = 4;
 hcan.Init.Mode = CAN_MODE_NORMAL;
 hcan.Init.SJW = CAN_SJW_4TQ;
 hcan.Init.BS1 = CAN_BS1_4TQ;
 hcan.Init.BS2 = CAN_BS2_5TQ;
 
CAN // 2.Device
 
hcan1.Init.Prescaler = 5;
 hcan1.Init.Mode = CAN_MODE_NORMAL;
 hcan1.Init.SJW = CAN_SJW_4TQ;
 hcan1.Init.BS1 = CAN_BS1_4TQ;
 hcan1.Init.BS2 = CAN_BS2_5TQ;
 
 

    This topic has been closed for replies.
    Best answer by Zek_De

    OK it is solved. Problem is that "HAL_CAN_Receive_IT(&hcan1, CAN_FIFO0); " function must be below in function.

    extern "C" void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef* CanHandle)
    {
     //HAL_CAN_Receive_IT(&hcan1, CAN_FIFO0);
    	if(hcan1.pRxMsg->StdId == SLAVE_CAN_ID)
    	{
    		if(hcan1.pRxMsg->Data[4] == US.index)
    		{
    			US.slaveDataOK[US.index-1] = true;
    		}
    	}
    	HAL_CAN_Receive_IT(&hcan1, CAN_FIFO0);
    }

    1 reply

    Zek_De
    Zek_DeAuthorBest answer
    Senior
    August 17, 2018

    OK it is solved. Problem is that "HAL_CAN_Receive_IT(&hcan1, CAN_FIFO0); " function must be below in function.

    extern "C" void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef* CanHandle)
    {
     //HAL_CAN_Receive_IT(&hcan1, CAN_FIFO0);
    	if(hcan1.pRxMsg->StdId == SLAVE_CAN_ID)
    	{
    		if(hcan1.pRxMsg->Data[4] == US.index)
    		{
    			US.slaveDataOK[US.index-1] = true;
    		}
    	}
    	HAL_CAN_Receive_IT(&hcan1, CAN_FIFO0);
    }