--- In [email protected], "Sharma, Hans Raj \(London\)"
<hansraj_sha...@...> wrote:
>
> Can someone please help me understand how can I write a program which,
> using volatile variable, access some memory mapped devices?
If you have an 8 bit register at address 0x1234 containing an unsigned 8 bit
value, then you might do something like:
volatile unsigned char *const reg = 0x1234;
printf("reg = %u\n", *reg);
It might work without the volatile, but the volatile tells the compiler that
the contents of the register might change outside of the thread's control eg.
because another thread is modifying it. Thus it shouldn't do any optimizations
which assume its value is constant between accesses.