Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    BMA456 no anymotion interrupt

    olafmeyer
    New Poster

    BMA456 no anymotion interrupt

    I want to use the BMA456 for anymotion detection. I'm using the config file from the bma456_an.c of the SensorApi on GitHub.

    But I don't get any interrupts (neither at the INT1-pin nor in the INT_STATUS Reg). Here is what I do:

    bma456WriteReg(0x7C, 0x02);
    busy_wait(TBW_1us(450));//wait for 450us

    bma456WriteReg(0x59, 0x00); //Adr. 0x59: INIT_CTRL

    //write Configfile
    (void)i2cWrite(BMA456_SLAVEADR_WRITE, (uint8*)bma456an_config_file, sizeof(bma456an_config_file));

    bma456WriteReg(0x59, 0x01); //Adr. 0x59: INIT_CTRL

    busy_wait(TBW_1ms(140));//wait for 140ms

    bma456WriteReg(0x41, 0x00);//Adr. 0x41: range

    bma456WriteReg(0x53, 0x0a);//Adr. 0x53: INT1_IO_CTRL
    bma456WriteReg(0x55, 0x01);//Adr. 0x55: INT_LATCH
    bma456WriteReg(0x56, 0x10);//Adr. 0x56: INT1_MAP

    bma456WriteReg(0x28, 0x38);//Adr. 0x28: FEAT_EN_1

    bma456WriteReg(0x7D, 0x04);//Adr. 0x7D: acc_en

    //read reg 0x2A, bit4 == 1? init_ok
    adr = 0x2A;
    (void)i2cWriteRead(BMA456_SLAVEADR, &adr, 1, buf, 1);
    printf("bma456 init: 0x%x", buf[0] & 0x1F);

    //read anymotion config

    adr = 0x5E;
    (void)i2cWriteRead(BMA456_SLAVEADR, &adr, 1, buf, 4);
    printf("bma456 config: 0x%x, 0x%x, 0x%x, 0x%x", buf[0], buf[1], buf[2], buf[3]);

    //write anymotion config

    buf[0] = 0x5E;
    buf[1] = 0x0A;
    buf[2] = 0x00;
    buf[3] = 0x05;
    buf[4] = 0xE0;//axes enable
    (void)i2cWrite(BMA456_SLAVEADR, buf, 5);

     

    reading Register INTERNAT_STATUS returns 0x01 (ASIC initialized)

    Reading the anymotion config returns 0xc8, 0x2e, 0x00, 0x2e. This should be default values 0xcc, 0x00, 0x05, 0x00 according to Application note "Hearables feature set"

     

    any ideas?

    7 REPLIES 7
    olafmeyer
    New Poster

    Re: BMA456 no anymotion interrupt

    ahh, what I read from Adr. 0x5e is what I've been written to it: it is the first 4 bytes of the configfile: 0xc8 0x2e 0x00 0x2e

    How does it work? It is the same adress to write the configfile to and to read the feature configuration from. It is not the same memory, is it? Is the separation done by writing the 1 in reg. 0x59?

    The configfiles begin with 0xc8 0x2e 0x00 0x2e 0xc8 0x2e 0x00 0x2e 0xc8 0x2e 0x00 0x2e 0xc8 0x2e 0x00 0x2e

    the feature configuation differs from that...

    vpaeder
    Member

    Re: BMA456 no anymotion interrupt

    If you can't write into 0x5e it's likely that the configuration phase went wrong. You should check the status from 0x2a (should be 1).

    Burst writing the configuration data requires that the I2C buffer is large enough. You can write it in chunks following the method that's used in the API (see stream_transfer_write in bma4.c). The trick is to write an offset value into reg 0x5b and 0x5c before sending the chunk's data (set 0x5b to (offset>>1)&0xf and 0x5c to offset >> 5).

    If the status register looks OK, you should be able to write into 0x5e. I also had to add a soft reset (write 0xb6 into reg 0x7e) in the beginning to make sure the chip gets reset when the MCU restarts.

    vpaeder
    Member

    Re: BMA456 no anymotion interrupt

    For reference, here's the quick'n'dirty code I used to test my board. I wired it to an arduino, so the code is for arduino. I took bma456_an_config_file from bma456_an.c.

     

    olafmeyer
    New Poster

    Re: BMA456 no anymotion interrupt

    thank You for your reply. The first problem was, that I didn't reset the BMA456 after downloading a new software to my target. I work with a debugger and make a target reset after downloading new code, but of course that didn't trigger a power up reset to the BMA456. After fixing this, the reading of the configuration worked.

    But still no anymotion interrupt!

    Then I enabled both the anymotion and the nomotion interrupt... and: there was an interrupt when moving the board!
    Disabling nomotion again: no interrupt
    Enabling nomotion and disabling anymotion: interrupt when moving the board.

    Conclusion: I have to use the nomotion interrupt to get an interrupt when the bord is moved? Can anyone confirm this?

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist