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.

eCAN issue

Other Parts Discussed in Thread: CODECOMPOSER

I have started a CAN communication project using board:
"TMS320F2812PGFA / CG-72AJF3W / G4" and DMC Developer Pro Software.

Now i have the board connected to my PC, also i have it powered and also
connected to a CAN bus with other CAN modules.

At my first steps i have loaded the demo can sample software to processor
RAM and all things worked great, that means that i have realized a can
communication within my CAN network (send and receive also).

Then, using Code Composer Studio and Flash Programmer Software
TMS320LF2812 i have written my test software into the processor FLASH
memory.

Now i noticed that the LED from the board is not ON anymore plus that i can
not connect to the board using monitor or other DMC software.

I'm not using a JTAG connector.

Can you send to me the default FLASH software?, or help with this issue?

Thank you.
  • i have found the default FLASH software(monitor) and downloaded to processor FLASH

    now is working, i can comunicate with the other can devices, with a sample software downloaded in RAM, and the LED on the board is ON again

    can anyone can tell me how do set  the LED ON/OFF?

    another question that i have, why same software loaded into RAM is workind and loaded into FLASH is not?

     

  • Liviu,

    Something in this FAQ may help you to determine why the flash code is not working:

    http://processors.wiki.ti.com/index.php/C2000_Flash_Common_Issues/FAQs#Code_Does_Not_Run_Standalone

    I am not familiar with the software you are using, but typically an LED will be connected to a GPIO pin.  To set/clear it you can change the state of the GPIO pin itself.   The GPIO is described in the System Control and Interrupts guide for your device.  There are also examples in the 281x C/C++ header files and peripheral examples that show how to toggle a GPIO.

    -Lori

     

  • Hello

    Thank you for your answer.

    I'm using SetReady(0); // Light on the led, function to debug my code.

    I have 2 questions:

    1.

    There is this part of code

    // Wait until the CPU no longer has permission to change the
    // configuration registers
    //!!!
    // 1 //
    //    do
    //    {
    //        DemoCAN.ret_val_mon = (*callmon2812)();          // call monitor
    //        ECanaShadow.CANES.all = ECanaRegs.CANES.all;
    //    } while(ECanaShadow.CANES.bit.CCE != 0 ); // Wait for CCE bit to be cleared..
    //!!!

    if i use the SetReady(0); function after this code, the led it never gets ON...why?????//

     

    2.

    In the while (1) loop i set the variabile DemoCAN.tx_msg_rq = 1; for continous transmission but it LED it never goes ON in this IF statement, so it never goes in:

            if(DemoCAN.tx_msg_rq != 0)                // test if there is a message to be sent
            {
    SetReady(0);       // Light on the led

    why???????????????

    I have to mention that same program is working loaded in RAM memory from DMC Developer Pro, but is not working in FLASH loaded from CodeComposer Studio V3.3 Platinum.

     

    Thanks.

     

    Here is my code:

     

    /****************************************************************************
     File name   : ExtCodeFlash.c, revision 1.0
     Project     : P043 MSK2812
     Originator  : D.Erhan
     Target Sys  : MSK2812 board
     Description : Exemple for automatically execution of the user code from flash
                   memory
     Status      : OK
     Last Update : 09 Jun 2003
    ****************************************************************************/
    #include "LF2812_Regs.h"
    #include "RegDef.h"
    #include "mon2812.h"
    #include "can.h"


    int UserVar;

    void main(void)
    {
        int ret_val_mon, stop;

    /////////CAN//////////

        struct ECAN_REGS ECanaShadow;

        DemoCAN.stop = 0;
    //===========================================================================
        DemoCAN.bit_tim_param = 0x000B007F;    // 500Kbs
        DemoCAN.op_mode = 0;//1
        DemoCAN.rx_format_id = 0x0000;
        DemoCAN.rx_std_id = 0x07FF;
        DemoCAN.rx_xtd_id = 0x1FFFFFFF;
        DemoCAN.tx_format_id = 0x0;
        DemoCAN.tx_std_id = 0x07FF;
        DemoCAN.tx_xtd_id = 0x1FFFFFFF;
        DemoCAN.std_accept_mask = 0x07FF;
        DemoCAN.xtd_accept_mask = 0x1FFFFFFF;
        DemoCAN.tx_data_len = 0x8;
        DemoCAN.tx_data_val[0] = 0x0000;   
        DemoCAN.tx_data_val[1] = 0x1111;
        DemoCAN.tx_data_val[2] = 0x2222;
        DemoCAN.tx_data_val[3] = 0x3333;
        DemoCAN.data_len = 0x0;
        DemoCAN.tx_msg_rq = 0x1;
        DemoCAN.rx_msg_rq = 0x0;

    // Enable CAN clock
        EALLOW;
           SysCtrlRegs.PCLKCR.bit.ECANENCLK=1;
        EDIS;

    // Configure CAN pins using GPIO regs here
        EALLOW;
        GpioMuxRegs.GPFMUX.bit.CANTXA_GPIOF6 = 1;
        GpioMuxRegs.GPFMUX.bit.CANRXA_GPIOF7 = 1;
        EDIS;

    // Configure the eCAN RX and TX pins for eCAN transmissions
        EALLOW;
        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;
        EDIS;

        EALLOW;
        ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;

    // select the operation mode      
        if (DemoCAN.op_mode == 0)                   
            ECanaShadow.CANMC.bit.STM = 0;    // set the CAN Network Mode (op_mode = 0)
        else
            ECanaShadow.CANMC.bit.STM = 1;    // set the Self Test Mode (op_mode = 1)   
        ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
       
         ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
        ECanaShadow.CANMC.bit.DBO = 1;        // configure data byte order as 0,1,2,..,7   
        ECanaShadow.CANMC.bit.ABO = 1;        // set Auto Bus On bit
        ECanaShadow.CANMC.bit.CCR = 1;        // CPU requests write access to Configuration Registers CANBTC
        ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;  
        EDIS;   

    // Wait until the CPU has been granted permission to change the configuration registers
        do
        {
            DemoCAN.ret_val_mon = (*callmon2812)();           // call monitor
            ECanaShadow.CANES.all = ECanaRegs.CANES.all;
        } while(ECanaShadow.CANES.bit.CCE != 1 );  // Wait for CCE bit to be set..

    // Configure the eCAN timing paramenters and baud rate prescaler
        EALLOW;
        ECanaShadow.CANBTC.all = DemoCAN.bit_tim_param;
        ECanaRegs.CANBTC.all = ECanaShadow.CANBTC.all;

    // CPU requests normal operation   
        ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
        ECanaShadow.CANMC.bit.CCR = 0 ;           // Set CCR = 0 to disable the write access to Configuration Registers
        ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
        EDIS;

    // Wait until the CPU no longer has permission to change the
    // configuration registers
    //!!!
    // 1 //
    //    do
    //    {
    //        DemoCAN.ret_val_mon = (*callmon2812)();          // call monitor
    //        ECanaShadow.CANES.all = ECanaRegs.CANES.all;
    //    } while(ECanaShadow.CANES.bit.CCE != 0 ); // Wait for CCE bit to be cleared..
    //!!!


    // clear transmission acknowledge bit for mailbox 5
        ECanaRegs.CANTA.bit.TA5 = 1;
       
    // clear receive message pending bit   
        ECanaRegs.CANRMP.bit.RMP0 = 0;
       
        ConfigRxMailBox();

    //////////////CAN/////////////

        // Disable watchdog module
        SysCtrlRegs.WDCR= 0x0068;
        // reset wd counter
        SysCtrlRegs.WDKEY= 0x0055;
        SysCtrlRegs.WDKEY= 0x00AA;

        DINT;    // Disable and clear all CPU interrupts:
        IER = 0x0000;
        IFR = 0x0000;   

        /*the initialization routines must be called for establishing the communication with the
        board when the user's extended code is located into the flash*/       
        (*CallInitializeInterrupts)();
        (*CallInitializeSystem)();
        (*CallInitializeData)();
        (*CallInitializeCOM)(B9600);

        EINT;   // Enable Global interrupt INTM
        ERTM;    // Enable Global realtime interrupt DBGM

        stop = 0;
        ret_val_mon = 1;  /* must be initialized */   
        UserVar = 0;
       
        /*main loop*/
    //    while (!stop)
        while (1)
        {
           
    ////////CAN/////////////
    ///!!!///
    /// 2 ///
            DemoCAN.ret_val_mon = (*callmon2812)();    // call monitor
            if(DemoCAN.tx_msg_rq != 0)                // test if there is a message to be sent
            {
    SetReady(0);       // Light on the led   
                DemoCAN.tx_msg_rq = 0;                // reset transmission flag
                ECanaRegs.CANTA.bit.TA5 = 1; // clear transmission acknowledge bit

                ConfigTxMailBox();            // configure MailBox 5
                SendMessage();                // send message from mailbox 5 if Send Message button is activated           
            }
            else
            {
                if(ECanaRegs.CANRMP.bit.RMP0 == 1) //  test if mailbox 0 has received a message
                {
                    DemoCAN.rx_msg_rq = 1;        // if message received, set reception flag
                    ReadMessage();
                    ECanaRegs.CANRMP.bit.RMP0 = 1; //  clear receive message pending bit
                }
                ///!!!///
                DemoCAN.tx_msg_rq = 1;
            }
    ////////CAN/////////////
           
            UserVar++;
            ret_val_mon = (*callmon2812)();       
        }


        DINT;
        EALLOW;
        SysCtrlRegs.SCSR.bit.WDOVERRIDE =1; // Set WDOVERRIDE bit to allow the Watchdog enable
        SysCtrlRegs.WDCR = 0x000F;            // Enable Watchdog and write incorrect WD Check Bits
    }

    /**************************************************************************/
    // Light on the led
    /**************************************************************************/
    void SetReady(int iOnOff)
    {
        EALLOW;
        GpioMuxRegs.GPFMUX.bit.XF_GPIOF14 = 0;    // configure shared pin XF/GPIOF14 as digital I/O
        GpioMuxRegs.GPFDIR.bit.GPIOF14 = 1;        // Configure GPIOF14 pin as output
        EDIS;
        GpioDataRegs.GPFDAT.bit.GPIOF14 = iOnOff;    // Turn on the light LED
    }

    //*******************************************************************************
    void SendMessage(void)
    {
        ECanaRegs.CANTRS.bit.TRS5 = 1;        // enable transmission of the mailbox 5   
    }

    //*******************************************************************************
    void ReadMessage(void)
    {
        if(DemoCAN.rx_format_id == 0) // test reception mailbox format: 0=standard format, 1=extended format
            // read standard identifier
            DemoCAN.rx_std_id = ((int)ECanaMboxes.MBOX0.MID.bit.MSGID_H) >> 2;
        else
            // read extended identifier
            DemoCAN.rx_xtd_id = ECanaMboxes.MBOX0.MID.all & 0x1FFFFFFF;

        // load data length
        DemoCAN.rx_data_len = ECanaMboxes.MBOX0.MCF.bit.DLC;
        //
        DemoCAN.tx_data_len = ECanaMboxes.MBOX0.MCF.bit.DLC;
       
        if(DemoCAN.rx_data_len != 0)    //  test if data was transmitted
        {
            // convert bytes in words
            DemoCAN.data_len = ( (DemoCAN.rx_data_len + 1) >> 1 ) - 1;

            // read received data
            switch (DemoCAN.data_len)
            {
                case 3:
                    DemoCAN.rx_data_val[3] = ECanaMboxes.MBOX0.MDRH.bit.HI_WORD;
                case 2:
                    DemoCAN.rx_data_val[2] = ECanaMboxes.MBOX0.MDRH.bit.LOW_WORD;
                case 1:
                    DemoCAN.rx_data_val[1] = ECanaMboxes.MBOX0.MDRL.bit.HI_WORD;
                case 0:
                    DemoCAN.rx_data_val[0] = ECanaMboxes.MBOX0.MDRL.bit.LOW_WORD;
                default: ;
            }
        }
    }

    //*******************************************************************************
    void ConfigRxMailBox(void)
    {
    // configure reception mailbox0
        ECanaRegs.CANME.bit.ME0 = 0; // disable mailbox 0
       
        if(DemoCAN.rx_format_id == 0)
        // reception mailbox format: 0=standard format
        {
            // set local acceptance mask   
            ECanaLam.LAM0.bit.LAM_H = DemoCAN.std_accept_mask;
            // set standard identifier
            ECanaMboxes.MBOX0.MID.bit.MSGID_H = DemoCAN.rx_std_id << 2;
            ECanaMboxes.MBOX0.MID.bit.IDE = 0;    // configure to Standard Identifier
        }
        else
        // reception mailbox format: 1=extended format
        {
            // set local acceptance mask   
            ECanaLam.LAM0.bit.LAM_L = (int) (DemoCAN.xtd_accept_mask & 0xFFFF);
            ECanaLam.LAM0.bit.LAM_H = (int) (DemoCAN.xtd_accept_mask >> 16);
            // set extended identifier
            ECanaMboxes.MBOX0.MID.bit.MSGID_L = (int)(DemoCAN.rx_xtd_id & 0xFFFF);
            ECanaMboxes.MBOX0.MID.bit.MSGID_H = (int)(DemoCAN.rx_xtd_id >> 16);
            ECanaMboxes.MBOX0.MID.bit.IDE = 1;    // configure to Extended Identifier
        }

        ECanaMboxes.MBOX0.MID.bit.AME = 1;    // enable the usage of the acceptance mask

        ECanaRegs.CANMD.bit.MD0 = 1;       // Config as receive mailbox
        ECanaRegs.CANME.bit.ME0 = 1;    // enable mailbox 0
    }

    //*******************************************************************************
    void ConfigTxMailBox(void)
    {
    // configure transmission mailbox5
        ECanaRegs.CANME.bit.ME5 = 0; // disable mailbox 5
        if(DemoCAN.tx_format_id == 0)
        // transmission mailbox format: 0=standard format
        {
            // set standard identifier
            ECanaMboxes.MBOX5.MID.bit.MSGID_H = DemoCAN.tx_std_id << 2;
            ECanaMboxes.MBOX5.MID.bit.IDE = 0;    // configure to Standard Identifier
        }
        else
        // transmission mailbox format: 1=extended format
        {
            // set extended identifier
            ECanaMboxes.MBOX5.MID.bit.MSGID_L = (int)DemoCAN.tx_xtd_id;
            ECanaMboxes.MBOX5.MID.bit.MSGID_H = (int)(DemoCAN.tx_xtd_id >> 16);
            ECanaMboxes.MBOX5.MID.bit.IDE = 1;    // configure to Extended Identifier
        }

        ECanaRegs.CANME.bit.ME5 = 1;        // enable mailbox 5

        ECanaMboxes.MBOX5.MCF.bit.RTR = 0; // no remote frame requested

        if(DemoCAN.tx_data_len != 0)    // test if data  be transmitted
        {
            ECanaMboxes.MBOX5.MCF.bit.DLC = DemoCAN.tx_data_len;

            // convert bytes in words
            DemoCAN.data_len = ( (DemoCAN.tx_data_len + 1) >> 1 ) - 1;

            // put data for transmission
            switch (DemoCAN.data_len)
            {
                case 3:
                    ECanaMboxes.MBOX5.MDRH.bit.HI_WORD = DemoCAN.tx_data_val[3];
                case 2:
                    ECanaMboxes.MBOX5.MDRH.bit.LOW_WORD = DemoCAN.tx_data_val[2];
                case 1:
                    ECanaMboxes.MBOX5.MDRL.bit.HI_WORD = DemoCAN.tx_data_val[1];
                case 0:
                    ECanaMboxes.MBOX5.MDRL.bit.LOW_WORD = DemoCAN.tx_data_val[0];
                default: ;
            }
        }
    }
    /****************************************************************************
    ****************************************************************************/