MPL3115A2 data ready interrupt issue

cancel
Showing results for 
Search instead for 
Did you mean: 

MPL3115A2 data ready interrupt issue

Jump to solution
297 Views
paolog
Contributor III

Hi everyone.

I have an issue with the interrupt generated by the sensor on data ready. Once in a while the interrupt is not generated, so the new reading from the sensor doesn't take place.

I followed some code samples, but still the interrupt is unreliable. Here are parts of my code:

Initialization

IIC_RegWrite(SlaveAddressIIC, CTRL_REG1, 0x04);
//delay
...
IIC_RegWrite(SlaveAddressIIC, CTRL_REG1, 0x80 | 0x18); // ALT_BIT, OSR8
IIC_RegWrite(SlaveAddressIIC, CTRL_REG2, 0x00);    
// Enable interrupt INT1 for data ready
IIC_RegWrite(SlaveAddressIIC, CTRL_REG3, 0x00); // Push/pull, active low
// INT_EN_DRDY_BIT is not enough to generate interrupt,
// INT_EN_PCHG_BIT must be also set
IIC_RegWrite(SlaveAddressIIC, CTRL_REG4, 0x80 | 0x02); // INT_EN_DRDY_BIT | INT_EN_PCHG_BIT
IIC_RegWrite(SlaveAddressIIC, CTRL_REG5, 0x80 | 0x02); // INT_EN_DRDY_BIT | INT_EN_PCHG_BIT - Interrupt su INT1
// DREM_BIT is not enough to generate interrupt,
// PDEFE_BIT must be also set
IIC_RegWrite(SlaveAddressIIC, PT_DATA_CFG_REG, 0x04 |0x02); // DREM_BIT | PDEFE_BIT

Start pressure acquisition 

// Enable data ready interrupt on GPIO pin
...
// Set OST
IIC_RegWrite(SlaveAddressIIC, CTRL_REG1, ALT_BIT | OSR_8 | OST_BIT);

ISR code clears MCU interrupt flag and sets a variable checked by main loop, where pressure reading is made as follows:

IIC_RegReadN(SlaveAddressIIC, 0x00, 5, (unsigned char *)mybuff);
// Convert readings
...

 

Data analyzer shows the correct communication between the MCU and sensor, with interrupt being generated and pressure reading performed. But once in a while the interrupt signal doesn't follow the request.

Any idea about the reason why this is happening? I'm currently using polling, but I would like to switch to a interrupt driven reading to reduce power consumption.

0 Kudos
1 Solution
292 Views
JozefKozon
NXP TechSupport
NXP TechSupport

Hi Paolog,

please test an MPL3115A2 code attached, my colleague had created few years ago. It might help you to solve the issue.

With Best Regards,

Jozef

View solution in original post

0 Kudos
2 Replies
293 Views
JozefKozon
NXP TechSupport
NXP TechSupport

Hi Paolog,

please test an MPL3115A2 code attached, my colleague had created few years ago. It might help you to solve the issue.

With Best Regards,

Jozef

View solution in original post

0 Kudos
286 Views
paolog
Contributor III

Hi Jozef, thank you for sharing the code.

I did some changes and the interrupt seems to be working fine now. This are the changes I did to my code:

1. Setting register PT_DATA_CFG_REG to 0x07 instead of 0x06 (all three bits DREM_BIT,  PDEFE_BIT and TDEFE_BIT are set, while I didn't set TDEFE_BIT), and moved the instruction before setting any of the other registers

2. Setting CTRL_REG4 and CTRL_REG5 to 0x80 instead of 0x82 (INT_EN_DRDY_BIT only, while I also set INT_EN_PCHG_BIT as it seemed like the interrupt wouldn't trigger without it)

I think that moving the instruction to set PT_DATA_CFG_REG in first place is the key, but well, code seems to be working fine and the analyzer always shows the interrupt now.

Thank you again.

Paolo

0 Kudos