External read not working

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

External read not working

1,322件の閲覧回数
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 返信

315件の閲覧回数
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 件の賞賛
返信