ARM Technical Support Knowledge Articles

DISABLING THE OPTIMIZER (FOR VOLATILE VARIABLES)

Applies to: General Topics

Answer

QUESTION

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.

ANSWER

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 C51INC directory for an example of absolute memory access macros.

Article last edited on: 2001-11-07 00:00:00

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential