diff options
author | Marti Bolivar <mbolivar@mit.edu> | 2010-11-28 11:23:33 -0500 |
---|---|---|
committer | Marti Bolivar <mbolivar@mit.edu> | 2010-11-28 11:23:33 -0500 |
commit | d9cbd78e29d42e70bb46641dd43ee0772c8c975f (patch) | |
tree | 80a67cba4468dbcd89b3cd23ad56695b1f146c66 /source/arduino/volatile.rst | |
parent | 546b34076d230b617ba86defb6b90cd934b01878 (diff) | |
download | librambutan-d9cbd78e29d42e70bb46641dd43ee0772c8c975f.tar.gz librambutan-d9cbd78e29d42e70bb46641dd43ee0772c8c975f.zip |
reorganized all the arduino/ docs into a lang/ subdirectory since
they're properly CC attributed now.
Diffstat (limited to 'source/arduino/volatile.rst')
-rw-r--r-- | source/arduino/volatile.rst | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/source/arduino/volatile.rst b/source/arduino/volatile.rst deleted file mode 100644 index fc02081..0000000 --- a/source/arduino/volatile.rst +++ /dev/null @@ -1,73 +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>`_ - - - - -.. include:: cc-attribution.txt |