KL17 and fxos8700 pulse interrupt

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

KL17 and fxos8700 pulse interrupt

396 Views
sripadakasivisw
Contributor I

Hi,This is kasi viswanadh

I'm using kl17 MCU and FXOS8700 acc+mag combo sensor in my project.  im using pulse interrupt in my code and i'm reading interrupt like below,

void PulseINTService(Motiontrack *hApp) {
int32_t status;
uint8_t Int_SourceSystem, Int_SourceTrans;

//Determine source of interrupt by reading the system interrupt register
status = Register_I2C_Read(&I2C_S_DRIVER_BLOCKING,
FXOS8700_DEVICE_ADDR_SA_00, FXOS8700_INT_SOURCE, 1, &Int_SourceSystem);
if (status != 0x00)
hApp->thisTrigger.pulseint = true;
else
hApp->thisTrigger.pulseint = false;
//Set up Case statement here to service all of the possible interrupts
if ((Int_SourceSystem & 0x08) == 0x08) {
//Perform an Action since pulse Flag has been set
//Read the pulse to clear system interrupt and pulse
status = Register_I2C_Read(&I2C_S_DRIVER_BLOCKING,
FXOS8700_DEVICE_ADDR_SA_00, FXOS8700_PULSE_SRC, 1, &Int_SourceTrans);
if (status != 0x00)
hApp->thisTrigger.pulseint = true;
else {
hApp->thisTrigger.pulsecnt++;
hApp->thisTrigger.pulseint = false;
}

}
}

I've connected 2 more devices(gyro and battery gauge) to the mcu with same i2c. my system is hanging and coming back to normal state after some time. is there any fault in the above code? or any other possibilities for the hanging issue?

Thank you

Labels (1)
0 Kudos
1 Reply

299 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Kasi,

What exactly you mean by "my system is hanging and coming back to normal state after some time"? 

Does it happen only if you connect other devices to the bus?

Do you have a logic analyzer or an oscilloscope to see what is going on the bus and interrupt line?

The code looks good. I would just recommend to read both the INT_SOURCE and PULSE_SRC registers in your main loop to keep your ISR as short as possible. In the ISR, I would just acknowledge an IRQ by writing to a specific bit of KL17 MCU and set another variable to indicate the interrupt in the main loop. 

Best regards,

Tomas

0 Kudos