Tool/software: Code Composer Studio
Hi,
I find that the execution time of same function are obvious difference when call from different files. Why? Is it alright?
Description,
Condition: CCS6.0; TMS320F28335/TMS320LF2407
I want to test the arithmetic speed of TMS320F28335, so i make a simple function to run. But There are different execution time when calling the same function between main.c and other file(non-main.c)
A) The function is defined in the main.c, and the execution time is 1.6us.
B) The function is defined in the sub_program.c, and the execution time is 3.6us.
It's the same stuation when I test the TMS320LF2407.
A)
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#include "DSP28335_ex.h"
#include "para_space.h"
#include "myinclude.h"
void sub_program3(void)
{
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
///////////////////////////////////////////////////////////////////////////////////
}
void main(void)
{
InitSysCtrl(); //PLL, WatchDog,Clocks
InitXintf16Gpio(); // configuer IO ,need revise
DINT; // Disable CPU interrupts
InitPieCtrl(); // Disable PIE interrupts,clear all PIE interrupt flags:
IER = 0x0000;
IFR = 0x0000; // Disable CPU interrupts and clear all CPU interrupt flags:
InitPieVectTable(); //Initialize the PIE vector table,open PIE interrupt
configtestled(); // configuer IO ,need revise
LED1=1;
//DELAY_time(10);
LED1=1; LED2=1; LED3=0; LED4=0;
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
InitFlash();
//DELAY_US(1)=10.5us
while(1)
{ //示波器测试IO周期,用于测试CPU速度
//调用子程序sub_program();sub_program3();两个程序相同,但是放的位置不一样
// 同样的程序代码,为什么调用sub_program();与sub_program3()比较;速度慢了很多?
LED3=~LED3; //IO口电平
sub_program(); //test deley time 3.6us 子程序
//sub_program3(); ////test deley time 1.6us
}
}
B)
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#include "DSP28335_ex.h"
#include "para_define.h"
#include "myinclude.h"
///*
void sub_program()
{
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
temp1=0;temp2=0;temp3=0;temp4=0;temp5=0;temp1=1;temp2=1;temp3=1;temp4=1;temp5=1;
//////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
}