2023-09-15 02:52 AM
Hello,
I am working on sensor fusion of LSM303AGR MEMS accelerometer, As a simple program to read acceleration values, I used the I2C read and write blocks, here is my step by step:
Initialize sensor: I2C write (0x32), write 0x57 on CTRL_REG1_A(0x20)
Read XYZ values: I2C read (0x33), read from 28, 29, 2A, 2B, 2C, 2D
however, on all displays I get only 00. and nothing else is happening when i move the board. I suspect, I might have an old version of the sensor where the address might be 0x19 for the acceleration sensor.
Is my methodology correct to work the sensor, or are there extra steps involved in initialization or does my returned data need to be multiplied with sensitivty?
I have another project in keil mdk where i added the ACC_I2C_ADDRESS to the watch window in debug mode to check if i am using the correct I2C address, but it does not display any value rather throws an error 'cannot evaluate'
Could anyone help?
2023-09-15 03:16 AM - edited 2023-09-15 03:17 AM
Hello @sanathhere
I suggest you to use this drive to communicate with your LSM303AGR. If not, you can use the same configuration (adress, commands ,....)as in this drive .
Best regards.
II
2023-09-15 03:41 AM
@Issamos In Keil MDK, I am infact using the STM provided example which uses these files for the sensor, what i am trying to do is use this example and get the I2C address to verify if I am infact using the correct addresses in my simulink code. Do you know how I can check that? I have read posts about who am i addresses to confirm which version you have is one of the methodologies, but my WHO_AM_I variable cannot be read in watch window, is there another way?
Thank you for replying