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.

TMS320F28069M: Problem Implementing CLA FFT on this MCU of series F2806x

Part Number: TMS320F28069M
Other Parts Discussed in Thread: C2000WARE

Hi,
So i am trying to implement CLA_FFT on MCU F28069M but am unable to execute it.
firstly Can this MCU run a 1024 point FFT.
Trying to Execute below Functions:

__interrupt void
Cla1Task1 (void)
{
    __mdebugstop();
 CLA_CFFT_run1024Pt();
 __mdebugstop();
 CLA_CFFT_unpack512Pt();
}


Also here is the linker command file i have designed to execute FFT and FIR through CLA
_Cla1Prog_Start = _Cla1funcsRunStart;
-heap 0x400
-stack 0x400

// Define a size for the CLA scratchpad area that will be used
// by the CLA compiler for local symbols and temps
// Also force references to the special symbols that mark the
// scratchpad are. 
// CLA_SCRATCHPAD_SIZE = 0x100;
--undef_sym=__cla_scratchpad_end
--undef_sym=__cla_scratchpad_start

MEMORY
{
PAGE 0 :
   /* BEGIN is used for the "boot to SARAM" bootloader mode   */
   BOOT_RSVD   : origin = 0x000000, length = 0x000050     /* Part of M0, BOOT rom will use this for stack */
   BEGIN       : origin = 0x3F7FF6, length = 0x000002     /* Part of FLASHA.  Used for "boot to Flash" bootloader mode. */
   RAMM0M1     : origin = 0x000050, length = 0x000750
   RAML5       : origin = 0x00E000, length = 0x002000
   FLASHH      : origin = 0x3D8000, length = 0x004000     /* on-chip FLASH */
   FLASHG      : origin = 0x3DC000, length = 0x004000     /* on-chip FLASH */
   FLASHF      : origin = 0x3E0000, length = 0x004000     /* on-chip FLASH */
   FLASHE      : origin = 0x3E4000, length = 0x004000     /* on-chip FLASH */
   FLASHD      : origin = 0x3E8000, length = 0x004000     /* on-chip FLASH */
   FLASHC      : origin = 0x3EC000, length = 0x004000     /* on-chip FLASH */
   FLASHA      : origin = 0x3F4000, length = 0x003F80     /* on-chip FLASH */
   ROM         : origin = 0x3FF3B0, length = 0x000C10     /* Boot ROM */
   RESET       : origin = 0x3FFFC0, length = 0x000002     /* part of boot ROM  */
   VECTORS     : origin = 0x3FFFC2, length = 0x00003E     /* part of boot ROM  */

  /* RAML0_L2       : origin = 0x008000, length = 0x001000 */	 
   RAML3		    : origin = 0x009000, length = 0x001000
   /* FPU Tables in Boot ROM */
   FPUTABLES        : origin = 0x3FD590, length = 0x0006A0	

    /* IQ Math Tables in Boot ROM */
   IQTABLES   		: origin = 0x3FDF00, length = 0x000B50 
   IQTABLES2  		: origin = 0x3FEA50, length = 0x00008C 
   IQTABLES3  		: origin = 0x3FEADC, length = 0x0000AA	

PAGE 1 :

   CLARAM0              : origin = 0x008800, length = 0x000400
   CLARAM1              : origin = 0x008C00, length = 0x000400
   CLARAM2				: origin = 0x008000, length = 0x000800
   /* on-chip RAM block L4-L8 */
   RAML4            	: origin = 0x00A000, length = 0x04000
   RAML5_2				: origin = 0x010000, length = 0x001000
   RAML6       			: origin = 0x011000, length = 0x001000
   RAML7       			: origin = 0x012000, length = 0x001000
   RAML8       			: origin = 0x013000, length = 0x001000
   USB_RAM     			: origin = 0x040000, length = 0x000800     /* USB RAM		  */
   FLASHB      			: origin = 0x3F0000, length = 0x004000     /* on-chip FLASH */
   CLA1_MSGRAMLOW       : origin = 0x001480, length = 0x000080
   CLA1_MSGRAMHIGH      : origin = 0x001500, length = 0x000080
}


SECTIONS
{

/* Setup for "boot to SARAM" mode:
      The codestart section (found in DSP28_CodeStartBranch.asm)
      re-directs execution to the start of user code.  */

	 ramfuncs            : LOAD = FLASHD,
                       RUN = RAML5,
                     LOAD_START(_RamfuncsLoadStart),
                   LOAD_END(_RamfuncsLoadEnd),
                 RUN_START(_RamfuncsRunStart),
			 LOAD_SIZE(_RamfuncsLoadSize),
           PAGE = 0

   .cinit              : > FLASHA,     PAGE = 0
   .pinit              : > FLASHA,     PAGE = 0
   .text               : > FLASHA,     PAGE = 0
   codestart           : > BEGIN,      PAGE = 0
    /* Allocate uninitialized data sections: */
   .stack              : > RAMM0M1,      PAGE = 0
   .ebss               : > RAML4,      PAGE = 1
   .esysmem            : > RAML4,     PAGE = 1
   .cio                : > RAML4,      PAGE = 1

   /* Initialized sections to go in Flash */
   /* For SDFlash to program these, they must be allocated to page 0 */
   .econst             : > FLASHA,     PAGE = 0
   .switch             : > FLASHA,     PAGE = 0

   .scratchpad      : > CLARAM0,   PAGE = 1
   .bss_cla		    : > CLARAM0,   PAGE = 1
   .const_cla	    : > CLARAM0,   PAGE = 1 
   
   IQmath           : > FLASHB,	   PAGE = 1
   IQmathTables     : > IQTABLES,  PAGE = 0, TYPE = NOLOAD
   //   CLA1fftTables    : > RAML3,                 PAGE = 1
   
   /* Allocate FPU math areas: */
   FPUmathTables    : > FPUTABLES, PAGE = 0, TYPE = NOLOAD
   RFFTdata1	           : > RAML6,      PAGE = 1
   RFFTdata2	           : > RAML7,      PAGE = 1
   RFFTdata3	           : > RAML8,      PAGE = 1
   RFFTdata4	           : > RAML5_2,      PAGE = 1



   Cla1Prog        : > RAML3,
                     LOAD_START(_Cla1funcsLoadStart),
                     LOAD_END(_Cla1funcsLoadEnd),
                     LOAD_SIZE(_Cla1funcsLoadSize),
                     RUN_START(_Cla1funcsRunStart),
                     PAGE = 0
   
   Cla1ToCpuMsgRAM  : > CLA1_MSGRAMLOW,   PAGE = 1
   CpuToCla1MsgRAM  : > CLA1_MSGRAMHIGH,  PAGE = 1
   Cla1DataRam0		: > CLARAM0,		  PAGE = 1
   Cla1DataRam1		: > CLARAM1,		  PAGE = 1
   Cla1DataRam2		: > CLARAM2,		  PAGE = 1

   CLA1mathTables	: > CLARAM1,
                      LOAD_START(_Cla1mathTablesLoadStart),
                      LOAD_END(_Cla1mathTablesLoadEnd), 
                      LOAD_SIZE(_Cla1mathTablesLoadSize),
                      RUN_START(_Cla1mathTablesRunStart),
                      PAGE = 1

   CLAscratch       : 
                     { *.obj(CLAscratch)
                     . += CLA_SCRATCHPAD_SIZE;
                     *.obj(CLAscratch_end) } > CLARAM0,
					 PAGE = 1
   .reset              : > RESET,      PAGE = 0, TYPE = DSECT
   vectors             : > VECTORS,    PAGE = 0, TYPE = DSECT


I am unable to find any Example code for implementing FFT on this MCU.
Kindly guide me whether it is acheivable or not.
Also please help identify the fault in above and how should i go about it.

I am measuring vibration of a engine using a ADXL359 accelerometer sensor.
As I am Sampling data at every 1 millisecond, i am using FFT 1024 point for higher accuracy.
But its taking a lot more time in computation

  • Hi Akshay,

    Since this is an older device, it doesn't have CLA FFT lookup tables programmed into the ROM like some newer devices do (for example the F2837xD etc.). You will have to instead load the FFT tables into Flash and copy them over to RAM. Also note that when copying it over to a section of RAM, it needs to be a section of RAM accessible by the CLA on the F2806x. This would include addresses in LSRAM1-LSRAM3.

    I will look into what needs to be done to port the library example over to the F2806x and get back to you in the next 1-2 days. For now, can you try looking through the below thread and see if this explanation helps? This thread refers to using the asin and acos math tables from the CLA math tables, but it should be a similar approach for the FFT functions.

    (+) CCS/TMS320F28069: Using Math Tables in CLA and FPU - C2000 microcontrollers forum - C2000Tm︎ microcontrollers - TI E2E support forums

    Another easier/quicker option would also be to switch to a newer device that has these CLA math tables programmed into ROM. Porting to those from the F2837xD would be much simpler, only a few lines in the projectspec file would need to change. Let me know if this would be a viable option for you.

    Best Regards,

    Delaney

  • Hi Delaney,
    Thanks for your Support.
    I will try and implement the earlier the solution. I tried implementing 1024 point FFT but it did not execute and caused a REBOOT of the MCU.
    Could it be cause of insufficient shared memory region.

    Also porting to another MCU option is not viable anymore as the product is already in development and on the last stage. Working on Optimizing the product.
    Hope to get that library example porting solution.

    Also how many point CLA FFT can this MCU support?

  • Hi Akshay,

    While I can't offer FFT example code specific to this device (as this goes beyond the scope of what we can support on E2E), my recommendations would be to do the following:

    1. Start with importing a F2806x CLA example, so that all of your CCS settings and paths are setup for the correct device and one of the CLA linker cmd files is used.
    2. Change/import the necessary source code files for your application.
    3. Import the cla_fft_tables.asm file into the CCS project. This file shows a representation of the data that is normally hardcoded into the ROM FFT tables for the newer devices (F2837xD and newer).
      1. This file can be found in the following path: [C2000ware install]\libraries\math\CLAmath\c28\source.
      2. In your case I believe you would also need to import the cla_cfft_1024.asm file from this folder since it defines the CLA_CFFT_run1024Pt(); function and the cla_cfft_unpack_512.asm since it defines the CLA_CFFT_unpack512Pt(); function you want to use in your .cla code.
    4. Add the below lines into the linker cmd file that will tell the linker where to put the CLA1fftTables. The picture below is where the tables are placed for the F2837xD library example when the hardcoded ROM tables aren't being used (if this is disabled by the preprocessor directive). Make sure to change the "RUN" memory to use LSRAM memory that the CLA has access to on the F2806x.

    Another thing to confirm is that the CLA program code and the FFT table will actually fit into the LSRAM1-3. If the FFT table combined with your CLA application code are too big to fit into the memory the CPU allocates for the CLA, it won't copy everything over correctly and you will run into issues.

    These should be the main configurations needed; however, I would also recommend going through the cla_cfft_1024 library example more in depth to see if any additional modifications need to be made. These files have detailed comments explaining the algorithm used.

    Best Regards,

    Delaney