Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    BMA2-Sensor-API bma2.c

    BMA2-Sensor-API bma2.c

    New Poster


    I am trying to set the registers for BMA253 and was looking at the source code - in BMA2-Sensor-API  bma2.c - and I have a few questions.

    I am looking at v0.3.0 

    On line 726, in bma2_set_accel_conf() function, it is reading the register 0x11(PMU_LPW) and that doesn't make sense.

    below is the code snippet:


    Line726: rslt = bma2_get_regs(BMA2_REG_PMU_LPW, reg_data, 2, dev);
    Line728: if (rslt == BMA2_OK)
    Line729: {
    Line730: reg_data[0] = BMA2_SET_BITS_POS_0(reg_data[0], BMA2_RANGE, accel_conf->range);
    Line731: reg_data[1] = BMA2_SET_BITS_POS_0(reg_data[1], BMA2_BW, accel_conf->bw);
    Line733: /* Set the values in the accel configuration registers */
    Line734: rslt = bma2_set_regs(BMA2_REG_PMU_RANGE, reg_data, 2, dev);


    it is reading from 0x11(PMU_LPW) , setting the range and bandwith and writing it to 0x0F(PMU_RANGE).

    shouldn' t it be getting from register 0x0F(PMU_RANGE)? (it doesn't really matter because PMU_LPW is 0x00 and you are setting the reg_data with your range and bw)


    The code just after this is, I think, setting 0x3 in the reserved bit. (Line742)

    code snippets below:


    Line736: if (rslt == BMA2_OK)
    Line737: {
    Line738: reg_data[0] = BMA2_SET_BITS(reg_data[0], BMA2_SHADOW_DIS, accel_conf->shadow_dis);
    Line739: reg_data[0] = BMA2_SET_BITS(reg_data[0], BMA2_DATA_HIGH_BW, accel_conf->data_high_bw);
    Line741: /* Set the values in the accel config register */
    Line742: rslt = bma2_set_regs(BMA2_REG_ACCD_HBW, &reg_data[0], 1, dev);


    when i printf the reg_data , reg_data[0] has 0x03 when setting data to register 0x13(ACCD_HBW).

    In the case of BMA253, according to the data sheet, bit7 and bit6 is for data_high_bw and shadow_dis.

    bit5 to bit0 are for reserved and setting 0x03 means strange because you set data on the reserved bit.

    I think you have previous data (pmu range) in reg_data[0].

    it seems that you should be calling bma2_get_regs() function with parameter 0x13(ACCD_HBW) before setting reg_data[0] on line738.

    that's all. I appreciate if you could give me a feedback.

    4 REPLIES 4

    Community Moderator
    Community Moderator


    Thanks for your feedback.

    Please refer to the latest BMA2x2 API code at to see if the issue is still there or not.


    I am planning to use the BMA2x2_driver for my BMA253.

    I guess the BMA2x2_driver doesn't have that issue.

    So it is OK, thank you for the reply anyways.


    The reason I was posting  a question was that:

    I am planning to use the BMA2x2_driver bma2x2.c for BMA253, and I want to set the low-g interrupt (freefall detection).

    But BMA2x2_driver bma2x2_support.c  didn't have an example to set the low-g interrupt.

    So I was referencing the BMA2-Sensor-API example/low-g.c for setting up the BMA253 low-g interrupt.

    While I was looking at BMA2-Sensor-API, I came across the code above (BMA2-Sensor-API bma2.c v0.3.0) and it didn't look right for BMA253.

    I thought BMA2-Sensor-API supported BMA253 because it had an if statements for BMA2_BMA253_CHIP_ID in bma2_init() function.

    Community Moderator
    Community Moderator


    You can directly configure BMA253 for low-g interrupt without the need of using BMA2x2 API code. Please see the attached "How to generate freefall interrupt using BMA253.pdf" for more information.


    Thank you for the reply.

    I will see the attached pdf file.