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.

create a look-up table for sine-wave

Other Parts Discussed in Thread: TMS320F28035

Hi,

Could anyone give me some suggestions on how to create and import a look-up table for a sine-wave in a TMS320F28035 application.

I've tried the sine-table from IQmath library, but it has 512 entries for each period. I need more entries in my project. Can I modify the IQmath library? or Should I use Matlab to generate the table then import?

I really need some advice.

Thank you,

Frank

  • Hi Frank,

    You can not modify IQmath  library because the look-up for this library is in the processor Boot ROM. You can use an array of the constants or may be it is more useful for you to use a floating point sin function from the standard math library. 

  • Hi Roman,

    I am wondering what the negative consequence is if I use a floating point sin function on a fixed-point micro-controller.

    What should I be aware of ?

    Thank you,

    Frank

  • Hardware floating point undoubtedly faster but in some cases using software floating point is also possible. For example if your sin function is not fast changed you will not need to calculate it frequently and may be it is not a bad idea for your application. On the contrary, in case your sin function is likely to be changed every ADC interrupt you  better should  use the look-up table and may be you even need to place this table to the RAM for the better performance. 

    You can place look-up table in your program like this

    int MySIN[]={

    0,

    ... ,

    ... ,

    ... ,

    };

    but I am not sure  if compiler place this array to the ROM or RAM. 

    Also you can create executable code directly from the Matlab.  

  • HI

    Roman Ermakov said:
    but I am not sure  if compiler place this array to the ROM or RAM.

    since this is a global array in your program it will be in your RAM and moreover you can force it to any section of RAM by using the #PRAGMA DATA_SECTION(SYMBOL_NAME, SECTION_NAME) directive.

     

    Best Regards

    Santosh

  • Thank you guys for your help.

    Frank

  • Santosh,

    what is the best way to place  this array in flash?

    Regards,

    Roman 

     

  • Hi Roman,

    this is explained more clearly in your device/compilers assembler reference guide or compilers reference guide, but a quick example is as below.

    declare the array as, in your C file: for ex:

    #PRAGMA DATA_SECTION(array, "SECTION_NAME_FLASH_SECTION");

    unsigned long array[32] = {1, 2,....32}

     

    in your linker command file

    in the memory directive:

    MEMORY

    {

    PAGE0 :

             ...

            ....

         ARRAY_MEM_INFLASH    :origin = $give_start_address, legth = $give_length_here

    ......

    }

    SECTIONS

    {

         ......

        ......

       SECTION_NAME_FLASH_SECTION  : load = ARRAY_MEM_INFLASH, PAGE = 0, ALIGN(2)

    ...

    ...

    }

     

  • Thank you for your answer.

    Regards,

    Roman