Hi,
In my C code, I need to assign a lot of values. Like this: a1,a2,... are variables as char. v1,v2...,w1,w2...y1,y2 are constant (like 0x00, 0x01, ...etc)
if (i==0){ a1 = v1; a2 = v2; ... a50=v50; } else if (i==2){ a1 = w1; a2 = w2; ... a50=w50; } else if (i==3){ a1 = y1; a2 = y2; ... a50=y50; } else { }
I would like to minimize the code memory usage as possible. Which coding style or method is suggested to implement it ? Should I declare "array" or use " #define " ? Please kindly provide suggestions. Thanks a lot!
"needs to choose one group to assign the constant values"
Does it really need to assign all the individual values?
Can't you just have a pointer and set that to point to the appropriate set of constants?
How about maybe respond with some answer to: "Another thing - should you really assign 50 values? Or have change one pointer to point to a struct/array containing the specific set of 50 values? Is it real variable variables or do you use them as constants, where it would be possible to have them stored in code memory?"
There are no reason to waste RAM if we are talking about constants.