Actions

EmSys

Tm4clib-rcc

From EdWiki

The TM4C clock API provides functionality for manipulating the system clock, oscillator, and PLL. Functions are provided for fine-grained control of clock control registers, while also providing higher level functionality to easily configure the main system clock source.

The following code snippet uses fine-grained mechanisms to configures the chip to run off an external 16MHz crystal, and use the PLL to derive a clock frequency of 80MHz.

/* A divisor of 5 gives us a clock of 400/5 = 80MHz */
#define PLLDIV_80MHZ 5
 
rcc_enable_main_osc();              /* Enable the main oscillator */
rcc_enable_rcc2();                  /* Make RCC2 override RCC */
rcc_configure_xtal(XTAL_16M);       /* Set XTAL value to 16MHz */
rcc_set_osc_source(OSCSRC_MOSC);    /* Set the oscillator source as the main oscillator */
rcc_pll_on();                       /* Enable the PLL */
rcc_set_pll_divisor(PLLDIV_80MHZ);  /* Change the clock divisor */
rcc_wait_for_pll_ready();           /* We cannot use the PLL as a clock source until it locks */
rcc_pll_bypass_disable();           /* Disable PLL bypass to derive the system clock from the PLL clock */
 
tm4c_rcc_sysclk_freq = 80E6;        /* Keep track of frequency */
 
/* The same can be achieved by a simple call to high-level routines: */
/* A divisor of 5 gives us a clock of 400/5 = 80MHz */
#define PLLDIV_80MHZ 5
rcc_sysclk_config(OSCSRC_MOSC, XTAL_16M, PLLDIV_80MHZ);

High-level clock control API

RCC - Low-level clock control API

Variables