Change the 0x32 in LSM303_ADDRESS_ACCEL to 0x30, rebuild and upload; then take a single sweep on the analyzer. The program attempts the read once a second, so the analyzer captures one within a second of being armed. Read the decoded row: what happened after the address byte?
If you finish early: explore what happens when you read a wrong register. Call lsm303_AccelRegisterRead(0x20) instead of reading the WHO_AM_I address. Predict first: will the transactions complete this time? What value comes back? Then capture it, and check the value you got against the LSM303AGR datasheet, §8.6 (CTRL_REG1_A).
One more prediction: suppose the program read register 0x0F from the display instead, at its address 0x70. Would the display acknowledge its address? And could the byte that comes back confirm that you reached the right device, the way 0x33 does for the accelerometer?
Figure12.2.23.The same read attempted at the wrong device address. One transaction: h18 WR goes out, no device answers, the acknowledge bit stays HIGH (the decoder prints NACK), and a STOP ends the transaction.
CoolTerm prints Could not connect to accelerometer once a second. After the NACK, i2c1_memRead() skips the read, so data keeps its starting value of 0, the WHO_AM_I check fails, and the loop carries on.
CoolTerm prints Could not connect to accelerometer once a second: after the NACK, i2c1_memRead() skips the read, data keeps its starting value of 0, and the loop carries on.
One transaction: h18 WR goes out, nothing pulls SDA LOW at the acknowledge bit, and a STOP, which the decoder labels Stop, ends it.
Figure12.2.25.The right device address, the wrong register address: reading register 0x20 instead of WHO_AM_I. Both transactions complete (every acknowledge the accelerometer owes is an ACK, and the read ends with the controller’s own NACK, exactly as the WHO_AM_I read did), and the value that comes back is h07: CTRL_REG1_A’s power-on default, 0b00000111 (LSM303AGR datasheet §8.6).
Figure12.2.26.The same wrong-register capture, close up: the write transaction delivering register address 0x20 (top), then the read transaction returning 0x07 (bottom).
Right device, wrong register: everything the accelerometer is asked to acknowledge, it acknowledges, and the value that comes back is h07, CTRL_REG1_A’s power-on default.