Skip to main content
Zek_De
Senior
Aug 17, 2018 5:31 AM UTC
Solved

Trying CAN and interrupt go in it just one time

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.
    Zek_De
    Zek_DeBest answer
    Senior
    Aug 17, 2018 5:57 AM UTC

    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
    Aug 17, 2018 5:57 AM UTC

    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);
    }