This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

EK-TM4C1294XL: CAN communication using EK-TM4C1294XL as the slave and STM32F407VET6 as the master

Part Number: EK-TM4C1294XL

Tool/software:

Hi

CAN communication using EK-TM4C1294XL as the slave  receiving mode. I downloaded the sample code (spna245.zip) according to spna245.pdf, executed [simple_can_rx] on the receiving side, and confirmed that communication could be performed normally.
https://www.ti.com/lit/an/spna245/spna245.pdf

Code Composer Studio Code has below 

//
// Initialize a message object to be used for receiving CAN messages with
// any CAN ID. In order to receive any CAN ID, the ID and mask must both
// be set to 0, and the ID filter enabled.
//
sCANMessage.ui32MsgID = 0x321;
sCANMessage.ui32MsgIDMask = 0;
sCANMessage.ui32Flags = MSG_OBJ_RX_INT_ENABLE | MSG_OBJ_USE_ID_FILTER;
sCANMessage.ui32MsgLen = 8;

//
// Now load the message object into the CAN peripheral. Once loaded the
// CAN will receive any message on the bus, and an interrupt will occur.
// Use message object 1 for receiving messages (this is not the same as
// the CAN ID which can be any value in this example).
//
CANMessageSet(CAN0_BASE, 0x321, &sCANMessage, MSG_OBJ_TYPE_RX);

//
// Enter loop to process received messages. This loop just checks a flag
// that is set by the interrupt handler, and if set it reads out the
// message and displays the contents. This is not a robust method for
// processing incoming CAN data and can only handle one messages at a time.
// If many messages are being received close together, then some messages
// may be dropped. In a real application, some other method should be used
// for queuing received messages in a way to ensure they are not lost. You
// can also make use of CAN FIFO mode which will allow messages to be
// buffered before they are processed.
//

for(;;)
{

unsigned int uIdx;
//
// If the flag is set, that means that the RX interrupt occurred and
// there is a message ready to be read from the CAN
//
if(g_bRXFlag)
{
//
// Reuse the same message object that was used earlier to configure
// the CAN for receiving messages. A buffer for storing the
// received data must also be provided, so set the buffer pointer
// within the message object.
//
sCANMessage.pui8MsgData = pui8MsgData;

//
// Read the message from the CAN. Message object number 1 is used
// (which is not the same thing as CAN ID). The interrupt clearing
// flag is not set because this interrupt was already cleared in
// the interrupt handler.
//
CANMessageGet(CAN0_BASE, 0x321, &sCANMessage, 0);

//
// Clear the pending message flag so that the interrupt handler can
// set it again when the next message arrives.
//
g_bRXFlag = 0;

//
// Check to see if there is an indication that some messages were
// lost.
//
if(sCANMessage.ui32Flags & MSG_OBJ_DATA_LOST)
{
UARTprintf("CAN message loss detected\n");
}

//
// Print out the contents of the message that was received.
//
UARTprintf("Msg ID=0x%08X len=%u data=0x",
sCANMessage.ui32MsgID, sCANMessage.ui32MsgLen);
for(uIdx = 0; uIdx < sCANMessage.ui32MsgLen; uIdx++)
{
UARTprintf("%02X ", pui8MsgData[uIdx]);
}
UARTprintf("total count=%u\n", g_ui32MsgCount);

}

}

When using STM32F407VET6 as the master and changing the receiving side to EK-TM4C1294XL, or when connecting with our own products communication cannot be performed.

PA0 = CAN_L
PA1 = CAN_H
GND = GND

  • Hi,

      Your below line is incorrect. You are specifying message object 0x321. There is no such message object as there are only 32 message objects. Why don't you just use the example which sets the message object ID to 1. 

    CANMessageSet(CAN0_BASE, 0x321, &sCANMessage, MSG_OBJ_TYPE_RX);

  • Hi, Charles

    My CAN Master Code has set To Msg Id=0x321 thats why I assigned to ID and also Default ID assigned still didnt get  any recieve data

    Could you Gudie me 

    6087.CAN_TX.zip

  • Hi,

      You can set whatever ID you want. Did you see my reply. It is the problem with the CANMessageSet API. This API asks you to pass the message object, NOT the message ID. The message object ranges from 1 to 32. It DOES NOT take a message ID value like 0x321 which is 801 decimal. You are trying to set up the message object equal to 801 here.  You need to at least fix this problem first before debugging the rest of your code.