Post Go back to editing

ADXL367设置FIFO采样长度后,使用轮询方式1s读取一次(非中断),但和预期的不一致

Thread Summary

The user is experiencing an issue with the ADXL367 FIFO in stream mode, where 513 data entries are read instead of the expected 64. The final answer clarifies that FIFO_SAMPLES does not control the FIFO depth but only the watermark interrupt threshold. To achieve the desired functionality, the user should read only the first 64 data entries from the FIFO, ignoring older data.
AI Generated Content
Category: Datasheet/Specs
Product Number: ADXL367

I use the FIFO of ADXL367 and set it to stream mode, hoping to save 64 sets of X, Y, and Z-axis data with a sampling frequency of 400Hz. I poll the FIFO data every 1 second (without using interrupts), but I always find 513 data entries when reading the FIFO, which is inconsistent with the manual description. How should I configure it to achieve my desired functionality?

我使用ADXL367的FIFO,并设置为流模式;采样频率为400Hz,FIFO长度设置为64;我每隔1s轮询读取FIFO中的数据(不使用中断) ,但是我发现FIFO中总是513、512条数据,不是我预期的64个数据;有什么方式可以实现我的功能吗?

this is my code 

uint16_t adx1367_get_fifo_xyz(uint16_t *buff)
{
uint8_t data_buff[512 * 2] = {0};
uint16_t fifo_entries = 0;
uint8_t reg_val[2] = {0};

adxl367_get_register_value(&reg_val[0], ADXL367_REG_STATUS, 1);
if(reg_val[0] & 1 << 2){
adxl367_get_register_value(reg_val, ADXL367_REG_FIFO_ENTRIES_L, 2);
fifo_entries = ((reg_val[1] & 0x03) << 8) | reg_val[0];
if((0 == fifo_entries)){
return 0;
}

adxl367_get_register_value(data_buff, ADXL367_REG_I2C_FIFO_DATA, fifo_entries);
fifo_entries = (fifo_entries > SAMPLE_DEFAULT_AXI_HZ*6 ? SAMPLE_DEFAULT_AXI_HZ*6:fifo_entries);
for(int index = 0; index < fifo_entries; index++){
buff[index] = (data_buff[index * 2] << 6) + (data_buff[index*2 + 1] >> 2);
}
return fifo_entries;
}

return 0;
}

void adxl367_fifo_setup(void)
{
sample_mode_info_t *p_sample = NULL;
uint8_t reg_value = 0;

p_sample = sample_config_get();

// Set fifo stream mode
adxl367_get_register_value(&reg_value, ADXL367_REG_FIFO_CONTROL, 1);
reg_value &= ~(3);
reg_value |= ADXL367_STREAM_MODE;

// Set fifo sample x,y,z
reg_value &= ~(0x0F << 3);

// set fifo sample 64/1
reg_value &= ~(1 << 2);
adxl367_set_register_value(reg_value, ADXL367_REG_FIFO_CONTROL);


// set fifo sample 64/1
reg_value = 0;
adxl367_get_register_value(&reg_value, ADXL367_REG_FIFO_SAMPLES, 1);
reg_value = p_sample->sample_axi_hz;
adxl367_set_register_value(reg_value, ADXL367_REG_FIFO_SAMPLES);
}

Parents
  • 1、FIFO_SAMPLES并不代表FIFO中的数据长度,FIFO_SAMPLES不是FIFO深度,只和触发FIFO watermark中断时所对应的数据个数有关

    2、即使把FIFO_SAMPLES设置成64,在读取时FIFO也不可能只有FIFO_SAMPLES*3组数据

    3、根据您的应用,只需要每次读取前FIFO_SAMPLES个数据即可,FIFO中老的数据可以不管

Reply
  • 1、FIFO_SAMPLES并不代表FIFO中的数据长度,FIFO_SAMPLES不是FIFO深度,只和触发FIFO watermark中断时所对应的数据个数有关

    2、即使把FIFO_SAMPLES设置成64,在读取时FIFO也不可能只有FIFO_SAMPLES*3组数据

    3、根据您的应用,只需要每次读取前FIFO_SAMPLES个数据即可,FIFO中老的数据可以不管

Children