Problem with CAN BUS communication (MK20DN512VLL10)

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

Problem with CAN BUS communication (MK20DN512VLL10)

Jump to solution
1,269 Views
huyho
Contributor III

We are developing a motion control board using the below processor MK20DN512VLL10.

I have pin 100, 98, 97,72, and 71 connected to a CAN transceiver (CAN address pin 0 - 4).  I also have pin 99, 42, and 43 connected to CAN transceiver (CAN_speed, CAN_TX, and CAN_RX).  There is also a DIP switch to set the CAN address.

The attached is what I implemented on Processor Expert. When I integrated to our project Landungsbruecke firmware, I could control the LEDs, get trace,... But there was a problem when I called CAN_SendFrame, the process was hang on when called ExitCritical() function!

Please tell me why?

Thanks in advance!

Original Attachment has been moved to: CAN_PE.tar.gz

Labels (1)
1 Solution
828 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Huy Ho,

    Please refer to this K70 CAN LDD code at first, this code also use CAN1_SendFrame function, and it works ok:

https://community.nxp.com/servlet/JiveServlet/download/605315-1-371647/K70_CANLDD.rar 

You can create a new project just contains CAN LDD, use CAN1_SendFrame function and test it, whether it still has the problem.

Please check it at first.

If you still have problem about it, please let me know.


Have a great day,
Kerry

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

View solution in original post

6 Replies
828 Views
huyho
Contributor III

Update:

#define ExitCritical() \
 do {\
   if (--SR_lock == 0u) { \
  /*lint -save  -e586 -e950 Disable MISRA rule (2.1,1.1) checking. */\
  printf("Before ExitCritical SR_reg %d\n",SR_reg);\
     __asm (                 \
       "ldrb r0, %[input]\n\t" /*Load register*/\

       "msr FAULTMASK,r0;\n\t" /**/ \
       ::[input] "m" (SR_reg)  \
       : "r0");\
   printf("After ExitCritical SR_reg %d\n",SR_reg);\
  /*lint -restore Enable MISRA rule (2.1,1.1) checking. */\
   }\
 } while(0)

The process continue running when I removed this line

"msr FAULTMASK,r0;\n\t" /**/ \

It seems that there was a problem in changing the FAULTMASK value.

Please help! Thanks.

829 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Huy Ho,

    Please refer to this K70 CAN LDD code at first, this code also use CAN1_SendFrame function, and it works ok:

https://community.nxp.com/servlet/JiveServlet/download/605315-1-371647/K70_CANLDD.rar 

You can create a new project just contains CAN LDD, use CAN1_SendFrame function and test it, whether it still has the problem.

Please check it at first.

If you still have problem about it, please let me know.


Have a great day,
Kerry

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

828 Views
huyho
Contributor III

Hi Kerry Zhou,

Thanks for your quick response!

I copied the interrupt functions in CAN.c then put in kinetis_sysinit.c of Landungsbruecke firmware. It did still not work.

I also connected this tool (CAN Tools | CAN Tools from LAWICEL AB ) and after opening the CAN bus by sending command "O" to bus, everything worked like a charm!

The CAN bus cannot work without opening. My question is "How do I open CAN bus by CAN module from my board code (without any tool)?".

Thank a lot!

0 Kudos
828 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Huy Ho,

   If you want to without any tool in the bus.

   You can add another CAN node in the CAN bus which can receive your K20 CAN code, you need another CAN node which ID is the K20 send ID .

Wish it helps you!


Have a great day,
Kerry

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

827 Views
huyho
Contributor III

Hi Kerry,

I had a problem with connection and after fixed it, CAN bus worked properly!

Thanks for your help!

Regards,

Huy.

0 Kudos
828 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Huy,

   Thank you for the information update.

   If your problem is solved, please mark the correct answer to close this case.

  Thank you!


Have a great day,
Kerry

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

0 Kudos