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/TMS320F280049: CCS/TMS320F280049: Running from FLASH

Part Number: TMS320F280049
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hi everyone,

I have a custom board for the TMS320F280049 microcontroller. I am using the example projects with the C200ware, which supports the new microcontroller. It looks like the header files are intended to be used with a development board or something. This is another thread I posted regarding my design https://e2e.ti.com/support/microcontrollers/c2000/f/171/p/673208/2478927#2478927.

I have a difficulty in running my code from the FLASH, however, it runs ok from the RAM. I have changed the variable ".TI.ramfunc" to "ramfuncs" to match all the other microcontroller families. 

I have included my code in this post.

/ Included Files
//
#include "F28x_Project.h"


//
// Defines
//
#define DEVICE_GPIO_PIN_LED1 12
uint32_t NewVar=10;

//
// Main
//
void main(void)
{
//
memcpy(&RamfuncsRunStart,&RamfuncsLoadStart,&RamfuncsLoadEnd - &RamfuncsLoadStart);


// Initialize device clock and peripherals
//

InitSysCtrl();   This function was internally changed to use an internal oscillator " InitSysPll(INT_OSC2,19,1,1);"

//
// Initialize GPIO and configure the GPIO pin as a push-pull output
//
InitGpio();

GPIO_SetupPinMux(DEVICE_GPIO_PIN_LED1, GPIO_MUX_CPU1, 0);

GPIO_SetupPinOptions(DEVICE_GPIO_PIN_LED1, GPIO_OUTPUT, GPIO_PUSHPULL);

//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;

//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
InitPieVectTable();

NewVar = 12;

//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;

NewVar = 13;


//
// Loop Forever
//
for(;;)
{
//
// Turn on LED
//
GPIO_WritePin(DEVICE_GPIO_PIN_LED1, 0);

//
// Delay for a bit.
//
DELAY_US(1000000);
//
// Turn off LED
//
GPIO_WritePin(DEVICE_GPIO_PIN_LED1, 1);
NewVar = 15;

//
// Delay for a bit.
//
DELAY_US(1000000);
}
}

//
// End of File
//

void InitSysCtrl(void)
{
//
// Disable the watchdog
//
DisableDog();

#ifdef _FLASH
//
// Copy time critical code and Flash setup code to RAM
// This includes the following functions: InitFlash();
// The RamfuncsLoadStart, RamfuncsLoadSize, and RamfuncsRunStart
// symbols are created by the linker. Refer to the device .cmd file.
//
//memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
memcpy(&RamfuncsRunStart,&RamfuncsLoadStart,&RamfuncsLoadEnd - &RamfuncsLoadStart);
#endif

//
// PLLSYSCLK = (XTAL_OSC) * (IMULT + FMULT) / (PLLSYSCLKDIV)
//
//InitSysPll(XTAL_OSC,IMULT_10,FMULT_0,PLLCLK_BY_2);

//InitSysPll(INT_OSC2,IMULT_19,FMULT_0pt25,PLLCLK_BY_2);
InitSysPll(INT_OSC2,19,1,1);

//
// Call Flash Initialization to setup flash waitstates
// This function must reside in RAM
//
InitFlash();

//
// Turn on all peripherals
//
InitPeripheralClocks();
}

//
// InitFlash - This function initializes the Flash Control registers
// CAUTION
// This function MUST be executed out of RAM. Executing it
// out of OTP/Flash will yield unpredictable results
//
#ifdef __cplusplus
#pragma CODE_SECTION("ramfuncs");
#endif
void InitFlash(void)
{
EALLOW;

//
// At reset bank and pump are in sleep
// A Flash access will power up the bank and pump automatically
// After a Flash access, bank and pump go to low power mode (configurable
// in FBFALLBACK/FPAC1 registers)- if there is no further access to flash
// Power up Flash bank and pump and this also sets the fall back mode of
// flash and pump as active
//
Flash0CtrlRegs.FPAC1.bit.PMPPWR = 0x1;
Flash0CtrlRegs.FBFALLBACK.bit.BNKPWR0 = 0x3;
Flash0CtrlRegs.FBFALLBACK.bit.BNKPWR1 = 0x3;

//
// Disable Cache and prefetch mechanism before changing wait states
//
Flash0CtrlRegs.FRD_INTF_CTRL.bit.DATA_CACHE_EN = 0;
Flash0CtrlRegs.FRD_INTF_CTRL.bit.PREFETCH_EN = 0;

//
// Set waitstates according to frequency
// CAUTION
// Minimum waitstates required for the flash operating
// at a given CPU rate must be characterized by TI.
// Refer to the datasheet for the latest information.
//
#if CPU_FRQ_100MHZ
if((ClkCfgRegs.CLKSRCCTL1.bit.OSCCLKSRCSEL == 0x0) ||
(ClkCfgRegs.CLKSRCCTL1.bit.OSCCLKSRCSEL == 0x2) ||
(ClkCfgRegs.CLKSRCCTL1.bit.OSCCLKSRCSEL == 0x3))
{
Flash0CtrlRegs.FRDCNTL.bit.RWAIT = 0x5;
}
else
{
Flash0CtrlRegs.FRDCNTL.bit.RWAIT = 0x4;
}
#endif

//
// Enable Cache and prefetch mechanism to improve performance
// of code executed from Flash.
//
Flash0CtrlRegs.FRD_INTF_CTRL.bit.DATA_CACHE_EN = 1;
Flash0CtrlRegs.FRD_INTF_CTRL.bit.PREFETCH_EN = 1;

//
// At reset, ECC is enabled. If it is disabled by application software
// and if application again wants to enable ECC
//
Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0xA;

EDIS;

//
// Force a pipeline flush to ensure that the write to
// the last register configured occurs before returning.
//
__asm(" RPT #7 || NOP");
}

//
// FlashOff - This function powers down the flash
// CAUTION
// This function MUST be executed out of RAM. Executing it
// out of OTP/Flash will yield unpredictable results.
// Note: a flash access after the flash pump and banks are powered down will
// wake the pump and bank
//
#ifdef __cplusplus
#pragma CODE_SECTION("ramfuncs");
#endif
void FlashOff(void)
{
EALLOW;

//
// Configure the fallback power mode as sleep
//
Flash0CtrlRegs.FBFALLBACK.bit.BNKPWR0 = 0;
Flash0CtrlRegs.FBFALLBACK.bit.BNKPWR1 = 0;

//
// Configure the fallback power mode as sleep
//
Flash0CtrlRegs.FPAC1.bit.PMPPWR = 0;

EDIS;
}

  • Hi Mohamed,

    What are the difficulties you're facing with the Flash configuration? Is it setting up the build configuration for Flash in your project, debugging in the Flash configuration, or another issue?

    Here is a resource to understand the difference between ".TI.ramfunc" and "ramfuncs" if you haven't seen it already:
    processors.wiki.ti.com/.../Placing_functions_in_RAM

    You mentioned that you're using C2000Ware example projects, so you may be aware that Flash build configuration is available with them. This is a good reference of how you can set up the Flash build configuration in your own project.

    The linker command files suitable with the Flash configuration can also be found in C2000Ware:
    C:\ti\c2000\C2000Ware_1_00_03_00\device_support\f28004x\common\cmd\28004x_generic_flash_lnk.cmd

    Regards,
    Elizabeth
  • Hi Elizabeth,
    Thanks for your response. I was not familiar with the differences between ".TI.ramfunc" and "ramfuncs" statements. However, I am not sure it is the cause of the problem or not. I have tried using the Flash build configuration with the example projects, it loads the code normally. However, I turn off the power supply, and turn it back on, I expect the code to be running normally as I expect it to boot from flash (Please let me know if that's wrong, I am quite new with microcontrollers programming).

    Thanks,
    Mohamed
  • Hi Mohamed,

    Yes, the code should continue to run after power cycle in Flash configuration. You mentioned that you're using a custom board with the F280049. If you have access to the experimenter kit (ie www.ti.com/.../TMDXDOCK280049M), can you see if you're encountering the same issues? If you're not seeing issues with the experimenter kit and C2000Ware examples, then this may be related to your board design.

    Regards,
    Elizabeth
  • Hi Elizabeth,
    The issue still exists. I do not have the control card/ development kit to compare with it. Unfortunately, all the sample codes are made specifically for the development kit, not like the other F28xx families.
    Mohamed
  • Hi Mohamed,

    The example projects in C2000Ware for any given device were primarily developed and tested with the experimenter kits, as that is the hardware provided by TI. But the software was was still developed to showcase the peripherals' functionality so that customers can have building blocks for their applications to suit their designed hardware. It seems that you'll have to do more debug with the board.

    Regards,
    Elizabeth
  • Hi Elizabeth!
    Thanks for your patience. It looks like the Development Kit includes switches to select the boot mode.
    I have changed the F28004x_dcsm_z1otp.asm file
    In .sect "b0_dcsm_otp_z1_linkpointer", the new value is .long 0x5AFFFFFF
    In .sect "b0_dcsm_otp_z1_bootctrl", the new value is .long 0xFFFFFF03

    I used the DCSM linker and now it is fixed! Thanks for brainstorming :)

    Mohamed