Setting up a CAN RX FIFO

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User6793
Level 4
Level 4
XMC4500F100K1024 AB:

I am a bit at a loss trying to set up a CAN RX FIFO.

DAVE App CAN001[1.0.8] have no setting for this, and none of the examples in the example library seems to provide an example.

I already have a CAN node running with 1 LMO for TX and 1 for RX, but we are experiencing packet loss, and would like to set up a RX FIFO of say 32 LMOs.
1 LMO for TX is fine.

Could you please provide some example code for this?

Cheers
0 Likes
10 Replies
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Hi OMR,

you are right DAVE 3 CAN apps does not support receive FIFO at the moment but there is plan for it. I will check if someone can contribute to this application.
0 Likes
lock attach
Attachments are accessible only for community members.
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Hi OMR,

There you go..
0 Likes
User6793
Level 4
Level 4
Thank you! 😮
0 Likes
User6793
Level 4
Level 4
The sample code in the attachment assumes that messages are to be read out on a FIFO full event.
FIFO full monitoring is nice, but an example of how to set up and read MO data on a regular RX interrupt from the base MO would be even nicer 🙂

How should the RX irq routine ensure that it reads all available data in the FIFO?
How should the FIFO be set up so that it produces interrupts for each messages received?

When keeping my RX ISR as it was for 1 RX MO, using that MO as the FIFO base, I only receive an interrupt when the CUR pointer matches the base MO.

Any pointers here would be greatly appreciated.
0 Likes
User6793
Level 4
Level 4
I now have a working solution for a RX ring-buffer using 31 MOs.
The multiCan HW solution to this is only partly implementing a FIFO as such. Its more like a ring buffer that needs a lot of administration in SW.
PM me if anyone is interested.

Cheers
0 Likes
Not applicable
Is there any example code for a CAN TX FIFO as well?
0 Likes
Not applicable
Hello.
I'm very interested in a CAN RX-buffer to receive more than one message with one LMO. Is there a way to get this working? Or do I really need a MO for each CAN RX?
At the moment I'm trying to store about 3 RX messages into a 3x8 array but the NVIC-Eventhandler only stores the last one.
Thanks a lot!


UPDATE:
Here is a snipped out of my working solution:

CAN001_MessageHandleType CanRecMsgObj;
uint8_t CanRecHeartbeatState[8];
uint8_t array_CanRec[30][8]; // 30 = messages that can be stored
int CAN_counter; // has to be set to "0" somewhere in the code after 30 messages have been received!!!

// NVIC-Interrupt für Message-Objekt LMO1 (Receive)
void EventHandlerCAN()
{
if(CAN001_GetMOFlagStatus(&CAN001_Handle0,1,RECEIVE_PENDING) == CAN_SET)
{
// Antwort erhalten, Flag löschen
CAN001_ClearMOFlagStatus(&CAN001_Handle0,1,RECEIVE_PENDING);
// Inhalt von LMO1 in CanRecMsgObj speichern
CAN001_ReadMsgObj(&CAN001_Handle0,&CanRecMsgObj,1);

if (CanRecMsgObj.Identifier==0xXXX) // Message mit ID XXX
{
// jede CAN-Antwort aus CanRecMsgObj ins array_CanRec kopieren
memmove(array_CanRec[CAN_counter],CanRecMsgObj.data,CanRecMsgObj.DataLength);
CAN_counter++; // Array wird nacheinander befüllt
IO003_TogglePort(IO003_Handle1,1); // Empfang einer CAN-Antwort: LED1 P1.1 an/aus
}

if(CanRecMsgObj.Identifier==0xYYY) // Message mit ID YYY
{
memmove(CanRecHeartbeatState,CanRecMsgObj.data,CanRecMsgObj.DataLength);
IO003_TogglePort(IO003_Handle2,1); // mit LED2 P1.0 an/aus quittieren
}
}
}
0 Likes
Not applicable
Hello OMR


OMR wrote:
I now have a working solution for a RX ring-buffer using 31 MOs.
The multiCan HW solution to this is only partly implementing a FIFO as such. Its more like a ring buffer that needs a lot of administration in SW.
PM me if anyone is interested.
Cheers


How can I have a look at it?
Grüße
0 Likes
Not applicable
Hi..OMR,
May I get your Working RX FIFO ...source code...with 32 MOs..??
0 Likes
User6793
Level 4
Level 4
0 Likes