Message ids 0x80 and 0x81 never received by s32 especially when more than 2 (0x80 and 0x81 and others) are configured

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

Message ids 0x80 and 0x81 never received by s32 especially when more than 2 (0x80 and 0x81 and others) are configured

1,515 Views
moreshwar
Contributor I

Dear All,

Details of Environment

--------------------------------

SDK : S32K144_SDK_gcc version 0.8.6 (S32K14x EAR SDK for GCC (S32K144))

FreeRTOS: version 8.2.1.

S32 Design Studio for ARM

Version: 2018.R1
Build id: 180815

Can message type: FLEXCAN_MSG_ID_STD,

Length :  8 bytes

Problem

--------------------

Summary: Can message id 0x80 and 0x81 not received while others are recieved

I am using S32K144 with FreeRTOS. I have configured mailboxes to receiive CAN messages for 2 message ids 0x80 and 0x81 as given below. The messages are one time messages (i,e. fault messages):

FLEXCAN_DRV_SetRxIndividualMask(INST_CANCOM1, FLEXCAN_MSG_ID_STD, 6, 0x0u);
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, 6, &dataInfo_std, 81);
FLEXCAN_DRV_SetRxIndividualMask(INST_CANCOM1, FLEXCAN_MSG_ID_STD, 7, 0x0u);
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, 7, &dataInfo_std, 0x80);

All functions are returning STATUS_SUCCESS.

Now I call 

FLEXCAN_DRV_Receive(INST_CANCOM1,6, &recvBuff1);

FLEXCAN_DRV_Receive(INST_CANCOM1,7, &recvBuff2);

and then

status =FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1,6);

while (status != STATUS_SUCCESS)

{

   status =FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1,6);

}

status =FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1,7);

while (status != STATUS_SUCCESS)

{

   status =FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1,7);

}

in both of above while loops status is STATUS_BUSY. 

I have other mailboxes with message ids 0x212, 0x319,0x361 which are periodic i.e. sent at regular intervals. For these, I am following the above steps, status is always STATUS_SUCCESS.

Why is there a problem with message ids 0x80 and 0x81?

The situation is more problematic for 0x80 and 0x81 when all of the above message ids are configured to be received (receive all of  0x212, 0x319,0x361, 0x80 and 0x81) simultaneously. Messages 0x80 and 0x81 are never received. Others are received as expected.

Please help me understand what is the problem and how to resolve it?

Regards

Moreshwar Salpekar

0 Kudos
6 Replies

1,379 Views
moreshwar
Contributor I

Hello Petr,

I made a mistake in posting, It should have been 0x81 and not 81. 

Regarding SDK, I am using the latest version of S32 for Arm (S32K144 is processor). Could you please tell me how to get RTM 3.0.0.

I am not clear what you mean by "If more MBs are defined in this way, it should not work as you expect, the MB will be updated depending if it is next free-to-receive MB", can you clear me?

Regarding your example, I am almost using the same code. My code is as follows (I posted it that to make my point):

=========================================================

while (1)

{

   FLEXCAN_DRV_Receive(INST_CANCOM1,6, &recvBuff1);

   FLEXCAN_DRV_Receive(INST_CANCOM1, 7, &recvBuff2);

    //all other message id receive goes here

   mcmsg81 = FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1,6);

   mcmsg80 = FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1,7);

   //all other message id transfer status check goes here

   while ((mcmsg81  == STATUS_BUSY)  &&  (mcmsg80 == STATUS_BUSY) 

   //all other message id transfer status check goes here

   {      

      mcmsg81 = FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1,6);

      mcmsg80 = FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1,7);

       //all other message id transfer status check goes here

   }

   if (mcmsg81 == STATUS_SUCCESS)

   {

      //process 81 data

   }

   if (mcmsg80 == STATUS_SUCCESS)

   {

      //process 80 data

   }

}

=========================================================

I added code for  0x212, 0x319,0x361 in same way.

My aim is to process whichever message that arrives first so if 0x212 arrives process it, if 0x212 and 0x81 arrive, process them together and so on. 0x81 and 0x80 are fault messages so they are not periodic while others are.

If my understanding of CAN is correct 0x80 and 0x81 have higher priority than  0x212, 0x319 and 0x361. Therefore, they should be signal even if any other message ids having number higher than 0x81 are being transmitted. However, this is not happening.

I will try mask 0x7FF and update if it works or not.

Regards

Mre

0 Kudos

1,379 Views
moreshwar
Contributor I

Hello Petr,

Further updates from yesterday:

Regarding RTM, I tried but it says SDK does not support toolchain required by the project.

I am using standard S32DS toolchain for my project as I need SDK as well as FreeRTOS. As per my reading, RTM will require bare metal which I cannot use.

Regarding using 0x7FF, I tried

My initialization is 

FLEXCAN_DRV_SetRxIndividualMask(INST_CANCOM1, FLEXCAN_MSG_ID_STD, 6, 0x7FFu);

FLEXCAN_DRV_SetRxIndividualMask(INST_CANCOM1, FLEXCAN_MSG_ID_STD, 7, 0x7FFu);
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, 6, &dataInfo_std, 0x81);
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, 6, &dataInfo_std, 0x80);

and further, my message reception is

while (1)

{

   FLEXCAN_DRV_Receive(INST_CANCOM1,6, &recvBuff1);

   FLEXCAN_DRV_Receive(INST_CANCOM1, 7, &recvBuff2);

    //all other message id receive goes here

 

   mcmsg81 = FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1,6);

   mcmsg80 = FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1,7);

   //all other message id transfer status check goes here

   while ((mcmsg81  == STATUS_BUSY)  &&  (mcmsg80 == STATUS_BUSY) 

   //all other message id transfer status check goes here

   {      

      mcmsg81 = FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1,6);

      mcmsg80 = FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1,7);

       //all other message id transfer status check goes here

   }

 

  if (mcmsg81 == STATUS_SUCCESS)
   {
      if (recvBuff1.msgId == 0x81)
         {
            while (mcmsg81 != STATUS_SUCCESS)
            {
               mcmsg81 = FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1,6);
            }

     // further processing of 0x81

   }

 

   if (mcmsg80 == STATUS_SUCCESS)

   {

      //process 80 data

   }

}

=========================================================

 With this my problem is partially solved. To be clearer message 0x81 can indicate fault and also fault recovery. I am receiving message when fault occurs but not when it recovers from fault though I can see 0x81 for both fault and fault recovery on can analyzer.

There is one more problem. I will try to explain it. Hope you understand it.

My message processing code (extracted from above is)

  if (mcmsg81 == STATUS_SUCCESS)
   {
      if (recvBuff1.msgId == 0x81)
         {
            while (mcmsg81 != STATUS_SUCCESS)
            {
               mcmsg81 = FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1,6);
            }

     // further processing of 0x81

   }

Here the problem (fault indicator but not fault recovery as I never get here for fault recovery) is if

(mcmsg81 == STATUS_SUCCESS) never gets true.

However, if I comment out

  if (mcmsg81 == STATUS_SUCCESS)

I see recvBuff1.msgId = 0x81but mcmsg81 is STATUS_BUSY. 

That is why I have to add the while loop (which you can inside  if (recvBuff1.msgId == 0x81) )

The while loop after " if (recvBuff1.msgId == 0x81)" always finishes and mcmsg81 has STATUS_SUCCESS after the while loop.

If my understanding is correct:

1. message 0x81 requires a special while loop after if (recvBuff1.msgId == 0x81) as it reception of message 0x81 is never completed if all other messages are coming.

2. Even with if (mcmsg81 == STATUS_SUCCESS) commented out, the reception of fault recovery message is not even started because (recvBuff1.msgId == 0x81) is never true for fault recovery message.

Just to add, I am creating and recovering from fault to test my code and if CAN bus shows both fault and fault recovery messages, both should be received in S32.

In the light of above findings, could you help me understand what I can do to get the fault recovery message?

Regards

Moreshwar

0 Kudos

1,379 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

I can only see you do not set MB7, but reconfig MB6. So check your code, but it could be just typo here...

FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, 6, &dataInfo_std, 0x81);
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, 6, &dataInfo_std, 0x80);

BR, Petr

0 Kudos

1,379 Views
moreshwar
Contributor I

Hi Petr,

Sorry for  copy paste mistake. it should be 

FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, 6, &dataInfo_std, 0x81);
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, 7, &dataInfo_std, 0x80);

I worried more about 0x81 than 0x80 as 0x81 carries critical faults.

Just an update (was going to write it today in any case)

I did an experiment:

I moved 0x81 reception to another task i.e. 0x81 in one task (task1) and rest in other task (0x80, 0x212, 0x319 and so on in task2). With this change 0x81 is coming as expected almost everytime (almost means 2 or 3 out of 25 times the breakpoint in reception and processing of 0x81 was not hit as expected every time else it was hit).

I think one task is not able to handle and process 0x81 if I receive and process in same task as other  can messages. However it can process 0x81 if it is in a different task than others. I am not able to understand the reason behind it. I would like to process 0x81 in same task as others.

To add: i am using mask of 0x7FF not 0 now.

Regards

Moreshwar

0 Kudos

1,379 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi Moreshwar, ovidiu.alexandru

unfortunately I have no more idea now. Moreover have minimum experiences with FreeRTOS.

It could be fine if you can post the project that shows the wrong behavior, so we can check and test it on the EVB.

BR, Petr

0 Kudos

1,379 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

see my comments below...

- old SDK version is used, use the latest one (RTM 3.0.0)

- decimal number is used as ID instead of hexa, FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, 6, &dataInfo_std, 81);

- you are clearing individual mask, so all IDs can be received into MB. If more MBs are defined in this way, it should not work as you expect, the MB will be updated depending if it is next free-to-receive MB. Use rather 0x7FF mask to receive just defined ID.

- the main while loop can be written in different way if more MBs are used, for example

FLEXCAN_DRV_Receive(INST_CANCOM1,6, &recvBuff1);

FLEXCAN_DRV_Receive(INST_CANCOM1,7, &recvBuff2);

while(1

{

      if(STATUS_SUCCESS==FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1,6)

      {

            // process recvBuff1 data

            // enable further receive into MB6 again

            FLEXCAN_DRV_Receive(INST_CANCOM1,6, &recvBuff1);

      }

      

      if(STATUS_SUCCESS==FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1,7)

      {

            // process recvBuff2 data

            // enable further receive into MB7 again

            FLEXCAN_DRV_Receive(INST_CANCOM1,7, &recvBuff2);

      }

}

BR, Petr

0 Kudos