Tool/software: Code Composer Studio
Hi,
I am trying to send CAN message from TMS320F28069 to a linux computer. The code on the MCU is listed as following, basically setup the GPIO and CAN timing first, then setup the CAN message before sending.
The issue I have is that the linux computer can get the message content, in following case is the 4 byte data counter up, but not seeing the message ID. Is there an working example to show how to setup the
controller and message object that can send the message along with can ID?
Thanks.
Linux computer output:
interface = can0, family = 29, type = 3, proto = 1
<0x000> [4] 78 56 34 12
<0x000> [4] 00 00 00 00
<0x000> [4] 01 00 00 00
<0x000> [4] 02 00 00 00
<0x000> [4] 03 00 00 00
<0x000> [4] 04 00 00 00
<0x000> [4] 05 00 00 00
<0x000> [4] 06 00 00 00
<0x000> [4] 07 00 00 00
<0x000> [4] 08 00 00 00
<0x000> [4] 09 00 00 00
TMS320F28069 code:
EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO30 = 0; // Enable pull-up for GPIO30 (CANRXA)
GpioCtrlRegs.GPAPUD.bit.GPIO31 = 0; // Enable pull-up for GPIO31 (CANTXA)
GpioCtrlRegs.GPAQSEL2.bit.GPIO30 = 3; // Asynch qual for GPIO30 (CANRXA)
GpioCtrlRegs.GPAMUX2.bit.GPIO30 = 1; // Configure GPIO30 for CANRXA operation
GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 1; // Configure GPIO31 for CANTXA operation
EDIS;
ECanaMboxes.MBOX0.MSGCTRL.all = 0x00000000; // clear control;
ECanaRegs.CANME.all = 0;
ECanaMboxes.MBOX0.MSGID.all = 0x000000A1; // message ID
ECanaRegs.CANMD.all = 0x00000000; // Configure Mailboxes 0 for Tx, 1 for Rx
ECanaRegs.CANME.all = 0x00000001; // Enable Mailboxes
ECanaMboxes.MBOX0.MSGCTRL.all = 0x00000004; // 4 bit to be transmitted
ECanaMboxes.MBOX0.MDL.all = 0x12345678; // actual data
EALLOW;
ECanaRegs.CANMIM.all = 0x0000000; // interrupt enable 1, disable 0
ECanaRegs.CANMC.all = 0x00001400; // Configure CAN for configuration
ECanaRegs.CANMC.all = 0x00001400; // Configure CAN for configuration
ECanaRegs.CANMC.all = 0x00001400; // Configure CAN for configuration
ECanaRegs.CANBTC.all = 0x0004011A; // BRPreg 4, TSEG1reg 3, TSEGreg 2, sam 0, SJW 1
ECanaRegs.CANMC.all = 0x00000400; // CAN done for configuration
ECanaRegs.CANMC.all = 0x00000400; // CAN done for configuration
ECanaRegs.CANMC.all = 0x00000400; // CAN done for configuration
ECanaRegs.CANTIOC.all = 0x00000008; // Tx pin being used
ECanaRegs.CANRIOC.all = 0x00000008; // Tx pin being used
EDIS;
int i = 0;
for (i =0 ; i < 100; i ++ )
{
ECanaMboxes.MBOX0.MDL.all = i;
ECanaRegs.CANTRS.all = 0x00000001; // Set TRS for transmit mailboxes
while(ECanaRegs.CANTA.all != 0x0000001 ) {} // Wait for all TAn bits to be set..
ECanaRegs.CANTA.all = 0x00000001; // Clear all TAn
DELAY_US(100000);
}
