Hi there,
I have a low power custom project utilising the TMAG5273 for sensing an open/close function.
The device is configured for Y-axis only, operates in W&S mode and initiates an interrupt on the INT pin when the magnetic field threshold is crossed. The configuration is set to use the absolute field strength so that it will work with both north and south poles. Once the threshold is crossed we read the field value and, once sufficiently high (or low), we swap the threshold detection direction so we can interrupt on the opposite threshold transition. (Note that reading the field value is to provide wider hysteresis for the transition than is provided by just a single threshold value.)
Once the transition takes place we update the I2C registers for the opposite transition and then place it back into W&S mode (the last single I2C transaction). Once in the closed state, the whole device remains asleep and there is no I2C activity.
The issue we have is that the operation usually works, but after some time (minutes to even a day or so) it just stops generating interrupts. The only work-around which seems to "work" is to wake up every minute and send the I2C message to place it in W&S mode, and then it continues to function normally again until it stops again later. This is not ideal for this product and we need to understand how to resolve the issue.
The register configurations are outlined below
Initialisation (only at start-up)
DEVICE_CONFIG_1 = 0x34 // NdBFe temp comp, CONV_AVG = 5 (32x)
DEVICE_CONFIG_2 = 0x22 // THR_HYST = 1, OPERATING_MODE = 2 (continuous)
SENSOR_CONFIG_1 = 0x27 // MAG_CH_EN = 2 (Y), SLEEPTIME = 7 (100mS)
SENSOR_CONFIG_2 = 0x00 or 0x20 // THRX_COUNT = 0 (1x), MAG_THR_DIR = 0 (above) or 1 (below) threshold
Y_THR_CONFIG = 0x02 // Note that the field we are detecting is quite small
INT_CONFIG_1 = 0x44 // THRSLD_INT = 1, INT_STATE = 0 (latch INT), INT_MODE = 1 (nINT)
Then select W&S mode:
DEVICE_CONFIG_2 = 0x23 // THR_HYST = 1, OPERATING_MODE = 3 (W&S mode)
On interrupt event
Read Y value (Y_MSB_RESULT, Y_LSB_RESULT - standard 3-byte read)
If Y > threshold (or less than for opposite transition),
SENSOR_CONFIG_2 = 0x00 or 0x20 (flip MAG_THR_DIR bit)
Select W&S mode:
DEVICE_CONFIG_2 = 0x23 // THR_HYST = 1, OPERATING_MODE = 3 (W&S mode)
When we reset the W&S mode every minute (work-around), the initial I2C message isn’t acknowledged, but the second one is. This would seem to indicate that it has to come out of W&S mode first, unless it is possible to transit to Sleep (only) mode. As far as I’m aware, the Sleep and W&S modes are the only states where the I2C bus is not active. Is it possible for it to get stuck in sleep mode?
Please let me know if there is something I’m missing in the configuration or operation, or if you are aware of any issues operating the device this way.
Kinds regards,
James.