AnsweredAssumed Answered

Problem with FXOS8700CQ and FXAS21002 operating together

Question asked by Can Altineller on Sep 11, 2019

Hello All,

 

I have managed to get both sensors generate data ready interrupts, routed at INT2 pin of each sensor, with active low polarity.

 

I am using a TM4C123 processor, with I2C3 connected to the gyro sensor, and I2C0 connected to accelmag sensor.

 

Here are my ISRs:

 

// gyro interrupt service routine
void gyro_isr(void) {
    MAP_GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2, GPIO_PIN_2);
    if(GPIOIntStatus(GPIO_PORTD_BASE, true) & GPIO_PIN_3) {
        GPIOIntClear(GPIO_PORTD_BASE, GPIO_PIN_3);
        gyro_data_ready = true;
    }
    GPIOIntStatus(GPIO_PORTD_BASE, false);
    MAP_GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2, 0x00);
}

// accelmag interrupt service routine
void accelmag_isr(void) {
    MAP_GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_PIN_3);
    if(GPIOIntStatus(GPIO_PORTB_BASE, true) & GPIO_PIN_5) {
        GPIOIntClear(GPIO_PORTB_BASE, GPIO_PIN_5);
        accelmag_data_ready = true;
    }
    GPIOIntStatus(GPIO_PORTB_BASE, false);
    MAP_GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, 0x00);
}

 

And in my main loop:

 

while(1) {

    if(gyro_data_ready) {
        GyroGetData(FXAS21002C_ADDRESS, &gyroRD);
        gyro_data_ready = false;
    }

    if(accelmag_data_ready) {
        AGGetData(FXOS8700_ADDRESS, &accelRD, &magRD);
        accelmag_data_ready = false;
    }
}

 


The system works, interrupts are generated, triggers the ISR's and data is read. But after a while, the accelmag sensor fails to deassert the interrupt. Thus never read again.

 

Here is a scopecap of the failure:

 

The top 4 (D0 to D3) is the gyro sensor, D0: interrupt D1: PA2, D2: SCL3, D3: SDA3

The bottom 4 (D4 to D7) is the accelmag sensor, D4: interrupt, D5: PA3, D6: SCL3, D7: SDA3

 

This is just where the accelmag sensor stops responding, near to the end, the interrupt line falls at D4, you see the spike at D5, and I2C data transfer takes place, but the interrupt line is never de-asserted again.

The spikes indicate entering and exiting of the ISR.

 

My aim is to syncronize the sensors. For making calculations to get orientation from gyro, accelmag with extended kalman filtering, it is of great importance that the dt does not jitter. At first I was reading gyro's data_ready interrupt, and then reading the accelmag sensor, but then I tried a 2 interrupt approach, and It works but only for few minutes, then I get this error. At higher speeds like 400hz it crashes within few seconds.

 

Any comments on sycnronization of these sensors, and ideas/help on the problem greatly appreciated.

 

Best regards,

Can

Outcomes