03-01-2021 04:25 PM
Hi, I'm using the latest BSEC Library with the BME680 and STM32L431RCTX MCU. After 4292490ms (~71minutes) runtime with 3 second sampling the library hangs. I've tried the float and non-float libraries, and the same failure happens. Either at calling sleep or after bme680_get_profile_dur, or after calculating time_stamp_interval_ms. I forced values of 2730 and 240 for sleep and found that the failure hangs in the library itself. It appears that there is an issue when the a 32bit counter value rolls over. Up to the hang, the sensor and library appear to be working okay. What may be causing this hang, and how does the library handle a timer tick rollover of a 32bit or 64bit integer? Thanks, Robert |
03-01-2021 09:00 PM
I got it work. The problem was in get_timestamp_us(). I needed to promote the return value from 32bit to 64bit. I added (int64_t) in front the calcuted ms to us value. That fix the hang at 32 bits. I'm still cursious if there will be hang at 2^64 like there was at 2^32. I would like to know how the timestamp roll over is handled in the library.
03-10-2021 09:41 AM
Hello rshuler,
In BSEC reference code, it described timestamp unit should be microseconds with 64 bit. User only need call algorithm library according algorithm's requirement.
/*!
* @brief Capture the system time in microseconds
*
* @return system_current_time current system timestamp in microseconds
*/
int64_t get_timestamp_us()
{
int64_t system_current_time = 0;
// ...
// Please insert system specific function to retrieve a timestamp (in microseconds)
// ...
return system_current_time;
}