S32K344 Using FlexCAN with RX FIFO and Interrupts

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

S32K344 Using FlexCAN with RX FIFO and Interrupts

跳至解决方案
2,570 次查看
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 项奖励
回复
1 解答
2,515 次查看
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 项奖励
回复
4 回复数
2,531 次查看
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 项奖励
回复
2,520 次查看
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 项奖励
回复
2,516 次查看
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 项奖励
回复
2,547 次查看
stefano_alloi
Contributor II

Can anyone help me?

0 项奖励
回复