Hello friends
I have encountered a very strange problem, I have keil with MDK3.08a version. When i compiled program and loaded in the target the execution speed of the program becomes considerably slower (not in debug mode). I have compared the speed with the previous version of keil (i don't remember may be 3.20).
Furthermore when i interchange the location of C file in the work space it effects the execution speed. When I compared the output hex file of the same project with interchanged c files position in work space, i found they were different.
Please help me out of this
You seem to have only compared old/new compiler.
It is expected that you will get big differences when switching compiler or compiler settings. That is why a delay using a C loop should not make use of a loop variable, but should repeat until a hw timer has ticked far enough.
But your claim seem to be that you can have a 10x speed difference for the same compiler by just changing order of the source files.
Have you produced any disassembly of the loop when switching location too? And have you checked if the processor have multiple code regions or if it has any execution cache that is only available for a limited range of the flash? Or are you running in RAM, and may get one of the loops in a RAM region where you also run heavy DMA transfers?
Again, the whole point of any High-Level Language (HLL) is that you do not have control of the generated machine code - you delegate that task to the compiler.
Since you do not have control of the generated machine code, you do not have control of its execution speed!
Since you do not have control of the execution speed, you must not rely upon the execution timing in any way!
If you really do need to rely upon the execution timing, then you really must write it in assembler; or use some means that does not rely upon the execution timing - such as a hardware timer.