Driving an RTC from clock other than 32.768kHz - Page 1
Forum section: electronics / beginners

author: bluespider
author_rank: Contributor
timestamp: April 20, 2024, 05:07:59 pm
content: ==Background==I am just starting out on the process of redesigning the MCU part of a battery powered datalogger. One feature it needs to have is an RTC or counter so that in the event of a low battery the device can enter some sort of low power state but that an external clock and counter remains powered.The device requires a highly accurate clock with a low drift, unless I find a better alternative I will reuse the clock in the new design (as it's on a separate PCB and also very expensive!).The clock has 3x outputs: PPS, 125Hz, 8.192MHz. The 8.192MHz is used to generate a 2.048MHz clock that is required by the ADC, The PPS is used for syncing the ADCs, measuring clock drift, and driving a counter in a CPLD which acts as the RTC in the old system (The main function of the CPLD is no longer required in the new design). The 125Hz output is not used.Ideally I'll just use a microcontroller with a built in RTC and Backup power input pin, however it seems that they expect a 32.768kHz clock or crystal, the same is true of the dedicated RTC chips and 32bit counters that I've found. Most of these devices internall divide down to PPS signals anyway so it would be really useful to be able to just supply the PPS directly.==Question==Is there an easy way to get a 32.768kHz clock from a PPS, 125Hz, or 8.192MHz signal? This would open up the most options for device selection.OrIs there a (popular) 32bit MCU (cortex-m0+ probably), RTC IC or 32bit Counter that will accept one of the clock speeds mentioned? Ideally any counter or rtc will be able to read/set via i2c.I think the Atmel samd chips have an adjustable rtc scaler which if I can set that to '1' will probably work. But I haven't been able to confirm yet.

author: langwadt
author_rank: Super Contributor
timestamp: April 20, 2024, 07:19:32 pm
content: most MCU's will probably run from 8.192MHz in place of an xtal. I know the RTC in an STM32 will run of the main clock divided and has prescalers to work with most frequencies.On I2C you can make it act like a standard RTC, I've done that so I didn't have to write a driver for linux to use it

author: aliarifat794
author_rank: Regular Contributor
timestamp: April 20, 2024, 07:39:34 pm
content: You have to look at the datasheet of the particular RTC that you'll be using. Thus you will find out if the RTC has configurable prescalers or not.

author: bluespider
author_rank: Contributor
timestamp: April 21, 2024, 08:21:00 pm
content: Thanks for the replies - I think I was getting really confused reading datasheets between /n and /2^n values for various pre-scalers. I think I just need to work out which clocks can be kept active in different power modes. Ideally I'll just try and use the PPS on a GPIO with a /1 prescaler so that there's no extra synchronization needed.I didn't find any RTC/Counters that would accept a different clock input.I probably should have also said - the main clocks I will be using have a draw of about 1.5mA at 3.3V so I don't really need 'really' low power.

author: edavid
author_rank: Super Contributor
timestamp: April 21, 2024, 10:31:41 pm
content: Why not divide the 8.192MHz by 250 to get 32768Hz? You can do that with 2 74HC390s.

author: bluespider
author_rank: Contributor
timestamp: April 22, 2024, 08:02:44 am
content: QuoteBecause I didn't know they existedI think I'd been assuming that I'd have to work with powers of 2.

author: Ground_Loop
author_rank: Frequent Contributor
timestamp: April 22, 2024, 09:37:39 am
content: Is a DS3231-based clock module an option? No need to configure clocks, highly stable and accurate, communicates via I2C, has battery backup.

author: bluespider
author_rank: Contributor
timestamp: April 22, 2024, 06:44:02 pm
content: Unfortuantly not, the application requires a much lower drift. The clocks we use at the moment are usually better than 1.5s per year, and given the cost I'd rather reuse them. If there was a better performing alternative, then it may be worthwhile.