How to read CVAL of RTC in MPC5606B? how to calculate time betn 2 ext. interrupts?

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read CVAL of RTC in MPC5606B? how to calculate time betn 2 ext. interrupts?

638 Views
akshaydaga
Contributor III

Hi,

Board: TRK-MPC5606B

Processor: MPC5606B

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?

Labels (1)
0 Kudos
3 Replies

438 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

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.

Regards,

Martin

PS: If the TIF flag is set, Time-out has occurred.

438 Views
akshaydaga
Contributor III

Finally, It worked.

We need to load (0xFFFFFFFF - 1) to LDVAL instead of 0xFFFFFFFF

0 Kudos

438 Views
akshaydaga
Contributor III

I did exactly same as you have mentioned. But it didn't work.

0 Kudos