Replies: 3 comments 5 replies
-
@trombik It looks like bug to me |
Beta Was this translation helpful? Give feedback.
-
I posted over at espressif's forums (https://esp32.com/viewtopic.php?f=13&t=38274).
|
Beta Was this translation helpful? Give feedback.
-
@trombik
_read_reg_nolock() is just a wrapper for i2c_dev_read_reg() so didn't feel the need to go that low. So I'll keep trying to dig up what the issue might be and if I figure out anything related to the DPS310 library I'll let you know. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I was wondering if anyone could help me figure out what is going on here.
I am using a DPS310 that every 1 second I use to take a Temperature Sample and a Pressure Sample.
Code works like this
This code will run for a long period of time usually more than 10 minutes have seen up to 2 hours then I'll get an Assert as follows.
assert failed: raw_to_scaled dps310.c:745 (rate <= N_SCALE_FACTORS - 1)
(I have added some debug code so the line number might be slightly off)
This line of code lives in the function raw_to_scaled(int32_t raw, uint8_t rate).
Some times a Temperature Read causes that function to trigger the assert some times its a Pressure Read so both some how end up getting a rate returned that is out of bounds.
I have added Debug code to print out the rate that is being passed to raw_to_scaled function. I have seen the value 13 and value 15 passed to it when the Assert gets triggered.
I then added code to fire a I/O pin when the value is greater than the Assert trigger value. This way I could check the i2c bus with a scope.
What I found was the following.
The scope triggered on the GPIO pin that was toggled when the Assert triggered. The rate value passed was 15.
The dps310_get_oversampling_p(dev, &P_rate) function in dps310_read_pressure(dps310_t *dev, float *pressure) is what triggered the assert. This function queries register (DPS310_REG_PRS_CFG) 0x06 and masks it with 0x1111 to get the Oversampling rate.
When I check for this on the scope in the I2C bus data I see DPS310_REG_PRS_CFG returned 0x04 which was what it should have been. As I have both temperature and pressure set to 16 times oversampling.
So now I'm left really confused because the data on the bus is correct but the value being passed to the raw_to_scaled function is 15 and the fact it happens after running for a long time makes me more confused.
Beta Was this translation helpful? Give feedback.
All reactions