The clock system of a microcontroller is a fundamental element. Clock system provides the heart-beat needed to keep applications running in a synchronous manner. In the case of Tiva C micros the clock system is as much as sophisticated and elaborate as with any other ARM micros. In this post we will explore this basic block of Tiva C micros. We will see that the clock system is a network of different clock sources and internal units that are intertwined in a complex but easy manner.

Clock System Basics
Just as with any modern era micros Tiva C micros have several clock sources. Some of these sources are external while most clock sources are internal.

I have taken the liberty to improve the clock tree of Tiva C micros by highlighting special areas of interest. For STM32s micros there is a great tool called STM32CubeMX that can be used to deduce system and peripheral clocks but for Tiva C we have no such tool. We need to do everything on our own and there we are very much likely to make mistakes if we cannot visualize the clock system well. If you notice the clock tree diagram above, it may look a bit complex but in practice it is simple. The green blocks are selectors or multiplexers that are governed by some bit settings. The red boxes are the clock sources. There are four clock sources and two Phase-Lock-Loop (PLL) designated by the purple boxes. The 480 MHz USB PLL is not a concern for now as we will not be discussing about USB communication here. We will be discussing about the 400 MHz PLL only. The interconnections of these sources and blocks make the clock tree appear like a spider web. To resolve this issue I highlighted these connections with different colours. It should be a relaxing view for the eyes now.
Main Oscillator (MOSC) Primary external source. Can be driven by an external single-ended clock generator or a crystal resonator. Only specific frequencies between 4 25 MHz are allowed. Can be used to drive the internal 400 MHz PLL. TM4C123GXL Tiva C Launchpad comes with a 16MHz on board crystal connected to MOSC. Needed to clock the 480 MHz USB PLL unit.

Precision Internal Oscillator (PIOSC) 16 MHz with 1% accuracy and 3% accuracy over temperature. Can be trimmed and calibrated. Can be used to drive the internal 400 MHz PLL. Can clock internal peripherals like ADC blocks, etc. Precision Internal Oscillator Divided by 4 (PI4OSC) Dependent on PIOSC . 4 MHz clock frequency with 1% accuracy. Cannot drive the internal 400 MHz PLL. Low Frequency Internal Oscillator (LFIOSC) Typical clock frequency 30 kHz with 50% accuracy. Intended for Deep-Sleep power saving modes. Can be used when either or both MOSC and PIOSC are powered down. Not suitable for accurate time-based operations. Hibernation Module Clock Source Clocked by an external 32.768 kHz RTC crystal or clock generator of same frequency. Can provide accurate clock source during Deep-Sleep power saving modes. TM4C123GXL Tiva C Launchpad comes with a 32.768 kHz on board RTC crystal.
All of the aforementioned sources can be system clock source. However peripheral clocks can be different. Most peripherals like SSI , UART , ADC , etc. can clocked by the PIOSC unless specified otherwise. PIOSC should never be disabled unless needed and that is because if MOSC is used and it fails for some reason, PIOSC will take over the role of providing clock signal.
400 MHz Phase-Lock-LoopARM micros are about speed and power and so most of the times we would want an ARM micro to be as fast as possible. To facilitate this speed thrust most ARM microcontrollers are equipped with Phase-Lock-Loops (PLL). Not only it cuts down cost by removing the need for rare, expensive high frequency external crystals but gives users lot of clock frequency options which would have been impossible otherwise. TM4C123x comes with an internal 400 MHz PLL, the internal working mechanism of which is not important here. However unlike the PLLs of other micros like STM32s, instead of multiplying input clock source, it is divided by System Divisor , Sysdiv to obtain desired clock speeds. No wonder Americans think differently from the rest of the world. With the internal PLL we can generate clock frequencies from 3.125 MHz to 80 MHz, 80 MHz being the top operating clock speed for the TM4C123x. The PLL can be driven by two sources only:
Precision Internal Oscillator (PIOSC) Main Oscillator (MOSC) Run-Mode Clock ControlThe system clock control is provided by a pair of registers called Run-Mode Clock Control , RCC . RCC and RCC2 registers does the following things:
Selects clock source for sleep and deep-sleep modes. Selects whether or not to use the internal 400 MHz PLL. Controls the oscillators’ and the PLL’s operating state. Set clock divisions and crystal input selection.The RCC register needs to be configured before RCC2 if RCC2 is needed. RCC2 is basically an extension of the RCC register and it overrides RCC settings. In most cases RCC2 will be needed.
Before going further I would like to reintroduce a very useful tool because what will be discussed next is related to this tool and its use. In several of my earlier posts I mentioned the advantage of using MikroC’s project editor. Using this tool we can easily set the required clock settings.

As seen we can see many drop-down menus. However these may look as much ambiguous as the clock tree itself. Thus we need to look at the three tables shown next. Note the 2 s in some menus. These refer to RCC2 while the reset are related to RCC registers.



When the BYPASS bit is 0 , the internal 400 MHz PLL is used and scaled. It is not bypassed. Likewise when it is 1 , preselected clock source is used and scaled accordingly. These tables demonstrate possible clock frequencies.
When using the MikroC’s Project Editor , we need to set system clock in a systematic order. Let us consider the 80 MHz max system clock speed setup. First we need to set the RCC settings as shown.