diff --git a/src/shared/i2c/stm32f2_f4_i2c.cpp b/src/shared/i2c/stm32f2_f4_i2c.cpp
index 1382a370879daf4ddbf4134183ab4d84a35a2bb8..617305301ed30199a06c9ef12b5d58cadc724f4a 100644
--- a/src/shared/i2c/stm32f2_f4_i2c.cpp
+++ b/src/shared/i2c/stm32f2_f4_i2c.cpp
@@ -33,8 +33,8 @@
 
 using namespace miosix;
 
-static bool error;        ///< Set to true by IRQ on error
-static Thread *waiting=0; ///< Thread waiting for an operation to complete
+static volatile bool error; ///< Set to true by IRQ on error
+static Thread *waiting=0;   ///< Thread waiting for an operation to complete
 
 /* In non-DMA mode the variables below are used to
  * handle the reception of 2 or more bytes through