External read not working

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

External read not working

1,629 次查看
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
标签 (1)
0 项奖励
回复
1 回复

622 次查看
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 项奖励
回复