AnsweredAssumed Answered

LIS3MDL_Interrupt problem

Question asked by snaghyun choi on Sep 3, 2017
Latest reply on Sep 5, 2017 by snaghyun choi

Hello sir,

 

HELLO EVERYBODY,


I have a question about LIS3MDL.   Expecially, interrupt problem.
I am using LIS3MDL below sequence.

=================================================================================

1. In normal circumstance, I get a basic data for reference threshold of Interrupt.

Normally, 0.4 ~0.5 gauss.   And plus 0.1 gause for offset value.


2. I put in the data for Threshold value. And I enable the interrupt. 


3. Wait the interrupt (basic data[0.4 ~0.5 gauss] + offset[0.1 gauss])


4. If interrupt is happened, the interrupt signal wake main CPU(stm32f103rct6)


problem

I checked how many times interrupt is happened, in normal circumstance(0.4 ~0.5gauss)

In our office, interrupt is not happened.   ( It is good because our office does not have the change of geomagnetic)

Outside, interrupt is happend eventhough there are nothing to change geomagnetic.


==>I wonder why the interrupt is happened outside?   

      I hope you give me the solution.

================================================================================

The function,

void LIS3MDL_Init(void)

{

   LIS3MDL_REGISTER_write_SET(LIS3MDL_ADDRESS1,CTRL_REG1,LIS3MDL_REG1_ULTRA_HIGH_XY | LIS3MDL_REG1_DR_80_HZ);  // ODR
   LIS3MDL_REGISTER_write_SET(LIS3MDL_ADDRESS1,CTRL_REG2,LIS3MDL_SCALE_4_GAUSS);            // scale
   LIS3MDL_REGISTER_write_SET(LIS3MDL_ADDRESS1,CTRL_REG3,LIS3MDL_REG3_CONTINUOUS);
   LIS3MDL_REGISTER_write_SET(LIS3MDL_ADDRESS1,CTRL_REG4,LIS3MDL_REG4_ULTRA_HIGH_Z);          // z-mode
   LIS3MDL_REGISTER_write_SET(LIS3MDL_ADDRESS1,CTRL_REG5,LIS3MDL_REG5_BDU);

}

 

 

void LIS3MDL_Reinit(uint16_t reference_data)
{
 uint8_t low_dataz=0, high_dataz =0;

 low_dataz = reference_data & 0x00ff;
 high_dataz = (reference_data>>8) & 0x00ff;

 


 LIS3MDL_REGISTER_write_SET(LIS3MDL_ADDRESS1,INT_THS_L,low_dataz); 
 LIS3MDL_REGISTER_write_SET(LIS3MDL_ADDRESS1,INT_THS_H,high_dataz);


 LIS3MDL_REGISTER_write_SET(LIS3MDL_ADDRESS1,INT_CFG,(LIS3MDL_INT_CFG_YIEN|LIS3MDL_INT_CFG_ZIEN|LIS3MDL_INT_CFG_IEA|LIS3MDL_INT_CFG_IEN));
}


================================================================================

The Code Sequence,

uint16_t  Geo_reference_offset = 250;

LIS3MDL_Init();

for(int i =0;i<Geo_Average;i++)
{
      do{  
         geo_status = LIS3MDL_STATUS_READ();
         geo_status = geo_status & geo_shift;
      }while(!geo_status);
               
   
 Geo_Ref[i] = Check_Geomagnetic_Value(OUT_Z_L,OUT_Z_H);
 if(Geo_Ref[i]>=32767)
 {
  if(i==0)Geo_max_value = Geo_Ref[i];
  else
  {
   if(Geo_Ref[i]<Geo_max_value)Geo_max_value = Geo_Ref[i];
  }
 }
 else
 {
   if(Geo_Ref[i]>Geo_max_value)Geo_max_value = Geo_Ref[i];
 }
 HAL_Delay(10);
}

Geo_data = Geo_max_value;
if(Geo_data>=Geo_Positive_MAX)geo_reference = (65535 - Geo_data)+Geo_reference_offset;
else geo_reference = Geo_data + Geo_reference_offset;

LIS3MDL_Reinit(geo_reference);
while(1)
{
  // wait interrupt of LIS3MDL
}
===============================================================================

 

I've been tryied this problem to solve it however, I can not solve it.

Please, help me.   

Outcomes