Hi everyone,
I'm trying to get the LIS2DH12 driver (SDK v15.0.0) to configure a LIS2DH12 sensor connected to my nRF52 Dev Kit.
I've wired the chip up as follows (using the I2C interface)
nRF52 -> chip
P0.26 -> SDA
P0.27 -> SCL
GND -> GND
VDD -> VDD, VDD_IO, CS, SDO
I've managed to read out the WHO_AM_I register using the driver and poll some samples. The samples do change when I drop my hand on the table on which the sensor is placed.
Now I'm trying to configure the FIFO and an interrupt (for now FIFO watermark) using this function:
#define TWI_INSTANCE_ID 0
#define MAX_PENDING_TRANSACTIONS 33
#define LIS2DH12_MIN_QUEUE_SIZE 32
NRF_TWI_MNGR_DEF(m_nrf_twi_mngr, MAX_PENDING_TRANSACTIONS, TWI_INSTANCE_ID);
NRF_TWI_SENSOR_DEF(m_nrf_twi_sensor, &m_nrf_twi_mngr, LIS2DH12_MIN_QUEUE_SIZE);
LIS2DH12_INSTANCE_DEF(m_lis2dh12, &m_nrf_twi_sensor, LIS2DH12_BASE_ADDRESS_HIGH);
...
/**
* initialize and configure LIS2DH12 sensor
*/
void acc_init()
{
ret_code_t err_code;
nrf_drv_twi_config_t const config = {
.scl = 27,
.sda = 26,
.frequency = NRF_DRV_TWI_FREQ_100K,
.interrupt_priority = APP_IRQ_PRIORITY_LOWEST,
.clear_bus_init = false
};
err_code = nrf_twi_mngr_init(&m_nrf_twi_mngr, &config);
APP_ERROR_CHECK(err_code);
err_code = nrf_twi_sensor_init(&m_nrf_twi_sensor);
APP_ERROR_CHECK(err_code);
// FIFO configuration
LIS2DH12_FIFO_CFG(m_lis2dh12, true, LIS2DH12_FIFO, false, 16);
// data acquisition configuration
LIS2DH12_DATA_CFG(m_lis2dh12, LIS2DH12_ODR_1HZ, false, true, true, true, LIS2DH12_SCALE_2G, false);
// interrupt configuration
LIS2DH12_INT1_PIN_CFG(m_lis2dh12, false, true, false, false, false, true, false, false);
err_code = lis2dh12_init(&m_lis2dh12);
APP_ERROR_CHECK(err_code);
err_code = lis2dh12_who_am_i_read(&m_lis2dh12, print_register, &m_data);
APP_ERROR_CHECK(err_code);
//LIS2DH12_INT1_CFG(m_lis2dh12, 100, 1, false, true, false, false, false, false, false, false, false);
//err_code = lis2dh12_cfg_commit(&m_lis2dh12);
//APP_ERROR_CHECK(err_code);
}
However I didn't manage to detect any interrupt (even with a oscilloscope) so far and the FIFO seems to be stuck at 32 available values while polling does not change the corresponding register value.
I am at a loss here - from what I've read in the LIS2DH12 data sheet and driver code, the driver seems to do the interfacing with the chip right. I'm suspecting a wrong order in my configuration function or wrong configuration parameters.
Any pointers on what I am doing wrong?