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.

TMS320F28069: CLA: global array values get shifted

Part Number: TMS320F28069


I have a strange bug in CLA code. I initialize values of a global array in CLA memory as follows:

interrupt void InitVars(void) {
    // TODO: Calculate these during initialization from Fourier coefficients specified in MotorControl.h
    float32 BackEmfProfInit[PROF_SIZE] =
        {0.9778235f,  0.9403109f,  0.8992523f,  0.8542375f,  0.8049480f,  0.7511688f,  0.6927969f,  0.6298467f,
         0.5624517f,  0.4908623f,  0.4154409f,  0.3366528f,  0.2550543f,  0.1712778f,  0.0860155f,  0.0000000f,
        -0.0860155f, -0.1712778f, -0.2550543f, -0.3366528f, -0.4154409f, -0.4908623f, -0.5624517f, -0.6298467f,
        -0.6927969f, -0.7511688f, -0.8049480f, -0.8542375f, -0.8992523f, -0.9403109f, -0.9778235f, -1.0122777f,
        -1.0442214f, -1.0742445f, -1.1029587f, -1.1309776f, -1.1588958f, -1.1872691f, -1.2165963f, -1.2473018f,
        -1.2797216f, -1.3140913f, -1.3505375f, -1.3890725f, -1.4295926f, -1.4718800f, -1.5156081f, -1.5603503f,
        -1.6055917f, -1.6507441f, -1.6951625f, -1.7381641f, -1.7790479f, -1.8171158f, -1.8516927f, -1.8821464f,
        -1.9079068f, -1.9284820f, -1.9434737f, -1.9525886f, -1.9556470f, -1.9525886f, -1.9434737f, -1.9284820f,
        -1.9079068f, -1.8821464f, -1.8516927f, -1.8171158f, -1.7790479f, -1.7381641f, -1.6951625f, -1.6507441f,
        -1.6055917f, -1.5603503f, -1.5156081f, -1.4718800f, -1.4295926f, -1.3890725f, -1.3505375f, -1.3140913f,
        -1.2797216f, -1.2473018f, -1.2165963f, -1.1872691f, -1.1588958f, -1.1309776f, -1.1029587f, -1.0742445f,
        -1.0442214f, -1.0122777f, -0.9778235f, -0.9403109f, -0.8992523f, -0.8542375f, -0.8049480f, -0.7511688f,
        -0.6927969f, -0.6298467f, -0.5624517f, -0.4908623f, -0.4154409f, -0.3366528f, -0.2550543f, -0.1712778f,
        -0.0860155f,  0.0000000f,  0.0860155f,  0.1712778f,  0.2550543f,  0.3366528f,  0.4154409f,  0.4908623f,
         0.5624517f,  0.6298467f,  0.6927969f,  0.7511688f,  0.8049480f,  0.8542375f,  0.8992523f,  0.9403109f,
         0.9778235f,  1.0122777f,  1.0442214f,  1.0742445f,  1.1029587f,  1.1309776f,  1.1588958f,  1.1872691f,
         1.2165963f,  1.2473018f,  1.2797216f,  1.3140913f,  1.3505375f,  1.3890725f,  1.4295926f,  1.4718800f,
         1.5156081f,  1.5603503f,  1.6055917f,  1.6507441f,  1.6951625f,  1.7381641f,  1.7790479f,  1.8171158f,
         1.8516927f,  1.8821464f,  1.9079068f,  1.9284820f,  1.9434737f,  1.9525886f,  1.9556470f,  1.9525886f,
         1.9434737f,  1.9284820f,  1.9079068f,  1.8821464f,  1.8516927f,  1.8171158f,  1.7790479f,  1.7381641f,
         1.6951625f,  1.6507441f,  1.6055917f,  1.5603503f,  1.5156081f,  1.4718800f,  1.4295926f,  1.3890725f,
         1.3505375f,  1.3140913f,  1.2797216f,  1.2473018f,  1.2165963f,  1.1872691f,  1.1588958f,  1.1309776f,
         1.1029587f,  1.0742445f,  1.0442214f,  1.0122777f,  0.9778235f};

    for (Uint16 iProf = 0; iProf < PROF_SIZE; iProf++) {
        BackEmfProf[iProf] = IntMotorParameters.PolePairs*IntMotorParameters.MotorTorqueConstant*BackEmfProfInit[iProf]/3.f;
    }
}

The values of BackEmfProfInit get shifted by three positions, i.e. 2->5, 3->6 etc. The first two values are rubbish. I am at a loss as to how this could happen. I configure CLA memory as follows:

    // Set memory available to CLA.
    Cla1Regs.MMEMCFG.all = 0;
    Cla1Regs.MMEMCFG.bit.PROGE = 1;
    Cla1Regs.MMEMCFG.bit.RAM0E = 1;
    Cla1Regs.MMEMCFG.bit.RAM1E = 1;
    Cla1Regs.MMEMCFG.bit.RAM2E = 1;
    Cla1Regs.MMEMCFG.bit.RAM0CPUE = 0;
    Cla1Regs.MMEMCFG.bit.RAM1CPUE = 0;
    Cla1Regs.MMEMCFG.bit.RAM2CPUE = 0;

And in the CMD linker file:

   CLARAM      : origin = 0x008000, length = 0x001000     /* on-chip RAM block L0/L1/L2 */
...
   .scratchpad      	: > CLARAM,   PAGE = 1
   .bss_cla		    	: > CLARAM,   PAGE = 1
   .const_cla	    	: > CLARAM,   PAGE = 1

I checked, the memory is not double-booked. Anybody any idea?