Other Parts Discussed in Thread: TMS320F28335
Hello TI E2E Community,
I am currently facing a challenge with my CAN bus setup and would appreciate any insights or guidance from the community. My CAN bus is only receiving data from CAN ID 000 (hex), and messages with other CAN IDs are not being received. I have thoroughly checked my hardware connections, and they seem to be correct.
I have attached configuration related to the CAN bus setup bellow. I would appreciate any advice or suggestions to troubleshoot and resolve this issue. Thank you in advance for your time and assistance.
//
// Included Files
//
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
int i;
long RX_A_loopcount = 0; // Counts the # of times eCAN-A Received successfully
Uint16 rxMsgData[8];
Uint16 IDData[6];
/************************************************************
These functions are invoked based on the GPIO value read
*************************************************************/
void Receive_A(void); // Receive Mailbox Data function for eCAN-A
void CCR_Enable(void);
void CCR_Disable(void);
void Enable_Mailboxes(void);
void Disable_Mailboxes(void);
struct ECAN_REGS ECanaShadow;
main()
{
/* Kill Watchdog, Init PLL, Enable peripheral clocks */
InitSysCtrl();
/* Initialize the CAN module */
InitECan();
InitECanGpio();
EALLOW;
/* Configure Mailbox as Receive */
ECanaShadow.CANMD.all = 0;
ECanaShadow.CANMD.bit.MD4 = 1; /* Configure Mailbox 4 as Receive */
ECanaRegs.CANMD.all = ECanaShadow.CANMD.all;
Enable_Mailboxes();
Receive_A();
ESTOP0;
}
/*****************/
/* End of main() */
/*****************/
void Receive_A(void) // Receive Data
{
while(1)
{
while(ECanaRegs.CANRMP.all != 0x00000010 ) {} // Wait for RMP4 to be set..
ECanaRegs.CANRMP.all = 0x00000010; // Clear RMP4 bit and start
rxMsgData[0] = ECanaMboxes.MBOX4.MDL.byte.BYTE0;
rxMsgData[1] = ECanaMboxes.MBOX4.MDL.byte.BYTE1;
rxMsgData[2] = ECanaMboxes.MBOX4.MDL.byte.BYTE2;
rxMsgData[3] = ECanaMboxes.MBOX4.MDL.byte.BYTE3;
rxMsgData[4] = ECanaMboxes.MBOX4.MDH.byte.BYTE4;
rxMsgData[5] = ECanaMboxes.MBOX4.MDH.byte.BYTE5;
rxMsgData[6] = ECanaMboxes.MBOX4.MDH.byte.BYTE6;
rxMsgData[7] = ECanaMboxes.MBOX4.MDH.byte.BYTE7;
IDData[0] = ECanaMboxes.MBOX4.MSGID.bit.IDE;
IDData[1] = ECanaMboxes.MBOX4.MSGID.bit.AME;
IDData[2] = ECanaMboxes.MBOX4.MSGID.bit.AAM;
IDData[3] = ECanaMboxes.MBOX4.MSGID.bit.STDMSGID;
IDData[4] = ECanaMboxes.MBOX4.MSGID.bit.EXTMSGID_H;
IDData[5] = ECanaMboxes.MBOX4.MSGID.bit.EXTMSGID_L;
RX_A_loopcount++ ; // all over again...
}
}
void CCR_Enable(void)
{
ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
ECanaShadow.CANMC.bit.CCR = 1 ; // Set CCR = 1
ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
// Wait until the CPU has been granted permission to change the configuration registers
do
{
ECanaShadow.CANES.all = ECanaRegs.CANES.all;
} while(ECanaShadow.CANES.bit.CCE != 1 ); // Wait for CCE bit to be set..
ECanaShadow.CANBTC.all = ECanaRegs.CANBTC.all;
}
void CCR_Disable(void)
{
ECanaRegs.CANBTC.all = ECanaShadow.CANBTC.all;
ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
ECanaShadow.CANMC.bit.CCR = 0 ; // Set CCR = 0
ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
// Wait until the CPU no longer has permission to change the configuration registers
do
{
ECanaShadow.CANES.all = ECanaRegs.CANES.all;
} while(ECanaShadow.CANES.bit.CCE != 0 ); // Wait for CCE bit to be cleared..
}
void Enable_Mailboxes(void) /* Enable Mailboxes under test */
{
ECanaShadow.CANME.all = 0;
ECanaShadow.CANME.bit.ME4 = 1;
ECanaRegs.CANME.all = ECanaShadow.CANME.all;
}
void Disable_Mailboxes(void) /* Disable Mailboxes */
{
ECanaRegs.CANME.all = 0;
}