32kHz Crystal driving QE128 RTC

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

32kHz Crystal driving QE128 RTC

683 Views
admin
Specialist II

Hello,

 

I'm trying to get a 32768 crystal to drive the RTC module for the QE128 while getting regular interrupts about every ms.

Right now, I have things working correctly using the internal oscillator, but I'd like to improve long term RTC accuracy.

 

First of all, is this even possible? When I set the prescale value to 0, it appears to disable the RTC clock source (the interrupt vector never runs).  So given that it appears I HAVE to use the prescaler, it's not possible for me to set the prescaler to a low value when using an external clock source.

 

Second, while I'm certain that the crystal and trim capacitors are installed correctly, I cannot get the RTC to use this crystal with any prescale value.  Does anyone have any suggestions?

 

Thank you. 

Labels (1)
0 Kudos
6 Replies

375 Views
TomE
Specialist II

> When I set the prescale value to 0, it appears to disable the RTC clock source

 

Do you mean the RTCSC[RTCPS] prescaler or some other prescaler?

 

"Table 14-3. RTC Prescaler Divide-by values" says the value "0" disables the RTC, which matches what you're seeing.

 

To get "divide by one" you set RTCSC[RTCPS] to "8" and RTCLKS[0] to "1".

 

Tom

 

0 Kudos

375 Views
admin
Specialist II

I am referring to the RTCSC[RTCPS] prescaler.

 

Based on what I'm seeing, there is no way to use an external clock and have a low prescale value?  I'd like to use a 32768Hz crystal with roughly 1kHz interrupts.

0 Kudos

375 Views
TomE
Specialist II

Yes, I see you were trying to "disable the prescaler", but "Figure 14-1. Real-Time Counter (RTC) Block Diagram" doesn't show any bypass path.

 

> there is no way to use an external clock and have a low prescale value?

 

I think the expectation is that the "external crystal" will be in the megahertz range and not in the kilohertz range.

 

Maybe you can use the "Timer/PWM" module in "Output Compare" mode to generate faster interrupts. It looks like it should run directly from the external clock.

 

It doesn't look to be flexible enough to have one counter running from an internal (fast) clock and another one running from the external clock, so if you're already using the PWM this may not be an option.

 

Can you run the FLL locked to your external clock to get a crystal-accurate internal clock, and then run the RTC or PWM from that?

 

Tom

 

0 Kudos

375 Views
admin
Specialist II

My goal for this is accurate internal time keeping, and the crystal is already installed to the xtal and extal pins.  The Timer/PWM module's external clock source is its respective clock pin, so that is not really an option at this point.

I'd be happy to use the crystal accurate FLL to generate a signal for the RTC, but unfortunately, it doesn't appear that the RTC can accept a different clock source.  Unless I'm mistaken.

0 Kudos

375 Views
TomE
Specialist II

> The Timer/PWM module's external clock source is its respective clock pin,

 

Look at "Figure 17-2. TPM Block Diagram". The timers are CLOCKED from the Internal or External clock. That increments the "16 bit counter" which free-runs. You use the timer in "output compare mode" which compares the free running timer with  the value you load into the Comparator register, and that generated an interrupt. No need to use the "timer pin" which is used for OUTPUT or input comparison. You reload the comparator every interrupt with the counter value when you want the next interrupt to happen at - simply on every interrupt you do "comparator += whatever".

 

> it doesn't appear that the RTC can accept a different clock source.

 

"Figure 14-1. Real-Time Counter (RTC) Block Diagram" shows the RTC can be driven from LPO (1-kHz low power oscillator), ERCLK (external clock) or IRCLK (internal clock).

 

I'm suggesting running the RTC from IRCLK, running that from the FLL and syncing the FLL to the external crystal if that's possible.

 

Tom

 

0 Kudos

375 Views
admin
Specialist II

I had thought that the external clock refers to a clock source at pin TPMxCLK, not ICSERCLK.  Figure 1-3 tends to support this assertion.

I don't think it's possible to set the IRCLK to the FLL output.  If so, I'd like to know how to do it.

It may be possible to combine your two suggestions. TPM can be timed from FFCLK, which can be sourced from an external reference clock. 

0 Kudos