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.

TMS320F280025: How to do initialization to receive different can packets?

Part Number: TMS320F280025
Other Parts Discussed in Thread: C2000WARE

Hi, guys

We found we can only receive the special can packet which ID is set in the initialization(In fact we want to receive all the can packets and filter the CAN ID we want ourself). How to do to receive all the can packets without any filter?

Following is the initialization function:

void BmuCanInit(void)
{
unsigned int i;
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_CANA);
CAN_selectClockSource(CANA_BASE,CAN_CLOCK_SOURCE_SYS);
CAN_enableController(CANA_BASE);
GPIO_setPinConfig(GPIO_12_CANA_RX);
GPIO_setPinConfig(GPIO_13_CANA_TX);
CAN_initModule(CANA_BASE);
//
// Set up the CAN bus bit rate to 500kHz for each module
// Refer to the Driver Library User Guide for information on how to set
// tighter timing control. Additionally, consult the device data sheet
// for more information about the CAN module clocking.
//
//CAN_setBitRate(CANA_BASE, DEVICE_SYSCLK_FREQ, 250000, 20);
CAN_setBitTiming(CANA_BASE, 19, 0, 13, 4, 3);

//
// Enable interrupts on the CAN A peripheral.
//
CAN_enableInterrupt(CANA_BASE, CAN_INT_IE0 | CAN_INT_ERROR |
CAN_INT_STATUS);

//
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
// This registers the interrupt handler in PIE vector table.
//
Interrupt_register(INT_CANA0,&canaISR);

CAN_setupMessageObject(CANA_BASE, 1, 0x18123456, CAN_MSG_FRAME_EXT,
CAN_MSG_OBJ_TYPE_RX, 0, CAN_MSG_OBJ_RX_INT_ENABLE,
8);

for(i=2;i<17;i++)
{
CAN_setupMessageObject(CANA_BASE, i, 0, CAN_MSG_FRAME_EXT,
CAN_MSG_OBJ_TYPE_RX, 0, CAN_MSG_OBJ_RX_INT_ENABLE,
8);
}
Interrupt_enable(INT_CANA0);
CAN_enableGlobalInterrupt(CANA_BASE, CAN_GLOBAL_INT_CANINT0);
}

ISR

__interrupt void canaISR(void)
{
uint32_t status;
CAN_MsgFrameType RecvType = CAN_MSG_FRAME_STD;
U32 Id=0;
U8 RecvData[16];

//
// Read the CAN-B interrupt status to find the cause of the interrupt
//
status = CAN_getInterruptCause(CANA_BASE);

//
// If the cause is a controller status interrupt, then get the status
//
if(status == CAN_INT_INT0ID_STATUS)
{
//
// Read the controller status. This will return a field of status
// error bits that can indicate various errors. Error processing
// is not done in this example for simplicity. Refer to the
// API documentation for details about the error status bits.
// The act of reading this status will clear the interrupt.
//
status = CAN_getStatus(CANA_BASE);
//
// Check to see if an error occurred.
//
}
else if((status > 16)&&(status < 33))
{
//
// Getting to this point means that the TX interrupt occurred on
// message object 1, and the message TX is complete. Clear the
// message object interrupt.
//
CAN_clearInterruptStatus(CANA_BASE, status);

//
// Increment a counter to keep track of how many messages have been
// transmitted. In a real application this could be used to set flags to
// indicate when a message is transmitted.
//
txMsgCount++;
}

else if((status <= 16)&&(status > 0))
{
//
// Get the received message
//
CAN_readMessageWithID(CANA_BASE,status,&RecvType,&Id,(uint16_t*)(&RecvData[4]));
RecvData[0] = (U8)Id;
RecvData[1] = (U8)(Id>>8);
RecvData[2] = (U8)(Id>>16);
RecvData[3] = (U8)(Id>>24);
//CAN_readMessage(CANA_BASE,status,RecvData);
//
// Getting to this point means that the RX interrupt occurred on
// message object 1, and the message RX

We can only receive can packets which ID is 0x18123456, other can packets can't be received.

  • Hi,

    Thank you for your question. Please review and run "can_ex8_mask.c" from C2000Ware. This has all required code for filtering and masking as you have requested. If the unmodified example does not work, then something is wrong with the set up.

    Regards,

    Vince