cancel
Showing results for 
Search instead for 
Did you mean: 

About CAN communicaton with STM32F042

Son, Dong-Seong
Associate III

Hi!

I am testing CAN communication using STM32F042.

The settings for CAN communication on the same two boards are also set the same.

One board transmits data through CAN communication once per second, and the other board receives data.

If I check the CAN_RX pin (pin no. 21) of the receiving board's stm32F042 with an oscilloscope, I can see the received signal.

But However, the program does not receive it.

Below is the setting and the code for receiving.

    Here is parameter setting.

       SonDongSeong_0-1688470052406.png

    Here is NVIC setting.

    SonDongSeong_1-1688470106790.png

   

HAL_CAN_Start(&hcan);  // in main function.
 

        Here is callback function

void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef *phcan)
{
if(HAL_CAN_GetRxMessage(phcan, CAN_RX_FIFO0, &canRxHeader, &canRx0Data[0]) != HAL_OK) {
}
else {
printf("RX : %c%c%c%c%c%c%c%c\r\n", canRx0Data[0], canRx0Data[1], canRx0Data[2], canRx0Data[3], canRx0Data[4], canRx0Data[5], canRx0Data[6], canRx0Data[7]);
}
}
If I look at the oscilloscope, the data is clearly received, but the callback function above is not called.
How should I set up to receive CAN data and which callback function should I use?
Please, help me.
Thank you.
 
1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello,

You have to configure correctly the filters otherwise you can't receive any message.

You can inspire from any CAN example provided in CubeF0 firmware. Example: Projects\STM32072B_EVAL\Examples\CAN\CAN_Networking\

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.

View solution in original post

5 REPLIES 5
SofLit
ST Employee

Hello,

You have to configure correctly the filters otherwise you can't receive any message.

You can inspire from any CAN example provided in CubeF0 firmware. Example: Projects\STM32072B_EVAL\Examples\CAN\CAN_Networking\

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.

Hi.

Thank you. I resolve it.

Hello,

Thank you for the confirmation. Please close this thread.

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.

hi

How can I close this thread?

Hello,

It was done from our side.

Thank you.

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.