AnsweredAssumed Answered

Receiving CANbus data

Question asked by olsson.steve on Apr 22, 2015
SO I am incredibly confused.  I have an application that uses CANbus.  I have the transmit running fine and I am to the point where I am receiving interrupts when I receive a message.  so I am confused by the lack of documents, but can anyone tell me what the difference is between HAL_CAN_Receive_IT() and HAL_CAN_Receive()?

I have seen code samples with HAL_CAN_Receive in the ISR and I have seen HAL_CAN_Receive_IT in regular code.  I am not sure how to get to the data when I am in the ISR.

I have seen samples that look like this:

CanRxMsgTypeDef RMess;

  RMess.FIFONumber = CAN_FIFO1;
  RMess.FMI = 14;
  RMess.StdId = 0x541;
  RMess.DLC = 0;
  RMess.RTR = 0;
  RMess.IDE = CAN_ID_STD;
  hcan2.pRxMsg = &RMess;
 
  HAL_CAN_Receive_IT(&hcan2,CAN_FIFO1);
  /* USER CODE BEGIN 3 */
  /* Infinite loop */
  while (1)

I don't understand why I would want to pre-populate RMess if I am about to overwrite it with receive data.  I already have a filter.

Can someone please help me understand these APIs and how I get data after the interrupt arrives?

BY the way -- I have a fully operational canbus and several nodes receiving the data and sending me data.  I understand the transceivers and terminations.  I can see the data arriving at the device with the scope and I am getting the interrupt when data arrives.

Thanks

Steve

Outcomes