- make it volatile : i can't store a volatile in banked memory (R/W needed)
Why not?
Volatile means that accessing the variable has side effects, so the compiler has to perform every access and is not allowed to optimize them away. That is completely independent of const. const means it cannot be written. A variable can be const and volatile at once, for example a read only real time counter could be declared naturally as volatile const.
- update the compiler (realy update or buy a new one ?)
Well, could be buy one. But I don't know the details there.
- change the code... could you explain me I try to declare with extern but it do the same (i think i haven't understood)
If the compiler does not see the actual initialization value when it compiles the code, it wont do any constant folding.
e.g.
a.h:
#pragma CONST_SEG __PPAGE_SEG CONST_USER
extern const int tada0;
#pragma CONST_SEG DEFAULT
a.c:
#include "a.h"
#pragma CONST_SEG __PPAGE_SEG CONST_USER
const int tada0=0x12345;
#pragma CONST_SEG DEFAULT
b.c:
#include "a.h"
int useTada(void) {
return tada0;
}
Actually it's sufficient if the compiler definition of the code using the constant is before the definition of the constant (but after a declaration of the constant, of course), it can be in the same file. I did just split the parts up into several files to be even more explicit.
Daniel