CAN_LDD mk22fn1m0vlk12 loopback issues

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

CAN_LDD mk22fn1m0vlk12 loopback issues

Jump to solution
2,239 Views
daafies
Contributor II


hi i've been unable to loopback any can frames. i've tried all examples here on the forum without any luck. i enabled int service. breakpoint on CAN1_OnFreeTxBuffer DOES hit, but CAN1_OnFullRxBuffer does NOT.

here's some code snippets:

events.c:

void CAN1_OnFullRxBuffer(LDD_TUserData *UserDataPtr, LDD_CAN_TMBIndex BufferIdx)

{

  canrx = TRUE;

  /* Write your code here ... */

}

main.c:

extern bool canrx;

LDD_TDeviceData *MyCANPtr=NULL;

LDD_TError Error;

LDD_CAN_TFrame Frame,RFrame;

void can_test(void)

{

  LDD_CAN_TAccMask AccMask;

  uint8_t OutData[8] = {0x00U, 0x01U, 0x02U, 0x03U};

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

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

   Frame.Length = sizeof(OutData);                                 /* Set number of bytes in data frame - 4B */

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

   //DataFrameTxFlg = FALSE;                                         /* Initialization of DataFrameTxFlg */

   Error = CAN1_SendFrame(MyCANPtr, 1U, &Frame);

   Error = CAN1_GetAcceptanceMask(MyCANPtr, 0U, &AccMask );

}

int main(void)

{

  /* Write your local variable definition here */

  MyCANPtr = CAN1_Init(NULL);

  for(;;){

          WAIT1_Waitms(5);
 

        if(canrx){

          canrx=FALSE;

          RFrame.Data = InpData;
          Error = CAN1_ReadFrame(MyCANPtr, 0U, &RFrame);
          }
                    cnt++;
          if ((cnt%1024)==0) { /* from time to time, write some text */

          can_test();

}}

thanks for any pointers

david

0 Kudos
Reply
1 Solution
1,818 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi David,

So sorry for it , i will attach it this time if need .

And about this "i enabled global acceptance mask of 0x1ffffff.. doesn't that mean it should accept all msgs?" ,yes ,

it can accept all msgs.

While here you configure it receive the ID 0x7ff

pastedImage_0.png

while in your project you writ the send can ID is 12473156, not 0x7ff.

      Frame.MessageID = (12473156 | LDD_CAN_MESSAGE_ID_EXT);

Hope it helps


Have a great day,
Alice Yang

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

View solution in original post

0 Kudos
Reply
13 Replies
1,818 Views
daafies
Contributor II

hi Alice, please find atached the poject in question. i've configure it for loopback

also please note i've tried it on 2 boards with same processor i have here. same result :smileysad:

0 Kudos
Reply
1,818 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello David,

From your project , i have not find the send data project , so i create one

new project for the CAN-loopback about the chip of  mk22fn1m0vlk12 , and as

to i have not this chip , so i test it on the similar chip , it can work well , can run into

the receive interrupt ,

pastedImage_0.png

please test it on your side .

BR

Alice

0 Kudos
Reply
1,818 Views
daafies
Contributor II

Alice,

i figured it out. i had to put a messageID in the rx buffer, and send a frame with that msg id.
Confusing though cause i enabled global acceptance mask of 0x1ffffff.. doesn't that mean it should accept all msgs?

pastedImage_0.png

0 Kudos
Reply
1,819 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi David,

So sorry for it , i will attach it this time if need .

And about this "i enabled global acceptance mask of 0x1ffffff.. doesn't that mean it should accept all msgs?" ,yes ,

it can accept all msgs.

While here you configure it receive the ID 0x7ff

pastedImage_0.png

while in your project you writ the send can ID is 12473156, not 0x7ff.

      Frame.MessageID = (12473156 | LDD_CAN_MESSAGE_ID_EXT);

Hope it helps


Have a great day,
Alice Yang

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

0 Kudos
Reply
1,818 Views
daafies
Contributor II

thanks for help!

0 Kudos
Reply
1,818 Views
daafies
Contributor II

here's another project, with just can_ldd. it does NOT hit the receive interrupt on my end

0 Kudos
Reply
1,818 Views
daafies
Contributor II

you forgot to attach it :smileyhappy:

0 Kudos
Reply
1,818 Views
daafies
Contributor II

btw the sendframe is in 'flash_test()'    sorry re-purposed test code.

0 Kudos
Reply
1,818 Views
daafies
Contributor II

hi Alice, how do I select my processor for the demo project?

i'lll zip up my project and send it to you later

thanks for help

0 Kudos
Reply
1,818 Views
daafies
Contributor II

more screens i've forgotten


pastedImage_0.png

pastedImage_1.png

pastedImage_2.png

pastedImage_3.png

0 Kudos
Reply
1,818 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi david,

From the PE configuration , it seems there is no error.

Pleas test the demo code under KSDK1.3 on your board :

KSDK_1.3.0\examples\twrk21f120m\driver_examples\flexcan\flexcan_loopback\kds

Pay attention , when you download the project , please select the part number  or your chip,

and also please send your project to me , i will test it on my side the TWR-K21 board ,

i have test the demo on my board , it can run into the receive interrupt , while i have not the

chip "mk22fn1m0vlk12 " , so only need your help to test the demo , then i would be confirm

whether is the project error or the chip .

BR

Alice

0 Kudos
Reply
1,818 Views
daafies
Contributor II

hi Alice,

yes i do use PE. and 'self reception' was set already. i've tried auto and non-auto initialization.

btw all methods called return 0x0 (ERR_OK)

here's all component inspector screens

pastedImage_2.png

pastedImage_3.png

pastedImage_4.png

pastedImage_5.png

pastedImage_6.png

pastedImage_7.png

0 Kudos
Reply
1,818 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello David,

From your code , it seems that you use the Processor Expert project ,

if yes, please also enalbe the "Self reception"on the CAN_LDD component :

pastedImage_0.png

If you do not use the PE, please set the SRXDIS to 0 to enable it on the CANx_MCR register .

Hope it helps


Have a great day,
Alice Yang

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

0 Kudos
Reply