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.