This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS320F28069M: how to save data in RAM and recall it for any process

Part Number: TMS320F28069M
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

I am sending data from one Launch pad to another using CAN bus. I want to save data avilable and receiving mailbox to the RAM and then CALL that data for further process and Resend it. How to do this??

I have flash memory and RAM also but I dont know that which is my running memory

Please suggest.

Thanks

  • Hi Ashwinee,

    ASHWINEE JADHAO said:
    I have flash memory and RAM also but I dont know that which is my running memory

    Project's linker file would shed some light on this.

    ASHWINEE JADHAO said:
    want to save data avilable and receiving mailbox to the RAM and then CALL that data for further process and Resend it. How to do this??

    Simply storing the Mailbox value to a variable and then processing the same is what you should look for.

    Refer this project: C:\ti\c2000\C2000Ware_1_00_05_00\device_support\f2806x\examples\c28\ecan_back2back

    TestMbox'x' variable is where the CAN Mailbox data is fetched to.

    Regards,

    Gautam

  • this is code i am doing


    //###########################################################################
    //
    // FILE: Example_2806xECanBack2Back.c
    //
    // TITLE: eCAN back to back Example
    //
    //! \addtogroup f2806x_example_list
    //! <h1>eCAN back to back (ecan_back2back)</h1>
    //!
    //! This example tests eCAN by transmitting data back-to-back at high speed
    //! without stopping. The received data is verified. Any error is flagged.
    //! MBX0 transmits to MBX16, MBX1 transmits to MBX17 and so on....
    //!
    //! This example uses the self-test mode of the CAN module. i.e. the
    //! transmission/reception happens within the module itself (even the required
    //! ACKnowldege is generated internally in the module). Therefore, there is no
    //! need for a CAN transceiver to run this particular test case and no activity
    //! will be seen in the CAN pins/bus. Because everything is internal, there is
    //! no need for a 120-ohm termination resistor. Note that a real-world CAN
    //! application needs a CAN transceiver and termination resistors on both ends
    //! of the bus.
    //!
    //! \b Watch \b Variables \n
    //! - PassCount
    //! - ErrorCount
    //! - MessageReceivedCount
    //
    //
    //###########################################################################
    // $TI Release: F2806x Support Library v2.04.00.00 $
    // $Release Date: Tue Jun 26 03:13:59 CDT 2018 $
    // $Copyright:
    // Copyright (C) 2009-2018 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without
    // modification, are permitted provided that the following conditions
    // are met:
    //
    // Redistributions of source code must retain the above copyright
    // notice, this list of conditions and the following disclaimer.
    //
    // Redistributions in binary form must reproduce the above copyright
    // notice, this list of conditions and the following disclaimer in the
    // documentation and/or other materials provided with the
    // distribution.
    //
    // Neither the name of Texas Instruments Incorporated nor the names of
    // its contributors may be used to endorse or promote products derived
    // from this software without specific prior written permission.
    //
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    // $
    //###########################################################################

    //
    // Included Files
    //
    #include "DSP28x_Project.h" // Device Headerfile and Examples Include File

    //
    // Function Prototypes
    //
    void mailbox_check(int32 T1, int32 T2, int32 T3);
    void mailbox_read(int16 i);

    //
    // Globals
    //
    Uint32 ErrorCount;
    Uint32 PassCount;
    Uint32 MessageReceivedCount;

    Uint32 TestMbox1 = 0;
    Uint32 TestMbox2 = 0;
    Uint32 TestMbox3 = 0;




    Uint32 MSGID_read = 0;//newly added //this variable declared to read from memory

    //
    // Main
    //
    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 F2806x_SysCtrl.c file.
    //
    InitSysCtrl();

    //
    // Step 2. Initalize GPIO:
    // This example function is found in the F2806x_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 F2806x_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 F2806x_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 F2806x_DefaultIsr.c.
    // This function is found in F2806x_PieVect.c.
    //
    InitPieVectTable();

    //
    // Step 4. Initialize all the Device Peripherals:
    // This function is found in F2806x_InitPeripherals.c
    //
    // InitPeripherals(); // Not required for this example

    //
    // Step 5. User specific code, enable interrupts:
    //
    MessageReceivedCount = 0;
    ErrorCount = 0;
    PassCount = 0;

    InitECana(); // Initialize eCAN-A module

    //
    // Mailboxs 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 = 0x9555AAA0; //MSGID=STORES THE MESSAGE ID

    //
    // Write to the MSGID field of RECEIVE mailboxes MBOX16 - 31
    //

    ECanaMboxes.MBOX18.MSGID.all = 0x9555AAA1; //MSGID=STORES THE MESSAGE ID

    //
    // 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; // MESSAGE BOX ENABLE

    //
    // Specify that 8 bits will be sent/received
    //
    //ECanaMboxes.MBOX0.MSGCTRL.bit.DLC = 8; //MSGCTRL= DEFINES NUMBER OF BYTES, TRANSMISSION PRIORITY
    // ECanaMboxes.MBOX1.MSGCTRL.bit.DLC = 8; // AND REMOTE FRAME

    //
    // Write to the mailbox RAM field of MBOX0 - 15
    //
    // ECanaMboxes.MBOX0.MDL.all = 0x01; //
    // ECanaMboxes.MBOX0.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; //MAILBOX INTERRUPT MASK ENABLE=1

    //
    // Configure the eCAN for self test mode
    // Enable the enhanced features of the eCAN.
    //
    ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
    ECanaShadow.CANMC.bit.STM = 0; // Configure CAN for self-test mode=1, 0=TX/RX
    ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;


    // ECanaShadow.MBOX16.MSGID.all = ECanaMboxes.MBOX16.MSGID.all;
    // ECanaShadow.MBOX16.MSGID.bit.AME = 1; // AUTO ANSWER MODE
    // ECanaMboxes.MBOX16.MSGID.all = ECanaShadow.MBOX16.MSGID.all;


    ECanaShadow.CANTIOC.all = ECanaRegs.CANTIOC.all;
    ECanaShadow.CANTIOC.bit.TXFUNC= 1; // Configure CAN for self-test mode=1, 0=TX/RX
    ECanaRegs.CANTIOC.all = ECanaShadow.CANTIOC.all;


    ECanaShadow.CANRIOC.all = ECanaRegs.CANRIOC.all;
    ECanaShadow.CANRIOC.bit.RXFUNC= 1; //
    ECanaRegs.CANRIOC.all = ECanaShadow.CANRIOC.all;

    ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
    ECanaShadow.CANMC.bit.CCR= 0; //
    ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;

    ECanaShadow.CANES.all = ECanaRegs.CANES.all;
    ECanaShadow.CANES.bit.CCE= 1; //
    ECanaRegs.CANES.all = ECanaShadow.CANES.all;



    ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
    ECanaShadow.CANMC.bit.CCR= 0;
    ECanaShadow.CANMC.bit.PDR= 0;
    ECanaShadow.CANMC.bit.DBO= 0;
    ECanaShadow.CANMC.bit.WUBA= 0;
    ECanaShadow.CANMC.bit.CDR= 0;
    ECanaShadow.CANMC.bit.ABO= 0;
    ECanaShadow.CANMC.bit.STM= 0;
    ECanaShadow.CANMC.bit.SRES= 0;
    ECanaShadow.CANMC.bit.MBNR= 0;
    ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;



    EDIS;

    //
    // Begin transmitting
    //
    for(;;)
    {
    //
    // Set TRS for all transmit mailboxes
    //
    ECanaRegs.CANTRS.all = 0x0000FFFF;

    //
    // Wait for all TAn bits to be set
    //
    while(ECanaRegs.CANTA.all != 0x0000FFFF )
    {

    }

    ECanaRegs.CANTA.all = 0x0000FFFF; // Clear all TAn
    MessageReceivedCount++;

    //
    // Read from Receive mailboxes and begin checking for data
    // Read & check 16 mailboxes
    //
    for(j=16; j<32; j++)
    {
    //
    // This func reads the indicated mailbox data
    //
    mailbox_read(j);

    //
    // Checks the received data
    //
    mailbox_check(TestMbox1,TestMbox2,TestMbox3);

    MSGID_read = ECanaMboxes.MBOX18.MSGID.all; ////here I am going to copy
    }
    }
    }

    //
    // mailbox_read - This function reads out the contents of the indicated
    // by the Mailbox number (MBXnbr). MSGID of a rcv MBX is transmitted as the
    // MDL data.
    //
    void
    mailbox_read(int16 MBXnbr)
    {
    volatile struct MBOX *Mailbox;
    Mailbox = &ECanaMboxes.MBOX0 + MBXnbr;
    TestMbox1 = Mailbox->MDL.all; // = 0x9555AAAn (n is the MBX number)
    TestMbox2 = Mailbox->MDH.all; // = 0x89ABCDEF (a constant)
    TestMbox3 = Mailbox->MSGID.all; // = 0x9555AAAn (n is the MBX number)
    }

    //
    // mailbox_check -
    //
    void
    mailbox_check(int32 T1, int32 T2, int32 T3)
    {
    if((T1 != T3) || ( T2 != 0x89ABCDEF))
    {
    ErrorCount++;
    }
    else
    {
    PassCount++;
    }
    }

    //
    // End of File
    //












    please check this code and give me suggestion.
  • What's the problem with the above code?
  • Hi,

    Were you able to resolve this?

    Regards
    Harshmeet
  • not resolve yet.

    actual it gives warning as data type miss match
  • Ashwini,

                It is conceivable you are new to C2000 microcontrollers. If so, you could benefit from some excellent training material available on our website. Your questions like "I have flash memory and RAM also but I don't know which is my running memory" are best answered by going through our the F28069 multi-day workshop:

     

    http://processors.wiki.ti.com/index.php/C2000_Archived_Workshops#C2000_Piccolo_Multi-Day_Workshop_-_Revision_5.0_May_2014_.28ExpKit_F28069.3B_CCSv6.0.29

     

    TI has invested considerable resources in this training material to help customers like you come up to speed. e2e is a good place when you have specific questions about a feature in our device, but posting your code for others to debug is not desirable.

  • thank you sir.

    i will keep in my mind .

    thanks again