Wistrio LoraWan 5205 and RTC clock

Hello,
I’m trying to determinate precisely the time an input is high, so I’m using a timer with interrupt that increments each time (1 second) the input is high. Also I write on Flash RAM this value every minute.
To be sure that it is in real time, I connected, in parallel to this input, an external time counter and I noticed a slight shift between the internal timer (STM32) and the external counter (2 minutes every 24 hours).
Looking inside the code, it seems that the basic timer is based on the RTC clock. But how to explain this shift then?
Do you think I could use a more accurate timer?

Thanks
Regards

Hello,
I finally found what was going wrong. I was using a kind of tick every second which had the effect of creating a slight delay each time I stopped and restarted the timer.
Now, I use the TimerGetElapsedTime (savedTime) function to determine the elapsed time since the beginning of the event and I no longer see any shift between the external counter and the internal one.
This is the best solution I think.
Regards