Hello,
I set flexcan of tx and rx the same ID, and find a strange phenomenon. Flexcan complete after sending will enter callback function and trigger rx flag, but I did not send any data to the MCU.I modified the two are not the same ID, return to normal.
However, I don't set loopback.
the same id:
rxid=txid =0x123;
different id:
txid = 0x321;
rxid = 0x122;
phenoemon:
Code function:
MCU waits after sending a data, and receive data from the computer.
Code:
while(1):
frame.id = FLEXCAN_ID_STD(txIdentifier);
frame.format = kFLEXCAN_FrameFormatStandard;
frame.type = kFLEXCAN_FrameTypeData;
frame.length = 1;
txXfer.mbIdx = TX_MESSAGE_BUFFER_NUM;
txXfer.frame = &frame;
FLEXCAN_TransferSendNonBlocking(EXAMPLE_CAN, &flexcanHandle, &txXfer);
while (!txComplete)
{
};
txComplete = false;
rxXfer.mbIdx = RX_MESSAGE_BUFFER_NUM;
rxXfer.frame = &frame;
FLEXCAN_TransferReceiveNonBlocking(EXAMPLE_CAN, &flexcanHandle, &rxXfer);
/* Wait until Rx MB full. */
while (!rxComplete)
{
};
rxComplete = false;
PRINTF("Rx MB ID: 0x%3x, Rx MB data: 0x%x\r\n", frame.id >> CAN_ID_STD_SHIFT, frame.dataByte0);
PRINTF("Press any key to trigger the next transmission!\r\n\r\n");
frame.dataByte0++;
}
Hi customer,
When you set the RX and TX as the same CAN ID, after you send the related ID to the CAN bus, your own CAN node RX will also receive the message from CAN bus, because you set the RX as the same ID as the TX, this function still like the loopback, but just not loop back from the chip internal side, it will loop back from the CAN bus side.
Wish it helps you!
If you still have questions about it, please kindly let me know.
Kerry
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hello kerry,
So,this is a function of FlexCAN. Can I close this function, and how to close?
Hello 植渲 周,
The solution is don't set your RX ID = TX ID, it is totally your own configuration.
Wish it helps you!
If you still have questions about it, please kindly let me know.
Kerry
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------