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.

TMS320F28379D: CAN Remote Frame in Loopback

Part Number: TMS320F28379D

Hi,

I want to see how the remote frame works in 28379D.

I have only one lauchpad..

Is it possible to do the remote frame application using Loopback ?

Below is the code i am trying ( edited in ex8_remote_tx file).

Request is going, but response is coming.

//
// Included Files
//
#include "driverlib.h"
#include "device.h"

//
// Defines
//
#define TXCOUNT 10
#define MSG_DATA_LENGTH 8
#define TX_MSG_OBJ_ID 1
#define RX_MSG_OBJ_ID 2

//
// Globals
//
volatile unsigned long i;
volatile uint32_t txMsgCount = 0;

//
// Buffer to store the message Received by node A
//
uint16_t rxMsgData[8];

//
// Main
//
void main(void)
{
//
// Initialize device clock and peripherals
//
Device_init();

//
// Initialize GPIO and configure GPIO pins for CANTX/CANRX
// on modules A & B
//
Device_initGPIO();
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXB); //Using 17 and 12 pin, which having CAN transceiver IC on the lauchpad.
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXB);

CAN_initModule(CANB_BASE);

CAN_setBitTiming(CANB_BASE, 0x09, 0x00, 0x04, 0x03, 0x01);

//
//
CAN_setupMessageObject(CANB_BASE, RX_MSG_OBJ_ID, 0x111,
CAN_MSG_FRAME_STD, CAN_MSG_OBJ_TYPE_RX, 0,
CAN_MSG_OBJ_NO_FLAGS, MSG_DATA_LENGTH);


CAN_setupMessageObject(CANB_BASE, TX_MSG_OBJ_ID, 0x111,
CAN_MSG_FRAME_STD, CAN_MSG_OBJ_TYPE_RXTX_REMOTE, 0,
CAN_MSG_OBJ_NO_FLAGS, MSG_DATA_LENGTH);

//
// Initialize the receive buffer to a known value
//
rxMsgData[0] = 0;
rxMsgData[1] = 0;
rxMsgData[2] = 0;
rxMsgData[3] = 0;
rxMsgData[4] = 0;
rxMsgData[5] = 0;
rxMsgData[6] = 0;
rxMsgData[7] = 0;

//
// Enable CAN test mode with external loopback
//
CAN_enableTestMode(CANA_BASE, CAN_TEST_EXL);


//
// Start CAN module operations
//
// CAN_startModule(CANA_BASE);
CAN_startModule(CANB_BASE);


//
// Copy data into the mailbox1 RAM of CAN-B. This is the data that will be
// automatically transmitted in response to a remote frame.
//
// Wait for busy bit to clear
//
while((HWREGH(CANB_BASE + CAN_O_IF1CMD) & CAN_IF1CMD_BUSY) ==
CAN_IF1CMD_BUSY)
{
}

//
// Write to IF1DATA & IF1DATB registers
//
HWREG_BP(CANB_BASE + CAN_O_IF1DATA) = 0x67452301UL;
HWREG_BP(CANB_BASE + CAN_O_IF1DATB) = 0xEFCDAB89UL;

//
// Transfer to MBX RAM
//
HWREG_BP(CANB_BASE + CAN_O_IF1CMD) = 0x00830001UL;

//
// Wait for busy bit to clear
//
while((HWREGH(CANB_BASE + CAN_O_IF1CMD) & CAN_IF1CMD_BUSY) ==
CAN_IF1CMD_BUSY)
{
}

//
// Transmit Remote frame(s) from CAN-A and await data frame(s) from node B
//
//while(1) // Uncomment for infinite transmissions
for(i = 0; i < TXCOUNT; i++)
{
//
// Initiate transmission of remote frame. "rxMsgData" is "dummy"
// No data will go out on a Remote Frame
//
CAN_sendMessage(CANB_BASE, RX_MSG_OBJ_ID, MSG_DATA_LENGTH, rxMsgData);

//
// Poll TxOk bit in CAN_ES register to check completion of transmission
//
// while(((HWREG_BP(CANB_BASE + CAN_O_ES) & CAN_ES_TXOK)) !=
// CAN_ES_TXOK){}

txMsgCount++; // Increment TX counter

//
// Poll RxOk bit in CAN_ES register to check completion of reception
//
// while(((HWREG_BP(CANB_BASE + CAN_O_ES) & CAN_ES_RXOK)) !=
// CAN_ES_RXOK){}

CAN_readMessage(CANB_BASE, RX_MSG_OBJ_ID, rxMsgData);
}

//
// Stop application
//
asm(" ESTOP0");
}

When both the while loops are uncommented, it is waiting at RxOk loop.