Skip to main content
Visitor II
May 30, 2019
Question

Why does an STM32 ARM Microcontroller have 2 resonators?

  • May 30, 2019
  • 10 replies
  • 6040 views

Hi guys,

I want to build my own Microcontroller development board from scratch, as I was checking the data sheet for the STM32F103C8T6 and STM32405RGT6 processors, there were 2 crystals specified on the data sheet. But when I look at tutorials online on how to design your own Microcontroller development board, he doesn't use a crystal at all (https://www.youtube.com/watch?v=tgUx0Gm7-RM you can skip to 18:27 to see his schematic).

And when I was watching another video on how to make your own (drone) Flight Controller this guys just uses 1 crystal than the two given on the data sheet (https://www.youtube.com/watch?v=Uu2vGFMq4Zo&list=PLoPtpxJIxgnYnPrOeGHs3rdhhPgNGIYN5&index=5 you can jump to 2:22 to see the schematic he is using.)

I am getting very confused wether I should put 2 crystals, 1, or no crystal on my board. Also, I am a 12th grader who has a passion in electronics and don't know much of the stuff as you know, so please try to make it simple for me to understand.

Thank you

    This topic has been closed for replies.

    10 replies

    Visitor II
    May 30, 2019

    Ok, also look at STM32L4 family.

    First, at boot, the STM32 boots with internal resonator (HSI = high frequency source internal clock) say 16MHz.

    It has some tolerances (percentage) so its precision has limitation in some specifics such as RS232 at high speed, USB, Ethernet.

    For such precise clocks, you need 24MHz for USB, 25MHz for Ethernet or 16MHz typically otherwise.

    The external clock source in Nucleo board by default comes from on board STLink MCU which sends its buffered clock to the target MCU (cost reduce).

    These are HSE (precise external high frequency source).

    If the HSE clock fails, the HSI will kick in as backup and the MCU can be let aware.

    Now for specific applications you need precise time clock and calendar, this goes to RTC (real time clock).

    There is an internal one (LSI) which allows some peripherals or the MCU to run at very low frequency aiming at low power.

    But if you implement a meter application, you need very precise clock over time, and consume low power.

    For this, you need very precise clock which comes from an external 32768Hz external clock source which is LSI.

    On the L4 family, it is possible to regenerate a high frequency from LSE at lower power budget than using external dual crystals.

    This is MSI.

    So it's application dependent. Power concern, precision concern, cost concern, drift over time concern.

    And like in the L4, most peripheral can choose their clock source. Now you have choice and enough degrees of freedom to get a solution for your implementation.

    SashvatAuthor
    Visitor II
    May 30, 2019

    Thank you very much for that simple explanation, just a few doubts, when seeing a STM32 blue pill, a 8MHz crystal is being used, but in the data sheet of the STM32, it says upto clock freq-72MHz, why?

    Second, do you think its a safe option to have both crystals on board?

    Visitor II
    May 30, 2019

    There is a PLL inside the STM which multiplies the 8MHz up to 72 MHz (or lots of other freqs if you prefer)

    Visitor II
    May 30, 2019

    As it's your own PCB, I would put pads for both crystals (and supporting Cs) but don't load them unless you find you need them for things like USB or audio.

    SashvatAuthor
    Visitor II
    May 30, 2019

    I will be using USB to send and receive data, so are you saying only the 8MHz crystal is enough? and what do you mean by "load them"?

    Visitor II
    May 30, 2019

    If you are using USB then the main crystal is essential I think.

    By "load them" I mean just because there are pads or holes on a PCB doesn't mean you have to put components on the board. But it's far easier to do so when you discover you need them.

    Visitor II
    May 30, 2019

    To be honest, why are you designing your own board ? I had to because nobody does a multiple H7 board but there's so many options for F1 and F4 series on AliExpress which are always cheaper than making your own. I use Blue Pills by the bucketload.

    SashvatAuthor
    Visitor II
    May 30, 2019

    just simply for fun, just to build on my circuit building skills and PCB. And not only that, I plan to make a robot, which I want to use this Microcontroller and make it all from scratch once I am satisfied with my prototype.

    Visitor II
    May 30, 2019

    I would reccomend to use STM32L496 it's a good mid-range low power part if later on you want to run on batteries.

    Decent amount of on board memory as well unless using a display.

    Some peripherals are 2nd gen such as the SPI with FIFO and programmable word length.

    SashvatAuthor
    Visitor II
    May 30, 2019

    Just an out of topic question for all those who have answered here, what have you guys studied that makes you know about all this? What degree have you guys done to be able to understand all this?

    Visitor II
    May 30, 2019

    We didn't have microprocessors for my first degree :) It's the 45 years of experience since that counts the most.

    SashvatAuthor
    Visitor II
    May 30, 2019

    ohh wow! but what is your specialisation in sir?

    Visitor II
    May 30, 2019

    To put it more simply: There are two clocks. One is processor clock and the other is for realtime clock (and some low power peripherals). Both have RC-oscillators built in, but the accuracy is not that great. Both clocks can be switched to crystal driven oscillators or external oscillators for better accuracy.

    SashvatAuthor
    Visitor II
    May 30, 2019

    So its not necessary to add an external oscillator, but adding one increases accuracy of timing. So there are 3 clocks in total- 1) the internal MCU's clock and the optional 8MHz and 32.768kHz crystals correct?

    But which increases the accuracy of the timing? the 8MHz, or the 32.768kHz crystal?

    Super User
    May 30, 2019

    Back to the USB question: if you need a USB device (not host) function - some STM32s do not need external crystal at all. Instead, they can sync by the start-of-frame signal sent by the host side.

    -- pa

    Visitor II
    May 30, 2019

    You have to dig the spec of the external oscillator and crystal, and the datasheet electrical tables for the STM32 to know what you get.

    Usually, accuracy comes at a cost, when justified. Otherwise, look at Nucleo's schematic for basic implementation.

    SashvatAuthor
    Visitor II
    May 30, 2019

    Thank you very much

    SashvatAuthor
    Visitor II
    May 31, 2019

    I was just seeing a STM32F302CBT6 data sheet and for the LSE (32.768kHz oscillator), the capacitor values are not specified, where is it specified for this MCU?

    Visitor II
    May 31, 2019

    The 8 MHz crystal or oscillator increases the accuracy of processor clock (as well as the USB and ethernet clocks). The 32 kHz crystal/oscillator increases the accuracy of realtime clock. The documents use these names:

    HSE = High speed external clock = processor clock crystal/oscillator (8 MHz)

    HSI = High speed internal clock = the RC-oscillator for processor clock

    LSE = Low speed external clock = RTC crystal/oscillatoe (32KHz)

    LSI = Low speed internal clock = the RC-oscillator for RTC clock

    You can use any combination of those. Some chips can also use one crystal for both, but I have no experience how well that works.

    Note, however, that when the system is set in low power mode, like standby, the processor clock is stopped.

    ST Employee
    May 31, 2019

    There is a detailed application note regarding the STM32 oscillators: AN2867