cancel
Showing results for 
Search instead for 
Did you mean: 

Trying CAN and interrupt go in it just one time

Zek_De
Senior

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;
 
 

1 ACCEPTED SOLUTION

Accepted Solutions
Zek_De
Senior

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

View solution in original post

1 REPLY 1
Zek_De
Senior

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