diff --git a/src/shared/sensors/LSM9DS1/LSM9DS1_AxelGyro.h b/src/shared/sensors/LSM9DS1/LSM9DS1_AxelGyro.h
index 652f982a920b1677a49810ababaed2502efda7ea..d1b0ffab235c4b9f6371f87e20392e2c31310221 100644
--- a/src/shared/sensors/LSM9DS1/LSM9DS1_AxelGyro.h
+++ b/src/shared/sensors/LSM9DS1/LSM9DS1_AxelGyro.h
@@ -268,18 +268,18 @@ class LSM9DS1_XLG : public GyroSensor, public AccelSensor, public TemperatureSen
                 mLastTemp =  tempZero + (temp / tempSensistivity); //25°C + TEMP*S devo castare a float "temp"?
             }
             else{ //if FIFO enabled: do not store temperature, it can be read using "temperatureUpdate()" function at low sampling frequency
-                uint8_t buf[384]; //2 bytes per data * 3 axes * 2 (axel+gyro) * 32(FIFO DEPTH) = 384 samples 
+                uint8_t buf[384]; //2 bytes per data * 3 axes * 2 (axel+gyro) * 32(FIFO DEPTH MAX) = 384 samples 
                 {
                     SPITransaction spi(spislave);
                     //read FIFO status and dump all the samples inside the FIFO
-                    uint8_t fifo_src = spi.read(FIFO_SRC);
-                    fifo_samples = fifo_src & 0x3F;
+                    //uint8_t fifo_src = spi.read(FIFO_SRC);
+                    //fifo_samples = fifo_src & 0x3F;
                     //sanity check
-                    if(fifo_samples > 32)
+                    /*if(fifo_samples > 32)
                     {
                         fifo_samples = 32;
-                    }
-                    spi.read(OUT_X_L_G, buf, fifo_samples*12); //format: gxl,gxh,gyl,gyh,gzl,gzh,axl,axh,ayl,ayh,azl,azh for each sample
+                    }*/
+                    spi.read(OUT_X_L_G, buf, fifo_watermark*12); //format: gxl,gxh,gyl,gyh,gzl,gzh,axl,axh,ayl,ayh,azl,azh for each sample
                 }
                 //convert & store
                 for(int i=0; i<fifo_samples; i++ )
diff --git a/src/tests/drivers/test-lsm9ds1-fifo.cpp b/src/tests/drivers/test-lsm9ds1-fifo.cpp
index 0f08af6acc92715dce5a525ed31f5630ec7b75b3..5ed77b7f9877b91d5cf1c5bd2f285028a48a915f 100644
--- a/src/tests/drivers/test-lsm9ds1-fifo.cpp
+++ b/src/tests/drivers/test-lsm9ds1-fifo.cpp
@@ -22,111 +22,129 @@
  * THE SOFTWARE.
  */
 
+#include <array>
+#include <iostream>
 #include "drivers/HardwareTimer.h"
 #include "drivers/spi/SPIDriver.h"
 #include "sensors/LSM9DS1/LSM9DS1_AxelGyro.h"
-#include <array>
 
 using namespace miosix;
 using namespace std;
 
-typedef Gpio<GPIOA_BASE, 5> GpioSck; //questi sono i pin SPI per f407_discovery
+typedef Gpio<GPIOA_BASE, 5> GpioSck;  // questi sono i pin SPI per
+                                      // f407_discovery
 typedef Gpio<GPIOA_BASE, 6> GpioMiso;
 typedef Gpio<GPIOA_BASE, 7> GpioMosi;
 
-typedef Gpio<GPIOB_BASE, 1> GpioINT1;
+typedef Gpio<GPIOA_BASE, 1> GpioINT1;
 
-static const bool FIFO_ENABLED = true;
+static const bool FIFO_ENABLED      = true;
 static const uint8_t FIFO_WATERMARK = 12;
+static const uint8_t FIFO_SAMPLES   = 5;
 
-//SPI
+// SPI
 SPIBus bus(SPI1);
 GpioPin cs_XLG(GPIOE_BASE, 7);
 
-//LED just for init 
+// LED just for init
 GpioPin LED1(GPIOD_BASE, 15);
 
-//SPI read flag 
-bool flagSPIReadRequest = false;
+// SPI read flag
+volatile bool flagSPIReadRequest = false;
 
-//High Resolution hardware timer using TIM5
+// High Resolution hardware timer using TIM5
 HardwareTimer<uint32_t> hrclock{
     TIM5, TimerUtils::getPrescalerInputFrequency(TimerUtils::InputClock::APB1)};
 
-//Last interrupt tick & delta
+// Last interrupt tick & delta
 volatile uint32_t last_tick;
-volatile uint32_t delta; 
+volatile uint32_t delta;
+
+//LSM9DS1 obj
+LSM9DS1_XLG* lsm9ds1 = nullptr; 
 
-//Interrupt handlers
+// Interrupt handlers
 void __attribute__((naked)) EXTI1_IRQHandler()
 {
     saveContext();
     asm volatile("bl _Z20EXTI1_IRQHandlerImplv");
-    restoreContext(); 
+    restoreContext();
 }
 
 void __attribute__((used)) EXTI1_IRQHandlerImpl()
-{   
-    //Computing delta beetween interrupts 
+{
+    // Computing delta beetween interrupts
     uint32_t tick = hrclock.tick();
-    delta = tick - last_tick;
-    last_tick = tick; 
+    delta         = tick - last_tick;
+    last_tick     = tick;
 
-    //Set read flag
+    // Set read flag
     flagSPIReadRequest = true;
 
-    //Clear pending interrupt register
-    EXTI->PR |= EXTI_PR_PR1;
-
-    //Built-in LED on
-    LED1.high(); 
+    // Built-in LED on
+    LED1.high();
 
+    // Clear pending interrupt register
+    EXTI->PR |= EXTI_PR_PR1;
 }
 
 void gpioConfig();
 void timer5Config();
-void EXTI1Config(); 
+void EXTI1Config();
+
+int main()
+{
 
-int main(){
+    uint8_t fifo_counter = 0;
+    uint32_t dt[FIFO_SAMPLES];
+    //array<Vec3, 32> axelData[FIFO_SAMPLES], gyroData[FIFO_SAMPLES];
 
     gpioConfig();
+
+    
+    Thread::sleep(4000);
+    LED1.low();
+
     timer5Config();
     EXTI1Config();
 
-    LSM9DS1_XLG lsm9ds1(
-                    bus,
-                    cs_XLG,
-                    LSM9DS1_XLG::AxelFSR::FS_8,
-                    LSM9DS1_XLG::GyroFSR::FS_245,
-                    LSM9DS1_XLG::ODR::ODR_15,
-                    FIFO_ENABLED,
-                    FIFO_WATERMARK);
-
-    while(!lsm9ds1.init());
+    std::cout << "Before allocation" << std::endl; //FA ANCORA STACK OVERFLOW DOPO QUI GRRRR
     
-    long long reset_tick = getTick();
+    lsm9ds1 = new LSM9DS1_XLG(bus, cs_XLG, LSM9DS1_XLG::AxelFSR::FS_8,
+                        LSM9DS1_XLG::GyroFSR::FS_245, LSM9DS1_XLG::ODR::ODR_15,
+                        FIFO_ENABLED, FIFO_WATERMARK);
+
+    std::cout << "After allocation" << std::endl;
+
+    while (!lsm9ds1->init());
 
-    while(1)
+    lsm9ds1->clearFIFO();
+
+    for (;;)
     {
-        if(flagSPIReadRequest)
+        if (flagSPIReadRequest && fifo_counter < FIFO_SAMPLES)
         {
-            flagSPIReadRequest = false; 
-            Thread::sleep(500);
+            flagSPIReadRequest = false;
+            dt[fifo_counter]   = delta;
+            lsm9ds1->onSimpleUpdate();
+            //axelData[fifo_counter] = lsm9ds1->getAxelFIFO();
+            //gyroData[fifo_counter] = lsm9ds1->getGyroFIFO();
             LED1.low();
-            Thread::sleep(500);
-            lsm9ds1.clearFIFO(); //to reset interrupt 
-            printf("interrupt occured...\n");
+            fifo_counter++;
         }
 
-        if(getTick() - reset_tick > 10000) //every 10 sec Clear FIFO
-        {   
-            printf("Resetting ... \n");
-            reset_tick = getTick();
-            lsm9ds1.clearFIFO();
+        if (fifo_counter == FIFO_SAMPLES)
+        {
+            break;
         }
     }
 
-    return 0; 
+    for (uint8_t i = 0; i < FIFO_SAMPLES; i++)
+    {
+        std::cout << dt[i] << std::endl;
+    }
+
+    return 0;
 }
 
 void gpioConfig()
@@ -134,66 +152,65 @@ void gpioConfig()
     {
         FastInterruptDisableLock dLock;
 
-        //Enable SPI1 Peripheral 
+        // Enable SPI1 Peripheral
         RCC->APB2ENR |= RCC_APB2ENR_SPI1EN;
 
-        //Select GPIO mode (ALTERNATE 5 for SPI1 on PA5, PA6, PA7)    
+        // Select GPIO mode (ALTERNATE 5 for SPI1 on PA5, PA6, PA7)
         GpioSck::mode(Mode::ALTERNATE);
         GpioMiso::mode(Mode::ALTERNATE);
         GpioMosi::mode(Mode::ALTERNATE);
 
-
         GpioSck::alternateFunction(5);
         GpioMiso::alternateFunction(5);
         GpioMosi::alternateFunction(5);
 
-        //Select Speed for clk (needs precision)
+        // Select Speed for clk (needs precision)
         GpioSck::speed(Speed::_25MHz);
 
-        //Select GPIO mode for Chip Select    
+        // Select GPIO mode for Chip Select
         cs_XLG.mode(Mode::OUTPUT);
 
-        //Select GPIO mode for INTERRUPT (PULL-DOWN because there's no pull-down in HW)
+        // Select GPIO mode for INTERRUPT (PULL-DOWN because there's no
+        // pull-down in HW)
         GpioINT1::mode(Mode::INPUT_PULL_DOWN);
 
-        //Select LED built in GPIO mode
+        // Select LED built in GPIO mode
         LED1.mode(Mode::OUTPUT);
     }
 
     cs_XLG.high();
-
 }
 
 void timer5Config()
 {
     {
         FastInterruptDisableLock dl;
-        //Enable high resolution TIM5
+        // Enable high resolution TIM5
         RCC->APB1ENR |= RCC_APB1ENR_TIM5EN;
     }
 }
 
-void EXTI1Config()
-{   
-    //Enable SYSCFG for setting interrupts 
+void EXTI1Config() //PC13
+{
+    // Enable SYSCFG for setting interrupts
     {
         FastInterruptDisableLock dl;
-        RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN; 
-    }   
+        RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;
+    }
 
-    //Configure mask bit of 1st interrupt line
-    EXTI->IMR  |= EXTI_IMR_MR1;
+    // Configure mask bit of 1st interrupt line
+    EXTI->IMR |= EXTI_IMR_MR1;
 
-    //Configure trigger selection bit (rising edge)
+    // Configure trigger selection bit (rising edge)
     EXTI->RTSR |= EXTI_RTSR_TR1;
 
-    //Clear pending interrupt register before enable
+    // Clear pending interrupt register before enable
     EXTI->PR |= EXTI_PR_PR1;
 
-    //Select PB1 as interrupt source in line 1 
-    SYSCFG->EXTICR[0] &= 0xFFFFFF1F;
+    // Select PB1 as interrupt source in line 1
+    SYSCFG->EXTICR[0] &= 0xFFFFFF0F;
 
-    //Enable the interrupt in the interrupt controller 
+    // Enable the interrupt in the interrupt controller
     NVIC_EnableIRQ(EXTI1_IRQn);
     NVIC_SetPriority(EXTI1_IRQn, 14);
-} 
\ No newline at end of file
+}
\ No newline at end of file