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/TMS320F28379D: Urgent: CLB not work when running from flash

Part Number: TMS320F28379D
Other Parts Discussed in Thread: CONTROLSUITE

Tool/software: Code Composer Studio

Hi Ti experts,

i encounter an issue when using tms320F28379D.

i need CLB function to access t-format library and it works fine when starting from RAM.

Unfortunately, when i change it to start from FLASH, it can not read t-format library normally.  then i debug the issue and find that it will halt up at the line while(tformatData.dataReady == 0);

but other functions are okay, just like CAN communication, GPIO, etc.

so, can you please advise how to troubleshoot the issue? is there any special setting for CLB when starting from FLASH? 

Looking forward to your reply.

Feng

  • I am not aware of CLB needing any specific flash settings. are you aware of anything that would cause this issue?

  • Do u have any ideal to debug it?

  • Hi,

    There is really no dependency on CLB w.r.t. flash. One of the aspects is that the code could be running at a slower rate when mapped to flash.
    For the purpose of debug, have you made sure the code, when running from RAM is working as expected?

  • Yes, we can read the encoder from t format lib and can run motor normally using the encoder reading.

    Is the clb cmd file same between running from Ram and from flash?

    Now I am using the same clb for ram and flash.

    Feng

  • And beside the cmd file, can you advise what steps should to do when changing to run from flash, especially for clb program??

  • Also I just want to make what hardware you are using. LaunchPad or Control Card or custom board?

  • We have demo board on hand, but we are working on my custom board now.

  • BTW, when changing code to run from flash,  the clb doesn't work normally but it works when using JETAG.

  • OK. Then it looks like some issue of booting from flash while running stand alone - not specific to the code.
    The example program is developed in RAM configuration.
    There are lot of tips on running code from flash. You can refer to thread below.

    https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/140316 

    You can also refer to:

  • Thanks for your reply.

    I understand that there are many steps need follow. And actually it works for gpio, epwm, can, etc when running stand alone from flash. But only    clb not work.

    Any ideal?

  • Is the clb cmd file same for ram and flash?

  • Hi, CLB configuration is like any other peripheral configuration.
    Since you are saying that it's working with flash as well with JTAG connected,
    i suspect there is some issue in your boot configuration or some variables remaining in RAM making it work/not-work.

  • Back to the question : is the clb cmd file same for ram and flash? I can only find one clb cmd file under the ti folder.. \\position manager

  • Hi,

    by clb command file do you mean F2837xD_Headers_clb_cpu1.cmd?
    If so, this is not dependent on RAM or Flash. This is a register offset definition.
    So it should work with flash or RAM. But make sure this file is included if you created a separate configuration for flash.

  • Yes, that command file is what I mention.

    How to check the clb cmd file is included for flash?

  • Hi,

    Simply add file to the Flash configuration - if you've not already done so.
    Also, if you've not included this file you would have got warnings when you compile the project for the corresponding offsets defined in the file.

  • If so, I think I have included the clb file already.

  • Feng,

    Any update on this? Did you solve the issue?

    Nima

  • No, do you have ideal I can try? Thanks.

  • i have attached code and can testing result to show my problem clearlly.

    conclusion: when booting from JTAGE, encoder result is Okay. however, when booting from flash, encoder data are all zeros. and the value "flag" is always 1, which means tformatData.dataReady is always equal to 0.

    is there anyone can help me? 

    figure 1: code to read encoder by calling t-format library

    figure 2: code to send encoder value by CAN

    figure 3: normal CAN result when run from JTAGE

    figure4:  abnormal CAN result when booting from flash

  • Dear ti experts,

    Can anyone help me???

    Or do you repeat my issue in your platform? I am using Tms320f28379d and use t format library example code under position manager lib. And I revise it to boot from flash and the issue should be repeated.

    Now I am waiting for your help.

    Looking forward to your reply

  • I search the E2e forum and no others have the similar issue with mine.

    So, can you please help me? Looking forward to your reply. Thanks a lot.

  • Hi,

    No problem - will check the flash configuration and get back to you.
    But, you had mentioned earlier that the Flash configuration also works when connected to the JTAG. Is this correct?

  • Yes, it works when using JETAG.

    And CAN also works when booting standalone without JETAG. Please refer to my previous can logging data.

    Shall I share my testing project to you?

  • My testing project only includes t format lib call and can communication.

    May I send it to you?

  • Yes please share your project.

    Nima Eskandari

  • Hi,

    To start with, could you just check the example project provided for tformat in flash configuration? I can also check the same at my end. Then we can debug your project.

  • I will share tomorrow.

  • Okay.

    And I will share my testing project to you tomorrow.

  • Hi,

    That's correct - the example provided is for RAM configuration. I'm suggesting that start with that example and create flash configuration - before we move to debugging your project. If you can first get the example project working in flash then you can debug other project as well. I will also try to port the example in flash and let you know.

  • Yes, I have the same ideal as yours and use the ti example project to debug the issue.

    Actually, What I will share to you tomorrow is based on the example project with ram booting from ti and I create flash configuration but the result is also failed. In other word, I can not get example project working in flash for t format.

    You can repeat it in your side to create flash configuration for t format and see whether the flash booting works or not. Please let me know.

  • Hi,

    I've tested the example in flash configuration. Didn't see any issues.
    Steps:
    1. Create a new FLASH configuration - copying from RAM configuration.
    2. Exclude RAM linker file and include flash linker file (2837xD_FLASH_lnk_cpu1.cmd)
    3. Define _FLASH in Build Properties-> Compiler -> Advanced options-> Predefined symbols

    Compile and run the code. It works with or without loading from JTAG.

  • How do u know it works without JETAG?

    I mean how do you decide it works or not when booting from flash? Did you send the encoder reading out by can or 232 or 485?

  • Hi,

    I mean without loading from JTAG - once the device is flashed - "It works with or without loading from JTAG."
    So, after the code is flashed, power cycle and run from flash - you can have JTAG connected to monitor results.
    You can also have some other interface, like UART or so, to transmit the results. 

  • my issue is encoder reading is not correct when booting from flash, which is alway my issue described in previous reply.

    I use  CAN to send the encoder reading out and then found the issue. If you don't send the encoder out, the issue cannot be found easily. Can you check like this in your side? This is very important and it shows my issue.

  • Without JETAG, my project can also start once it is    flashed. And led works, CAN works. But, the encoder reading from t format doesn't work. Can you repeat this?

    I will share my project when I go back to office today.

  • When we get correct encoder value under running from flash, then, we can see t format is okay in flash mode. Otherwise, you can not make any judgement.

  • please find my project in attached, which is based on TI example "PM_tformat_systemtest". PM_tformat_systemtest.zip

    //----------------------------------------------------------------------------------
    //	FILE:			PM_tformat-Main.C
    //
    //	Description:	Example project for using PM tformat Library.
    //					Includes PM_tformat_lib library and correspoding include files.
    //					Initializes the encoders and performs delay compensation.
    //					Runs tformat command set.
    //					Continuously Read position value in an infinite loop
    //
    //	Version: 		1.0
    //
    //  Target:  		TMS320F28379D
    //
    //----------------------------------------------------------------------------------
    //  Copyright Texas Instruments ��2004-2015
    //----------------------------------------------------------------------------------
    //  Revision History:
    //----------------------------------------------------------------------------------
    //  Date	  | Description / Status
    //----------------------------------------------------------------------------------
    // Apr 2016  - Example project for PM T-Format Library Usage
    //----------------------------------------------------------------------------------
    #include "F28x_Project.h"    // Device Headerfile and Examples Include File
    #include "tformat.h"		 // Include file for tformat interface
    #include "CANSetup.h"
    #include "string.h"
    
    uint32_t crcResult;
    uint16_t retval1;		//used for function return val storage and checks
    uint32_t position, turns;
    __interrupt void cpu_timer0_isr();
    uint16_t flag = 0;
    Uint32    nCnt = 0;
    
    #pragma CODE_SECTION(cpu_timer0_isr, "ramfuncs");
    //#pragma CODE_SECTION(CANIntHandler, "ramfuncs");
    //#pragma CODE_SECTION(spiRxFifoIsr, "ramfuncs");
    //#pragma CODE_SECTION(can_send, "ramfuncs");
    //#pragma CODE_SECTION(InitFlash, "ramfuncs");
    //#pragma CODE_SECTION(tformat_Init, "ramfuncs");
    
    
    
    void main(void) {
    
    //    memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
        // Call Flash Initialization to setup flash waitstates
            // This function must reside in RAM
    //    InitFlash();
    
    
    // Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    // This example function is found in the F2837xD_SysCtrl.c file.
    	InitSysCtrl();
    
    // Step 3. Clear all interrupts and initialize PIE vector table:
    // Disable CPU interrupts
    	DINT;
    
    // Initialize the 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 F2837xD_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 F2837xD_DefaultIsr.c.
    // This function is found in F2837xD_PieVect.c.
    	InitPieVectTable();
    	EALLOW;
    	PieVectTable.TIMER0_INT = &cpu_timer0_isr;
    	//can interrupt
        PieVectTable.CANB0_INT = &CANIntHandler;
    	EDIS;
    	InitCpuTimers();
    	ConfigCpuTimer(&CpuTimer0,200,20);
    	CpuTimer0Regs.TCR.all = 0x4000;
    
    	// Configure GPIO34 as a GPIO output pin
    	EALLOW;
    	GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 0;
    	GpioCtrlRegs.GPADIR.bit.GPIO9 = 1;
    	GpioDataRegs.GPACLEAR.bit.GPIO9 = 1;
        //led2
        GpioCtrlRegs.GPAMUX2.bit.GPIO22 = 0;
        GpioCtrlRegs.GPADIR.bit.GPIO22 = 1;
        GpioDataRegs.GPACLEAR.bit.GPIO22 = 1;
    	EDIS;
    	InitCANBGpio();
    
    
    //Initialization routine for tformat operation - defined in tformat.c
    //Configures the peripherals and enables clocks for required modules
    //Configures GPIO and XBar as needed for t-format operation
    //Sets up the SPI peripheral in tformat data structure and enables interrupt
    
    	tformat_Init();
    	DELAY_US(800L); 	//Delay 800us
    
    	//can setup
        // Initialize the CAN controller
        CANInit(CANB_BASE);
        // Setup CAN to be clocked off the PLL output clock
        CANClkSourceSelect(CANB_BASE, 0);   /* 500kHz CAN-Clock */
        // Set up the bit rate for the CAN bus
        CANBitRateSet(CANB_BASE, 200000000, 250000);
        CANIntEnable(CANB_BASE, CAN_INT_MASTER | CAN_INT_ERROR | CAN_INT_STATUS);
        can_rec_setup();
    
    //Optional function exercising several tformat commands including eeprom accesses
    ////	retval1 = tformat_exCommands();
    
    	IER |= M_INT1;
    	PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
    	//CAN B
        PieCtrlRegs.PIEIER9.bit.INTx7 = 1;//canb
    
    //Infinite loop to read position using DATAID3 command - returns position and turns information
    	while(1)
    	{
    /*		retval1 = PM_tformat_setupCommand (DATAID3, 0, 0, 0);
    		PM_tformat_startOperation();
    		while (tformatData.dataReady != 1) {}
    		retval1 = PM_tformat_receiveData(DATAID3);
    
    		crcResult = PM_tformat_getCRC(0, 80, 8, (uint16_t *)&tformatData.rxPkts, tformatCRCtable, 10);
    		crcResult = crcResult ^ (0xFF);
    		 if (!CheckCRC(crcResult,tformatData.crc))
    		 {
    				 ESTOP0;
    		 }
    
    		 //Invert the received bit sequence for position and turns for actual data
    		 position = ((__flip32((uint32_t) tformatData.dataField0) >> 24 ) & 0xFF)|
    				    ((__flip32((uint32_t) tformatData.dataField1) >> 16 ) & 0xFF00)|
    					((__flip32((uint32_t) tformatData.dataField2) >> 8 )  & 0xFF0000);
    
    		 turns = ((__flip32((uint32_t) tformatData.dataField4) >> 24 ) & 0xFF)|
    					((__flip32((uint32_t) tformatData.dataField5) >> 16 ) & 0xFF00)|
    					((__flip32((uint32_t) tformatData.dataField6) >> 8 )  & 0xFF0000);
    
    		 DELAY_US(200L);*/
    /*	    GpioDataRegs.GPBTOGGLE.bit.GPIO45 = 1;
    	    ucTXMsgData[0] = ((Uint32)(position)) & 0xFF;
            ucTXMsgData[1] = ((Uint32)(position)>>8) & 0xFF;
            ucTXMsgData[2] = ((Uint32)(position)>>16) & 0xFF;
            ucTXMsgData[3] = ((Uint32)(position)>>24) & 0xFF;
            ucTXMsgData[4] = ((Uint32)(turns)) & 0xFF;
            ucTXMsgData[5] = ((Uint32)(turns)>>8) & 0xFF;
            ucTXMsgData[6] = ((Uint32)(turns)>>16) & 0xFF;
            ucTXMsgData[7] = ((Uint32)(turns)>>24) & 0xFF;
            can_send(0x555,2);
    
            DELAY_US(1000000L);*/
    	}
    }
    
    __interrupt void cpu_timer0_isr()
    {
        // Put the Flash to sleep
        EALLOW;
        Flash0CtrlRegs.FPAC1.bit.PMPPWR = 0x0;
        EDIS;
        //GpioDataRegs.GPBTOGGLE.bit.GPIO45 = 1;
        if(flag == 0)
        {
            flag = 1;
            retval1 = PM_tformat_setupCommand (DATAID3, 0, 0, 0);
            PM_tformat_startOperation();
        }
        if(tformatData.dataReady == 1)
        {
            flag = 0;
            retval1 = PM_tformat_receiveData(DATAID3);
    
            crcResult = PM_tformat_getCRC(0, 80, 8, (uint16_t *)&tformatData.rxPkts, tformatCRCtable, 10);
            crcResult = crcResult ^ (0xFF);
             if (!CheckCRC(crcResult,tformatData.crc))
             {
                     //ESTOP0;
             }
    
             //Invert the received bit sequence for position and turns for actual data
             position = ((__flip32((uint32_t) tformatData.dataField0) >> 24 ) & 0xFF)|
                        ((__flip32((uint32_t) tformatData.dataField1) >> 16 ) & 0xFF00)|
                        ((__flip32((uint32_t) tformatData.dataField2) >> 8 )  & 0xFF0000);
    
             turns = ((__flip32((uint32_t) tformatData.dataField4) >> 24 ) & 0xFF)|
                        ((__flip32((uint32_t) tformatData.dataField5) >> 16 ) & 0xFF00)|
                        ((__flip32((uint32_t) tformatData.dataField6) >> 8 )  & 0xFF0000);
        }
        if(nCnt == 50000)
        {
            nCnt=0;
            GpioDataRegs.GPATOGGLE.bit.GPIO9 = 1;
            ucTXMsgData[0] = ((Uint32)(position)) & 0xFF;
            ucTXMsgData[1] = ((Uint32)(position)>>8) & 0xFF;
            ucTXMsgData[2] = ((Uint32)(position)>>16) & 0xFF;
            ucTXMsgData[3] = ((Uint32)(position)>>24) & 0xFF;
            ucTXMsgData[4] = ((Uint32)(turns)) & 0xFF;
            ucTXMsgData[5] = ((Uint32)(turns)>>8) & 0xFF;
            ucTXMsgData[6] = ((Uint32)(turns)>>16) & 0xFF;
            ucTXMsgData[7] = flag;//((Uint32)(turns)>>24) & 0xFF;
            can_send(0x555,2);
        }
        else
            nCnt++;
        PieCtrlRegs.PIEACK.bit.ACK1 = 1;
    }
    // End of file
    

  • Any update? Do you chech my example project?

  • Any update? Do you check my example project shared?

  • Any update? Do you check my example project shared

  • Hi, I'll try to check your example project tomorrow.

    Did you try what i suggested earlier?

    >>>
    I've tested the example in flash configuration. Didn't see any issues.
    Steps:
    1. Create a new FLASH configuration - copying from RAM configuration.
    2. Exclude RAM linker file and include flash linker file (2837xD_FLASH_lnk_cpu1.cmd)
    3. Define _FLASH in Build Properties-> Compiler -> Advanced options-> Predefined symbols
    >>>

  • yes, I have done the same steps like your suggestion.

  • Hi,

    I tried running the code you attached as it is and it seems to work fine in Flash. I'm wondering something else in your set up could be causing this issue.
    Please try to explore sources that could be causing the code failure, outside the encoder function.

  • You can receive correct encoder value running my example project when booting from flash? Right?

  • Hi,

    Yes - same code you've attached, run as it is.

  • That's strange. I try to run it on another pc, installing new ccs and controlsuite today. But the same failure result is received.

    I have no ideal.

  • At this stage, you should look at the other possible sources that could be causing this in your hardware.
    Also, probe signals to figure out what exactly is happening in the encoder interface and attempt next level of debug - as Software you sent seems to be working fine.

  • Okay.

    I will check hardware next week. And update to you soon.

  • Hi Subrahmanya,

    the issued is solved now. 

    it should give some delay before reading encoder when power-on in flash.

    Thanks very much for all time support from you. 

    Feng