M5223X RTC details

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

M5223X RTC details

1,822件の閲覧回数
mjbcswitzerland
Specialist V
Hi All

I am just integrating a driver interface to use the RTC in the M5223X.

Since I haven't used it just yet I thought that may be someone who has can answer a couple of points which are not totally clear from the documentation...

1. I would like to be able to read back the time. This involves reading three registers (seconds, hours_minutes, days).
There is a small risk involved because whilst reading one of them it could be possible that others get incremented due to the fact that a 1Hz clock arrives between instructions.
Therefore I will try disabling the RTC during the read sequence and re-enabling it again afterwards.
Will this work or will disabling cause side effects (apart from possibly losing a 1 Hz tick?)

2. I have seen that the set up of the RTC 1Hz rate is given in the example as:
        MCF_CLOCK_RTCDR = 48000000;  /* device dependent */

I think that the oscillator clock is required and not the PLL rate (?)

The M5223X has (always) 25MHz so 25000000 would seem appropriate. However I have also read that the value 0 disables the clock and the divide value is one more that the register value.

This would suggets that the best setting would be (25000000 - 1) - or in the example case (48000000 - 1).

Have I understood this correctly?



Apart from those points it seems quiet straight forward. Or is there anything else to watch out for?

Regards

Mark

www.uTasker.com


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

471件の閲覧回数
rocco
Senior Contributor II
Hi Mark

I have not used the Coldfires yet, but had a similar problem with a real-time clock. My solution was to always read the clock starting with the most significant data: days, then hours, then minutes and finally seconds. Then I would test the seconds value, and if it was zero I would simply read everything again. It potentually adds a few instructions every minute, but works everytime.

As far as your second question:
http://forums.freescale.com/freescale/board/message?board.id=CFCOMM&message.id=2188&query.id=18916#M...
0 件の賞賛
返信

471件の閲覧回数
mjbcswitzerland
Specialist V
Hi Rocco

Thanks for the idea and the link to the other posting - I did search for RTC but not the register so didn't find it.
It will not be practical to test whether 25000000 or (25000000-1) is correct since it will only be measurable over long periods with an accurate 25000000 monitor at the same time so it doesn't really make any difference. I will go for the (25000000-1) since it seems to correspond with the instructions.

There is another method to ensure that the overflow doesn't occur and that is to set a second interrupt and read the time on that, however it is not very practicle. I think that I will use your suggested method since it will then not involve with playing with the enable.

Cheers

Mark

www.uTasker.com

0 件の賞賛
返信

471件の閲覧回数
mjbcswitzerland
Specialist V
Hi

Here's my new code:


Code:
    case RTC_GET_TIME:        {        int iLoop = 0;            do {                ((RTC_SETUP *)ptrSettings)->usDays = DAYS;                ((RTC_SETUP *)ptrSettings)->hours = (unsigned char)(HOURMIN >> 8);                ((RTC_SETUP *)ptrSettings)->ucMinutes = (unsigned char)(HOURMIN & MINUTES_MASK);                ((RTC_SETUP *)ptrSettings)->ucSeconds = (unsigned char)(SECONDS & SECONDS_MASK);            } while ((((RTC_SETUP *)ptrSettings)->ucSeconds == 0) && (iLoop++ == 0)); // if seconds is zero re-read to ensure no overflow during first read sequence        }        break;

Mark
 

0 件の賞賛
返信