Keil Logo



Is there any way to totally disable optimizing? I need to do 2 consecutive reads of an external unsigned byte pointer. Instead of reading it the second time, the compiler just gives me the value from the first read. I tried setting optimizer to zero, but it didn't change.


Multiple accesses to the same external variable may require that the variable is declared as volatile. This will force the compiler to access the variable the second time. Variables are declared this way as follows:

volatile unsigned char variable;

For more information, refer to the volatile keyword in Kernighan & Ritchie's "The C Programming Language". Also, refer to the ABSACC.H header file in the \C51\INC directory for an example of absolute memory access macros.

Last Reviewed: Wednesday, November 7, 2001

Did this article provide the answer you needed?
Not Sure
  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.