CAN_LDD TRK_KEA128 sendFrame (NOT LOOPBACK)

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

CAN_LDD TRK_KEA128 sendFrame (NOT LOOPBACK)

4,442 Views
michaelamici
Contributor II

I got loopback working fine on TRK-KEA128 board but I cant get the real thing working! My sendFrame function returns ERR_OK but the TX buffer is never cleared!

I am following the suggested code and cant get it right. I know my code is ok. I am looking for tips to get it working on the real CANBUS, not loopback

I repeat, NOT LOOPBACK

Please do NOT send me code suggestions for loopback, they work in loopback but not on a real network!

          LDD_CAN_TFrame Frame;

        Frame.MessageID = (0x201U | LDD_CAN_MESSAGE_ID_EXT);

        Frame.FrameType = LDD_CAN_DATA_FRAME;

        uint8_t data[] = {0x02U, 0x10U, 0x68U}; //{0x68U, 0x10U, 0x02U};

        Frame.Data = data;

        Frame.Length = sizeof(data);

        LDD_TError error = CAN1_SendFrame(CAN1_DeviceData, 1U, &Frame);

TX free buffer never fires!!!

PLEASE HELP TIME CRITICAL

11 Replies

2,870 Views
maxv
Contributor I

I'm having this problem as well on the MagniV S12ZVC Evaluation Board (VLG-MC9S12ZVC), and it is kind of a surprising behavior.

I have the CANH and CANL lines hooked up to an oscilloscope and it just keeps sending the same TX message over and over, and the CAN1_OnFreeTxBuffer ISR is never triggered.

I don't have this hooked onto a real CAN bus yet, but I'm surprised that the ISR doesn't get triggered once the message has been sent? Shouldn't the ISR trigger regardless of whether the CAN transceiver is actually connected to a bus? I would not have assumed that a single call to CAN1_SendFrameExt() would ever produce more than a single transmission. This definitely violates the principle of least surprise and is to me a bit baffling.

What it means in practice is that should this device ever be plugged into a faulty bus, it will send data forever. Or if it thinks its connections are faulty, could it flood the bus with the same message forever? :smileysad:

I may have to go with interrupt-driven receive and blocking transmit, just to ensure that this case can never happen.

Update: I hooked this up to an Arduino Microchip MCP2562 + MCP2515 CAN transceiver shield, which is transmitting a CAN message once per second. The CAN1_OnFreeTxBuffer ISR doesn't trigger, the S12ZVC chip sends its message infinitely.

0 Kudos
Reply

2,870 Views
tonymor90
Contributor I

Hello Max, 

Did you finde a solution for this issue? I've been having the same issue but the difference is that I am using just the S9KEAZ128AMLH with a single wire CAN transceiver but the TX free buffer call never fires, If you found a solution I would appreciate if you can help me.

Thank you.

0 Kudos
Reply

2,870 Views
zhangsheng
Contributor II

Hey Hugo,

   I think you have already fixed this, just in case others came across this issue,here I wanna share my solution to this. Just my case. This problem mainly appear in those PE projects.

   My CAN project is set according to the example code. The reason why "TX free buffer call never fires" is because the CAN module did not managed to sent the message to other device successfully. You may already connected CAN node to it, but unfortunately the PE has a bug with the baud rate timing ,then the baud rate of CAN is not right. you may use some CAN Tool to find its right baud rate. 

0 Kudos
Reply

2,870 Views
egoodii
Senior Contributor III

It is the definition for CAN peripherals to automatically retry a TX which is either not ACKed or is NAKed, for 'guaranteed' delivery.  A 'babble limit' must be enforced by higher layers and/or the 'excessive TX errors' interrupt.

0 Kudos
Reply

2,870 Views
sruthyuk
Contributor I

hi michael,

this was my problem also. Am trying to test communication between two CAN nodes.When loopback mode is tested for CAN controller transmit and receive interrupts are generated. But this is not possible in real CAN bus communication. Whether the transmitted message will not store in any of the message buffers when loopback mode is disabled??

Best regards

sruthy uk

0 Kudos
Reply

2,870 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Michael Amici,

     About the CAN_LDD for TRK_KEA128 without loopback code, I already share it in the community, and it can works ok on the TRK_KEA128, you can refer to my project:

I wonder how to get CAN to work with KDS's Processor Expert?

Wish it helps you!

If you still have question, please let me know!

Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------

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

----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

2,870 Views
michaelamici
Contributor II

This code does not work, did you test in on an ACTUAL canbus? not loopback

The interrupts are not called, the TX buffer is not being cleared!!! What the hell?

M

0 Kudos
Reply

2,870 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Michael Amici,

    Of course, my code works on the real canbus, not the loopback mode.

    If it works in the loopback mode, the data won't sent to the CAN bus, it will loopback through the chip internal pin circuit.

    My test result is from the J15, pin1,2, CANH and CANL, this is the ACTUAL canbus, not the loopback.

76.jpg

You also can test the wave from CANH and CANL: J15 pin1 and 2.

   You said, the interrupt are not called, I don't know whether you put an breakpoint in the PE_ISR(CAN1_TxInterrupt) or not?

If you put a breakpoint in the interrupt service code, you will find the interrupt is entered, just like the following test picture:

75.jpg

The above test result is from the CANBUS tools which connect to the KEA128 CANH and CANL in the CANBUS.

Besides the CAN_LDD code, I also have a CW barebone CAN code for KEA128, you also can refer to that sample code.

Wish these code can help you!

Take care, it is really not the loopback mode, if in loopback mode, the Loop mode in the CAN_LDD will be yes, but now, we configure it as no:

77.jpg

If you still have question, please let me know!

Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------

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

0 Kudos
Reply

2,870 Views
michaelamici
Contributor II

The interrupt in event.c (freeTXbuffer) is never called and therefor the flag is not set and it stays in the while loop in main(). the buffer is not cleared and the message is not sent. I don't understand what's going on! Why isnt your code working on my board? The buffer is not clearing and the second CAN issue is not going through.

When I tried with my previous code which was setup to send a CAN message with sendFrame every time button0 was pressed (toggle mode), the first time i press sendFrame returns ERR_OK. The next time i press (2 seconds later) the sendFrame command returns ERR_BUSY which leads me to believe the frame was not transmitted!

Is this a hardware issue? MSCAN issue? what revision board is your TRK-kea128?

M

0 Kudos
Reply

2,870 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Give you a connect picture for your reference:

79.jpg

Wish it helps you!

Have a great day,

Jingjing

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

0 Kudos
Reply

2,870 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Michael Amici,

      I tried both TRK-KEA128 SCH-28200 REV B and SCH-28200 REV D, these two boards, are all working ok on my side.

     I have a question, did you connect any other CAN node in the CAN BUS, if you connect nothing in the CAN bus, of course, it won't enter in CAN1_OnFreeTxBuffer, because no other CAN node give feedback, it will have error, it won't send successfully.

    I have connect my CAN_BUS tool in the CAN bus which used as the CAN date analyzer, I can enter the CAN1_OnFreeTxBuffer function:

78.jpg

Please make sure you already add another CAN node in the CAN bus!

Wish it helps you!

Have a great day,

Jingjing

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