01-03-2020 09:35 AM
hello,
01-03-2020 03:39 PM
Hi mariswamy,
Given that the values are not changing, there is a possibility that the oversampling settings are not written into the sensor. This could happen if the I2C write function is not implemented properly. Can you share your implementation of the write function?
01-07-2020 11:26 AM
Hi,
Please find the I2C write function below, nrf_drv_twi_tx API generated by nordic semiconductor, but these drivers already used for Accelerometer and gyroscope there it is working fine.
int8_t BEM280_I2C_Write(uint8_t dev_id, uint8_t reg_addr, uint8_t *data, uint16_t len)
{
if( nrf_drv_twi_tx(&m_twi, BME280_I2C_ADDR_PRIM, ®_addr, 1, 1) == NRF_SUCCESS )
{
if(nrf_drv_twi_tx(&m_twi, BME280_I2C_ADDR_PRIM, data, len, 1) == NRF_SUCCESS )
{
return 0;
}
return 1;
}
else
{
return 1;
}
}
here,
m_twi :- I2C Instance
reg_addr:- Location Address where we are writing
data:- actual data (like sensor settings etc)
len:- number of bytes (data length)
1:- no stop
thanks & regards,
Swamy M.
01-08-2020 09:58 AM
Hi mariswamy,
It is recommended to complete it register address and data write in a single transaction. Assuming that setting the last parameter of the function nrf_drv_twi_tx to 1 allows for a single write sequence, the second call of the function nrf_drv_twi_tx to write the data should have the last parameter set to 0 to complete the transaction. If this doesn't work, then you may have to create a single array of len+1 and copy the register address and data accordingly.