S32K344 Using FlexCAN with RX FIFO and Interrupts

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K344 Using FlexCAN with RX FIFO and Interrupts

Jump to solution
1,610 Views
stefano_alloi
Contributor II

Hello all,

I'm trying to configure the FlexCAN in order to use the RX FIFO with interrupts, on a S32K344 eval board (Q172)

The problem is that when I activate the interrupts through the ERFIER register, it seems that the FIFO stops being filled with new messages. Instead, when the ERFIER register is 0 (interrupts disabled), the FIFO gets filled regularly and also the watermark flag is correctly set.

I noticed that there exists the function FlexCAN_Ip_RxFifo which temporarily activates the interrupts, which will then be disabled by the corresponding function FlexCAN_CompleteRxMessageEnhancedFifoData at the end of the reception. But it seems to me that this function reads a message in the FIFO even if the watermark flag is not set; also, it is necessary to call this function in polling to keep getting new reads.

Have I misunderstood something in the behavior of the driver?

 

Thank you to everyone that will help me

Stefano

0 Kudos
1 Solution
1,555 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

it is possible to have module running this way, but the driver is written as is. RXFIFO interrupts are enabled once FlexCAN_Ip_RxFifo is called. If meanwhile watermark fag is set you will got a notification about it using callback event, then single message will be read out from RXFIFO. To read another message a FlexCAN_Ip_RxFifo must be called again.
An option could be modify a driver or create own.

BR, Petr

View solution in original post

0 Kudos
4 Replies
1,571 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

enhanced RXFIFO is filled even if its interrupts are enabled or disabled, I do not see issue here.

Your understanding of the driver behavior is quite correct. FlexCAN_Ip_RxFifo is used to receive a CAN frame using the Rx FIFO or Enhanced Rx FIFO. It enables RXFIFO interrupts and if there is a message within RXFIFO interrupt is called, message read out, callback called  and interrupts disabled again. So yes, to read another message from RXFIFO this function has to be called again. If you look over FlexCAN_IRQHandlerEnhancedRxFIFO function upon watermark flag setting a callback with that event is just called, no RXFIFO reading is done, so I think it is there just for notification.

You should get into this event if you do not call FlexCAN_Ip_RxFifo, receive several messages into RXFIFO (more then watermark set) and finally call FlexCAN_Ip_RxFifo.

BR, Petr 

0 Kudos
1,560 Views
stefano_alloi
Contributor II

Hello PetrS,

thank you for your reply.

Regarding your explanation about the watermark, are you saying that there's no way to get an interrupt automatically as soon as the watermark flag is set? Should it be me who, at a certain point, calls the FlexCAN_Ip_RxFifo function and sees what happens? (i.e. if a watermark interrupt is thrown?)

In this case, how should I read all the messages in the FIFO? From what I could see the FlexCAN_Ip_RxFifo reads 1 message at once..

Thanks again,

Stefano

0 Kudos
1,556 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

it is possible to have module running this way, but the driver is written as is. RXFIFO interrupts are enabled once FlexCAN_Ip_RxFifo is called. If meanwhile watermark fag is set you will got a notification about it using callback event, then single message will be read out from RXFIFO. To read another message a FlexCAN_Ip_RxFifo must be called again.
An option could be modify a driver or create own.

BR, Petr

0 Kudos
1,587 Views
stefano_alloi
Contributor II

Can anyone help me?

0 Kudos