top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

When should the volatile and dregister modifier be used

+6 votes
154 views
When should the volatile and dregister modifier be used
posted Dec 3, 2013 by Prachi Agarwal

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button
dregister or register, please clarify?

3 Answers

+3 votes

volatile qualifier always a good idea when reading or writing hardware registers, because it ensures that each access you perform in your C code actually shows up in the generated code.

Usually prefer to write macros like this

#define READ_LCDCW1() ...  
#define WRITE_LCDCW1(value) ...

LCDCW1 i Some registers require a multi-step process to read from the hardware.
the simplest definitions should be:

#define LCDCW1_ADDR 0xc000  
#define READ_LCDCW1()  (*(volatile uint32_t *)LCDCW1_ADDR)
#define WRITE_LCDCW1(val)   ((*(volatile uint32_t *)LCDCW1_ADDR) = (val))
answer Dec 3, 2013 by Giri Prasad
+1 vote

The volatile modifier is a directive to the compiler’s optimizer that operations involving this variable should not be optimized in certain ways. There are two special cases in which use of the volatile modifier is desirable. The first case involves memory-mapped hardware (a device such as a graphics adaptor that appears to the computer’s hardware as if it were part of the computer’s memory), and the second involves shared memory (memory used by two or more programs running simultaneously).

answer Dec 3, 2013 by Salil Agrawal
+1 vote

The volatile modifier is a directive to the compiler’s optimizer that operations involving this variable should not be optimized in certain ways. There are two special cases in which use of the volatile modifier is desirable. The first case involves memory-mapped hardware (a device such as a graphics adaptor that appears to the computer’s hardware as if it were part of the computer’s memory), and the second involves shared memory (memory used by two or more programs running simultaneously).

The register modifier hints to the compiler that the variable will be heavily used and should be kept in the CPU’s registers, if possible, so that it can be accessed faster.

answer Dec 4, 2013 by Neeraj Pandey
Similar Questions
+3 votes

Suppose I have two eNBs, configured as S1 intra-frequency neighbours and my UE is attached to one of them. There is no X2 connection present between them.
Now, I have done admin down to the source eNB. So, HO process is triggered. As a consequence of this, source eNB sends HO required message to MME.

My query is, in this HO required message, what should be the value of ac-BarringFactor??
Should it be P00 or the last value set before admin down(e.g., P95)?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...