External read not working

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

External read not working

1,323 Views
NZ_Design
Contributor I
I have a periperal decleared called pGraphicCTRL.
 
Writing data to this address works fine.
 
but I wont to do this.
 
pGraphicCTRL = pGraphicCTRL | Graphic_CD
 
This should generate a read and then a write on the data bus. I only get a write.
 
if I change it to
 
cControl = pGraphicCTRL;
pGraphicCTRL = cControl | Graphic_CD;
 
I still only get a write and if I step though the code the cControl = pGraphicCTRL line is not compiled in.
 
Why?
 
Is this a optimizer thing if so its great job but not this time. What if my signal lines are different.
 
How do I get around it.
 
Can I turn the optimizer off?
 
Daniel
Labels (1)
0 Kudos
Reply
1 Reply

316 Views
CrasyCat
Specialist III
Hello
 
Did you define and declare pGraphicCTRL as volatile?
This is the only way you can tell the compiler it should not optimize away memory access to
the variable.
 
volatile is recommended for all variables, which may change asynchronously from the normal execution flow (i.e. I/O ports, global variables modified in an interrupt functions, global variables modified in different tasks when you are running a multi-tasking application).
 
CrasyCat
0 Kudos
Reply