This are some of my const agreements. It works.
#define Clock (32768*1275) const unsigned int Mem_size[8] = { 32, 320, 3200, 3200, 3200, 3200, 3200, 3200 }; // Delay-time * Clock * 1024 / 10 / Mem_size[0~7] const unsigned int Multiplicator[8] = { 0.0001 * Clock * 1024 / 10 / 32, 0.001 * Clock * 1024 / 10 / 320, 0.01 * Clock * 1024 / 10 / 3200, 0.1 * Clock * 1024 / 10 / 3200, 1.0 * Clock * 1024 / 10 / 3200, 10.0 * Clock * 1024 / 10 / 3200, 100.0 * Clock * 1024 / 10 / 3200, 1000.0 * Clock * 1024 / 10 / 3200 };
But one const can not refer to another const. For example i can not replace the number 3200 by Mem_size[2]. Why not? Is there a work around?
Sincerly yours
xxx, For your own good, try to refrain from using floating point numbers...
0.0001 * Clock * 1024 / 10 / 32
can become
Clock * 1024 / 10 / 32 / 10000
That will save you code size and processing time.
That will save you code size and processing time. I can not agree with your opinion. In my opinion const values are computed by the compiler at compiling time. The values are not computed by the uC at run time.
I didn't notice a significant increase of code because of my loquacious const declaration. But maybe i didn't payed enough attention to that?
In this case, the compiler will do the evaluation, so it will not affect any code size. Even in expressions in executable statements, the compiler will pre-compute constant expressions. This normally happens even if optimization is turned off.
View all questions in Keil forum