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.

F28335 and maths library

Other Parts Discussed in Thread: CONTROLSUITE, INSTASPIN-BLDC

Hello,

I am currently facing a problem on the DSP F28335.

When my application is running in RAM, it runs correctly.

When my application is running in FLASH, the problem is as follows : the CAN communication, that is normally driven by a 10ms task, is disrupted and for example the CAN frames are sampled at 20ms (not stable, between 9ms and 20ms) instead of 10ms. In my application I have another task at 100µs.

We supposed this is a problem of CPU load, and I did the following :

- measure of CPU load with a Simulink tool that allows that when running in RAM : I got about 70µs calculation time for the 100µs task, and 105µs for the 10ms task; this is quite high but OK for a RAM execution

- in Simulink, all the tasks (100µs and 10ms) are defined to be loaded in ramfunc (stored in Flash, then copied from Flash to RAM at DSP start) --> that should decreased the CPU load, but it is not enough and I still have CPU load problem

- we saw that maths functions are not located in ramfunc, so we add the following in the .cmd file to locate these functions (sinus, cosinus, ...) in ramfunc :

ramfuncs: LOAD = FLASH,
RUN = RAML4L7,
LOAD_START(_RamfuncsLoadStart),
LOAD_END(_RamfuncsLoadEnd),
RUN_START(_RamfuncsRunStart),
PAGE = 0
{
-l rts2800_fpu32.lib <sin.obj> (.text)
-l rts2800_fpu32.lib <cos.obj> (.text)
-l rts2800_fpu32.lib <sqrt.obj> (.text)
-l rts2800_fpu32.lib <modf.obj> (.text)
-l rts2800_fpu32.lib <fmod.obj> (.text)
-l rts2800_fpu32.lib <memcpy_ff.obj> (.text)
-l rts2800_fpu32.lib <fs_div.obj> (.text)
-l rts2800_fpu32.lib <memset.obj> (.text)
}

...but we still have the problem.

Is it correct to locate all the maths functions like we did ?

What else can we do to locate the maximum of code in ramfunc to optimize the CPU load?

Thank you,

Best regards,

Julien

  • Hi Julien,

    What you did with the ramfuncs and manual relocation of the math functions is correct. We do provide a faster run time support library though, its located under C:\ti\controlSUITE\libs\math\FPUfastRTS - insteadof using the standard RTS, try this library and see if it gets you to your desired frame rate

  • Hi Vishal,

    Thank you for your answer, we will try this library.

    Another question related to this one : how to be sure to locate the maximum code in ramfuncs, to have the lowest CPU load possible? Indeed I saw that even by suppressing all the maths functions in my model, I still have CPU load problem when working in Flash, so I suppose that even using this new library I will still have the problem.

    Which other files can I locate in ramfuncs ? In attached file you will find my .map file, in case it cans help you.

    Best regards,

    Julien

  • Hi Julien,

    didnt find any attachment. You could, if you wanted to, dump the entire .text section from all .obj files into ramfuncs like you did with the math lib and have your entire code run out of RAM. Its not possible to tell from the .map what sections of code are loading the CPU more or less than any other section. You are going to have to identify code that runs frequently and put those in ramfuncs.

    Also, the flash has waitstates associated with it. You may not be running with the best possible wait state. Im not the expert on that but im pretty sure its documented in the flash or system control chapter in the TRM on how to optimize the wait-states

  • Thank you Vishal,
    I will apply all your recommendations and will keep you informed of my results.

    Best regards,
    Julien
  • Hello,

    I tried to dump all the .text section into ramfuncs by doing this :

        ramfuncs:     LOAD = FLASH,
            RUN = RAML4L7,
            LOAD_START(_RamfuncsLoadStart),
            LOAD_END(_RamfuncsLoadEnd),
            RUN_START(_RamfuncsRunStart),
            PAGE = 0
                     {
                       *.obj (.text)                   
                       -l rts2800_fpu32.lib<sin.obj sqrt.obj modf.obj fmod.obj fs_div.obj memcpy_ff.obj memset.obj> (.text)
                     }

    Thus, I am able to compile and flash the DSP, but then the DSP does not start (no LED flashing, no CAN communication). Is it normal ? Are there any .obj that we should not dump into ramfuncs?

    Then, what is the syntax if I want to dump a specific .obj file into ramfuncs (for example MW_c28xx_pwm.obj) : I tried "MW_c28xx_pwm.obj (.text)" but doing so the link fails.

    Best regards,

    Julien

  • Now that i think about it , you probably shouldnt dump the .text sections from the run time support library like boot.obj.

    I would identify the math functions from the rts library and dump those into ramfuncs, as you did. I would then look at your code and then assign frequently executed code to ramfuncs by using preprocessor pragmas in the code itself not through the linker file.

    #pragma CODE_SECTION(foo, "ramfuncs")
    void foo ( void)
  • Also as to the syntax of dumping sections from .obj files, what you wrote doe work, i tried the following

       ramfuncs        :  LOAD = FLASHC,
                          RUN = RAMLS1,
                          RUN_START(_RamfuncsRunStart),
                          LOAD_START(_RamfuncsLoadStart),
                          LOAD_SIZE(_RamfuncsLoadSize),
                          PAGE = 0
                          {
                            main.obj(.text)
                           }

    in the map file i see

    ramfuncs   0    00084000    000000e6     RUN ADDR = 00008800
                      00084000    00000093     main.obj (.text)
                      00084093    0000004f     main.obj (.text:retain)
                      000840e2    00000004     driverlib.lib : sysctl.obj (ramfuncs)

  • Hi,
    Actually we are using automatic code generation with Matlab/Simulink, and configured in Simulink all the "applicative" code to be located in ramfuncs. But reading the .map file, we can see that there are a lot of other .obj that are still in .text , not in ramfuncs.
    We wanted to do the dump into ramfuncs using the linker file to avoid any manual coding : do you think it is necessary to add some #pragma directly in the generated code, instead of using the linker file ? Could you explain biefly what the problem could be if we use the linker file ?

    Regards,
    Julien
  • There isnt a problem doing it through the linker command file, but you dump the entire .text section of an .obj file - so if i had 10 functions in 1 file, but only 1 was frequently used, i am dumping all 10 to ramfuncs and wasting valuable RAM space. But if you have it where 1 function per obj file there is no problem.

    If you have the space in RAM, you can dump the entire .text section of the .obj in there.
  • Hello Vishal,

    We worked on the .cmd file to optimize a little bit the mapping, that allowed us to decrease a little bit the CPU load but we still got the problem.
    Then we added the faster run time support library and now the CPU load is correct even when working from the ramfuncs location.

    Thank you for your help !

    Best regards,
    Julien
  • If foo is not a user-defined function, but a function in a LIB library, such as InstaSPIN_BLDC in InstaSPIN-BLDC, will # pragma CODE_SECTION (InstaSPIN_BLDC, "ramfuncs") be useful? I found that I did not succeed in moving InstaSPIN_BLDC into ramfuncs;