I have initialised the RTC. I have two external interrupts.
In first interrupts, I am loading the full 0xFFFFFFFF value to the LDVAL and started the timer. (It is down timer)
In second interrupt, I am reading the Current value of the timer using CVAL register. and clearing to TIF bit & disabling the timer. So as to calculate the time between two interrupts. (I have taken care that time between two interrupt is less than 60 seconds so that timer is not getting reloaded again and again)
But, It is not giving me expected result.
Can anyone help me through this or suggest any other method to calculate the time between two interrupts?
at first, do you really use RTC? Because the registers you describe are part of PIT (periodic interrupt timer).
About the time calculation, you need to know the frequency of the PIT module which is the same as system clock frequency.
The calculation is following:
difference = LDVAL on beginning minus CVAL during second interrupt
time = difference * (1/system_frequency)
So for example:
Fsys = 66MHz
LDVAL = 0xFFFFFFFF
Read CVAL during second interrupt (example only) 0xFFFFFFF0
difference = 0xFFFFFFFF - 0xFFFFFFF0 = F
time = 15*(1/66MHz) = 0,000 000 227s = 227ns.
Hope it helps.
PS: If the TIF flag is set, Time-out has occurred.