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.

TMS320F28027: C2000 FLASH API questions

Part Number: TMS320F28027

Hi all!

I'm using FLASH API library for storing some data in FLASH memory on TMS320F28027 device., CCSv6.1.1, Win8.1

I'm using Flash2802x_API_Quickstart.pdf and Flash2802x_API_using_CCS4.0v_Readme.pdf as a doc and Example_Flash2802x_API.c as a template. FLASH API resides in On-chip ROM, so I don't

copy them into RAM, but run from ROM.

I have some questions:

1. Section definitoin for placement variales Flash_CallbackPtr and Flash_CPUScaleFactor In .cmd file DSP2802x_Headers_nonBIOS.cmd is

/*** PIE Vect Table and Boot ROM Variables Structures ***/
  UNION run = PIE_VECT, PAGE = 1
   {
      PieVectTableFile
      GROUP
      {
         EmuKeyVar
         EmuBModeVar
         FlashCallbackVar	//this should be @0x000D02
         FlashScalingVar	       //this should be @0x000D04
      }
   }

How it is told to linker to place FlashCallbackVar section @0x000D02 and FlashScalingVar @0x000D04 as it is required by FLASH API?

Why they are not placed say @0x000D02 and 0x000D03 respectively or somewhere else?

2. After using API routines I must restore Pie interrupt vector table, coz it is "corrupted" by Flash_CallbackPtr and Flash_CPUScaleFactor variables, right?

3. In sample code in Example_Flash2802x_API.c, function Example_CallFlashAPI placed in RAM (not FLASH):

#pragma CODE_SECTION(Example_CallFlashAPI,"ramfuncs");
void Example_CallFlashAPI(void)
{
   Uint16  i;
   Uint16  Status;
   Uint16  *Flash_ptr;     // Pointer to a location in flash
   Uint32  Length;         // Number of 16-bit values to be programmed
   float32 Version;        // Version of the API in floating point
   Uint16  VersionHex;     // Version of the API in decimal encoded hex

/*------------------------------------------------------------------
...etc...
------------------------------------------------------------------*/
   VersionHex = Flash_APIVersionHex();
   if(VersionHex != 0x0201)
   {
       // Unexpected API version
       // Make a decision based on this info. 
       asm("    ESTOP0");
   }   
   Version = Flash_APIVersion();
   if(Version != (float32)2.01)
   {
       // Unexpected API version
       // Make a decision based on this info. 
       asm("    ESTOP0");
   }
   
   // SECTORA-SECTORH are defined in Flash2802x_API_Library.h
   Status = Flash_Erase((SECTORB|SECTORC|SECTORD),&FlashStatus);
   if(Status != STATUS_SUCCESS) 
   {
       Example_Error(Status);
   } 
   
    for(i=0;i<WORDS_IN_FLASH_BUFFER;i++)
    {
        Buffer[i] = 0x100+i;
    }
    
    Flash_ptr = Sector[1].StartAddr;
    Length = 0x400;
    Status = Flash_Program(Flash_ptr,Buffer,Length,&FlashStatus);
    if(Status != STATUS_SUCCESS) 
    {
        Example_Error(Status);
    }

    // Verify the values programmed.  The Program step itself does a verify
    // as it goes.  This verify is a 2nd verification that can be done.      
    Status = Flash_Verify(Flash_ptr,Buffer,Length,&FlashStatus);
    if(Status != STATUS_SUCCESS) 
    {
        Example_Error(Status);
    }            
}

But this function itself does not perform any time critical code. The question is - can this function be run from FLASH? That is. Why not? Time critical API functions Flash_Verify, Flash_Erase, Flash_Program is run from ROM, so this should be ok, isn't it?

The prime purpose for this is that I don't want waste on chip RAM for that function.

4. In example project in Example_Flash2802x_API.h defined a PLLCR_VALUE:

/*-----------------------------------------------------------------------------
     Specify the PLLCR (PLL Control Register) value.   

      Uncomment the appropriate line by removing the leading double slash: // 
      Only one statement should be uncommented.

      The user's application must set the PLLCR Register before calling any
      of the Flash API functions.
 
      Example:  CLKIN is a 10MHz crystal.  
                The user wants to have a 60Mhz CPU clock (SYSCLKOUT = 60MHz).  
                In this case, PLLCR must be set to 12 (0x000C)
                Uncomment the line: #define PLLCR_VALUE 0x000C
                Comment out the remaining lines with a double slash: //
-----------------------------------------------------------------------------*/

#define PLLCR_VALUE  0x000C     // SYSCLKOUT = (OSCLK*12)/2
// #define PLLCR_VALUE  0x000B     // SYSCLKOUT = (OSCLK*11)/2
// #define PLLCR_VALUE  0x000A     // SYSCLKOUT = (OSCLK*10)/2
// #define PLLCR_VALUE   0x0009     // SYSCLKOUT = (OSCLK*9)/2
//#define PLLCR_VALUE   0x0008     // SYSCLKOUT = (OSCLK*8)/2
// #define PLLCR_VALUE   0x0007     // SYSCLKOUT = (OSCLK*7)/2
// #define PLLCR_VALUE   0x0006     // SYSCLKOUT = (OSCLK*6)/2
// #define PLLCR_VALUE   0x0005     // SYSCLKOUT = (OSCLK*5)/2
// #define PLLCR_VALUE   0x0004     // SYSCLKOUT = (OSCLK*4)/2
// #define PLLCR_VALUE   0x0003     // SYSCLKOUT = (OSCLK*3)/2
// #define PLLCR_VALUE   0x0002     // SYSCLKOUT = (OSCLK*2)/2
// #define PLLCR_VALUE   0x0001     // SYSCLKOUT = (OSCLK*1)/2
// #define PLLCR_VALUE   0x0000     // SYSCLKOUT = (OSCLK)/2 (PLL Bypassed)

I set up PLLCR register earlier in proprietary initialization code. Should I do as described above if this constant used in FLASH API, or I can ignore this guidance?

Thanks.

  • 1) Start address of PIEVECT is 0xD00. When you group data sections in a specific order, the linker automatically stores the variable in that order.

                         So, linker places the variable in the specific order shown below

                                  0xD00               - EmuKeyVar

    0xD01               - EmuBModeVar

    0xD02 / 0xD03 - FlashCallbackVar

    0xD04 / 0xD05 - FlashScalingVar

    2) Run Flash API routines shouldn't corrupt FlashCallbackVar / FlashScalingVar

    3) Example_CallFlashAPI function calls Flash API function. As Flash API functions shouldn't be called / executed from flash, it has be run from RAM

    4) If it is defined earlier, then it should be okay. Flash API algorithms timing are based out of SYSCLK. so, make sure SYSCLK frequency is configured correctly otherwise Flash API timing will be wrong.

    Regards,

    Manoj

  • Manoj, thank you
    Everything clear now.