cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving CAN frames in interrupt (HAL)

Posted on July 24, 2015 at 15:43

Hello there,

I am using STM 32F4 cube to generate code for my application (stm32f4discovery board). I Can succesfully send can messages using:

/* CAN message to send */

  CanTxMsgTypeDef TxMess;

  TxMess.ExtId = 0x234501;

  //TxMess.StdId = 0x241;

  TxMess.RTR = CAN_RTR_DATA;

  TxMess.IDE = CAN_ID_EXT;

  TxMess.DLC = 4;

  TxMess.Data[0] = 0x04;

  TxMess.Data[1] = 0x01;

  TxMess.Data[2] = 0x02;

  TxMess.Data[3] = 0x11;

  hcan1.pTxMsg = &TxMess;

  HAL_StatusTypeDef status1 = HAL_CAN_Transmit(&hcan1, 10);

But I dont know how to configure the receiver using Rx interrupt. I Am looking up the examples from the Cube but I cannot get it working.

I have enabled the interrupts:

if(HAL_CAN_Receive_IT(&hcan1, CAN_FIFO0) != HAL_OK)

{

      return 0;

}

And now I am waiting with a breakpoint in the generated callback by the cube:

/**

* @brief This function handles CAN1 RX0 interrupts.

*/

void CAN1_RX0_IRQHandler(void)

{

  /* USER CODE BEGIN CAN1_RX0_IRQn 0 */

  /* USER CODE END CAN1_RX0_IRQn 0 */

  HAL_CAN_IRQHandler(&hcan1);

  /* USER CODE BEGIN CAN1_RX0_IRQn 1 */

  /* USER CODE END CAN1_RX0_IRQn 1 */

}

I havent set any ID filters for rx message. What am I missing, why the receiving doesnt work? I would apreciate all help!

#stm32 #interrupt #can #hal
1 REPLY 1
Posted on July 27, 2015 at 08:59

Anyone please?