I use MPL3115A2 (M3PR YI0C) to measure temperature, pressure and elevation. Periodically change the mode of the altimeter to barometer mode and Vice versa. I ran into the following problem: After some time of operation, the STATUS register (0x00) stops updating and becomes always equal to 0x00. Registers the altitude/pressure and temperature (0x01 - 0x05) are set to zero. While reading the configuration registers shows that MPL3115A2 configured true.
Here is an example of registers in a single measurement prior to the crash:
STATUS: 0x0e
OUT P_MSB: 0x61
OUT_P_CSB: 0xa0
OUT_P_LSB: 0xd0
OUT_T_MSB: 0x1a
OUT_T_LSB: 0x50
SYSMOD: 0x01
INT_SOURCE: 0x00
PT_DATA_CFG: 0x07
CTRL_REG1: 0x39
CTRL_REG2: 0x00
CTRL_REG3: 0x00
CTRL_REG4: 0x00
CTRL_REG5: 0x00
Here is the first failed measurement:
STATUS: 0x00
OUT P_MSB: 0x61
OUT_P_CSB: 0xa0
OUT_P_LSB: 0xd0
OUT_T_MSB: 0x1a
OUT_T_LSB: 0x50
SYSMOD: 0x01
INT_SOURCE: 0x00
PT_DATA_CFG: 0x07
CTRL_REG1: 0x39
CTRL_REG2: 0x00
CTRL_REG3: 0x00
CTRL_REG4: 0x00
CTRL_REG5: 0x00
Here are 10 unsuccessful measurement (with attempt to switch mode):
STATUS: 0x00
OUT P_MSB: 0x00
OUT_P_CSB: 0x00
OUT_P_LSB: 0x00
OUT_T_MSB: 0x00
OUT_T_LSB: 0x00
SYSMOD: 0x01
INT_SOURCE: 0x00
PT_DATA_CFG: 0x07
CTRL_REG1: 0xb9
CTRL_REG2: 0x00
CTRL_REG3: 0x00
CTRL_REG4: 0x00
CTRL_REG5: 0x00
The problem appears both when using the interrupt, and when using polling. The only way to MPL3115A2 return to normal operation is a software reboot. What could be the problem?
(Sorry for translate)
We also encountered this issue. After extensive testing, we didn't manage to resolve it, but we found a work around. It was to "software reset" (Search for RST in datasheet) the device in the initialise routine.
mpl3115a2_write(MPL3115A2_CTRL_REG1,0b00000100);
Hope this helps.
TrackerSense Support
Hi Alexander,
I checked your source code and I didn't see anything that could cause the problem you are mentioning.
Can I asked if you found the source of your problem? If you did, can you share it, please?
If not, please let me know if there are further details from the mentioned in the community.
Regards,
Jose
Thanks Alexander for sharing,
I have taken a quick look on your source code. I did not spot any specific problem. If I have time, I'll check that in detail. If anybody has the answer, do not hesitate to reply.
Thanks,
Anthony
Hi Alexander,
I'm not sure to answer the question but did you put the MPL3115A2 to Standby mode before switching the mode? It could be a problem.
Can you share with us your code? I'd like to check your configuration.
Thanks
Anthony
Hi Anthony!
Thanks for answer!
I use my own driver for MPL3115A2. The driver source code in attachment.
And so I use it:
//
// ...
//
mpl3115a2_init( &mpl3115a2 );
mpl3115a2_set_pwrmode( &mpl3115a2, MPL3115A2_PWRMODE_STANDBY );
mpl3115a2_set_ready_mode(
&mpl3115a2,
MPL3115A2_READY_MODE_POLLING );
mpl3115a2_set_mode(
&mpl3115a2,
MPL3115A2_MODE_ALTIMETER,
MPL3115A2_OSR_128 );
mpl3115a2_set_pt(
&mpl3115a2,
MPL3115A2_PT_DREM |
MPL3115A2_PT_PDEFE |
MPL3115A2_PT_TDEFE );
mpl3115a2_set_pwrmode( &mpl3115a2, MPL3115A2_PWRMODE_ACTIVE );
//
// ...
//
while ( 1 ) {
//
// ...
//
dev_res = mpl3115a2_update( &mpl3115a2 );
dev_res = mpl3115a2_get_h( &mpl3115a2, &data->alt, NULL );
dev_res = mpl3115a2_get_t( &mpl3115a2, &data->temp, &data->temp_l );
dev_res = mpl3115a2_get_p( &mpl3115a2, &data->ph, &data->pl );
//
// ...
//
// (In timer-counter value of 'mode_change' increment)
if ( mode_change >= 50 ) {
if ( mpl3115a2.mode == MPL3115A2_MODE_ALTIMETER ) {
mpl3115a2_set_pwrmode( &mpl3115a2, MPL3115A2_PWRMODE_STANDBY );
mpl3115a2_set_mode( &mpl3115a2, MPL3115A2_MODE_BAROMETER, MPL3115A2_OSR_128 );
mpl3115a2_set_pwrmode( &mpl3115a2, MPL3115A2_PWRMODE_ACTIVE );
}
else {
mpl3115a2_set_pwrmode( &mpl3115a2, MPL3115A2_PWRMODE_STANDBY );
mpl3115a2_set_mode( &mpl3115a2, MPL3115A2_MODE_ALTIMETER, MPL3115A2_OSR_128 );
mpl3115a2_set_pwrmode( &mpl3115a2, MPL3115A2_PWRMODE_ACTIVE );
}
mode_change = 0;
}
//
// ...
//
// And sleep at 1 - 2 sec...
//
//...
//Restore after fail
#if MPL3115A2_DEBUG
if ( mpl3115a2_get_fail_count( &mpl3115a2 ) > 11 ) {
mpl3115a2_reset( &mpl3115a2 );
mpl3115a2_set_pt(
&mpl3115a2,
MPL3115A2_PT_DREM |
MPL3115A2_PT_PDEFE |
MPL3115A2_PT_TDEFE );
mpl3115a2_set_pwrmode( &mpl3115a2, MPL3115A2_PWRMODE_ACTIVE );
mpl3115a2_fail_count_clear( &mpl3115a2 );
}
#endif
}