Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    BMA456 no anymotion interrupt

    BMA456 no anymotion interrupt

    New Poster

    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

    New Poster

    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...

    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.

    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.


    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?