Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BMA456 read raw accelerometer values

    btruden_henway
    Long-established Member

    BMA456 read raw accelerometer values

    Hello,

    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?

    Thanks

    4 REPLIES 4
    Minhwan
    Community Moderator

    Re: BMA456 read raw accelerometer values

    Hi, 

     

    https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bma456-ds000.pdf

    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. 

    https://github.com/BoschSensortec/BMA456-Sensor-API

    https://github.com/boschsensortec/BMA456-Sensor-API/blob/master/bma456an_examples/accelerometer/acce...

    Please check our API and use it. 

    Thank you. 

    btruden_henway
    Long-established Member

    Re: BMA456 read raw accelerometer values

    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:

    STEP-BY-STEP

    Step1 - Read chip ID

    Datasheet specification

    btruden_henway_1-1674684365056.png

    My implementation

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

    btruden_henway_0-1674684081737.png

     

    Step2 - Initialization sequence

    Datasheet specification

    btruden_henway_2-1674684480370.png

    My implementation

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

    btruden_henway_3-1674684569882.png

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

    btruden_henway_4-1674684783932.png

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

    btruden_henway_5-1674684923935.png

    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.

    btruden_henway_6-1674685332526.png

    btruden_henway_8-1674685361525.png

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

    btruden_henway_9-1674685585580.png

     

    Step 3 - Check feature engine status

    Datasheet specification

    btruden_henway_10-1674685668466.png

    My implementation

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

    btruden_henway_11-1674685783763.png

     

    Step 4 - Configure accelerometer

    Datasheet specification

    btruden_henway_12-1674685843582.png

    My implementation

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

    btruden_henway_15-1674686061954.png
    btruden_henway_14-1674686040853.png

    btruden_henway_16-1674686081845.png

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

    btruden_henway_17-1674686236203.png

     

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

    Thanks

     

    Minhwan
    Community Moderator

    Re: BMA456 read raw accelerometer values

    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. 

    Thanks, 

    btruden_henway
    Long-established Member

    Re: BMA456 read raw accelerometer values

    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.

    Regards

    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