2018-01-10 01:32 AM
I am trying to interface LIS2DH12 with NRF51822 chip using SPI communication no matter in what way i configure my spi, it is always returning fixed values 0x80,0x40,0xc0 in all six registers for x,y,z co-ordinate.
I am not using FIFO but trying directly to read from register is it right way or should i choose FIFO mode.
thanks in advance.
2018-01-10 01:48 AM
To check your SPI communication first try to read who_am_i (0x0F) register, if it works then try to write a value to a register and read it back.
If this works, please share you sensor configuration and I can check it.
2018-01-10 02:00 AM
Thanks for your attention and I am able to read value 0x33 from WHO_M_I register as well as able to write and read from any register.
This are my MEMS configuration function:
void MCAL_MEMS_Init()
{
int i; /* MEMS Configuration Register */LIS2DH12_Write( LIS2DH12_REG_CTRL_REG1,0x77);
for(i=0;i<100;i++);LIS2DH12_Write( LIS2DH12_REG_CTRL_REG2,0x00); for(i=0;i<100;i++);LIS2DH12_Write( LIS2DH12_REG_CTRL_REG4,0x00); for(i=0;i<100;i++);LIS2DH12_Write( LIS2DH12_REG_CTRL_REG5,0x00); for(i=0;i<100;i++);LIS2DH12_Write( FIFO_CTRL_REG ,0x00); for(i=0;i<100;i++);LIS2DH12_Write( TEMP_CFG_REG ,0x00); for(i=0;i<100;i++); LIS2DH12_Write( INT1_CFG ,0x00); for(i=0;i<100;i++);}Please suggest me if i am doing anything wrong in configuring MEMS registers.
2018-01-10 03:26 AM
You configuration is correct, only set the CTRL_REG1 is enough to make the sensor work, other registers are in default value.
Are you sure you you are reading the correct output registers. You wrote that you read 3 values (0x80, 0x40, 0xC0) in all six registers, it doesn't make much sense. What are the values in all six registers? Are they stable?
2018-01-10 07:45 PM
Thanks for your attention again and for testing purpose if i check only one register suppose OUT_X_L or any other it will return those values(0x80,0x40,0xc0) which is not right i guess, i am suppose to get variable and not fix values in these registers on movement of the sensor.
What could be the possible reason if u can tell.
2018-01-11 01:20 AM
Unfortunately, your explanation is not clear. I think, the sensors works, you only misinterpret the results.
Please read all six output registers (during movement or in different sensor position) and share the values, I can then check it.
2023-09-16 12:06 PM
I had the same issue using I2C - the XYZ values received by reading 6 bytes in one go were as Neha Tawale described. In my case the solution was to enable automatic incrementation of the address register by adding 0x80 to the address value.