Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How to configure interrupt to Any-Motion-Detection. #12

Open
TEQ-Andre opened this issue Jun 12, 2024 · 0 comments
Open

How to configure interrupt to Any-Motion-Detection. #12

TEQ-Andre opened this issue Jun 12, 2024 · 0 comments

Comments

@TEQ-Andre
Copy link

Hello, im trying to configure the BMX160 Interrupt to anymotion detection but i get no interrupt. Do i anything wrong?
I will be happy when anyone can help me :-) Thanks

    /*
    * The register controls which interrupt engines are enabled.
    * This enable Anymotion engine and disables all other interrupts.
    * 0x07 = 0b00000111 = int_anymo_z_en (2), int_anymo_y_en (1), int_anymo_x_en (0)
    * Page 70
    */
    uint8_t _int_en = {0};
    bmx160.readReg(BMX160_INT_ENABLE_0_ADDR, &_int_en, 1);
    Serial.printf("[I] [initIMU]: Current INT_EN Configuration: %x\r\n", _int_en);

    bmx160.writeBmxReg(BMX160_INT_ENABLE_0_ADDR, 0x07); 

    delay(2);
    uint8_t _new_int_en = {0};
    bmx160.readReg(BMX160_INT_ENABLE_0_ADDR, &_new_int_en, 1);
    Serial.printf("[I] [initIMU]: New INT_EN Configuration: %x\r\n", _new_int_en);


    /*
    * The register contains the behavioral configuration (electrical definition of the interrupt pins).
    * Page 71
    */
    uint8_t _int_out_ctrl = {0};
    bmx160.readReg(BMX160_INT_OUT_CTRL_ADDR, &_int_out_ctrl, 1);
    Serial.printf("[I] [initIMU]: Current INT_OUT_CTRL Configuration: %x\r\n", _int_out_ctrl);

    bmx160.writeBmxReg(BMX160_INT_OUT_CTRL_ADDR, 0XA8); 
    delay(2);

    uint8_t _new_int_out_ctrl = {0};
    bmx160.readReg(BMX160_INT_OUT_CTRL_ADDR, &_new_int_out_ctrl, 1);
    Serial.printf("[I] [initIMU]: New INT_OUT_CTRL Configuration: %x\r\n", _new_int_out_ctrl);


    /*
    * Map INT1 to Anymotion / Siginificant Motion interrupt.
    * Map INT2 to PMU trigger interrupt.
    * Page 73
    */
    uint8_t _int_map[3] = {0};
    bmx160.readReg(BMX160_INT_MAP_0_ADDR, _int_map, 3);
    Serial.printf("[I] [initIMU]: Current INT_MAP Configuration: %s\r\n", buffer_to_string(_int_map, 3));

    bmx160.writeBmxReg(BMX160_INT_MAP_0_ADDR, 0x04); 
    delay(2);

    bmx160.writeBmxReg(BMX160_INT_MAP_1_ADDR, 0x01); 
    delay(2);

    uint8_t _new_int_map[3] = {0};
    bmx160.readReg(BMX160_INT_MAP_0_ADDR, _new_int_map, 3);
    Serial.printf("[I] [initIMU]: New INT_MAP Configuration: %s\r\n", buffer_to_string(_new_int_map, 3));


    /*
    * Threshold definition of the anymotion interrupt.
    * 0x00 = 1.95mg (2g range)
    * Page 78
    */
    uint8_t _int_motion[4] = {0};
    bmx160.readReg(BMX160_INT_MOTION_0_ADDR, _int_motion, 4);
    Serial.printf("[I] [initIMU]: Current INT_MOTION Configuration: %s\r\n", buffer_to_string(_int_motion, 4));

    bmx160.writeBmxReg(BMX160_INT_MOTION_1_ADDR, 0x00); 
    delay(2);

    /*
    * Contains motion configuration 
    * Bit 0 (int_no_mot_sel)      = 0. No-motion / Slow-motion interrupt function disabled.
    * Bit 1 (int_sig_sel)         = 1. Anymotion/Significant motion interrupt function enabled.
    * Bit 2:3 (int_sig_mot_skip)  = 1. Set the skip time of the significant motion interrupt to 3 seconds.
    * Bit 4:5 (int_sig_mot_proof) = 1. Proof time of the significant motion interrupt is 0.5 seconds.
    * Page 79
    */
    bmx160.writeBmxReg(BMX160_INT_MOTION_3_ADDR, 0x16);
    delay(2);

    uint8_t _new_int_motion[4] = {0};
    bmx160.readReg(BMX160_INT_MOTION_0_ADDR, _new_int_motion, 4);
    Serial.printf("[I] [initIMU]: New INT_MOTION Configuration: %s\r\n", buffer_to_string(_new_int_motion, 4));
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant