Part Number: TMS320F28069M
Tool/software: Code Composer Studio
Hello,
I have been trying to receive data through can communiaction in f28069. The sender is a CAN module for Raspberry pi based on MC2515 transmitting 500kbps with 75% sample point. f28069 can transmit data without issues to the Raspberry pi.
following is initialization code:
void can_init_scc_recv_mode(void)
{
/* Create a shadow register structure for the CAN control registers. This is
needed, since only 32-bit access is allowed to these registers. 16-bit access
to these registers could potentially corrupt the register contents or return
false data. */
struct ECAN_REGS ECanaShadow;
EALLOW; /*EALLOW enables access to protected bits*/
/* Configure eCAN RX and TX pins for CAN operation using eCAN regs*/
ECanaShadow.CANTIOC.all = ECanaRegs.CANTIOC.all;
ECanaShadow.CANTIOC.bit.TXFUNC = 1;
ECanaRegs.CANTIOC.all = ECanaShadow.CANTIOC.all;
ECanaShadow.CANRIOC.all = ECanaRegs.CANRIOC.all;
ECanaShadow.CANRIOC.bit.RXFUNC = 1;
ECanaRegs.CANRIOC.all = ECanaShadow.CANRIOC.all;
/* Configure eCAN for HECC mode - (reqd to access mailboxes 16 thru 31) */
/* HECC mode also enables time-stamping feature*/
ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
ECanaShadow.CANMC.bit.SCB = 0;
ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
/* TAn, RMPn, GIFn bits are all zero upon reset and are cleared again
as a matter of precaution.*/
ECanaRegs.CANTA.all = 0xFFFFFFFF; /* Clear all TAn bits */
ECanaRegs.CANRMP.all = 0xFFFFFFFF; /* Clear all RMPn bits */
ECanaRegs.CANGIF0.all = 0xFFFFFFFF; /* Clear all interrupt flag bits */
ECanaRegs.CANGIF1.all = 0xFFFFFFFF;
/* Configure bit timing parameters for eCANA*/
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=0x00040053; //500kbps 75% sample point
ECanaRegs.CANBTC.all = ECanaShadow.CANBTC.all;
/* The previous block is for 80 MHz SYSCLKOUT. (40 MHz CAN module clock Bit rate = 0.5 Mbps
See Note at end of file. */
/*CAN GAM settings allowed only in initialization mode*/
ECanaShadow.CANGAM.all=0x8FFFFFFF;
ECanaShadow.CANGAM.bit.AMI=1;
ECanaRegs.CANGAM.all= ECanaShadow.CANGAM.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..*/
/* Disable all Mailboxes */
ECanaRegs.CANME.all = 0; /* Required before writing the MSGIDs*/
EDIS;
}
For configuring mailboxes i have seperate code:
void InitCANMailbox(uint16_t mailboxIndex, uint32_t filterMaskID,
uint16_t mailboxDirection, uint16_t mailBoxDLC)
{
Uint32 mask;
Uint32 CAN_MD_REG;
Uint32 CAN_ME_REG;
ECanaMboxes.MBOX[mailboxIndex].MSGID.all = filterMaskID;
ECanaMboxes.MBOX[mailboxIndex].MSGCTRL.bit.DLC = mailBoxDLC;
mask = 0u;
mask = (Uint32)(0x00000001u) << mailboxIndex;
CAN_MD_REG = ECanaRegs.CANMD.all;
CAN_MD_REG &= ~(mask); /*first clear the corresponding bit to modify it*/
/*after the bit is cleared then modify it 0=out 1=in */
CAN_MD_REG |= ((uint32_t)mailboxDirection << (uint32_t)mailboxIndex);
ECanaRegs.CANMD.all = CAN_MD_REG;
CAN_ME_REG = ECanaRegs.CANME.all;
CAN_ME_REG |= mask;
ECanaRegs.CANME.all = CAN_ME_REG; /*enable = 1*/
}
And finally in main i also change the AME bit for each mailbox in following manner:
ECanaMboxes.MBOX[0].MSGID.bit.AME=1; //repeat for mailboxes 0-15
Change Local Acceptance mask for LAM0 and LAM3 as following:
ECanaLAMRegs.LAM0.all=0x8FFFFFFF;
ECanaLAMRegs.LAM3.all=0x8FFFFFFF;
ECanaLAMRegs.LAM0.bit.LAMI=1;
ECanaLAMRegs.LAM3.bit.LAMI=1;
I Have tried the same in eCAN mode by changing the SCB bit to 1 but it didnt help i still cant receive data.
I have changed mailbox definitions in ECAN.h to the following:
struct ECAN_MBOXES {
struct MBOX MBOX[32];
};
I can only receive can messages of message ID with all bits '0'. I cannot receive any message with any other msg id apart from 0. I can receive this message in mailbox 15 because it has the highest receive priority and any other message is not receievd.
Thanks,
Shadab