Real time Counter S08RTCV1 accuracy

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Real time Counter S08RTCV1 accuracy

1,046 Views
Richly
Contributor III

In discussing the real time counter (S08RTCV1), the MC9S08SH32 reference manual says "Because the 1-kHz clock source is not as accurate as a crystal, ...."  However, the block diagrams all show the 1-kHz internal low-power oscillator (LPO), a potential clock source for the RTC module, with leads to the external crystal.

 

Does this mean that if there is an external crystal, the RTC can use the LPO as its clock source and that the LPO can be synced to the crystal, which in our design will be 32.768 kHz, to produce a crystal-controlled time base?  Our goals are

  1) to generate 10ms interrupts and

  2) provide reasonably accurately timed intervals lasting up to 100 hours. 

 

I find the documentation less than clear on this point.  Can anyone enlighten me?

 

Thanks!

    - Richly

Labels (1)
0 Kudos
3 Replies

227 Views
bigmac
Specialist III

Hello Richly,

 

One of three clock sources can be selected for the RTC module, either the LPO, the internal reference (IRCLK), or the external reference (ERCLK).  Of these sources, ERCLK will have the best accuracy, and the LPO the worst accuracy.  IRCLK is capable of being trimmed, so should have better accuracy than the LPO.

 

However, ERCLK and IRCLK are available in stop 3 mode, and not in stop 2.  In stop 2, the LPO is the only option.

 

Using a 32.768kHz crystal for ERCLK, you might use a prescale value of 2, and a modulo value of 163. This should give a RTC overflow period very close to (but not exactly) 10 ms.  Longer timed intervals can then utilize variables that are incremented (or decremented) within the RTC ISR, each 10 ms.  For timed periods of 100 hours, a 32-bit variable would be required.

 

Regards,

Mac

0 Kudos

227 Views
Richly
Contributor III

Thanks, Mac, for your help.  From your reply, it's clear that I should use the ERCLK as the clock source for both the MTIM and the RTC. I don't need to worry about low power, since the device is plugged in.

 

Using the MTIM, prescaler set to 256 and modulo set to 163, its interrupt is 10.009 ms, close enough for what I need since the error doesn't get much time to accumulate in this particular part of the application.

 

The RTC can be used with prescaler set to 1024 and modulo set to 39 to give 1.25 second interrupts, an interval I need anyway.  Then, 48 of these RTC interrupts is exactly one minute (with crystal accuracy), and from that, I can easily manage intervals up to 100 hours, since the required resolution is one minute.

 

Cheers, 

    Richly

0 Kudos

227 Views
Richly
Contributor III

I was a little slapdash in my reply above.  The two units use different clock sources to get the results mentioned:

    The MTIM uses the Bus Clock.

    The RTC uses the External Clock.

 

0 Kudos