03-11-2024 07:48 PM - edited 03-12-2024 11:27 AM
I have been using BMM350. I am initialising it using APIs from the library and setting power mode suspend and then when I put it in forced mode and see data , it returns me same data all the time ? what can be the problem ?
following is my code.
if I do not put sensor in suspend mode , it runs ok! @BSTRobin
--------
bmm350_init(&dev);/* Initialize BMM350 */
/* Set ODR and performance */
bmm350_set_odr_performance(BMM350_DATA_RATE_1_5625HZ, BMM350_NO_AVERAGING, &dev);
/* Enable all axis */
rslt = bmm350_enable_axes(BMM350_X_EN, BMM350_Y_EN, BMM350_Z_EN, &dev);
rslt = bmm350_set_powermode(BMM350_NORMAL_MODE, &dev);
rslt = bmm350_delay_us(10000, &dev);
rslt = bmm350_get_compensated_mag_xyz_temp_data(&mag_temp_data, &dev);
bmm350_set_powermode(BMM350_SUSPEND_MODE,&dev); // power saving while not in use
while (1){
bmm350_set_powermode(BMM350_FORCED_MODE,&dev); // power saving while not in use
bmm350_get_compensated_mag_xyz_temp_data(&mag_temp_data, &dev);
delay(1000);
}
I can not see updated data if sensor is not sampling at ODR rate as can be seen in the following picture. Only when I see periodic current consumption at ODR rate I see updated data. The time between two current peak is around 663 ms which is inverse of 1.5625 Hz.
Solved! Go to Solution.
03-21-2024 11:28 AM - edited 03-21-2024 12:28 PM
@BSTRobin
I am using exactly same code without any change.
I am using Renesas MCU and sensor interfaced as shown in following figure. VCC is having 1.8V
I also tried to put a loop around PMU busy and it seems like it is busy always, never gets free.
loop looks like this
/* Check PMU busy */
rslt = bmm350_get_pmu_cmd_status_0(&pmu_cmd_stat_0, &dev);
bmm350_error_codes_print_result("bmm350_get_pmu_cmd_status_0", rslt);
printf("Expected : 0x07 : PMU cmd busy : 0x0\n");
printf("Read : 0x07 : PMU cmd busy : 0x%X\n", pmu_cmd_stat_0.pmu_cmd_busy);
while(pmu_cmd_stat_0.pmu_cmd_busy != 0){
/* Check PMU busy */
rslt = bmm350_get_pmu_cmd_status_0(&pmu_cmd_stat_0, &dev);
bmm350_error_codes_print_result("bmm350_get_pmu_cmd_status_0", rslt);
printf("Expected : 0x07 : PMU cmd busy : 0x0\n");
printf("Read : 0x07 : PMU cmd busy : 0x%X\n", pmu_cmd_stat_0.pmu_cmd_busy);
R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS);
}
output looks like this Always, you can also see my code in the attachment
Expected : 0x07 : PMU cmd busy : 0x0
Read : 0x07 : PMU cmd busy : 0x1
Also I tried to put a loop around error checking which is returning 0xff always!
And I want to know what is the correct way to put sensor in low power mode and read valid values occasionally. It is not clear from the examples.
shold I configure it
1. init -> Normal mode -> suspend mode -> loop [forced mode -> read]
2. init -> Normal mode -> suspend mode -> loop [read ] --- this is in example , but as you said it is not useful
3. init -> forced mode -> loop[read] -- I tried forced mode example but results are not changing the same as this one, I have attached that logs and code as well.
03-21-2024 01:36 PM
@BSTRobin
I am putting this sensor in Suspend mode and reading it after putting it into forced mode, it seems all the registers have FF
init->normal mode -> suspend mode -> loop [ forced mode -> wait 2s -> read]
03-21-2024 06:12 PM - edited 03-21-2024 06:17 PM
The issue is solved by lowering the baud rate on I2C from around 300k to around 100k.
correct sequence to read in suspend mode is
init -> settings -> suspend mode -> loop [forced mode -> read sensor]
combination 1 in example of forced mode is not following the above mentioned sequence and not producing updated value in each loop.
Thanks a lot for your help @BSTRobin