aboutsummaryrefslogtreecommitdiffstats
path: root/docs/source/arduino/volatile.rst
diff options
context:
space:
mode:
authorPerry Hung <iperry@gmail.com>2011-01-24 23:23:29 -0500
committerPerry Hung <iperry@gmail.com>2011-01-24 23:23:29 -0500
commitc48689d34809943a5907884bd287cea9ae275352 (patch)
treed49ff06b0d4b81f6ab0eac8060d178ce7542476c /docs/source/arduino/volatile.rst
parent64431fd4b59cb8656365f1fad5f679cd4d756239 (diff)
parenta9b2d70bc7799ca96c1673b18fe3012b1a4dd329 (diff)
downloadlibrambutan-c48689d34809943a5907884bd287cea9ae275352.tar.gz
librambutan-c48689d34809943a5907884bd287cea9ae275352.zip
Merge remote branch 'leaf/master'
Diffstat (limited to 'docs/source/arduino/volatile.rst')
-rw-r--r--docs/source/arduino/volatile.rst70
1 files changed, 0 insertions, 70 deletions
diff --git a/docs/source/arduino/volatile.rst b/docs/source/arduino/volatile.rst
deleted file mode 100644
index 4212ac5..0000000
--- a/docs/source/arduino/volatile.rst
+++ /dev/null
@@ -1,70 +0,0 @@
-.. _arduino-volatile:
-
-volatile keyword
-================
-
-volatile is a keyword known as a variable *qualifier*, it is
-usually used before the datatype of a variable, to modify the way
-in which the compiler and subsequent program treats the variable.
-
-
-
-Declaring a variable volatile is a directive to the compiler. The
-compiler is software which translates your C/C++ code into the
-machine code, which are the real instructions for the Atmega chip
-in the Arduino.
-
-
-
-Specifically, it directs the compiler to load the variable from RAM
-and not from a storage register, which is a temporary memory
-location where program variables are stored and manipulated. Under
-certain conditions, the value for a variable stored in registers
-can be inaccurate.
-
-
-
-A variable should be declared volatile whenever its value can be
-changed by something beyond the control of the code section in
-which it appears, such as a concurrently executing thread. In the
-Arduino, the only place that this is likely to occur is in sections
-of code associated with interrupts, called an interrupt service
-routine.
-
-
-
-Example
--------
-
-::
-
- // toggles LED when interrupt pin changes state
-
- int pin = 13;
- volatile int state = LOW;
-
- void setup()
- {
- pinMode(pin, OUTPUT);
- attachInterrupt(0, blink, CHANGE);
- }
-
- void loop()
- {
- digitalWrite(pin, state);
- }
-
- void blink()
- {
- state = !state;
- }
-
-
-
-See also
---------
-
-
-- `AttachInterrupt <http://arduino.cc/en/Reference/AttachInterrupt>`_
-
-