Setting up CAN between two FRDM-KE06Z boards

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

Setting up CAN between two FRDM-KE06Z boards

1,065 Views
andrewmeyerbti
Contributor III

07 Mar 2016

 

I've been setting up a can link to transfer data between two FRDM boards using KDS version 3.0.0 with KDSK 1.3.0, using processor Expert in bare-board mode.  The first error I had was a series of undefined references such as

 

"undefined reference to `CAN1_ReadFrame(void*, unsigned char, LDD_CAN_TFrame*)'  "

 

I eventually made these go away by adding the line

  "include "CAN1.c" "

into my main.cpp file.  This seems more like a work-around than a solution.  I think there is some problem with the makefiles, but so far have not been able to find it.  Makefiles are attached, if someone else knows where to look.  I would love to fix this properly.

 

I connected the two units together with twisted wire pair going from CAN+ to CAN+ and CAN- to CAN- on the board, and using the on-board resistors for the bus terminations.  I assume future node additions will need to have the 120 ohm on-board resistors removed in order for the bus to work most efficiently.

 

Second problem:  I could not get the transmitting unit to work in the interrupt mode.  Tried forcing all three enable bits in CANTFLG to 1, but still it does not work.  Not sure the other interrupts are working either as breakpoints set on them never get triggered, so maybe something needs to be set in the debugger?

 

Fell back to the polled transmitter mode.  In order have activity on the bus, kept sending the message over and over in a loop.  Eventually ended up sending two different messages over in a loop, to test the receiving unit's ability to discern only the messages meant for it.

 

 

At first the receiving unit would not receive in interrupt mode.  Eventually I figured out that the receiver FIFO bits are offset three bits to the right relative to the LDD_CAN_TFRAM.MessageID bits.  For example, if the MessageID is set to 0x123U, the ID filter table must be set to 0x0246 in order for a match to occur.  With this offset, reading with an interrupt appears to function properly.

 

 

So now, my questions

     1) how do I modify the makefiles or the project so that I do not need CAN1.c included in the main.cpp file

     2) do I need to remove the 120 ohm resistor from the FRDM-KE06Z boards for intermediate nodes on the bus?

     3) is there a standard "keep-alive" signal for low activity busses to keep everything synchronized?

     4) any hints why the interrupt driven transmitter is not working?  Is there something I need to turn on in the debugger to be able to run the interrupts?

Thank you for your kind assistance.

Original Attachment has been moved to: makefile.txt.zip

Labels (1)
0 Kudos
Reply
2 Replies

676 Views
andrewmeyerbti
Contributor III

Thank you Alice for your prompt reply which clearly describes the basics.  It is helpful to have this all in one place.

Sorry for the long delay in getting back to you.

Yes, the demo code compiles and links when used with either a new project in KDS 3.0 or adding to an existing project in KDS 2.0.  What doesn't work is adding CAN to a project imported from 2.0 to 3.0, unless I include the can.c file in the main file.

One issue between 2.0 and 3.0--the clock frequency is different.  To get the two boards to communicate, I need to set the 2.0 code and 100K baud and the 3.0 code at 114 k Baud.  I think the 2.0 code frequency is wrong--had to do similar tweak with serial connections in 2.0.

Since the demo works, I can either send or receive from a demo board, but not both.

Second issue and current problem--when trying to write an interrupt driven routine to send and receive with the same controller the read interrupt bit RXFIE in the interrupt enable register CANRIER is being cleared when either CAN1_SendFrame or CAN1_ReadFrame is called.    If I go into EmbSys Registers and set the RXFIE bit, the code works and expected, but the bit gets cleared so that the code doesn't function.  The main file is attached--the interrupts are set up the same way as in the demos.

I tried adding calls to "SetEvenMask" after the CAN1_SendFrame and ReadFrame calls, but this did no good.  Trying to figure out the structure of the processor expert generated code and see where the bug is--haven't solved it yet.

Another Issue which cropped up and perhaps should be another thread or a bug report somewhere--gdb stopped launching with no cogent error notification.  It started again when I cleared the breakpoints I had set in the code--I think there were more than 3 breakpoints so that gdb didn't launch.  Not hard to fix if you know where to look, but discouraging and time consuming when you don't.   Where would be the best place to report this with the details?

0 Kudos
Reply

676 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Andrew,

1. Does the error show when you only add the CAN_LDD component , click generate button , the build the project ?

(if yes ,  pleas screenshot to me how do you operate step by step , i just test it on my side , it with no error .)

2.No, you needn't , only connect the 1-1 ,2-2 between the two board.

3-4. About the use the  CAN_LDD , there are demo code, it includes the interrupt mode :

    please right click the CAN_LDD component ->select the "help on component "-> "CAN_LDD Typical Usage"

pastedImage_0.png

pastedImage_1.png

pastedImage_2.png

Please refer to the configuration and code .


Have a great day,
Alice Yang

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

0 Kudos
Reply