Bosch Sensortec Community

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

    BMA2-Sensor-API bma2.c

    BMA2-Sensor-API bma2.c

    Coleman
    New Poster

    Hello

    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);
    Line727:
    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);
    Line732:
    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);
    Line740:
    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

    FAE_CA1
    Community Moderator
    Community Moderator

    Hi,

    Thanks for your feedback.

    Please refer to the latest BMA2x2 API code at https://github.com/BoschSensortec/BMA2x2_driver/blob/master/bma2x2.c to see if the issue is still there or not.

    Thanks.

    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.

    FAE_CA1
    Community Moderator
    Community Moderator

    Hi,

    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.

    Thanks.

    Thank you for the reply.

    I will see the attached pdf file.

    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