4 years, 3 months ago.  This question has been closed. Reason: Duplicate question

ADXL345 FIFO 3200 samples per second issue

Hello,

I would like to achieve 3200 samples using ADxl345 interfacing STM32L073 with frequency 32 MHz using SPI communication running at 5 MHz (Highest Frequency). Normally i am using USART2 with 115200 baud to communicate with device so that whenever I send command to ON and OFF Adxl sensor and its data rate setting are written through my protocol. Until 1600 Hz it works perfectly all right no issue with communication (serial com provides response from device). As per the System Frequency is 32000000 i.e HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); which means time between interrupt generation is 1/32000 = 0.03125 msec. Every interrupt generated @ 0.03125 Msec. Now coming to ADXL 345 sensor 3200 samples per second for 1 sample to achieve is 0.3125 msec every interrupt executes. My question is that as per the system frequency it is good enough to achieve 3200 samples per second but I could not get any response after initialization the command to start adxl sensor with 3200 samples. It never comes out of the loop to execute the statement so no response is produced in turn. I would like to attach code snippets. Kindly help me if i would like to acheive 3200 samples per second.

ADXL data read with Interrupt

if( flag_ADXL_Update)
{
  _DRDY.disable_irq();
																			
  //_accelerometer.setInterruptEnableControl(0x00);
  do{
																						
    _accelerometer.getOutput(ADXL_Readings);
																						
    fwrite((char*)ADXL_Readings,sizeof(int16_t),3,logFile);
																						
}while(_accelerometer.getInterruptSource() & 0x80);
																			
flag_ADXL_Update = 0;
																			//_accelerometer.setInterruptEnableControl(0x80);
_DRDY.enable_irq();
}  

ADXL data Update Interrupt Routine

_DRDY.rise(callback(this,&ADXL_dataupdate));

ADXL Update data flag

void ADXL_dataupdate(void)
{
        flag_ADXL_Update = 1;
}