Kinetis K64 CAN communication

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

Kinetis K64 CAN communication

812 Views
LArmstrong1985
Contributor III

Good morning,
starting from the example fdrmk64f_flexcan_loopback I made two programs, one transmitter and one receiver, installed on two boards connected via two TJA1050 transceivers. Signals seem ok, but the interrupt does not trigger on the receiver.

The changes I made are the following:

- in both software I setted flexcanConfig.enableLoopBack to false

- in both software I configured CAN0 to pin PTB18 and PTB19 on pinmux

- on trasmitter I removed receive mb configuration and receive interrupts

- on receiver I removed transmitter mb configuration

Can you take a look to find out if I did well or is there something wrong?

Thank you in advance!

Labels (1)
0 Kudos
6 Replies

637 Views
LArmstrong1985
Contributor III

I solved. The problem was that the frdmk64_interrupt_loopback example had to do only with Message Buffers.

By configuring CAN TX and RX pins and disabling the loopback, most likely, however, it was transmitting but was not enabled to receive. I found another example, specifically twrk64f120m_flexcan_interrupt_transfer and all works well.

Now I have some doubts about how to configure the CAN module to receive from multiple transmitters.

Do I have to configure a message buffer for each ID I want to manage?

And if I don't know which IDs can send me data and want to receive from all possible IDs?

0 Kudos

637 Views
senthilprabhug
Contributor I

Fabio,

 i have same issue what you tell above. i have only one board configure as transmitter and i connect the CAN_H through the Transceiver to the CAN analyzer. i also disable the loopback and cinfig the pin mux. then i start debugging but message not send because of program stopped here. 

while (0U == FLEXCAN_GetMbStatusFlags(base, u32flag << mbIdx))
{
}

the flag not set. are you facing this issue or not.

i attaced the pic for your reference.

I'm using MKV42F microcontroller. i do code with example of frdmk64_interrupt_loopback.

can_stop.png

0 Kudos

637 Views
LArmstrong1985
Contributor III

I attached the decoded signal that I received and it is correct. However, it still does not trigger any interrupt in reception.

The doubts I have from the beginning looking at the example are the following:

- where is setted the CAN ID of each individual board? From the example it seems that it can be set only in the messages in transmission and in reception therefore each card can send and receive messages with different IDs. It's correct?

- the ID entered in the txframe is that of the transmitter or that of the recipient of the message? Same question for the receiver: the ID entered in rxframe is that of the transmitter to be listened to or that of the receiver? In my separate examples for transmitter and receiver I left the same id value in the txframe and in the rxframe that is 0x123

- Through the logical analyzer I see that the message is repeated several times even if it is sent only once in the example.
Why? Is it the CAN controller that sends back if there is no answer?

- In the original example CAN RX and TX pin were not configured. That is the configuration that I added in MCUXpresso Config Tool. Is OK?CAN configuration.JPG

- The last doubt is on the transceiver that I used, the TJA1050. I looked that I needed 5V on VCC. I think the signal is still 3.3v as it is generated by MCU. Could it be that it is not compatible as a transceiver?

I hope you can help me!

Thank you very much!CAN_RX_SIGNAL.JPG

0 Kudos

638 Views
LArmstrong1985
Contributor III

Hi Mark,

thank you very much but unfortunately I can't use uTasker.

Regards

Fabio

0 Kudos

638 Views
mjbcswitzerland
Specialist V

Fabio

As noted, the uTasker project can be used as "working reference" to solve problems with environments that don't yet work but are specified to be used. Its simulation capability is very useful in understanding how the code flow and the register settings should be. Since it is free open source there should be no objections from finance departments or developments on a shoe-string either.

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]

0 Kudos

638 Views
mjbcswitzerland
Specialist V

Hi

Take a look at https://www.utasker.com/docs/uTasker/uTaskerCAN.PDF
and
https://www.youtube.com/watch?v=Ha8cv_XEvco
It is available in the open source uTasker project on all Kinetis processors with FlexCAN.
It allows the FlexCAN to be simulated and easily investigated to help solve problems.

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]

0 Kudos