05-01-2021 01:22 AM - edited 05-01-2021 02:26 AM
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, ®_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.
Solved! Go to Solution.
05-03-2021 04:41 PM
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.
05-05-2021 10:52 AM - edited 05-05-2021 02:41 PM
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.
05-05-2021 05:28 PM
05-06-2021 06:01 AM
Thank you for the reply.
I will see the attached pdf file.