I am trying to configure the FXOS8700CQR in magnetic threshold interrupt mode. I am using SPI to communicate witth the sensor.
Whenever a magnet is in the vicinity of the sensor, the programmed magnetic threshold values is supposed to trigger an interrupt.
When the data is streaming I can clearly see the spikes on the signal passing the programmed threshold.
The interrupt pin does not go high however. I checked with a scope.
I don't see the magnetic interrupts happening.The problem is that the magnetic interrupts in the ISR are not triggered.
Even if I trigger them manually by the shaking the unit I cannot clear them. Pin stays always high.
Is there any application note with regard to the magnetic threshold interrupt specifically. (not the vector magnitude)?
void FXOS8700CQ_ConfigMagTHS(void){
MAG_RST_HIGH();
__delay_ms(5);
MAG_RST_LOW();
__delay_ms(1);
FXOS8700CQ_WriteByte(CTRL_REG2, SMOD_LOW_NOISE|SLPE_MASK|MOD_LOW_NOISE);
FXOS8700CQ_WriteByte(CTRL_REG3, IPOL_MASK);
FXOS8700CQ_WriteByte(CTRL_REG4, 0x00 );
FXOS8700CQ_WriteByte(CTRL_REG5, 0x00 );
FXOS8700CQ_WriteByte(ASLP_COUNT, 0x05);
FXOS8700CQ_WriteByte(M_CTRL_REG1, M_ACAL_MASK| M_OSR_50_HZ | M_HMS0_MASK);
FXOS8700CQ_WriteByte(M_CTRL_REG2, M_MAXMIN_DIS_MASK | M_MAXMIN_DIS_THS_MASK | M_MAXMIN_RST_MASK | RST_DISABLED);
FXOS8700CQ_WriteByte(M_CTRL_REG3, M_ASLP_OSR_100_HZ | M_THS_XYZ_MASK | M_ST_Z_MASK | M_ST_XY_MASK);
FXOS8700CQ_WriteByte(M_THS_CFG, M_THS_ELE | M_THS_OAE | M_THS_WAKE_EN | M_THS_ZEFE | M_THS_YEFE | M_THS_XEFE| M_THS_WAKE_EN | M_THS_INT_EN );
uint16_t magThreshold = 0x200;
uint8_t magThresholdHi = (magThreshold & 0xFF00) >> 8;
uint8_t magThresholdLo = magThreshold & 0xFF;
FXOS8700CQ_WriteByte(M_THS_Z_MSB, magThresholdHi);
FXOS8700CQ_WriteByte(M_THS_Z_LSB, magThresholdLo);
magThreshold = 0x200;
magThresholdHi = (magThreshold & 0xFF00) >> 8;
magThresholdLo = magThreshold & 0xFF;
FXOS8700CQ_WriteByte(M_THS_X_MSB, magThresholdHi);
FXOS8700CQ_WriteByte(M_THS_X_LSB, magThresholdLo);
magThreshold = 0x200;
magThresholdHi = (magThreshold & 0xFF00) >> 8;
magThresholdLo = magThreshold & 0xFF;
FXOS8700CQ_WriteByte(M_THS_Y_MSB, magThresholdHi);
FXOS8700CQ_WriteByte(M_THS_Y_LSB, magThresholdLo);
FXOS8700CQ_WriteByte(M_THS_COUNT, 1);
FXOS8700CQ_WriteByte(CTRL_REG1, ASLP_RATE_20MS | DATA_RATE_100HZ |LNOISE_MASK );
}
The code above is executed between:
FXOS8700CQ_StandbyMode();
...
FXOS8700CQ_ActiveMode();
On the interrupt I try to clear the interrupt and in the main () function I try to print the source but I don't see anything at all.
void _INTInterrupt(void){
MagTHSEvent = 1;
magintsrc = FXOS8700CQ_ReadByte(M_INT_SRC);
srcmag = FXOS8700CQ_ReadByte(M_THS_SRC);
magintsrc = FXOS8700CQ_ReadByte(M_INT_SRC);
.....
}