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;
}
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.