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.

[TMS320F28335] Calculation Time Consumption of Multiplication Division and Square-root functions

Hi,

 

I'm curious about the time it takes to do simple calculations such as multiplication and division.

 

I'm aware that using the square root function by including  <math.h> is possible. If so, how could you estimate the time it takes for the calculation to be completed?

 

Is there any documentation related to the above? I would like to know the exact or approximate number of CPU clocks it takes for the functions to take place.

 

Thanks in advance.

  • Jay Lee said:

    I'm curious about the time it takes to do simple calculations such as multiplication and division.

    Look at the fast RTS library below for benchmarks on the number of cycles for division.

     

    Jay Lee said:

    I'm aware that using the square root function by including  <math.h> is possible. If so, how could you estimate the time it takes for the calculation to be completed?

    Take a look at the fast RTS library for square root, etc.  There are some benchmark numbers in the documentation of this download.

    http://www.ti.com/lit/zip/SPRC664

  • HI,

    I want to calculate the duration of computation time of my program to know (what_time() )

    Is there any clock () function?

    Thank you

  • Hi,

    I want to calculate the time duration..

    I used Timer0 and the delay routine..  I configure the timer 0 to interrup after 1ms to compare : 


    //###########################################################################
    #include "DSP2833x_Device.h"
    #include <stdio.h>

    // Prototype statements for functions found within this file.
    void Gpio_select(void);
    void InitSystem(void);
    void delay_loop(long);

    //External functions
    extern void InitSysCtrl(void);
    extern void InitPieCtrl(void);
    extern void InitPieVectTable(void);
    extern void InitCpuTimers(void);
    extern void ConfigCpuTimer(struct CPUTIMER_VARS *, float, float);
    //Interrupt ISR
    interrupt void cpu_timer0_isr (void);

    //###########################################################################

    // main code
    //###########################################################################
    void main(void)
    {
    int counter=0; // binary counter for digital output
    int time;
    InitSysCtrl(); // Basic Core Init from DSP2833x_SysCtrl.c

    EALLOW;
    SysCtrlRegs.WDCR= 0x00AF; // Re-enable the watchdog
    EDIS; // 0x00AF to NOT disable the Watchdog, Prescaler = 64

    DINT; // Disable all interrupts

    Gpio_select(); // GPIO9,GPIO11,GPIO34 and GPIO49 as output (LEDs @ peripheral explorer)

    InitPieCtrl();

    InitPieVectTable();

    EALLOW;
    PieVectTable.TINT0 = &cpu_timer0_isr;
    EDIS;

    InitCpuTimers();

    ConfigCpuTimer(&CpuTimer0, 150, 1000);

    PieCtrlRegs.PIEIER1.bit.INTx7 = 1;

    IER |= 1;

    EINT;
    ERTM;

    //while(1)
    {
    counter++;
    if(counter&1) GpioDataRegs.GPASET.bit.GPIO9 = 1;
    else GpioDataRegs.GPACLEAR.bit.GPIO9 = 1;
    if(counter&2) GpioDataRegs.GPASET.bit.GPIO11 = 1;
    else GpioDataRegs.GPACLEAR.bit.GPIO11 = 1;
    if(counter&4) GpioDataRegs.GPBSET.bit.GPIO34 = 1;
    else GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1;
    if(counter&8) GpioDataRegs.GPBSET.bit.GPIO49 = 1;
    else GpioDataRegs.GPBCLEAR.bit.GPIO49 = 1;

    CpuTimer0Regs.TCR.bit.TSS = 0; // start timer0

    delay_loop(1000000);

    EALLOW;
    SysCtrlRegs.WDKEY = 0x55; // service WD #1
    EDIS;

    time = CpuTimer0.InterruptCount *  1000 ;   // 1000 µs
    CpuTimer0.InterruptCount = 0;

    printf("%d = ", time);

    }
    }

    void Gpio_select(void)
    {
    EALLOW;
    GpioCtrlRegs.GPAMUX1.all = 0; // GPIO15 ... GPIO0 = General Puropse I/O
    GpioCtrlRegs.GPAMUX2.all = 0; // GPIO31 ... GPIO16 = General Purpose I/O
    GpioCtrlRegs.GPBMUX1.all = 0; // GPIO47 ... GPIO32 = General Purpose I/O
    GpioCtrlRegs.GPBMUX2.all = 0; // GPIO63 ... GPIO48 = General Purpose I/O
    GpioCtrlRegs.GPCMUX1.all = 0; // GPIO79 ... GPIO64 = General Purpose I/O
    GpioCtrlRegs.GPCMUX2.all = 0; // GPIO87 ... GPIO80 = General Purpose I/O

    GpioCtrlRegs.GPADIR.all = 0;
    GpioCtrlRegs.GPADIR.bit.GPIO9 = 1; // peripheral explorer: LED LD1 at GPIO9
    GpioCtrlRegs.GPADIR.bit.GPIO11 = 1; // peripheral explorer: LED LD2 at GPIO11

    GpioCtrlRegs.GPBDIR.all = 0; // GPIO63-32 as inputs
    GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; // peripheral explorer: LED LD3 at GPIO34
    GpioCtrlRegs.GPBDIR.bit.GPIO49 = 1; // peripheral explorer: LED LD4 at GPIO49
    GpioCtrlRegs.GPCDIR.all = 0; // GPIO87-64 as inputs
    EDIS;
    }

    interrupt void cpu_timer0_isr(void)
    {
    CpuTimer0.InterruptCount++;

    EALLOW;
    SysCtrlRegs.WDKEY = 0xAA; // service WD #2
    EDIS;
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    }
    void delay_loop(long end)
    {
    long i;
    for (i = 0; i < end; i++)
    {
    asm(" NOP");
    EALLOW;
    SysCtrlRegs.WDKEY = 0x55;
    SysCtrlRegs.WDKEY = 0xAA;
    EDIS;
    }
    }
    //===========================================================================
    // End of SourceCode.
    //===========================================================================

    The result of the time = 173 !!

    Any solution ?!

    Thank you