Hi Tomas
thanks for the correct link.
the problem still exist.
see below more details (code) of my project
Sensor initialization:
MMA865x_Standby();
IIC_RegWrite(CTRL_REG4,0x02);
IIC_RegWrite(A_VECM_THS_MSB,0x80);
IIC_RegWrite(A_VECM_THS_LSB,Acc_THS);
IIC_RegWrite(A_VECM_CNT,Acc_COUNT);
IIC_RegWrite(A_VECM_INITX_MSB, 0x00);
IIC_RegWrite(A_VECM_INITX_LSB, 0x00);
IIC_RegWrite(A_VECM_INITY_MSB, 0x00);
IIC_RegWrite(A_VECM_INITY_LSB, 0x00);
IIC_RegWrite(A_VECM_INITZ_MSB, 0x00);
IIC_RegWrite(A_VECM_INITZ_LSB, 0x00);
IIC_RegWrite(A_VECM_CFG,0x78);
IIC_RegWrite(M_CTRL_REG1,((IIC_RegRead(M_CTRL_REG1))&(~0x03)));
IIC_RegWrite(M_CTRL_REG2,((IIC_RegRead(M_CTRL_REG2))&(~0x20)));
MMA865x_Active();
IntSource=IIC_RegRead(INT_SOURCE);
now I'm polling for A_VECM event
General_IntSource= IIC_RegRead(INT_SOURCE);
if (General_IntSource&0x02) readdata();
and finally the function readdata()
void readdata(void) //
{
IntSource=IIC_RegRead(INT_SOURCE);
MMA865x_Standby();
IIC_RegWrite(M_CTRL_REG1,((IIC_RegRead(M_CTRL_REG1))|0x03)); //hybrid mode
IIC_RegWrite(M_CTRL_REG2,((IIC_RegRead(M_CTRL_REG2))|0x20)); //enable magnetic auto increment
IIC_RegWrite(CTRL_REG4,0x01); //enable data ready interrupts and disable A_VECM interrupts
MMA865x_Active(); //ACTIVATE THE SENSOR
here I read several times the accelerometer and magnetic data using data ready interrupt to retrieve new data
after finalizing reading data I set the parameters to re-accept A_VECM interrupts
MMA865x_Standby();
IIC_RegWrite(CTRL_REG4,0x02); //Disable Data Ready interrupts, enable A_VECM interrupts
for (i=0; i<60000; i++); - if this line is removed the A_VECM interrupt is not asserted anymore unless I restart the system
IIC_RegWrite(M_CTRL_REG1,((IIC_RegRead(M_CTRL_REG1))&(~0x03))); //Enable Accelerometer_Only
IIC_RegWrite(M_CTRL_REG2,((IIC_RegRead(M_CTRL_REG2))&(~0x20))); //Disable autoincrement mode
MMA865x_Active(); //ACTIVATE THE SENSOR
IntSource=IIC_RegRead(INT_SOURCE); //Read 0x0C INT_SOURCE register to clear the interrupt
}
the first interrupt is always asserted and the system works as expected. i get all data readings.
when the delay line is placed also the system is working fine. the question is why is it needed at all.
i got the idea that the delay is needed because i had there several lines of printing for the debugging. once i removed those lines i stopped getting interrupts after the first A_VECM.
after an investigation i made i realized that a delay after setting CTRL_ REG4 is required in order to get the successive interrupts.
i positively know the interrupt in no asserted because in debug mode i can see the General_IntSource variable get the value of 0x00.
I would appreciate if you can look into this case and come with your insights.
thanks
Meir
MMA865x_Standby(); IIC_RegWrite(CTRL_REG4,0x02); IIC_RegWrite(A_VECM_THS_MSB,0x80); IIC_RegWrite(A_VECM_THS_LSB,Acc_THS); IIC_RegWrite(A_VECM_CNT,Acc_COUNT); IIC_RegWrite(A_VECM_INITX_MSB, 0x00); IIC_RegWrite(A_VECM_INITX_LSB, 0x00); IIC_RegWrite(A_VECM_INITY_MSB, 0x00); IIC_RegWrite(A_VECM_INITY_LSB, 0x00); IIC_RegWrite(A_VECM_INITZ_MSB, 0x00); IIC_RegWrite(A_VECM_INITZ_LSB, 0x00); IIC_RegWrite(A_VECM_CFG,0x78);
IIC_RegWrite(M_CTRL_REG1,((IIC_RegRead(M_CTRL_REG1))&(~0x03))); IIC_RegWrite(M_CTRL_REG2,((IIC_RegRead(M_CTRL_REG2))&(~0x20))); MMA865x_Active(); IntSource=IIC_RegRead(INT_SOURCE);