cancel
Showing results for 
Search instead for 
Did you mean: 

Configure CAN to receive in both FIFOs

Posted on June 09, 2016 at 10:58

Hello there,

I am using STM32F4. I am trying to configure can peripheral the way that when messages are received, they pass through 2 filters. If filter 0 matches they go to FIFO0, if filter 1 matches they should be stored in FIFO1. Is this possible? A for now I have a problem with can busy flag- Im am trying to turn rx interrupts to work for FIFO0 and FIFO1, like this:

HAL_CAN_Receive_IT(canHandle, 0);
HAL_CAN_Receive_IT(canHandle, 1);

The problem is that after the 1st line of code is executed, the can status is set to HAL_CAN_STATE_BUSY_RX so the second one doesnt work. What is the proper way of making this idea work? 2 different filters, 2 different FIFO's, 1 can peripheral. I would really appreciate all help.
15 REPLIES 15
Imen.D
ST Employee
Posted on January 19, 2017 at 19:06

Dear @Users,

I would inform you that the reported issue about

HAL_CAN_Receive_IT() function

missed to get FIFO Number parameter is already fixed in the last release of STM32CubeF4.

Thank you for bringing this issue to our attention and all your feedback are welcome.

Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on January 19, 2017 at 21:00

DAHMEN.IMEN

‌ Do you mean what I written in the post above about just setting the FIFO flag or is the FMI issue fixed as well?

Posted on January 20, 2017 at 14:47

Hello @

Przenioslo.Lukasz

,

Sorry for this quite late answered about your reported FMI isssue.This is highlighted internally andI will come back to youas soon as I have update on this.

We are sorry for the inconvenience and thank you for your comprehension.

Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on March 08, 2017 at 17:23

Hi Lukasz Przenioslo,

After 

deep check, we

 do not observe the FMI issue reported and

 the following line in CAN_Receive_IT() works fine:

hcan->pRxMsg->FMI = (uint8_t)0xFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RDTR >> 8U);

It correctly extract the FMI (Filter Match Index) applicable to the message received, from the RDTR register.

So, i

n both cases of FIFO0 and FIFO1 usage, t

he FMI obtained is not always 0, it depends on the programmed filters.

For that, I suggest you check the values of CAN_RDT0R and CAN_RDT1R in debug mode when you are expecting value different of 0.

P

lease refer to your Reference Manual, in the CAN chapter, 'Filter Match Index' paragraph for more clarification on how FMI (in RDTR register) is computed by Hardware: 

The index value of the filter number does not take into account the activation state of the filter banks. In addition, two independent numbering schemes are used, one for each FIFO. 

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on March 13, 2017 at 08:58

I seem to have stumbled upon the same issue: In HAL_CAN_RxCpltCallback I cannot see what fifo caused the receive.

I can get this working by adapting CAN_Receive_IT such that it copies the FIFONumber into the hcan-pRxMsg->FIFONumber before it calls HAL_CAN_RxCpltCallback.

I updated Cube last friday (and boy do I regret having done that, but that's for another thread)

CubeMX version: 4.20.0

Library version: L4_V1.7.0

For now I stick to adapting the 'library' myself..

clonephone82
Associate III
Posted on October 02, 2017 at 14:58

@jonker.hans

I do have the same problem. How can I found out if I have to read from pRxMsg, or pRxMsg1 from the HAL_CAN_RxCpltCallback. 

@STM dev. Any ideas? I think there is something missing in the architecture.

many thanks.

cheers

mathias