Re: lpc2138 taking commands merely as a suggestion?
- From: "William Munns" <Will_Munns@xxxxxxxxx>
- Date: Tue, 31 Jul 2007 11:18:00 +0100
"kosta" <kostak@xxxxxxxxx> wrote in message
news:1185690759.615158.229930@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I compile the code with -O0 optimizations usually, but oddly enough
sometimes
when I try other types of optimization, some work better in making the
leds work
correctly.
It sounds like you are expecting your code to do what you write, in the
order you write it.
Consider the following code:
int i=10;
i++;
i=30;
return i;
assuming that i is kept in normal memory the compiler can see that the
intermediate results are not used, so this code will turn into:
set r0 to30;
branch exchange lr;
The compiler will do this wherever it can see that the results should not
change between source lines, but obviously this is not what you want when
manipulating system control registers that are not just memory.
There is a keyword in C: "volatile" which effectivly means "assume nothing
about memory thru this pointer" any writes will cause a write to the
location and any reads will cause a read from the location, the same code
with volatile would probebly turn into:
write 10 to location i;
read location i;
add one to read value;
store to location i;
store 30 to location i;
read location i into r0;
branch exchange lr;
you can see why the compiler does the optimizations!
I will be glad to provide any other information which might help
resolve this, I
just don't really know what might be needed - please tell me if theres
anything
else you need to know, and I will promptly provide the info.
the source code of your simpilest example might help
.
- References:
- lpc2138 taking commands merely as a suggestion?
- From: kosta
- lpc2138 taking commands merely as a suggestion?
- Prev by Date: How Multi-ICE Debug works?
- Previous by thread: lpc2138 taking commands merely as a suggestion?
- Next by thread: How Multi-ICE Debug works?
- Index(es):
Relevant Pages
|