AnsweredAssumed Answered

FXOS8700 magnetic interrupt

Question asked by Di Ken on Sep 17, 2017
Latest reply on Sep 20, 2017 by Tomas Vaverka

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();                         // Hard Reset , RST active HIGH  
__delay_ms(5);   
MAG_RST_LOW();                            
__delay_ms(1);                         

FXOS8700CQ_WriteByte(CTRL_REG2, SMOD_LOW_NOISE|SLPE_MASK|MOD_LOW_NOISE);      // Low noise, low power, auto-sleep mode enabled
FXOS8700CQ_WriteByte(CTRL_REG3, IPOL_MASK);                     // Active HIGH on INT, push-pull mode  
FXOS8700CQ_WriteByte(CTRL_REG4, 0x00 );                         // No interrupt enabled here   
FXOS8700CQ_WriteByte(CTRL_REG5, 0x00 );                         // No interrupt routed to pin 2
FXOS8700CQ_WriteByte(ASLP_COUNT, 0x05);                         // 20 ms -  if not interrupt is asserted in 20 ms the system will go back to sleep mode
FXOS8700CQ_WriteByte(M_CTRL_REG1, M_ACAL_MASK| M_OSR_50_HZ | M_HMS0_MASK);     //  automatic calibration,  one shot magnetic reset, only mag active 
FXOS8700CQ_WriteByte(M_CTRL_REG2, M_MAXMIN_DIS_MASK | M_MAXMIN_DIS_THS_MASK | M_MAXMIN_RST_MASK | RST_DISABLED);        //Magnetic min/max enabled   
FXOS8700CQ_WriteByte(M_CTRL_REG3, M_ASLP_OSR_100_HZ | M_THS_XYZ_MASK | M_ST_Z_MASK | M_ST_XY_MASK);        // all updated when THS ISR happens      

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 );  //M_INT_threshold on INT2 pin  OR INT of all axes for threshold, latch disabled.

uint16_t magThreshold = 0x200;                               //counts;   
uint8_t magThresholdHi = (magThreshold & 0xFF00) >> 8;   
uint8_t magThresholdLo = magThreshold & 0xFF;   
FXOS8700CQ_WriteByte(M_THS_Z_MSB, magThresholdHi);        // Debounce countered cleared to zero when threshold is not longer true   
FXOS8700CQ_WriteByte(M_THS_Z_LSB, magThresholdLo);   
   
magThreshold = 0x200;                               //counts;   
magThresholdHi = (magThreshold & 0xFF00) >> 8;  
magThresholdLo = magThreshold & 0xFF;  
FXOS8700CQ_WriteByte(M_THS_X_MSB, magThresholdHi);        // Debounce countered cleared to zero when threshold is not longer true   
FXOS8700CQ_WriteByte(M_THS_X_LSB, magThresholdLo);   

magThreshold = 0x200;                               //counts;   
magThresholdHi = (magThreshold & 0xFF00) >> 8;  
magThresholdLo = magThreshold & 0xFF;  
FXOS8700CQ_WriteByte(M_THS_Y_MSB, magThresholdHi);        // Debounce countered cleared to zero when threshold is not longer true   
FXOS8700CQ_WriteByte(M_THS_Y_LSB, magThresholdLo);   
   
FXOS8700CQ_WriteByte(M_THS_COUNT, 1); //debounce sample counts required before a magnetic threshold event is triggered, depends on ODR
FXOS8700CQ_WriteByte(CTRL_REG1, ASLP_RATE_20MS | DATA_RATE_100HZ |LNOISE_MASK );     // in sleep mode data rate 50Hz, awake ODR = 100Hz, low noise mode, in standby
}

 

 

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);           
//Read interrupt source to clear int   
srcmag = FXOS8700CQ_ReadByte(M_THS_SRC);  
magintsrc = FXOS8700CQ_ReadByte(M_INT_SRC);           
//Read interrupt source to clear int

    ..... //Clear the INT interrupt flag
}

Outcomes