Strictly necessary cookies are on by default and cannot be turned off. Functional, Performance and Tracking/targeting/sharing cookies can be turned on below based on your preferences (this banner will remain available for you to accept cookies). You may change your cookie settings by deleting cookies from your browser. Then this banner will appear again. You can learn more details about cookies HERE.
Strictly necessary (always on)
Functional, Performance and Tracking/targeting/sharing (default off)
It is a pressure sensor returning a 16 bit value over I2C.
My sensor does have an interrupt line but as I said earlier its not reliable (+-15%) and the output is not fixed. And the exact time of each sample is vital so this is not an option.
I need a way of polling the data in fixed intervals. I have set it up in a for loop with a delay to space out my reads to give me 1.811khz and it works but i feel this is not the best way to do. I know from my experience with stm32 mcu you can internal interrupt to call a function at fixed intervals.
As ehoffman previously suggested, the only feasible way to do this is to run an infinite loop, kicking the watchdog on every loop and breaking the loop on the appropriate end condition (some number of samples).
This is possible since you'll be out of connection at the time, but it's tough to say how the system will react to this afterward. If you store your data in NVRAM and do a soft reset, you'll probably be good to go. It shouldn't take long to write some code that does this--just sit in a loop for a couple seconds, break it and check the functionality of the BLE, SW timers, callbacks, etc.
I have the watch dog disabled and not connected via bluetooth while i will be reading.
Id prefer not read my data by a for loop and a delay between each read to try set my sampling frequency.
Id like to do it by an internal interrupt so i know no matter what happens in the code my function will be called at the correct time and no matter what happenes on the i2c bus the time between each read will be fixed.