cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Communication in stm32f407 discovery board

rohitkumarkv07
Associate III

Hello,

I am trying to send the message from USB-CAN Aanlyzer and want to read that message in STM32F407 discovery board in interrupt mode. My RxFIFO0 buffer got updated and FMP gets filled with messages and Overrun occur but  RFOM register not able to release the messages so that i can read that messages in my rx_data.

Below is pendingcallback function and IRQHandler.

 

void CAN1_TXIRQHandler(void)
{
  HAL_CAN_IRQHandler(&hcan1);
}
void CAN1_RX0IRQHandler(void)
{
  HAL_CAN_IRQHandler(&hcan1);
}
void CAN1_RX1IRQHandler(void)
{
  HAL_CAN_IRQHandler(&hcan1);
}
void CAN1_SCEIRQHandler(void)
{
  HAL_CAN_IRQHandler(&hcan1);
}
void WWDG_APPIRQHandler(void)
{

}

void CANRxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
{
	CAN_RxHeaderTypeDef rx_header;
	uint8_t rx_data[8];

	if (HAL_CAN_GetRxMessage(&hcan1, CAN_RX_FIFO0, &rx_header, rx_data) != HAL_OK)
	{
		Error_Handler();
	}

	/*// Process received message
	if (rx_header.StdId == 0x123)
	{
		HAL_GPIO_TogglePin(LD4_GPIO_Port, LD4_Pin|LD3_Pin|LD5_Pin);
		HAL_Delay(1000); // Example delay before next reception/transmission

	}*/
}

 

Below I have attach the images of USB-CAN Analyzer in which I am sending data to the board and what update I got in RXFIFO buffer.

 

B.R

Rohit

2 REPLIES 2
SofLit
ST Employee

Hello,

I didn't understand this statement:

" but  RFOM register not able to release the messages so that i can read that messages in my rx_data."

The message is released by software after reading it from the FIFO. So the reading of the message from the FIFO is not blocked by RFOM bit.

Could you please share your project?

Are you trying to "bombard" the STM32F4 with CAN messages? how much time between two CAN frame?

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Don't look at the CAN registers in the debug whilst in use.

Don't use printf and other blocking functions in interrupts and callbacks especially when the servicing is fast and critical. Buffer data and print/process in a foreground loop.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..