accelerometer vector magnitude

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

accelerometer vector magnitude

3,550 Views
meirsudry
Contributor I

Hi i encounter an odd response when trying to use the A_VECM feature in FXOS8700.

i have the following piece of code:

MMA865x_Standby();

IIC_RegWrite(CTRL_REG4,0x02); //Disable Data Ready interrupts, enable A_VECM interrupts

IIC_RegWrite(A_VECM_THS_MSB,0x80);   //update MSB THS, reset when condition fails

print_string("A_VECM_THS_MSB= ",16); print_hex(IIC_RegRead(A_VECM_THS_MSB)); WaitPrintBuffer();

IIC_RegWrite(A_VECM_THS_LSB,Acc_THS);   //update LSB THS

print_string("A_VECM_THS_LSB= ",16); print_hex(IIC_RegRead(A_VECM_THS_LSB)); WaitPrintBuffer();

IIC_RegWrite(A_VECM_CNT,Acc_COUNT); //update counter

print_string("A_VECM_CNT= ",13); print_hex(IIC_RegRead(A_VECM_CNT)); printENTER; WaitPrintBuffer();

IIC_RegWrite(A_VECM_CFG,0x78); //0111 1000  Latch enable, A_VECM_INIT, don't update reference when event

IIC_RegWrite(M_CTRL_REG1,((IIC_RegRead(M_CTRL_REG1))&(~0x03))); //Enable Accelerometer_Only

Data_Mode= Accelerometer_Only; //notify EX0 interrupt to read Accelerometer data

IIC_RegWrite(M_CTRL_REG2,((IIC_RegRead(M_CTRL_REG2))&(~0x20))); //Disable autoincrement mode

//    IntSource=IIC_RegRead(TRANSIENT_SRC); //Read 0x1E TRANSIENT_SRC register to clear the interrupt

MMA865x_Active(); //ACTIVATE THE SENSOR

with this code the program works fine and every time i move the device A_VECM is asserted.

in this stage i decided to delete the print_string() lines.

after i did that the A_VECM is asserted once and not asserted anymore.

i tried to replace the print_string() lines with simple delay: for(i=0; i<60000; i++);

with this line, again A_VECM is asserted with no problems.

i can read CNTR_REG4 and it is set to 0x02. nevertheless the A_VECM is not asserted.

any idea what is the reason for that?

thanks

Labels (2)
0 Kudos
4 Replies

2,697 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Meir,

Please look at my example code. You need to read the INT_SOURCE register (0x0C) to clear the the SRC_A_VECM status bit and deassert the INTx pin.

Hope it helps.

Regards,

Tomas

PS: If my answer helps to solve your question, please mark it as "Correct". Thank you.

0 Kudos

2,697 Views
meirsudry
Contributor I

Hi Tomas

thanks for your prompt response.

Unfortunately I can’t open the link you sent for your example code.

Indeed I copied paste a previous piece of code from a program deal with Transient interrupt so I read the transient source instead of INT_Source.

The piece of code I attached in my question is the last part of handling the A_VECM interrupt.

Immediately after the interrupt is asserted I do read INT_SOURCE register.

Finally, I changed the line as you suggested

// IntSource=IIC_RegRead(TRANSIENT_SRC); //Read 0x1E TRANSIENT_SRC register to clear the interrupt

and replaced it with

IntSource=IIC_RegRead(INT_SOURCE); //Read 0x0C INT_SOURCE register to clear the interrupt

The problem still exist.

The point in my case is a beat different.

It looks like if I have a delay after the line:

IIC_RegWrite(CTRL_REG4,0x02); //Disable Data Ready interrupts, enable A_VECM interrupts

I do get interrupts.

The delay is either by setting and printing several registers (see the code I sent in my question),

or even by simple for(i=0; i<60000; i++); to implement the delay.

In these cases I do get A_VECM interrupts after the first one, which is always asserted as expected.

If the delay is not implemented I don't get interrupts after the 1st that was asserted.

thanks

Meir SUDRY

0 Kudos

2,697 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Meir,

Sorry, the correct link is: https://community.freescale.com/docs/DOC-106050

Please try to reproduce my settings and let me know if the problem persists.

Regards,

Tomas

0 Kudos

2,697 Views
meirsudry
Contributor I

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);

0 Kudos
%3CLINGO-SUB%20id%3D%22lingo-sub-421405%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Eaccelerometer%20vector%20magnitude%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-421405%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20i%20encounter%20an%20odd%20response%20when%20trying%20to%20use%20the%20A_VECM%20feature%20in%20FXOS8700.%3C%2FP%3E%3CP%3Ei%20have%20the%20following%20piece%20of%20code%3A%20%3C%2FP%3E%3CBLOCKQUOTE%3E%3CP%3EMMA865x_Standby()%3B%3C%2FP%3E%3CP%3EIIC_RegWrite(CTRL_REG4%2C0x02)%3B%20%2F%2FDisable%20Data%20Ready%20interrupts%2C%20enable%20A_VECM%20interrupts%3C%2FP%3E%3CP%3EIIC_RegWrite(A_VECM_THS_MSB%2C0x80)%3B%26nbsp%3B%26nbsp%3B%20%2F%2Fupdate%20MSB%20THS%2C%20reset%20when%20condition%20fails%3C%2FP%3E%3CP%3Eprint_string(%22A_VECM_THS_MSB%3D%20%22%2C16)%3B%20print_hex(IIC_RegRead(A_VECM_THS_MSB))%3B%20WaitPrintBuffer()%3B%3C%2FP%3E%3CP%3EIIC_RegWrite(A_VECM_THS_LSB%2CAcc_THS)%3B%26nbsp%3B%26nbsp%3B%20%2F%2Fupdate%20LSB%20THS%3C%2FP%3E%3CP%3Eprint_string(%22A_VECM_THS_LSB%3D%20%22%2C16)%3B%20print_hex(IIC_RegRead(A_VECM_THS_LSB))%3B%20WaitPrintBuffer()%3B%3C%2FP%3E%3CP%3EIIC_RegWrite(A_VECM_CNT%2CAcc_COUNT)%3B%20%2F%2Fupdate%20counter%3C%2FP%3E%3CP%3Eprint_string(%22A_VECM_CNT%3D%20%22%2C13)%3B%20print_hex(IIC_RegRead(A_VECM_CNT))%3B%20printENTER%3B%20WaitPrintBuffer()%3B%3C%2FP%3E%3CP%3EIIC_RegWrite(A_VECM_CFG%2C0x78)%3B%20%2F%2F0111%201000%26nbsp%3B%20Latch%20enable%2C%20A_VECM_INIT%2C%20don't%20update%20reference%20when%20event%3C%2FP%3E%3CP%3EIIC_RegWrite(M_CTRL_REG1%2C((IIC_RegRead(M_CTRL_REG1))%26amp%3B(~0x03)))%3B%20%2F%2FEnable%20Accelerometer_Only%3C%2FP%3E%3CP%3EData_Mode%3D%20Accelerometer_Only%3B%20%2F%2Fnotify%20EX0%20interrupt%20to%20read%20Accelerometer%20data%3C%2FP%3E%3CP%3EIIC_RegWrite(M_CTRL_REG2%2C((IIC_RegRead(M_CTRL_REG2))%26amp%3B(~0x20)))%3B%20%2F%2FDisable%20autoincrement%20mode%3C%2FP%3E%3CP%3E%2F%2F%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IntSource%3DIIC_RegRead(TRANSIENT_SRC)%3B%20%2F%2FRead%200x1E%20TRANSIENT_SRC%20register%20to%20clear%20the%20interrupt%3C%2FP%3E%3CP%3EMMA865x_Active()%3B%20%2F%2FACTIVATE%20THE%20SENSOR%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CPRE%20__default_attr%3D%22c%2B%2B%22%20__jive_macro_name%3D%22code%22%20class%3D%22_jivemacro_uid_1438975314850828%20jive_macro_code%20jive_text_macro%22%20data-renderedposition%3D%22385_30_1190_16%22%20jivemacro_uid%3D%22_1438975314850828%22%20modifiedtitle%3D%22true%22%3E%3CP%3E%3C%2FP%3E%3C%2FPRE%3E%3C%2FBLOCKQUOTE%3E%3CP%3Ewith%20this%20code%20the%20program%20works%20fine%20and%20every%20time%20i%20move%20the%20device%20A_VECM%20is%20asserted.%3C%2FP%3E%3CP%3Ein%20this%20stage%20i%20decided%20to%20delete%20the%20print_string()%20lines.%3C%2FP%3E%3CP%3Eafter%20i%20did%20that%20the%20A_VECM%20is%20asserted%20once%20and%20not%20asserted%20anymore.%3C%2FP%3E%3CP%3Ei%20tried%20to%20replace%20the%20print_string()%20lines%20with%20simple%20delay%3A%20for(i%3D0%3B%20i%26lt%3B60000%3B%20i%2B%2B)%3B%3C%2FP%3E%3CP%3Ewith%20this%20line%2C%20again%20A_VECM%20is%20asserted%20with%20no%20problems.%3C%2FP%3E%3CP%3Ei%20can%20read%20CNTR_REG4%20and%20it%20is%20set%20to%200x02.%20nevertheless%20the%20A_VECM%20is%20not%20asserted.%3C%2FP%3E%3CP%3Eany%20idea%20what%20is%20the%20reason%20for%20that%3F%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Ethanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-421405%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EAccelerometers%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMagnetic%20Sensors%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-421409%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20accelerometer%20vector%20magnitude%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-421409%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Tomas%3C%2FP%3E%3CP%3Ethanks%20for%20the%20correct%20link.%3C%2FP%3E%3CP%3Ethe%20problem%20still%20exist.%3C%2FP%3E%3CP%3Esee%20below%20more%20details%20(code)%20of%20my%20project%3C%2FP%3E%3CP%3E%3CSTRONG%3ESensor%20initialization%3C%2FSTRONG%3E%3A%3C%2FP%3E%3CTABLE%20height%3D%220%22%20style%3D%22width%3A%200px%3B%20height%3A%201px%3B%22%20width%3D%220%22%3E%3CTBODY%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%20%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3EMMA865x_Standby()%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIIC_RegWrite(CTRL_REG4%2C0x02)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIIC_RegWrite(A_VECM_THS_MSB%2C0x80)%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIIC_RegWrite(A_VECM_THS_LSB%2CAcc_THS)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIIC_RegWrite(A_VECM_CNT%2CAcc_COUNT)%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IIC_RegWrite(A_VECM_INITX_MSB%2C%200x00)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IIC_RegWrite(A_VECM_INITX_LSB%2C%200x00)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IIC_RegWrite(A_VECM_INITY_MSB%2C%200x00)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IIC_RegWrite(A_VECM_INITY_LSB%2C%200x00)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IIC_RegWrite(A_VECM_INITZ_MSB%2C%200x00)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IIC_RegWrite(A_VECM_INITZ_LSB%2C%200x00)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%26nbsp%3B%20%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIIC_RegWrite(A_VECM_CFG%2C0x78)%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIIC_RegWrite(M_CTRL_REG1%2C((IIC_RegRead(M_CTRL_REG1))%26amp%3B(~0x03)))%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIIC_RegWrite(M_CTRL_REG2%2C((IIC_RegRead(M_CTRL_REG2))%26amp%3B(~0x20)))%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EMMA865x_Active()%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIntSource%3DIIC_RegRead(INT_SOURCE)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3Enow%20I'm%20polling%20for%20%3C%2FSTRONG%3E%3CSTRONG%3EA_VECM%20%3C%2FSTRONG%3E%3CSTRONG%3Eevent%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%20General_IntSource%3D%20IIC_RegRead(INT_SOURCE)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%20if%20(General_IntSource%26amp%3B0x02)%20readdata()%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3Eand%20finally%20the%20function%20%3CSPAN%20style%3D%22line-height%3A%201.5%3B%22%3Ereaddata()%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3Evoid%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3Ereaddata%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E(void)%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2F%2F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%7B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIntSource%3DIIC_RegRead(INT_SOURCE)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%20MMA865x_Standby()%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%20IIC_RegWrite(M_CTRL_REG1%2C((IIC_RegRead(M_CTRL_REG1))%7C0x03))%3B%26nbsp%3B%20%2F%2Fhybrid%20mode%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%20IIC_RegWrite(M_CTRL_REG2%2C((IIC_RegRead(M_CTRL_REG2))%7C0x20))%3B%26nbsp%3B%20%2F%2Fenable%20magnetic%20auto%20increment%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%20IIC_RegWrite(CTRL_REG4%2C0x01)%3B%26nbsp%3B%20%2F%2Fenable%20data%20ready%20interrupts%20and%20disable%20A_VECM%20interrupts%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%20MMA865x_Active()%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%2F%2FACTIVATE%20THE%20SENSOR%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CEM%3Ehere%20I%20read%20several%20times%20the%20accelerometer%20and%20magnetic%20data%20using%20data%20ready%20interrupt%20to%20retrieve%20new%20data%3C%2FEM%3E%3C%2FP%3E%3CP%3Eafter%20finalizing%20reading%20data%20I%20set%20the%20parameters%20to%20re-accept%26nbsp%3B%20%3CSPAN%20style%3D%22line-height%3A%201.5%3B%22%3EA_VECM%20interrupts%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3EMMA865x_Standby()%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3EIIC_RegWrite(CTRL_REG4%2C0x02)%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%2F%2FDisable%20Data%20Ready%20interrupts%2C%20enable%20A_VECM%20interrupts%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%3CSPAN%20style%3D%22line-height%3A%201.5%3B%22%3Efor%20(i%3D0%3B%20i%26lt%3B60000%3B%20i%2B%2B)%3B%20%3CSPAN%20style%3D%22color%3A%20%23303030%3B%22%3E%3CSTRONG%3E-%20if%20this%20line%20is%20removed%20the%20%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%23303030%3B%22%3E%3CSTRONG%20style%3D%22line-height%3A%201.5%3B%22%3EA_VECM%20interrupt%20is%20not%20asserted%20anymore%20unless%20I%20restart%20the%20system%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3EIIC_RegWrite(M_CTRL_REG1%2C((IIC_RegRead(M_CTRL_REG1))%26amp%3B(~0x03)))%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%2F%2FEnable%20Accelerometer_Only%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%3CSPAN%20style%3D%22line-height%3A%201.5%3B%22%3EIIC_RegWrite(M_CTRL_REG2%2C((IIC_RegRead(M_CTRL_REG2))%26amp%3B(~0x20)))%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22line-height%3A%201.5%3B%20white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22line-height%3A%201.5%3B%22%3E%2F%2FDisable%20autoincrement%20mode%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3EMMA865x_Active()%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%2F%2FACTIVATE%20THE%20SENSOR%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3EIntSource%3DIIC_RegRead(INT_SOURCE)%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%2F%2FRead%200x0C%20INT_SOURCE%20register%20to%20clear%20the%20interrupt%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%22%3E%7D%3C%2FSPAN%3E%3C%2FP%3E%3CP%3Ethe%20first%20interrupt%20is%20always%20asserted%20and%20the%20system%20works%20as%20expected.%20i%20get%20all%20data%20readings.%3C%2FP%3E%3CP%3Ewhen%20the%20delay%20line%20is%20placed%20also%20the%20system%20is%20working%20fine.%20the%20question%20is%20why%20is%20it%20needed%20at%20all.%3C%2FP%3E%3CP%3Ei%20got%20the%20idea%20that%20the%20delay%20is%20needed%20because%26nbsp%3B%20i%20had%20there%20several%20lines%20of%20printing%20for%20the%20debugging.%20once%20i%20removed%20those%20lines%20i%20stopped%20getting%20interrupts%20after%20the%20first%20A_VECM.%3C%2FP%3E%3CP%3Eafter%20an%20investigation%20i%20made%20i%20realized%20that%20a%20delay%20after%20setting%20CTRL_%20REG4%20is%20required%20in%20order%20to%20get%20the%20successive%20interrupts.%3C%2FP%3E%3CP%3Ei%20positively%20know%20the%20interrupt%20in%20no%20asserted%20because%20in%20debug%20mode%20i%20can%20see%20the%26nbsp%3B%20%3CSPAN%20style%3D%22color%3A%20%237ed529%3B%20line-height%3A%201.5%3B%22%3EGeneral_IntSource%20%3CSPAN%20style%3D%22color%3A%20%23303030%3B%22%3Evariable%20get%20the%20value%20of%200x00.%3C%2FSPAN%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI%20would%20appreciate%20if%20you%20can%20look%20into%20this%20case%20and%20come%20with%20your%20insights.%3C%2FP%3E%3CP%3Ethanks%3C%2FP%3E%3CP%3EMeir%3C%2FP%3E%3CP%3E%26nbsp%3B%20%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EMMA865x_Standby()%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIIC_RegWrite(CTRL_REG4%2C0x02)%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIIC_RegWrite(A_VECM_THS_MSB%2C0x80)%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%20%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIIC_RegWrite(A_VECM_THS_LSB%2CAcc_THS)%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIIC_RegWrite(A_VECM_CNT%2CAcc_COUNT)%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IIC_RegWrite(A_VECM_INITX_MSB%2C%200x00)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IIC_RegWrite(A_VECM_INITX_LSB%2C%200x00)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IIC_RegWrite(A_VECM_INITY_MSB%2C%200x00)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IIC_RegWrite(A_VECM_INITY_LSB%2C%200x00)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IIC_RegWrite(A_VECM_INITZ_MSB%2C%200x00)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IIC_RegWrite(A_VECM_INITZ_LSB%2C%200x00)%3B%26nbsp%3B%20%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIIC_RegWrite(A_VECM_CFG%2C0x78)%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIIC_RegWrite(M_CTRL_REG1%2C((IIC_RegRead(M_CTRL_REG1))%26amp%3B(~0x03)))%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIIC_RegWrite(M_CTRL_REG2%2C((IIC_RegRead(M_CTRL_REG2))%26amp%3B(~0x20)))%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EMMA865x_Active()%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3EIntSource%3DIIC_RegRead(INT_SOURCE)%3B%3CSPAN%20class%3D%22Apple-tab-span%22%20style%3D%22white-space%3A%20pre%3B%22%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-421408%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20accelerometer%20vector%20magnitude%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-421408%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Meir%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ESorry%2C%20the%20correct%20link%20is%3A%20%3CA%20_jive_internal%3D%22true%22%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Fdocs%2FDOC-106050%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.freescale.com%2Fdocs%2FDOC-106050%3C%2FA%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EPlease%20try%20to%20reproduce%20my%20settings%20and%20let%20me%20know%20if%20the%20problem%20persists.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3ETomas%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-421407%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20accelerometer%20vector%20magnitude%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-421407%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Tomas%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Ethanks%20for%20your%20prompt%20response.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EUnfortunately%20I%20can%E2%80%99t%20open%20the%20link%20you%20sent%20for%20your%20example%20code.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIndeed%20I%20copied%20paste%20a%20previous%20piece%20of%20code%20from%20a%20program%20deal%20with%20Transient%20interrupt%20so%20I%20read%20the%20transient%20source%20instead%20of%20INT_Source.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThe%20piece%20of%20code%20I%20attached%20in%20my%20question%20is%20the%20last%20part%20of%20handling%20the%20A_VECM%20interrupt.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EImmediately%20after%20the%20interrupt%20is%20asserted%20I%20do%20read%20INT_SOURCE%20register.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EFinally%2C%20I%20changed%20the%20line%20as%20you%20suggested%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%2F%2F%20%20%20%20IntSource%3DIIC_RegRead(TRANSIENT_SRC)%3B%20%2F%2FRead%200x1E%20TRANSIENT_SRC%20register%20to%20clear%20the%20interrupt%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Eand%20replaced%20it%20with%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIntSource%3DIIC_RegRead(INT_SOURCE)%3B%20%2F%2FRead%200x0C%20INT_SOURCE%20register%20to%20clear%20the%20interrupt%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThe%20problem%20still%20exist.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThe%20point%20in%20my%20case%20is%20a%20beat%20different.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIt%20looks%20like%20if%20I%20have%20a%20delay%20after%20the%20line%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIIC_RegWrite(CTRL_REG4%2C0x02)%3B%20%2F%2FDisable%20Data%20Ready%20interrupts%2C%20enable%20A_VECM%20interrupts%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EI%20do%20get%20interrupts.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThe%20delay%20is%20either%20by%20setting%20and%20printing%20several%20registers%20(see%20the%20code%20I%20sent%20in%20my%20question)%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Eor%20even%20by%20simple%20for(i%3D0%3B%20i%26lt%3B60000%3B%20i%2B%2B)%3B%20%20to%20implement%20the%20delay.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIn%20these%20cases%20I%20do%20get%20A_VECM%20interrupts%20after%20the%20first%20one%2C%20which%20is%20always%20asserted%20as%20expected.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIf%20the%20delay%20is%20not%20implemented%20I%20don't%20get%20interrupts%20after%20the%201st%20that%20was%20asserted.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Ethanks%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EMeir%20SUDRY%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-421406%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20accelerometer%20vector%20magnitude%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-421406%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Meir%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EPlease%20look%20at%20my%20%3CA%20href%3D%22http%3A%2F%2Fhttps%2F%2Fcommunity.freescale.com%2Fdocs%2FDOC-106050%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3Eexample%20code%3C%2FA%3E.%20You%20need%20to%20read%20the%20INT_SOURCE%20register%20(0x0C)%20to%20clear%20the%20the%20SRC_A_VECM%20status%20bit%20and%20deassert%20the%20INTx%20pin.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EHope%20it%20helps.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3ETomas%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2011.3333320617676px%3B%20font-family%3A%20arial%2C%20helvetica%2C%20'helvetica%20neue'%2C%20verdana%2C%20sans-serif%3B%20color%3A%20%2351626f%3B%22%3E%3CEM%3EPS%3A%20If%20my%20answer%20helps%20to%20solve%20your%20question%2C%20please%20mark%20it%20as%20%22Correct%22.%20Thank%20you.%3C%2FEM%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E