Need Sample code for CAN protocol of FRDM-KW36 kit

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

Need Sample code for CAN protocol of FRDM-KW36 kit

2,975 Views
chandramani_pra
Contributor I

Hello,

I am working on FRDM-KW36 on mcuxpresso ide. I was looking for sample codes for CAN protocol through which i can read the data of any car(PID value).There are some flexcan sample example available on the ide but i am facing  a lot of problems for communication between the devices.

Please help me in the implementation of code or any sample code regarding this topic will be appreciable.

Thanks in advance.

Labels (5)
0 Kudos
8 Replies

2,621 Views
sjerlin
Contributor I

Hi 

   I have some problem related to CAN communication.i can able to communicate between two kw 36 boards.

but when i try to communicate with any other controller or hardware simulator(not FlexCan) it's not working.Is there any configuration issues related to FlexCAN and CAN communication? or anyone having sample code?

thank u.

0 Kudos

2,621 Views
chandramani_pra
Contributor I

Thank you very much for the help.

I am going through the documents and trying to find out the solution.

I was just looking for any available sample program through which i can communicate between the two kw36 board or with one of any different board using CAN.

0 Kudos

2,621 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

If you are looking to communicate two KW36 you can flash into both boards the same frdmkw36_driver_examples_flexcan_interrupt_transfer available in the SDK, the example has already both functionalities and it should communicate correctly.

If you are looking to communicate with another board, you will need to set all the parameters mentioned previously.

Regards,

Estephania

0 Kudos

2,621 Views
chandramani_pra
Contributor I

config->clkSrc = kFLEXCAN_ClkSrcOsc;
config->baudRate = 500000U;
config->baudRateFD = 3200000U;
config->maxMbNum = 16;
config->enableLoopBack = false;
config->enableTimerSync = true;
config->enableSelfWakeup = false;
config->enableIndividMask = false;

This is my default configuration of can/flexcan.

FLEXCAN_TransferSendNonBlocking(EXAMPLE_CAN, TX_MESSAGE_BUFFER_NUM, &txFrame);

and using the above function to send the data to another kit likewise esp32.

But i am unable to receive any message from frdm-kw36 board to esp32 and vice versa.

The baudrate for both the kit is same.

Please guide me how to reach up to the solution.

0 Kudos

2,621 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello ,

Still , you will need to really understand how the CAN protocol works, besides the timing , baudrate and quantums configuration.

If you are using an esp32 there are some CAN identifiers that are defined in the demo that will either allow or deny the packets from another device that does not have the same configuration.

It is not for the KW36, but you can understand more about this concepts in this application note and you will also need to check the specification and be sure that both settings and configurations are compliant between each other.

Hope this helps.

Regards,
Estephania

0 Kudos

2,621 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

if you are just using the FlexCan demo you will need to guarantee the baudrate and the quantums to match your device.

[KW36] FlexCAN Bit Timing Parameters Setup 

 Please check the community thread above.

Also, you can try the following set up for your tests and verify if this works on your side

    flexcanConfig.baudRate = 500000U;
    flexcanConfig.clkSrc = kFLEXCAN_ClkSrcOsc;

Regards,

Estephania

0 Kudos

2,621 Views
chandramani_pra
Contributor I

Thank you for your quick reply. I am using the same baudrate as 500000U and kFLEXCAN_CLKSrcOsc as 0. But still I am facing issues in coding. I am looking for sample code in which the kw36 board can communicate to any other board or to car.

0 Kudos

2,621 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

It will depend on your other MCU or car parameters, I was able by setting that and just setting the TXID, RXID and the mailboxes correctly in both sides to communicate with a Kinetis with MSCAN.

So, you can take one of the basic examples and as long as those have the same baudrate and identifiers set correctly you should not have that many problems.

Regards,
Estephania

0 Kudos