4
\$\begingroup\$

STM32F030 Datasheet here.

  1. On page 14, it's mentioned that:

"System clock selection is performed on startup, however the internal RC 8 MHz oscillator is selected as default CPU clock on reset. An external 4-32 MHz clock can be selected, in which case it is monitored for failure."

I believe that microcontroller can be run perfectly using internal crystal. Am I right? If I am, then in what cases would someone want to connect an external crystal to the controller? Is it to run the controller at a lower frequency (to save power)? I think this can also be achieved by setting some prescalers on the internal clock. Are there certain applications which mandate the requirement of an external crystal? If yes, what could they be?

  1. Page 21 says:

The RTC clock sources can be:

• A 32.768 kHz external crystal

• A resonator or oscillator

• The internal low-power RC oscillator (typical frequency of 40 kHz)

• The high-speed external clock divided by 32

Will RTC be able to keep accurate time on internal clock source? I am fine with +-5 seconds per day. Can I achieve that comfortably?

I have always seen 32.768 kHz crystal being used with RTC chips which makes it easy to count due to 2^15 value. However internal clock source gives it a 40 kHz signal. Could there be any issues arising due to this?

  1. Usually in microcontrollers with internal RTC, there is a dedicated VBAT pin which is used to keep the RTC alive during power failure. I couldn't find such a pin on this device. Where can I connect the battery to get the intended backup supply for RTC? There are multiple VDD pins but I am unable to make out whether one of them is VBAT pin or not and if yes, then which one. Pin definitions are from page 28-33.
\$\endgroup\$
4
\$\begingroup\$

1) High-Speed clock

Typically, the tolerance on internal MCU oscillators is bad. It is very difficult for manufacturers to trim the internal RC network that generates the frequency to obtain something stable and accurate. In the MCU you mention, for example, the HSI is 8MHz +/-1%, which is very inaccurate for a time reference. USB, for example, which is made to be easily implementable and does not require very accurate timings, still requires +/-0.25% for full-speed communication. So, in this case, you need a crystal. A crystal typically has +/-50-100ppm tolerance (0.005%-0.01%).

From a consumption point of view, however, you'd better use the HSI than a crystal. The crystal requires an oscillator circuit that usually consumes more (at least for crystals in the 8MHz range).

And, yes, the prescaler allows to run the MCU at a lower frequency than the HSI or crystal. But this is available whatever the timing source is.

2) Low-Speed clock

If you look at page 60, you'll see the internal low speed oscillator (LSI) can be anywhere from 30KHz to 50KHz. So, it would accumulate up to 6 hours of error a day! And the 1% HSI clock, 15 minutes a day. So, if you need less than +-5 seconds per day of drift, you need a crystal. And if you do the math, you even need a 50ppm crystal (at least).

Otherwise, there would be no problem in dividing the LSI frequency by 40000 rather than 32768 to obtain a ~1 second timer. The hardware allows this.

3) VBAT

There is no VBAT pin, indeed. And this functionality is not provided by one of the VDD pin. It simply does not exist on this MCU. However, you could have some external circuitry to supply the whole chip with the battery when the normal supply is not available (e.g. with or-ing diodes), and put the MCU in standby mode (with LSE active) so you don't draw too much current on the battery. But it is less paractical indeed.

\$\endgroup\$
  • \$\begingroup\$ dim, you brightened my day. Well puns aside, thanks a lot for your answer. Few follow up questions - Do I need external crystal for i2c, UART etc? Without VBAT pin, don't you think the purpose of having RTC is defeated? What could be a possible use for such an RTC, which doesn't have a battery backup? \$\endgroup\$ – Whiskeyjack Jul 4 '16 at 13:49
  • \$\begingroup\$ As I said, you can still have a battery backup. It just becomes more complicated because you have to add some external circuitry to pick the supply from the normal DC input or backup battery. If you need more info on this, maybe it deserves its own question. \$\endgroup\$ – dim Jul 4 '16 at 13:53
  • \$\begingroup\$ Regarding I2C, the timing does not need no be accurate because it is synchronous (there is a clock), so you're fine without a crystal. Regarding UART, you may want to check if the other side can tolerate 1% clock drift, but it certainly isn't a problem. Resynchronization is done for every byte, and a byte is 10bits with start and stop, so it makes 0.1 bit of drift max in the end. Well within the specs of most RS232 devices. \$\endgroup\$ – dim Jul 4 '16 at 14:04
  • \$\begingroup\$ @Whiskeyjack and I just understood your joke, actually... dim/brighten... I can't really tell if it's good or bad, but it actually made me smile. \$\endgroup\$ – dim Jul 4 '16 at 14:13
  • 1
    \$\begingroup\$ I have posted another question asking for backup circuit here: electronics.stackexchange.com/q/244335/68606 \$\endgroup\$ – Whiskeyjack Jul 4 '16 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.