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.

MCU won't start after disconnecting JTAG

Other Parts Discussed in Thread: CONTROLSUITE

I have a TMS320F28069PZ which is supposed to control three BLDC motors through motor drivers, using PWM.

I have made a program which turns on an onboard LED as the first thing in the main()-loop. This works perfectly when I click the debug-icon in CCS.

However, if I disconnect the JTAG, and then turns the MCU-power OFF and ON, the program does not seem to start, because the LED does not turn on.

Is there any special steps I need to take to:

A) Transfer the code to the MCU's onboard memory

or

B) Make the program start automatically when the MCU is powered on?

Thank you in advance

  • Hi Glenn,

    This is because your code is configured to run through your RAM and not Flash.

    Here are the steps:
    You need to add these two statements

    MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
    InitFlash(); after InitPieVectTable();

    Add DSP2806x_MemCopy.c file to the project.

    Define extern variables above main() function.

    extern Uint16 RamfuncsLoadStart;
    extern Uint16 RamfuncsLoadEnd;
    extern Uint16 RamfuncsRunStart;

    Replace 28069_RAM_lnk.cmd with F28069.cmd
    Compile the code.
    Configure your GPIO's to boot to flash.

    Also, you can refer a direct example code present here:
    C:\ti\controlSUITE\device_support\f2806x\v140\F2806x_examples_ccsv5\flash_f28069

    The above header and linker files can be found here: C:\ti\controlSUITE\device_support\f2806x\v140

    Regards,
    Gautam

  • Hi Gautam,

    Thanks for the quick reply. A question regarding some of the steps: Do I add the two first statements (MemCopy...) inside main(), or somewhere else??

    For the last step (Configure your GPIO's to boot fo flash) - How is this performed?
  • In main(). Boot setting can be found in datasheet.
  • Thank you Gautam.

    This was helpful, but I'm currently stuck in a function called DELAY_US. During debugging (and normal execution), the execution does not go past this piece of code (.asm):

    It does not go past the line called BF, but the message: "No source available for "0x3ff782"" comes when I execute that line, every time.

    Any suggestions here? This file is called "F2806x_usDelay.asm".

  • Going through the example you mentioned, I see that the function "memcpy" is used, rather than what you suggested - "MemCopy". Regardless, it doesn't seem like I'm able to write to flash, because every time I start the MCU now, it's the Flash example program that runs, not my program.

    Current snippets of code:

    #include "DSP28x_Project.h"
    #include "Motor.h"
    #include "System.h"
    #include "Spi.h"
    #include "Math.h"
    #include "Adc.h"
    
    extern Uint16 RamfuncsLoadStart;
    extern Uint16 RamfuncsLoadEnd;
    extern Uint16 RamfuncsRunStart;
    
    void main()
    {
    	initializeSystemClocks();
    	//initializeAdc()
    	initializeGpio();
    	initializeSpi();
    	initializeMotors();
    
    	testLedOn();
    
    	// ...
    	// Lots of code, regarding ePWM
    	// ...
    
    	MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
    	InitFlash();
    
    	while(1) {}
    }

    What happens when I debug:

    When I get to the line InitFlash();, the Flash example code starts running, rather than my code.

  • Glenn, please refer this example code: C:\ti\controlSUITE\device_support\f2806x\v150\F2806x_examples_ccsv5\flash_f28069
    for reference.
  • Hi again Gautam,

    I appreciate your help. However I'm having some trouble.

    After reviewing the example code, and modified my code accordingly, I find that I still have some issues. I will try to explain it briefly.

    This is the code of my main document currently:

    #include "DSP28x_Project.h"
    #include "Motor.h"
    #include "System.h"
    #include "Spi.h"
    #include "Math.h"
    #include "Adc.h"
    
    extern Uint16 RamfuncsLoadStart;
    extern Uint16 RamfuncsLoadEnd;
    extern Uint16 RamfuncsRunStart;
    extern Uint16 RamfuncsLoadSize;
    
    void main()
    {
    	InitSysCtrl();
    	DINT;
    	InitPieCtrl();
        IER = 0x0000;
        IFR = 0x0000;
    	InitPieVectTable();
    
    	memcpy(&RamfuncsLoadStart, &RamfuncsLoadEnd, (Uint32)&RamfuncsRunStart);
    	InitFlash();
    	EINT;   // Enable Global interrupt INTM
    	ERTM;   // Enable Global realtime interrupt DBGM
    
    	while(1) {}
    }
    

    This has the same structure as the example code: First calling InitSysCtrl(), then DINT, InitPieCtrl(), disabling CPU interrupts, then calling InitPieVectTable(), before running memcpy() and InitFlash(). Later in the code, EINT and ERTM is called.

    The behaviour when debugging is as follows:

    I can step over functions including line 22:  memcpy(&RamfuncsLoadStart, &RamfuncsLoadEnd, (Uint32)&RamfuncsRunStart);

    When I then try to step over line 23:  InitFlash();

    The debugger takes me into F2806x_DefaultIsr.c, to the function __interrupt void RTOSINT_ISR(void)   // RTOS interrupt.

    This indicates an illegal call has been made, so I try to run again, stepping into InitFlash(). Inside InitFlash(), trying to step past FlashRegs.FOPT.bit.ENPIPE = 1;, the debugger takes me to the same RTOSINT_ISR function.

    I believe my code is functionally same as the example I mentioned (which runs fine), but I cannot figure out how to make this run.

    Do you have any ideas?

  • I figured it out. I edited line 22 to:

    memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (Uint32)&RamfuncsLoadSize);

    I had kept the argument order of your first suggestion, after changing from MemCopy to memcpy.

    Thank you for your help through this.

  • Excellent Glenn! Nice to know you were successful in realizing the standalone operation through Flash.

    Goodluck & Regards,
    Gautam