Communicate with sensor in timer interrupt occurs issue

Hi,

My product uses two sensors, and S113 on nrf52833

I need to communicate and compute data before to update my ble caracteristic.

Sensor 1 takes 45ms to do this tasks ( communication + computation + update ble carac).

Sensors 2 takes 16ms.

I do this periodically with timer interrupt each 100ms for Sensor 1, and each second for sensor 2.

App Timer interrupt is set to 6 in my sdk_config.h.

I remark that ble connexion crash when sensor 1 timer happen. I guess it comes from the fact i'm blocking the software and softdevice or may be others tasks can not execute.

So i decided to use a flag set in timer, and execute sensor communication and ble update in the main loop, by checking the flag.

Now it works better.

I would like confirmation it is the issue and or reference value of the time we could spend in interrupt to aovid issue. 

Is also my solution the good way to proceed? Is there a more professionnal way to do it ?

Thank you very much !

Related