Electronic – Sanity check: Using the DS3231 as a clock source for uC

clockdesignmicrocontrollerpicrtc

The DS3231 is an RTC chip with an onboard temperature compensated oscillator and 32kHz output.

I want to use this chip in a small clock project I'm designing because I've got a couple lying around. Since it's got the the 32kHz output, I want to use that as a main clock source for the microcontroller (PIC18F4550) and skip the discrete XTAL to save on space and BOM.

All the examples I have found use a higher-speed crystal to drive the main microcontroller and ignore the 32kHz output of the RTC, although sometimes the 32kHz is used to drive other circuitry.

This is making me doubt my design decision, but I haven't found anything that outright says I can't do it. Are there any gotchas I should know about before I fab the board? I realize that by using this method I don't have a second clock source to tune the oscillator. I do plan on prototyping it.

Here is my schematic:

enter image description here

(The TPS chip is a 3.3V regulator connected right up to the 9V battery. EN should read /EN)

Best Answer

This PIC, and all other PIC18's that I know of, have an internal oscillator block. There is no need for an external crystal, even if you didn't have the 32kHz output. The only time you would need to use an external XTAL or clock would be:

  1. To synchronize multiple devices to the same clock,
  2. If you need a very specific frequency (for serial communications, etc), or
  3. If you need more accuracy that the internal oscillator would provide.

You configure this INTOSC block by setting bits in the OSCCON register. You can choose from eight values from 31kHz to 8MHz to run the system clock.

In the OSCCON register, set the SCS1 bit to use the internal oscillator block. Then, set the IRCF2:IRCF0 bits to choose your frequency. This picture is from Section 2.4.1 of the datasheet:

INTOSC

This is convenient because you can choose a slow frequency for lower power usage, and then increase it if you need to.

You could, of course, use the 32kHz RTC output, but it may just be unnecessary complexity. Also, keep in mind that the PIC18F4550 has a different oscillator architecture than other PIC18's because of the way it clocks it's USB module. This won't stop you from using the 32kHz signal, but it will require a different configuration that you may be used to.

Related Topic