This group contains functions and definitions related to configuring and enabling/disabling on-chip PLLs. A PLL will take an input signal (the source), optionally divide the frequency by a configurable divider, and then multiply the frequency by a configurable multiplier.
Some devices don't support input dividers; specifying any other divisor than 1 on these devices will result in an assertion failure. Other devices may have various restrictions to the frequency range of the input and output signals.
- Example: Setting up PLL0 with default parameters
The following example shows how to configure and enable PLL0 using the default parameters specified using the configuration symbols listed above.
To configure, enable PLL0 using the default parameters and to disable a specific feature like Wide Bandwidth Mode (a UC3A3-specific PLL option.), you can use this initialization process.
return;
}
pll_config_set_option(&pllcfg, PLL_OPT_WBM_DISABLE);
When the last function call returns, PLL0 is ready to be used as the main system clock source.
Configuration Symbols
Each PLL has a set of default parameters determined by the following configuration symbols in the application's configuration file:
- CONFIG_PLLn_SOURCE: The default clock source connected to the input of PLL n. Must be one of the values defined by the pll_source enum.
- CONFIG_PLLn_MUL: The default multiplier (loop divider) of PLL n.
- CONFIG_PLLn_DIV: The default input divider of PLL n.
These configuration symbols determine the result of calling pll_config_defaults() and pll_get_default_rate().
◆ CONFIG_PLL1_DIV
#define CONFIG_PLL1_DIV 0 |
◆ CONFIG_PLL1_MUL
#define CONFIG_PLL1_MUL 0 |
◆ CONFIG_PLL1_SOURCE
◆ NR_PLLS
◆ pll_config_defaults
#define pll_config_defaults |
( |
|
cfg, |
|
|
|
pll_id |
|
) |
| |
Value: CONFIG_PLL##pll_id##_SOURCE, \
CONFIG_PLL##pll_id##_DIV, \
CONFIG_PLL##pll_id##_MUL)
static void pll_config_init(struct pll_config *p_cfg, enum pll_source e_src, uint32_t ul_div, uint32_t ul_mul)
Initialize PLL configuration using default parameters.
After this function returns, cfg will contain a configuration which will make the PLL run at (CONFIG_PLLx_MUL / CONFIG_PLLx_DIV) times the frequency of CONFIG_PLLx_SOURCE.
- Parameters
-
cfg | The PLL configuration to be initialized. |
pll_id | Use defaults for this PLL. |
Definition at line 131 of file same70/pll.h.
◆ PLL_COUNT
◆ pll_get_default_rate
#define pll_get_default_rate |
( |
|
pll_id | ) |
|
Value: * CONFIG_PLL##pll_id##_MUL) \
/ CONFIG_PLL##pll_id##_DIV)
static uint32_t osc_get_rate(uint32_t ul_id)
Get the default rate in Hz of pll_id.
Definition at line 82 of file same70/pll.h.
◆ PLL_INPUT_MAX_HZ
#define PLL_INPUT_MAX_HZ 32000000 |
◆ PLL_INPUT_MIN_HZ
#define PLL_INPUT_MIN_HZ 3000000 |
◆ PLL_OUTPUT_MAX_HZ
#define PLL_OUTPUT_MAX_HZ 500000000 |
◆ PLL_OUTPUT_MIN_HZ
#define PLL_OUTPUT_MIN_HZ 160000000 |
◆ PLL_UPLL_HZ
#define PLL_UPLL_HZ 480000000 |
◆ PLLA_ID
◆ UPLL_ID
◆ pll_source
PLL clock source.
Enumerator |
---|
PLL_SRC_MAINCK_4M_RC | Internal 4MHz RC oscillator.
|
PLL_SRC_MAINCK_8M_RC | Internal 8MHz RC oscillator.
|
PLL_SRC_MAINCK_12M_RC | Internal 12MHz RC oscillator.
|
PLL_SRC_MAINCK_XTAL | External crystal oscillator.
|
PLL_SRC_MAINCK_BYPASS | External bypass oscillator.
|
PLL_NR_SOURCES | Number of PLL sources.
|
Definition at line 69 of file same70/pll.h.
◆ pll_config_init()
static void pll_config_init |
( |
struct pll_config * |
p_cfg, |
|
|
enum pll_source |
e_src, |
|
|
uint32_t |
ul_div, |
|
|
uint32_t |
ul_mul |
|
) |
| |
|
inlinestatic |
- Note
- The SAMV71 PLL hardware interprets mul as mul+1. For readability the hardware mul+1 is hidden in this implementation. Use mul as mul effective value.
Definition at line 106 of file same70/pll.h.
◆ pll_config_read()
static void pll_config_read |
( |
struct pll_config * |
p_cfg, |
|
|
uint32_t |
ul_pll_id |
|
) |
| |
|
inlinestatic |
◆ pll_config_write()
static void pll_config_write |
( |
const struct pll_config * |
p_cfg, |
|
|
uint32_t |
ul_pll_id |
|
) |
| |
|
inlinestatic |
◆ pll_disable()
static void pll_disable |
( |
uint32_t |
ul_pll_id | ) |
|
|
inlinestatic |
- Note
- This will only disable the selected PLL, not the underlying oscillator (mainck).
Definition at line 175 of file same70/pll.h.
◆ pll_enable()
static void pll_enable |
( |
const struct pll_config * |
p_cfg, |
|
|
uint32_t |
ul_pll_id |
|
) |
| |
|
inlinestatic |
◆ pll_enable_config_defaults()
void pll_enable_config_defaults |
( |
unsigned int |
pll_id | ) |
|
|
inlinestatic |
Enable the pll with the default configuration. PLL is enabled, if the PLL is not already locked.
- Parameters
-
pll_id | The ID of the PLL to enable. |
Definition at line 215 of file same70/pll.h.
◆ pll_enable_source()
Enable the source of the pll. The source is enabled, if the source is not already running.
- Parameters
-
src | The ID of the PLL source to enable. |
Definition at line 197 of file same70/pll.h.
◆ pll_is_locked()
static uint32_t pll_is_locked |
( |
uint32_t |
ul_pll_id | ) |
|
|
inlinestatic |
◆ pll_wait_for_lock()
static int pll_wait_for_lock |
( |
unsigned int |
pll_id | ) |
|
|
inlinestatic |
Wait for PLL pll_id to become locked.
- Todo:
- Use a timeout to avoid waiting forever and hanging the system
- Parameters
-
pll_id | The ID of the PLL to wait for. |
- Return values
-
STATUS_OK | The PLL is now locked. |
ERR_TIMEOUT | Timed out waiting for PLL to become locked. |
Definition at line 317 of file pll.h.