diff --git a/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c
index 017ae5cf3fa4dae496a8605e7875ca0da9a14bc2..fad33ba8f4df30272c8b28bf5986a86d8613f0e9 100644
--- a/cores/arduino/WInterrupts.c
+++ b/cores/arduino/WInterrupts.c
@@ -106,12 +106,13 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
     // Look for right CONFIG register to be addressed
     if (in > EXTERNAL_INT_7) {
       config = 1;
+      pos = (in - 8) << 2;
     } else {
       config = 0;
+      pos = in << 2;
     }
 
     // Configure the interrupt mode
-    pos = (in - (8 * config)) << 2;
     EIC->CONFIG[config].reg &=~ (EIC_CONFIG_SENSE0_Msk << pos); // Reset sense mode, important when changing trigger mode during runtime
     switch (mode)
     {