cancel
Showing results for 
Search instead for 
Did you mean: 

LSM303AGR temperature sensor returns the same value every time [LO: 0x00 HI: 0x81]

Max Payne
Associate

Hello, ST community!

Recently I got a custom board from my customer to help with creating the lsm303agr driver.

What I'm struggling with is the temperature sensor reading. No matter what I do, the sensor returns 0x0 0x81

Here is a dump from lsm303agr ACC registers prior to reading sensor data.

# Log format: [%register_address%] -> %register_value%
 
acc: [0x7] -> 0xff
acc: [0xf] -> 0x33
acc: [0x1f] -> 0xc0
acc: [0x20] -> 0x47
acc: [0x21] -> 0x0
acc: [0x22] -> 0x0
acc: [0x23] -> 0x90
acc: [0x24] -> 0x0
acc: [0x25] -> 0x0
acc: [0x27] -> 0xff
acc: [0x3e] -> 0x0
acc: [0x3f] -> 0x0
acc: [0x25] -> 0x0

So three requirements are met, according to log:

  1. TEMP_CFG_REG_A (0x1f) register bits are set (check: 0xc0 != 0)
  2. CTRL_REG4_A (0x23) BDU bit (0x80) is set (check: 0x90 | 0x80 != 0)
  3. Both registers are read in the same time.

Here is a code of getting sensor data (for clarity):

while (1) {
                delay_ms(1000);
                uint8_t buf[6];
 
                /* Burst read function: 1 argument is a device, 
                 * second is a register address, 3rd and 4th - buffer and its size 
                 */
                lsm303agr_burst_read(SELECTOR_ACC, 0x0C, buf, 2);
                printf("--> %#x %#x\r\n", buf[0], buf[1]);
 
                /* For convinience, I'm also printing ACC data */
                lsm303agr_burst_read(SELECTOR_ACC, REG_OUT_X_L_A, buf, 6);
                printf("--> %#x %#x; %#x %#x; %#x %#x\r\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
}

This is the output of that code:

--> 0x0 0x81
--> 0x80 0xff; 0x0 0xff; 0xc0 0x1e
--> 0x0 0x81
--> 0xc0 0xff; 0xc0 0xfe; 0xc0 0x1f
--> 0x0 0x81
--> 0x40 0x0; 0x80 0xfe; 0xc0 0x1e
--> 0x0 0x81
--> 0x0 0x0; 0x0 0xff; 0x80 0x1e
 
# ...and so on

As you may see, accelerometer data is read correctly, but temperature - isn't.

Could you please guide me what might be wrong here?

Regards,

Max

0 REPLIES 0