      }
  
    /* Loop until the transfer is complete. */
+@@ -1034,6 +1034,10 @@ static inline void stm32_i2c_sem_waitstop(FAR struct stm32_i2c_priv_s *priv)
+   start = clock_systimer();
+   do
+     {
++      /* Calculate the elapsed time */
++
++      elapsed = clock_systimer() - start;
++
+       /* Check for STOP condition */
+ 
+       cr = stm32_i2c_getreg32(priv, STM32_I2C_CR2_OFFSET);
+@@ -1050,9 +1054,6 @@ static inline void stm32_i2c_sem_waitstop(FAR struct stm32_i2c_priv_s *priv)
+           return;
+         }
+ 
+-      /* Calculate the elapsed time */
+-
+-      elapsed = clock_systimer() - start;
+     }
+ 
+   /* Loop until the stop is complete or a timeout occurs. */
 diff --git NuttX/nuttx/arch/arm/src/stm32l4/stm32l4_i2c.c NuttX/nuttx/arch/arm/src/stm32l4/stm32l4_i2c.c
-index eed199f..d5027bf 100644
+index eed199f..be46524 100644
 --- NuttX/nuttx/arch/arm/src/stm32l4/stm32l4_i2c.c
 +++ NuttX/nuttx/arch/arm/src/stm32l4/stm32l4_i2c.c
 @@ -4,7 +4,7 @@

     }
 
   /* Loop until the transfer is complete. */

     }
 
   /* Loop until the transfer is complete. */
@@ -729,6 +729,10 @@ static inline void stm32_i2c_sem_waitstop(FAR struct stm32_i2c_priv_s *priv)
   start = clock_systimer();
   do
     {
+      /* Calculate the elapsed time */
+
+      elapsed = clock_systimer() - start;
+
       /* Check for STOP condition */
 
       cr1 = stm32_i2c_getreg(priv, STM32_I2C_CR1_OFFSET);
@@ -744,10 +748,6 @@ static inline void stm32_i2c_sem_waitstop(FAR struct stm32_i2c_priv_s *priv)
         {
           return;
         }
-
-      /* Calculate the elapsed time */
-
-      elapsed = clock_systimer() - start;
     }
 
   /* Loop until the stop is complete or a timeout occurs. */
diff --git NuttX/nuttx/arch/arm/src/stm32/stm32_i2c_alt.c NuttX/nuttx/arch/arm/src/stm32/stm32_i2c_alt.c
index 545a647..981edb6 100644
--- NuttX/nuttx/arch/arm/src/stm32/stm32_i2c_alt.c
+++ NuttX/nuttx/arch/arm/src/stm32/stm32_i2c_alt.c
@@ -7,7 +7,7 @@
