Hello,
Basically I can communicate with MPL3115A2 pressure sensor but the result is useless.
I have impression that whenever I try to read a value from any register it always returns me value of the STATUS register.
I followed Quick start setup (chapter 12).
screenshot 1: In the beginning I tried to perform software reset 0x26, 0x04. Why the last byte wasn't acknowledged?
screenshot 2: I set the oversampling in CTRL_REG1 (0x26, 0x38) and this time everything was acknowledged.
screenshot 3: In PT_DATA_CFG (0x13, 0x07) flags were set.
screenshot 4: Set active (0x26, 0x39).
screenshot 5: Read CTRL_REG1. 0xEE??? Is it STATUS?
screenshot 6: Read WHO_AM_I. 0xEE??? Is it STATUS?
No mater what register I read from, I always get same response.
If in step 3 I set 0x13, 0x02 (PT_DATA_CFG) then I always read 0x44.
Hi Tomas,
I experience the same issue, however as I'm using the factory I2C HAL drivers (provided by ST Cube MX IDE) - I'm not sure how I can change the behaviour.
Would you have an advice in this situation where/how I can reconfigure the drivers?
I'm using a Blackpill, with STM32F411.
Here is a code snippet:
HAL_I2C_Master_Transmit(&hi2c2, barometerAddW, ®, 1, 100);
HAL_I2C_Master_Receive(&hi2c2, barometerAddR, &dataOut, 1, 100);
dataOut is always 0xEE
Many thanks!
Balazs
Hi Maciej,
After reviewing your I2C traffic, I guess the problem is that you are sending the stop condition (a LOW to HIGH transition of SDA while SCL is HIGH) after the second byte instead of sending the repeated start condition. So try to modify your source code so that SDA transitiones to HIGH before the SCL goes HIGH in order to eliminate the stop condition.
Here is an example of a single byte read from the WHO_AM_I register (0x0C). As you can see, it returns the correct device ID 0xC4.
I hope it helps!
Best regards,
Tomas
Hi Tomas,
You're right, it is all about repeated start. This is what I suspected before but didn't do anything to change it. By the way, it is is my first experience with I2C. Previously I used two HAL functions (STM32L4) to write and read instead of one which is hal_i2c_mem_read.
Thanks for your help!