Seems that MPL3115A2 always returns value of STATUS register

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Seems that MPL3115A2 always returns value of STATUS register

896 Views
maciej_wujciow
Contributor II

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.

4 Replies

410 Views
marcell06
Contributor I

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, &reg, 1, 100);
HAL_I2C_Master_Receive(&hi2c2, barometerAddR, &dataOut, 1, 100);

dataOut is always 0xEE

 

Many thanks!

Balazs

0 Kudos

752 Views
maciej_wujciow
Contributor II

MAP001.BMPMAP002.BMPMAP003.BMPMAP004.BMPMAP005.BMPMAP006.BMP

0 Kudos

752 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

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.

I2C+Read.JPG (1).jpg

I hope it helps!

Best regards,

Tomas

752 Views
maciej_wujciow
Contributor II

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!

0 Kudos