CANBUS problem on micro MK60FN1M0VLQ12

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

CANBUS problem on micro MK60FN1M0VLQ12

1,158 Views
massimobrugia
Contributor I

We have already produce a board with installed the micro

MK60DN512ZVLL10. The firmware was developed with KDS 2.0.0 and

library MQX 4.1.1 and all working fine.

Now, on the same board (opportunely revised), we have installed the micro

MK60FN1M0VLQ12 and using the same application firmware (only the low

level firmware was adapted to the new micro using "processor expert" tool)

we have some problem on CAN bus communication where we have many

errors. Using the debbugger seems that some times the reception interrupt

not occurred and the CAN communication fails for timeout.

If required, we can send our firmware.

Using the oscilloscope we have verified that the signal on Tx and Rx pins

are ok.

Below some questions:

1) Also if the two micro are of same family, there are some hw differences

that can explain this problem?

2) On the document "KINETIS_3N96B" (related to our micro mask) we

have see following EERATA ID:

- 6939 Core: Interrupted loads to SP can cause erroneous behavior

- 6940 Core: VDIV or VSQRT instructions might not complete correctly

when very short ISRs are used

It's possible that this bugs can cause our problem or there are others

reason that explain it?

Thank you

0 Kudos
4 Replies

602 Views
soledad
NXP Employee
NXP Employee

please check my comments below:

1) Also if the two micro are of same family, there are some hw differences that can explain this problem?

Yes,

a) For K60 devices MQX supports the boards: TWR-K60D100M, TWR-K60N512 and TWR-K60F120M.  If you were using the MK60DN512ZVLL10 then I assume you clone the BSP for the Frescale TWR- K60D100M or TWR-K60N512.

b) If the board has a different clock configuration. For example the TWR-K60N512 features a 50 MHz on-board clock oscillator as seen in sheet 4 of the schematics. If you have a different configuration you needs to change the BSP.

2) On the document "KINETIS_3N96B" (related to our micro mask) we have see following EERATA ID:

Yes, however unfortunately I cannot to reproduce the issue because I don’t have a board with this mask set in order to test this issue.

Could you please try cloning the BSP for the MK60FN1M0VLQ12 using as base the TWR-K60F120M?


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

602 Views
massimobrugia
Contributor I

below my replay at your consideration

1)

a) I Confirm that on the micro MK60DN512ZVLL10 we have cloned the BSP of TWR-K60N512, while for micro MK60FN1M0VLQ12 we have cloned the BSP of TWR-K60F120M.

b) For the new micro MK60FN1M0VLQ12 we have already changed the BSP considering that core clock is 120MHz.

2) We have always used the BSP cloned from TWR-K60120M.

3) I add that our application using 3 UART, 1 I2C, Ethernet, USB and uSD but we have problem only on CAN communication when the micro MK60FN1M0VLQ12 is used.

On the last days we have make the simple task below where a message is sent from port CAN1 and then a response is sent from port CAN0, and so on.

When transmission on CAN1 is completed then the call-back function "CANBUS1_OnFreeTxBuffer()" should be called from the interrupt and so the program can start to manage the Rx message.

The problem is that when on CAN1 is sent the massage with "CANBUS1_SendFrame(CANBUS1Ptr, 9, &Frame)" the call-back function "CANBUS1_OnFreeTxBuffer()" is correctly executed for the first 5-10 times (the number of times is random) and then the program remain on the loop "while ( (!DataFrameTxFlg[CAN_DEV1]) && (i<1000) ) {}" because the flag DataFrameTxFlg[CAN_DEV1] not became never "TRUE". The only way to exit from this loop is to disable and re-enable the CAN1 module and so the communication working correctly for 5-10times and so on.

At present we don't have "TWR-K60120M" and so we don't see if the problem is reproducible on this board also.

At your disposal for other information.

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

void _CAN0Master_task(uint32_t initial_data)

{

      short RetVal = 0;

      unsigned char Data[8];

      LDD_CAN_TFrame Frame;

      LDD_TError ret;

      unsigned short i=0;

      /* Initialize the CANBUS1 device */

      if( (CANBUS1Ptr = CANBUS1_Init((LDD_TUserData *)NULL)) != NULL )

      {

            // ricezione su Message Buffer 0 con ID=0x001, trasmissione su Message Buffer 9

            if( CANBUS1_SetRxBufferID( CANBUS1Ptr, 0, 0x001 ) == ERR_OK ) /* Set new value of the Rx ID for receive buffer */

            {

                  /* Initialize the CANBUS0 device */

                  if( (CANBUS0Ptr = CANBUS0_Init((LDD_TUserData *)NULL)) != NULL )

                  {

                        // ricezione su Message Buffer 0 con ID=0x002, trasmissione su Message Buffer 9

                        if( CANBUS0_SetRxBufferID( CANBUS0Ptr, 0, 0x002 ) == ERR_OK ) /* Set new value of the Rx ID for receive buffer */

                        {

                             // enable both CAN devices

                             CANBUS0_Disable( CANBUS0Ptr );

                             CANBUS1_Disable( CANBUS1Ptr );

                             _time_delay( 2 );

                             CANBUS0_Enable( CANBUS0Ptr );

                             CANBUS1_Enable( CANBUS1Ptr );

                             _time_delay( 2 );

                             // pausa iniziale

                             _time_delay(300);

                             // task loop

                             for(;;)

                             {

                                   // Test CANBUS1 -> CANBUS0

                                   memcpy( Data, VersSw, 8 );

                                   Frame.MessageID = 0x002;                               /* Set Tx ID value - standard */

                                   Frame.FrameType = LDD_CAN_DATA_FRAME; /* Specyfying type of Tx frame - Data frame */

                                   Frame.Length = 8;                                 /* Set number of bytes in data frame - 4B */

                                   Frame.Data = Data;                       /* Set pointer to Data buffer */

                                   var_debug1++;

                                   DataFrameTxFlg[CAN_DEV1] = FALSE;

                                   ret = CANBUS1_SendFrame(CANBUS1Ptr, 9, &Frame);

                                   if( ret == ERR_OK )                   /* Sends the data frame over buffer 1 */

                                   //if( CANBUS1_SendFrame(CANBUS1Ptr, 9, &Frame) == ERR_OK )                   /* Sends the data frame over buffer 1 */

                                   {

                                         var_debug2++;

                                         // Wait Tx date frame trasmission is complete

                                         i=0;

                                         while ( (!DataFrameTxFlg[CAN_DEV1]) && (i<1000) )

                                         {

                                               i++;

                                               if (i==1000)

                                               {

                                                     // Resetto CAN1

                                                     CANBUS1_Disable( CANBUS1Ptr );

                                                     _time_delay( 2 );

                                                     CANBUS1_Enable( CANBUS1Ptr );

                                               }

                                               _time_delay( 1 );

                                               TWDOG_CAN0_MASTER = 1;

                                         }

                                         // Rx date frame reading

                                         while (!DataFrameRxFlg[CAN_DEV0])

                                         {

                                               _time_delay( 1 );

                                               TWDOG_CAN0_MASTER = 1;

                                         }

                                         memset( Data, 0, 8 );

                                         memset( &Frame, 0, sizeof(Frame) );

                                         Frame.Data = Data; /* Set pointer to Data buffer */

                                         if( CANBUS0_ReadFrame(CANBUS0Ptr, 0, &Frame) == ERR_OK )              /* Reads a data frame from buffer 0 and fills Frame structure */

                                         {

                                               var_debug3++;

                                               /*

                                                     Frame.MessageID => Contains ID value. if((Frame.MessageID & LDD_CAN_MESSAGE_ID_EXT)!=0) then extended ID, else standard ID

                                                     Frame.FrameType => Type of Rx frame, e.g. LDD_CAN_DATA_FRAME

                                                     Frame.Length => Number of Rx bytes in Rx frame

                                                     Frame.Data => Contains Rx data bytes

                                               */

                                               if( !(Frame.MessageID & LDD_CAN_MESSAGE_ID_EXT) &&

                                                     (Frame.MessageID == 0x002) &&

                                                     (Frame.Length == 8) &&

                                                     !memcmp( Frame.Data, VersSw, 8) )

                                               {

                                                     // Test CANBUS1 -> CANBUS0 OK

                                                     var_debug4++;

                                               }

                                         }

                                         DataFrameRxFlg[CAN_DEV0] = FALSE;

                                   }

                                   var_debug5 = ret;

                                   _time_delay( 2 );

                                   //The task was unblocked after the timeout.

                                   TWDOG_CAN0_MASTER = 1;

                             }

                        }

                  }

            }

      }

}

/*

** ===================================================================

**     Event       : CANBUS1_OnFreeTxBuffer (module Events)

**

** Component   :  CANBUS1 [CANBUS1_LDD]

*/

/*!

**     @brief

**         This event is called when the buffer is empty after a

** successful transmit of a message. This event is available

**         only if method SendFrame is enabled.

**     @param

** UserDataPtr     - Pointer to the user or

**                           RTOS specific data. This pointer is passed

**                           as the parameter of Init method.

**     @param

** BufferIdx       - Receive message buffer index.

*/

/* ===================================================================*/

void CANBUS1_OnFreeTxBuffer(LDD_TUserData *UserDataPtr, LDD_CAN_TMBIndex BufferIdx)

{

      unsigned char entry;

      CANBUF *pt;

      if( BufferIdx >= MAX_NUM_DOUBLE_BUFFER )

      {

            entry = BufferIdx - MAX_NUM_DOUBLE_BUFFER;

            pt = &CANBuf_tab[CAN_DEV1][entry];

            if( pt->onCANtx != NULL )

                  pt->onCANtx();

      }

      DataFrameTxFlg[CAN_DEV1] = TRUE; /* Set DataFrameTxFlg flag */         // DA ELIMINARE: PER DEBUG CAN

}

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

0 Kudos

602 Views
soledad
NXP Employee
NXP Employee

The MQX FlexCAN driver doesn't enable FlexCAN hardware module receive fifo.

Thus, software shall read each incoming message with a small latency, move it from the Rx Message Buffer into memory, otherwise new incoming message will be lost or overwritten.

The FlexCAN hardware module supports features like Rx FIFO (for up to 8 incoming CAN messages) or Rx Queue, none of these features is enabled in the MQX FlexCAN driver.

If you wish to use MQX FlexCAN software driver, I recommend to keep Rx interrupts enabled, and move the received data from Message buffer to a memory as quickly as possible. You can buffer the data in memory and process them by a task once per 1 sec if you wish, but moving data between Message Buffer and memory should be active all the time.

In addition please check the below “Known Issue and Limitation” from the MQX release notes:

The 10-kbit baudrate doesn't generally work. FlexCAN detects bit0 errors in its own transmitted messages.


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

602 Views
massimobrugia
Contributor I

We are not using the MQX FlexCAN driver, but the FlexCAN driver generated with Processor Expert integrated in KDS and CodeWarrior. Processor Expert is also used to generate all the driver, except the ones related to uSD, USB and Ethernet.

So the MQX Known Issues are not applicable in our application.

I remember that the same application software (middle and High level) working correctly in the micro MK60DN512ZVLL10, while in the micro MK60FN1M0VLQ12 is present the problem on FlexCAN explain below.

At your disposal for any information.

0 Kudos