Part Number: TMS320F280049C
Hi,
I am using ti CAN (TMS320F280049C) for Communication
I have enabled CAN Silent MODE operation for RX data analysis
I have configured CANB for my operation.
Can you Please Make an analysis and comment back on my code (attached below) that why i am not able to receive data on rxMsgData[].
I am send 4 bytes of data 4001, 4002 from IXXAT USB- CAN analyzer.
I am sure that my CAN ID and Bit are set properly at both the ends.
//#############################################################################
//
// FILE: can_ex1_loopback.c
//
//
//
#include "driverlib.h"
#include "device.h"
//
// Defines
//
#define MSG_DATA_LENGTH 4
//
// Globals
//
volatile unsigned long msgCount = 0;
uint16_t txMsgData[8], txMsgData_1[8],txMsgData_2[8] , rxMsgData_2[8],rxMsgData[4], rxMsgData_1[8];
//volatile float txVariable[4]={-999,504.89,-85,-789.685};
//uint16_t txVariable[12] = {4000,4001,4002,4003,4004,4005,4006,4007,4008,4009,4010,4011};
uint16_t data[12];
uint16_t txVariable[12];
uint16_t data_receive[8];
float rxVariable[8];
//
// Main
//
void main(void)
{
/ //65535/2=32768
int k,i,z = 0;
//
//
Device_init();
// UV Changes
GPIO_setMasterCore(25, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_25_GPIO25);
GPIO_setDirectionMode(25, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(25, GPIO_PIN_TYPE_STD);
GPIO_writePin(25,1);
GPIO_setMasterCore(26, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_26_GPIO26);
GPIO_setDirectionMode(26, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(26, GPIO_PIN_TYPE_STD);
GPIO_writePin(26,1);
// Initialize GPIO and configure GPIO pins for CANTX/CANRX
//
Device_initGPIO();
//
// UV Changes
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXB);
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXB);
// UV Changes
CAN_initModule(CANB_BASE);
CAN_setBitRate(CANB_BASE, DEVICE_SYSCLK_FREQ, 500000, 20);
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
Interrupt_initVectorTable();
EINT;
ERTM;
//
// Enable CAN test mode with external loopback
CAN_enableTestMode(CANB_BASE, CAN_TEST_SILENT);
// UV Changes
CAN_startModule(CANB_BASE);
*(uint16_t *)rxMsgData = 0;
for(;;)
{
// Delay before receiving the data
//
DEVICE_DELAY_US(150);
//UV Changes
if (CAN_readMessage(CANB_BASE, 2, rxMsgData))
{
for(i=0;i<4;i++)
{
data_receive[z] = (rxMsgData[i] >> 8);
z++;
data_receive[z] = (rxMsgData[i] & 0x00FF);
z++;
}
}
}
}
//
// End of File
//
Regards shivashankar