Part Number: TMS320F28035
// //########################################################################### // $TI Release: F2803x C/C++ Header Files and Peripheral Examples V130 $ // $Release Date: May 8, 2015 $ // $Copyright: Copyright (C) 2009-2015 Texas Instruments Incorporated - // http://www.ti.com/ ALL RIGHTS RESERVED $ //########################################################################### #include "DSP28x_Project.h" // Device Headerfile and Examples Include File // Prototype statements for functions found within this file. void mailbox_check(int32 T1, int32 T2, int32 T3); void mailbox_read(int16 i); // Global variable for this example Uint32 ErrorCount; Uint32 PassCount; Uint32 MessageReceivedCount; Uint32 TestMbox1 = 0; Uint32 TestMbox2 = 0; Uint32 TestMbox3 = 0; int MIV = 0; struct ECAN_REGS ECanaShadow; interrupt void eCAN0INT_ISR(void); interrupt void eCAN1INT_ISR(void); void main(void) { Uint16 j; // eCAN control registers require read/write access using 32-bits. Thus we // will create a set of shadow registers for this example. These shadow // registers will be used to make sure the access is 32-bits and not 16. //struct ECAN_REGS ECanaShadow; // Step 1. Initialize System Control: // PLL, WatchDog, enable Peripheral Clocks // This example function is found in the DSP2803x_SysCtrl.c file. InitSysCtrl(); // Step 2. Initialize GPIO: // This example function is found in the DSP2803x_Gpio.c file and // illustrates how to set the GPIO to it's default state. // InitGpio(); // Skipped for this example // For this example, configure CAN pins using GPIO regs here // This function is found in DSP2803x_ECan.c InitECanGpio(); // Step 3. Clear all interrupts and initialize PIE vector table: // Disable CPU interrupts DINT; // Initialize PIE control registers to their default state. // The default state is all PIE interrupts disabled and flags // are cleared. // This function is found in the DSP2803x_PieCtrl.c file. InitPieCtrl(); // Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000; IFR = 0x0000; // Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR). // This will populate the entire table, even if the interrupt // is not used in this example. This is useful for debug purposes. // The shell ISR routines are found in DSP2803x_DefaultIsr.c. // This function is found in DSP2803x_PieVect.c. InitPieVectTable(); // Step 4. Initialize all the Device Peripherals: // Not required for this example // Step 5. User specific code, enable interrupts: MessageReceivedCount = 0; ErrorCount = 0; PassCount = 0; InitECana(); // Initialize eCAN-A module MBXwrA(); // Mailboxes can be written to 16-bits or 32-bits at a time // Write to the MSGID field of TRANSMIT mailboxes MBOX0 - 15 ECanaMboxes.MBOX0.MSGID.all = 1;// ECanaMboxes.MBOX1.MSGID.all = 2; ECanaMboxes.MBOX2.MSGID.all = 0x9555AAA2; ECanaMboxes.MBOX3.MSGID.all = 0x9555AAA3; ECanaMboxes.MBOX4.MSGID.all = 0x9555AAA4; ECanaMboxes.MBOX5.MSGID.all = 0x9555AAA5; ECanaMboxes.MBOX6.MSGID.all = 0x9555AAA6; ECanaMboxes.MBOX7.MSGID.all = 0x9555AAA7; ECanaMboxes.MBOX8.MSGID.all = 0x9555AAA8; ECanaMboxes.MBOX9.MSGID.all = 0x9555AAA9; ECanaMboxes.MBOX10.MSGID.all = 0x9555AAAA; ECanaMboxes.MBOX11.MSGID.all = 0x9555AAAB; ECanaMboxes.MBOX12.MSGID.all = 0x9555AAAC; ECanaMboxes.MBOX13.MSGID.all = 0x9555AAAD; ECanaMboxes.MBOX14.MSGID.all = 0x9555AAAE; ECanaMboxes.MBOX15.MSGID.all = 0x9555AAAF; // Write to the MSGID field of RECEIVE mailboxes MBOX16 - 31 ECanaMboxes.MBOX16.MSGID.all = 0x9555AAA0; ECanaMboxes.MBOX17.MSGID.all = 0x9555AAA1; ECanaMboxes.MBOX18.MSGID.all = 0x9555AAA2; ECanaMboxes.MBOX19.MSGID.all = 0x9555AAA3; ECanaMboxes.MBOX20.MSGID.all = 0x9555AAA4; ECanaMboxes.MBOX21.MSGID.all = 0x9555AAA5; ECanaMboxes.MBOX22.MSGID.all = 0x9555AAA6; ECanaMboxes.MBOX23.MSGID.all = 0x9555AAA7; ECanaMboxes.MBOX24.MSGID.all = 0x9555AAA8; ECanaMboxes.MBOX25.MSGID.all = 0x9555AAA9; ECanaMboxes.MBOX26.MSGID.all = 0x9555AAAA; ECanaMboxes.MBOX27.MSGID.all = 0x9555AAAB; ECanaMboxes.MBOX28.MSGID.all = 0x9555AAAC; ECanaMboxes.MBOX29.MSGID.all = 0x9555AAAD; ECanaMboxes.MBOX30.MSGID.all = 0x9555AAAE; ECanaMboxes.MBOX31.MSGID.all = 0x9555AAAF; // Configure Mailboxes 0-15 as Tx, 16-31 as Rx // Since this write is to the entire register (instead of a bit // field) a shadow register is not required. ECanaRegs.CANMD.all = 0xFFFF0000; // Enable all Mailboxes */ // Since this write is to the entire register (instead of a bit // field) a shadow register is not required. ECanaRegs.CANME.all = 0xFFFFFFFF; // Specify that 8 bytes will be sent/received ECanaMboxes.MBOX0.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX1.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX2.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX3.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX4.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX5.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX6.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX7.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX8.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX9.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX10.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX11.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX12.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX13.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX14.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX15.MSGCTRL.bit.DLC = 8; // Write to the mailbox RAM field of MBOX0 - 15 ECanaMboxes.MBOX0.MDL.all = 0x9555AAA0; ECanaMboxes.MBOX0.MDH.all = 0x89ABCDEF; ECanaMboxes.MBOX1.MDL.all = 0x9555AAA1; ECanaMboxes.MBOX1.MDH.all = 0x89ABCDEF; ECanaMboxes.MBOX2.MDL.all = 0x9555AAA2; ECanaMboxes.MBOX2.MDH.all = 0x89ABCDEF; ECanaMboxes.MBOX3.MDL.all = 0x9555AAA3; ECanaMboxes.MBOX3.MDH.all = 0x89ABCDEF; ECanaMboxes.MBOX4.MDL.all = 0x9555AAA4; ECanaMboxes.MBOX4.MDH.all = 0x89ABCDEF; ECanaMboxes.MBOX5.MDL.all = 0x9555AAA5; ECanaMboxes.MBOX5.MDH.all = 0x89ABCDEF; ECanaMboxes.MBOX6.MDL.all = 0x9555AAA6; ECanaMboxes.MBOX6.MDH.all = 0x89ABCDEF; ECanaMboxes.MBOX7.MDL.all = 0x9555AAA7; ECanaMboxes.MBOX7.MDH.all = 0x89ABCDEF; ECanaMboxes.MBOX8.MDL.all = 0x9555AAA8; ECanaMboxes.MBOX8.MDH.all = 0x89ABCDEF; ECanaMboxes.MBOX9.MDL.all = 0x9555AAA9; ECanaMboxes.MBOX9.MDH.all = 0x89ABCDEF; ECanaMboxes.MBOX10.MDL.all = 0x9555AAAA; ECanaMboxes.MBOX10.MDH.all = 0x89ABCDEF; ECanaMboxes.MBOX11.MDL.all = 0x9555AAAB; ECanaMboxes.MBOX11.MDH.all = 0x89ABCDEF; ECanaMboxes.MBOX12.MDL.all = 0x9555AAAC; ECanaMboxes.MBOX12.MDH.all = 0x89ABCDEF; ECanaMboxes.MBOX13.MDL.all = 0x9555AAAD; ECanaMboxes.MBOX13.MDH.all = 0x89ABCDEF; ECanaMboxes.MBOX14.MDL.all = 0x9555AAAE; ECanaMboxes.MBOX14.MDH.all = 0x89ABCDEF; ECanaMboxes.MBOX15.MDL.all = 0x9555AAAF; ECanaMboxes.MBOX15.MDH.all = 0x89ABCDEF; // Since this write is to the entire register (instead of a bit // field) a shadow register is not required. EALLOW; ECanaRegs.CANMIM.all = 0xFFFFFFFF; // Configure the eCAN for self test mode // Enable the enhanced features of the eCAN. EALLOW; ECanaShadow.CANMC.all = ECanaRegs.CANMC.all; ECanaShadow.CANMC.bit.STM = 1; // Configure CAN for self-test mode ECanaRegs.CANMC.all = ECanaShadow.CANMC.all; EDIS; /* Configure CAN interrupts */ ECanaShadow.CANMIL.all = 0xFFFFFFFF ; // Interrupts asserted on eCAN1INT // Select interrupt on the following mailbox //ECanaShadow.CANMIL.all = 0x00000000 ; // Interrupts asserted on eCAN0INT ECanaRegs.CANMIL.all = ECanaShadow.CANMIL.all; ECanaShadow.CANMIM.all = 0xFFFFFFFF; // Enable interrupts for all mailboxes ECanaRegs.CANMIM.all = ECanaShadow.CANMIM.all; ECanaShadow.CANGIM.all = 0; // ECanaShadow.CANGIM.bit.I0EN = 1; // Enable eCAN1INT or eCAN0INT ECanaShadow.CANGIM.bit.I1EN = 1; ECanaRegs.CANGIM.all = ECanaShadow.CANGIM.all; /* Reassign ISRs. i.e. reassign the PIE vector for ECAN0INTA_ISR and ECAN0INTA_ISR to point to a different ISR than the shell routine found in DSP28_DefaultIsr.c. This is done if the user does not want to use the shell ISR routine but instead wants to embed the ISR in this file itself. */ PieVectTable.ECAN0INTA = &eCAN0INT_ISR; PieVectTable.ECAN1INTA = &eCAN1INT_ISR; /* Configure PIE interrupts */ PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable vector fetching from PIE block PieCtrlRegs.PIEACK.bit.ACK9 = 1; // Enables PIE to drive a pulse into the CPU // The interrupt can be asserted in either of the eCAN interrupt lines // Comment out the unwanted line... PieCtrlRegs.PIEIER9.bit.INTx5 = 0; // Enable INTx.5 of INT9 (eCAN0INT) // interrupt disabled PieCtrlRegs.PIEIER9.bit.INTx6 = 1; // Enable INTx.6 of INT9 (eCAN1INT) // interrupt enabled /* Configure system interrupts */ IER |= 0x0100; // Enable INT9 of CPU EINT; // Begin transmitting for(;;) { ECanaRegs.CANTRS.all = 0x0000FFFF;//0x0000FFFF; // Set TRS for all transmit mailboxes while(ECanaRegs.CANTA.all !=0x0000FFFF){}; //0x0000FFFF ) {} // Wait for all TAn bits to be set.. ECanaRegs.CANTA.all = 0x0000FFFF;//0x0000FFFF; // Clear all TAn MessageReceivedCount++; DELAY_US(1000*100); // Read Mail box number 2 via polling //mailbox_read(2); //Read from Receive mailboxes and begin checking for data */ /*for(j=16; j<32; j++) // Read & check 16 mailboxes { mailbox_read(j); // This func reads the indicated mailbox data mailbox_check(TestMbox1,TestMbox2,TestMbox3); // Checks the received data }*/ } }
I want to TX Mailbox #0 and Mailbox#1 to 28379 D where I have configured to receive the same on mailbox 1 and 2.
I want to make sure if I am sending it correctly from 28035? Since I am not able to receive on 28379. (I was successful in communicating between 2 28379 launchpad)
Thanks