Keil Logo

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;
}
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.