FXAS21002 Not Generating Interrupts

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

FXAS21002 Not Generating Interrupts

Jump to solution
1,373 Views
kaslewis
Contributor III

Hello,

I am using the FSAX21002 on the FRDM-STBC-AGM01 board along with the FRDM-KL25Z and writing all the code using mbed. The issue that I am having is that the sensor does generate any interrupts no matter how I setup the sensor. I have tried using both with interrupts for the FIFO and for Data Ready in all cases no interrupt is generated. My setting tried for the interrupts are for the data ready interrupt (CRTL_REG2 - 0x0F or 0x0E) and for the FIFO interrupt (CRTL_REG2 - 0xC3 or 0xC2) all these setting produced no results. When using the FIFO F_SETUP was set to 0x54. My setup code is below.

int fxas_init() {

    int return_val = 0;

    int test = 0;

 

    sensor_data[0] = i2c_read(FXAS_ADDRESS_W, FXAS_WHO_AM_I);

    pc.printf("Expected ID from FXAS21002C is 0xD7\n\r");

    pc.printf("Returned value: %X\n\n\r", sensor_data[0]);

   

    if (sensor_data[0] == FXAS_ID){

        return_val = 0;

        return_val += i2c_write_verify(FXAS_ADDRESS_W, FXAS_CTRL_REG_1, 0x00);

        return_val += i2c_write_verify(FXAS_ADDRESS_W, FXAS_F_SETUP, 0x00);

        return_val += i2c_write_verify(FXAS_ADDRESS_W, FXAS_F_SETUP, 0x54);

        return_val += i2c_write_verify(FXAS_ADDRESS_W, FXAS_CTRL_REG_0, 0x03);

       

        return_val += i2c_write_verify(FXAS_ADDRESS_W, FXAS_CTRL_REG_2, 0xEB);//Also tried 0xAF with FXAS_F_SETUP set to 0x00 (0x54 line removed)

        return_val += i2c_write_verify(FXAS_ADDRESS_W, FXAS_CTRL_REG_3, 0x08);//0x0C for INT2 to be used as sampling control or 0x08 for software control

        return_val += i2c_write_verify(FXAS_ADDRESS_W, FXAS_CTRL_REG_1, 0x13);

   }

    else{

        return_val = -1;   

    } 

Here is a logic capture of some of the setup and some data capture

FXAS setup & capture.png

Setup and data capture (First two blips verify the devices, FXAS and FXOS using the ID registers, next blip is FXAS setup and then finally data capture)

FXAS setup.png

FXOS setup

FXAS capture 3.png

Data Capture

Any help getting this sensor working would be very much appreciated.

Thankfully

Kas

Labels (2)
0 Kudos
1 Solution
902 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Kas,

How did you configure the corresponding PTA5 pin on the KL25Z MCU?

In my example code the INT1 pin of the FXAS21002CQ is configured as a push-pull (PP_OD = 0) active-low (IPOL = 0) output, so the corresponding PTA5 pin configuration is GPIO with an interrupt on falling edge:

//Configure the PTA5 pin (connected to the INT1 of the FXAS21002) for falling edge interrupts

SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;          // Turn on clock to Port A module

PORTA_PCR5 |= (0|PORT_PCR_ISF_MASK|         // Clear the interrupt flag

                  PORT_PCR_MUX(0x1)|        // PTA5 is configured as GPIO

                  PORT_PCR_IRQC(0xA));      // PTA5 is configured for falling edge interrupts

Capture.JPG

Could you please try to reproduce my setting?

Hope it helps.

Regards,

Tomas

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

View solution in original post

0 Kudos
3 Replies
903 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Kas,

How did you configure the corresponding PTA5 pin on the KL25Z MCU?

In my example code the INT1 pin of the FXAS21002CQ is configured as a push-pull (PP_OD = 0) active-low (IPOL = 0) output, so the corresponding PTA5 pin configuration is GPIO with an interrupt on falling edge:

//Configure the PTA5 pin (connected to the INT1 of the FXAS21002) for falling edge interrupts

SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;          // Turn on clock to Port A module

PORTA_PCR5 |= (0|PORT_PCR_ISF_MASK|         // Clear the interrupt flag

                  PORT_PCR_MUX(0x1)|        // PTA5 is configured as GPIO

                  PORT_PCR_IRQC(0xA));      // PTA5 is configured for falling edge interrupts

Capture.JPG

Could you please try to reproduce my setting?

Hope it helps.

Regards,

Tomas

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

0 Kudos
902 Views
kaslewis
Contributor III

Hello Tomas,

I was sure I had tried that combination as I had gone through all 4 possibilities for those two bits but after taking your suggestions along with looking for a falling edge seems to have resolved this issue. Thank you for your help :smileyhappy:  For others who may find this and wonder what my final setup for this was and how I did it in mbed I have included the setup code for both the FXAS21002 as well as for the interrupt on the FRDM-KL25Z

int fxas_init() {

    int return_val = 0;

 

    sensor_data[0] = i2c_read(FXAS_ADDRESS_W, FXAS_WHO_AM_I);

//    pc.printf("Expected ID from FXAS21002C is 0xD7\n\r");

//    pc.printf("Returned value: %X\n\n\r", sensor_data[0]);

   

    if (sensor_data[0] == FXAS_ID){

        return_val = 0;

        return_val += i2c_write_verify(FXAS_ADDRESS_W, FXAS_CTRL_REG_1, 0x00);

        return_val += i2c_write_verify(FXAS_ADDRESS_W, FXAS_F_SETUP, 0x00);

//        return_val += i2c_write_verify(FXAS_ADDRESS_W, FXAS_F_SETUP, 0x54);

        return_val += i2c_write_verify(FXAS_ADDRESS_W, FXAS_CTRL_REG_0, 0x03);

       

        return_val += i2c_write_verify(FXAS_ADDRESS_W, FXAS_CTRL_REG_2, 0x0E);//AF

        return_val += i2c_write_verify(FXAS_ADDRESS_W, FXAS_CTRL_REG_3, 0x08);//0x0C for INT2 to be used as sampling control or 0x08 for software control

        return_val += i2c_write_verify(FXAS_ADDRESS_W, FXAS_CTRL_REG_1, 0x13);      

    }

    else{

        return_val = -1;   

    }   

    pc.printf("Returned value A: %d\n\n\r", return_val);

    return return_val;

}

int main() {

    int initialized = 0;

    //Configure interrupts

    fxas_int1_21002.rise(&read_fxas_data);

    //initialize the FXOS8700CQ Accelorometer & the FXAS21002C Gyroscope

    initialised = fxas_init() & fxos_init();

    pc.printf("Returned value: %d\n\n\r", initialized);

   

    if (initialized == 0){

        led_2.write(0);

    }

    else{

        led_1.write(0);

    }

 

    while(1) {

0 Kudos
902 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Glad to hear it is now working and thanks for posting parts of your initialization code, Kas.

Regards,

Tomas

0 Kudos