This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is ble_hrs_heart_rate_measurement_send safe to call in interrupt?

developer.nordicsemi.com/.../a00969.html

I'm trying to understand whether this can be called in a timer interrupt (app_timer) and how frequently. I seem to have a bug where after the first 60 or so samples, not every sample is being sent up to the nRF Toolbox iOS app.

Test setup

Foreground

Push an incrementing counter to a queue every 100ms via a repeating timer interrupt.

Background (main loop)

If there is a sample in the queue, remove that sample and send it with ble_hrs_heart_rate_measurement_send

I just clocked on an oscilloscope that it takes ~77us from the moment the counter is incremented to the moment the code enters ble_hrs_heart_rate_measurement_send so I'm definitely consuming the data from the queue much faster than it is being generated.

Observed result

On nordic's HRM iOS app, after about 50 or so samples, everything that follows is a sequence of ~5 of the same number e.g. 4 5 6 7 8 9 ... 55 55 55 55 55 65 65 65 65 65 ...

Am I calling the send function too frequently?