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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

1,248件の閲覧回数
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?

ラベル(1)
0 件の賞賛
3 返答(返信)

1,048件の閲覧回数
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.

1,048件の閲覧回数
akshaydaga
Contributor III

Finally, It worked.

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

0 件の賞賛

1,048件の閲覧回数
akshaydaga
Contributor III

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

0 件の賞賛