Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    BMA456 read raw accelerometer values

    BMA456 read raw accelerometer values

    Long-established Member


    I'm using BMA456 hosted by a AVR microcontroller over I2C.

    My goal is just to read continuous XYZ acceleration data from the chip, I don't need any of the special features.

    I've just finished writing the initialization code on my MCU but unfortunately, when I read the accel_drdy flag in the STATUS register, it never goes high. Meaning that there's no acceleration data available. 

    This is how I'm proceeding:

    • I execute the initialization sequence that appears in the document "Wearables Feature Set - Application Note" section 1.1. All goes well here.
    • Then I write the following registers with the following configurations:
      • ACC_CONFIG (0x40)................................ODR:100Hz, AVRG of 32samples, AVERAGE mode selected
      • ACC_RANGE (0x41).................................. +-2g
      • INT1_IO_CTRL (0x53)................................Edge Trigger, Active High, Push-Pull, Output enable, Input disable
      • INT_MAP_DATA(0x58)................................int1_drdy = 1
      • PWR_CONF(0x7C).....................................Advanced power save mode enabled
      • PWR_CTRL(7D)..........................................Enable Accelerometer

    After this initialization, I read the STATUS register (0x03) and wait for the drdy_acc flag to turn on, but it never turns on.

    Am I missing something?


    4 REPLIES 4

    Community Moderator
    Community Moderator



    Please follow p11 ~13.

    You need to check below things.

    1)  0x7D should be done before 0x7C. 

    2) Once initialization done, you should check 0x2A and get 0x01. 


    We have API to support BMA456 features as below.

    Please check our API and use it. 

    Thank you. 

    Long-established Member

    Hello Minhwan,

    Thank you for the feedback.

    I've updated my code with your suggestions. I want to clarify that I won't use your driver, since it needs the user to provide blocking functions for I2C communication and delay functionality. And that's unacceptable for our application since it's implemented in a bare-metal fashion (the driver provided is unacceptable for virtually any bare-metal solution though). For example, during the configuration file uploading, your driver calls a delay of 150ms. That delay in a blocking fashion is unacceptable in a bare-metal solution. Let me know if there's a misunderstanding here.

    That being clarified, here is a step-by-step of what I've done until now. Please take a look and let me know if I'm missing something:


    Step1 - Read chip ID

    Datasheet specification


    My implementation

    • I check the chip ID by reading the register 0x00 (CHIP_ID). I read the value 0x16. This is OK.



    Step2 - Initialization sequence

    Datasheet specification


    My implementation

    • I write the value 0x00 to the register 0x7C ()


    • I wait for ~18ms instead of 500uS (but I don't see this could be a problem, if yes let me know).


    • I prepare the feature engine by writing 0x00 to the register 0x59 (INIT_CTRL)


    I write the configuration file all at once in a single I2C write operation, this means that I write 1200 Bytes in a single write operation (let me know if this is a problem). But for writing that file I first write the registers 0x5B and 0x5C with the index value 0x0000 (LSB to 0x5B and MSB to 0x5C), because I'll write the entire file in a single write operation. Unfortunately, there's no information in the datasheet on how to write the chip in burst mode, so I had to reverse-engineer your driver. This is absolutely inconceivable, but I had to do it.



    After writing the index (0x0000) to the registers 0x5B and 0x5C, I transfer the entire configuration file. I won't include the picture of that capture because is huge.

    • Then I write the value 0x01 to the register 0x59 (INIT_CTRL).



    Step 3 - Check feature engine status

    Datasheet specification


    My implementation

    • I basically read the register 0x2A (INTERNAL_STATUS) until I get 0x01.



    Step 4 - Configure accelerometer

    Datasheet specification


    My implementation

    • I write the values 0x17, 0x04, and 0x03 to the registers 0x40 (ACC_CONF), 0x7D (PWR_CTRL), and 0x7C (PWR_CONF) respectivelly.



    • After that, I keep reading the register 0x1D (INT_STATUS_1) and waiting for the acc_drdy_int flag (bit7) to turn on. But that never happens. That register returns 0x00 every time I read it.



    Please, take your time to review these details and let me know where's the mistake. 



    Hi Btruden, 


    Did you put 150ms delay after writing initialization file ? 

    Before you read 0x2A register, you need 150ms delay for ASIC is intialized. 

    You should value 0x01 once you try to read 0x2A register, not trying continously until you get. 


    Long-established Member

    Hi Minhwan,

    It didn't work. To wait 150ms and then read the register to see if it's 0x01 or keep reading the register until it's 0x01 is almost the same. That change is trivial.