2018-08-31 04:35 AM
Dear community
I'm using the LIS2DW12 accelerometer with 800Hz ODR in continuous mode. I've set the fifo watermark threshold to 25 samples and enabled the watermark interrupt on INT1-pin. I read the data from the fifo inside an interrupt-routine on a STM32 microcontroller.
The application works and the data can be read correctly. So far so good...
Sometimes there is a second (unexpected) interrupt event generated by the sensor, right after the "normal" interrupt was set low again.
Here a screenshot from the oscilloscope on the INT1-Pin of the accelerometer:
This second pulse causes the microcontroller to enter the interrupt-routine again, although there shouldn't be new data available after this short time.
Many thanks for your answers!
Best regards,
Silas
2018-08-31 05:47 AM
Can you please share your sensor configuration?
I guess it can happen when you read a one sample and then the sensor will put one sample to the FIFO and reach again FIFO watermark.
2018-08-31 06:58 AM
Hello Miroslav
This is the configuration code of the sensor:
// Configure power mode
lis2dw12_power_mode_set(LIS2DW12Handler, LIS2DW12_HIGH_PERFORMANCE);
// Enable Block Data Update
lis2dw12_block_data_update_set(LIS2DW12Handler, PROPERTY_ENABLE);
// Set full scale
lis2dw12_full_scale_set(LIS2DW12Handler, LIS2DW12_16g);
// Set output data rate
lis2dw12_data_rate_set(LIS2DW12Handler, LIS2DW12_XL_ODR_800Hz);
// Set mode
lis2dw12_fifo_mode_set(LIS2DW12Handler, LIS2DW12_STREAM_MODE);
// Set fifo threshold
lis2dw12_fifo_watermark_set(LIS2DW12Handler, (25- 1));
// Auto-Increment memory address in sensor (for continuous data reading)
lis2dw12_auto_increment_set(LIS2DW12Handler, PROPERTY_ENABLE);
// Set interrupt settings
lis2dw12_int_notification_set(LIS2DW12Handler, LIS2DW12_INT_PULSED);
lis2dw12_pin_mode_set(LIS2DW12Handler, LIS2DW12_PUSH_PULL);
lis2dw12_pin_polarity_set(LIS2DW12Handler, LIS2DW12_ACTIVE_HIGH);
lis2dw12_ctrl4_int1_pad_ctrl_t RegisterValue;
RegisterValue.int1_fth = PROPERTY_ENABLE;
lis2dw12_pin_int1_route_set(LIS2DW12Handler, &RegisterValue);
And the readout code in the interrupt routine looks like this (there are always 25 samples read together):
// Read sensor data
HAL_GPIO_WritePin(LIS2DW12_SPI_CS_GPIO_Port, LIS2DW12_SPI_CS_Pin, GPIO_PIN_RESET);
uint8_t Register = LIS2DW12_OUT_X_L;
Register |= 0x80;
if(HAL_SPI_TransmitReceive_DMA(SensorHandler->SPIHandler, &Register,
(uint8_t *)TempSensorDataBuffer, 25 * 6) != HAL_OK)
{
sensor_error(SensorHandler);
}
2018-09-03 07:25 AM
The configuration seems OK to me.
Can you please capture also the SPI communication, or at least the SPI clock, so we can see the correlation between interrupt and SPI read transaction. If the second interrupt will be at the beginning of the data read, than my idea is correct (so the simple solution could be ignore all interrupts until you read all 25 samples from FIFO).