 | C251 User's Guide |  |
|
|
| NVM_CONST Compiler Directive| Abbreviation | NVMC | | Arguments | None. | | Default | The compiler assumes that const variables never change the value. | | µVision | Options — C251 Compiler — Misc Controls. | | Description | The NVM_CONST directive causes that variables automatically are mapped to const volatile. All accesses to variables are therefore executed and the compiler no longer assumes that the value of a const variable is actually a constant. This directive is useful when you are using in-system Flash programming as it is typically for EEPROM memory. | | Example |
#pragma NVM_CONST // re-load const variables on each access
extern void isp_program (void);
int prog (void) {
unsigned char chk;
const unsigned char far v = 1;
chk = v; // store 'v' for verification
isp_program ();
if (chk != v) { // reload 'v' even when 'const'
return -1;
}
return 0;
}
|
|
|