Driver API for PMC (plib_pmc.h) More...
Macros | |
| #define | PMC_SLOW_CLK_FREQ (32768U) |
| #define | PMC_UPLL_CLK_FREQ (32768U) |
Typedefs | |
| typedef void(* | PMC_CALLBACK) (uint32_t int_status_reg) |
| Callback function type for PMC interrupt events. | |
| typedef uint32_t | PMC_INT_SOURCE |
| PMC interrupt source mask type. | |
| typedef uint32_t | PMC_MOSCRCF |
| Main RC Oscillator frequency selection. | |
| typedef uint32_t | PMC_MCKR_PRESCALAR |
| Host Clock prescaler selection. | |
| typedef uint32_t | PMC_MCKR_DIV |
| Host Clock divider selection. | |
| typedef uint32_t | PMC_MCKR_CLKSS |
| Main/Host Clock source selection. | |
| typedef uint32_t | PMC_PCK_CLKSS |
| Programmable Clock source selection. | |
| typedef uint32_t | PMC_GCLKCSS |
| Generic Clock source selection for peripherals. | |
Enumerations | |
| enum | PMC_PERIPH_CLK_SOURCE { PMC_PERIPH_CLK_SOURCE_HOST_CLK , PMC_PERIPH_CLK_SOURCE_GCLK } |
| Peripheral clock source selection. More... | |
Functions | |
| uint32_t | CLOCK_GetPeripheralChannelFreq (uint32_t peripheral_id, PMC_PERIPH_CLK_SOURCE clock_source) |
| Gets the frequency of the peripheral clock channel. | |
| bool | PMC_MainRCOscIsReady (void) |
| Checks if the Main RC Oscillator is ready. | |
| void | PMC_EnableMainRCOsc (void) |
| Enables the Main RC Oscillator. | |
| void | PMC_SetMainRCOscFreq (PMC_MOSCRCF freq_sel_value) |
| Sets the frequency of the Main RC Oscillator. | |
| void | PMC_DisableMainRCOsc (void) |
| Disables the Main RC Oscillator. | |
| void | PMC_EnableMainCrystalOsc (uint32_t startup_time, bool bypass_mode) |
| Enables the Main Crystal Oscillator with specified startup time and mode. | |
| bool | PMC_MainCrystalOscIsReady (void) |
| Checks if the Main Crystal Oscillator is ready. | |
| void | PMC_SetMainClockSource (uint32_t clock_source) |
| Selects the source for the MAINCK clock line. | |
| void | PMC_SetCounterClockSource (uint32_t clock_source) |
| Selects the clock source for the Main Clock frequency counter. | |
| uint32_t | PMC_GetMainClockFreqCount (void) |
| Gives the number of cycles of the clock selected by the bit CCSS within 16 SLOW_CLK periods.To calculate the frequency of the measured clock: fSELCLK = (MAINF x fSLOW_CLK)/16 , where frequency is in MHz. | |
| uint32_t | PMC_GetMainClockFreq (uint32_t slow_clk_freq) |
| Calculates the frequency of the Main Clock based on the count value and the slow clock frequency. | |
| bool | PMC_MainClockFreqIsReady (void) |
| Checks if the Main Clock frequency measurement is ready. | |
| void | PMC_SetPLLAClock (uint32_t mula, uint32_t diva, uint32_t plla_count) |
| Configures the PLLA clock with specified multiplier, divider, and count values. | |
| bool | PMC_PLLAClockIsLocked (void) |
| Checks if the PLLA is locked and ready. | |
| uint32_t | PMC_GetPLLAFreq (void) |
| Gets the current frequency of the PLLA clock. | |
| bool | PMC_HostClockIsReady (void) |
| Checks if the Host Clock (MAIN_CLK) is ready. | |
| void | PMC_SetHostClockPrescaler (PMC_MCKR_PRESCALAR prescaler_value) |
| Sets the prescaler value for the Host Clock. | |
| void | PMC_SetHostClockDivider (PMC_MCKR_DIV divider_value) |
| Sets the divider value for the Host Clock. | |
| void | PMC_SetHostClockSource (PMC_MCKR_CLKSS clock_source) |
| Selects the clock source for the Host Clock. | |
| void | PMC_ConfigureProgrammableClock (uint32_t clock_id, PMC_PCK_CLKSS clock_source, uint8_t prescaler) |
| Configures a programmable clock with the specified source and prescaler. | |
| void | PMC_EnableProgrammableClock (uint32_t clock_id) |
| Enables the specified programmable clock output. | |
| void | PMC_DisableProgrammableClock (uint32_t clock_id) |
| Disables the specified programmable clock output. | |
| bool | PMC_ProgrammableClockIsReady (uint32_t clock_id) |
| Checks if the specified programmable clock is ready. | |
| void | PMC_EnablePeripheralClock (uint32_t peripheral_id) |
| Enables the clock for the specified peripheral. | |
| void | PMC_DisablePeripheralClock (uint32_t peripheral_id) |
| Disables the clock for the specified peripheral. | |
| void | PMC_EnableGenericClock (uint32_t peripheral_id, PMC_GCLKCSS clock_source, uint32_t gclkdiv) |
| Enables and configures the Generic Clock for the specified peripheral. | |
| void | PMC_DisableGenericClock (uint32_t peripheral_id) |
| Disables the Generic Clock for the specified peripheral. | |
| void | PMC_EnableInterrupt (PMC_INT_SOURCE source_msk) |
| Enables the specified PMC interrupt source(s). | |
| void | PMC_DisableInterrupt (PMC_INT_SOURCE source_msk) |
| Disables the specified PMC interrupt source(s). | |
| bool | PMC_InterruptFlagIsSet (PMC_INT_SOURCE source_msk) |
| Checks if the specified PMC interrupt flag is set. | |
| void | PMC_SetCallbackHandler (PMC_CALLBACK callback) |
| Registers a callback function for PMC interrupt events. | |
Variables | |
| uint32_t | SystemCoreClock |
| System core clock frequency. This global variable holds the current core (CPU) clock frequency in Hertz. Update the value with SystemCoreClockUpdate() whenever the core clock is changed. | |
Driver API for PMC (plib_pmc.h)
| #define PMC_SLOW_CLK_FREQ (32768U) |
| #define PMC_UPLL_CLK_FREQ (32768U) |
| PMC_CALLBACK |
Callback function type for PMC interrupt events.
| int_status_reg | The value of the PMC interrupt status register at the time of the interrupt. |
Generic Clock source selection for peripherals.
This type is intended to be configured using the device family pack (DFP) field macros for the Generic Clock source selection.
PMC_PCR_GCLKCSS_* macros, for example:PMC_PCR_GCLKCSS_SLOW_CLK_Val (Slow Clock)PMC_PCR_GCLKCSS_MAIN_CLK_Val (Main Clock)PMC_PCR_GCLKCSS_PLLA_CLK_Val (PLLA Clock)PMC_PCR_GCLKCSS_UPLL_CLK_Val (UPLL Clock)PMC_PCR_GCLKCSS_MCK_CLK_Val (Master Clock) PMC interrupt source mask type.
This type is intended to be configured using the device family pack (DFP) interrupt mask macros for PMC interrupt sources.
PMC_IER_*_Msk or PMC_IDR_*_Msk mask macros from the DFP. Multiple interrupt sources can be combined using bitwise OR operation. Main/Host Clock source selection.
This type is intended to be configured using the device family pack (DFP) field macros for the Main/Host Clock source selection.
PMC_MCKR_CSS_* macros, for example:PMC_MCKR_CSS_SLOW_CLK_Val (Slow Clock)PMC_MCKR_CSS_MAIN_CLK_Val (Main Clock)PMC_MCKR_CSS_PLLA_CLK_Val (PLLA Clock)PMC_MCKR_CSS_UPLL_CLK_Val (UPLL Clock) Host Clock divider selection.
This type is intended to be configured using the device family pack (DFP) field macros for the Host Clock divider setting.
PMC_MCKR_MDIV_* macros, for example:PMC_MCKR_MDIV_EQ_PCK_Val (no division)PMC_MCKR_MDIV_PCK_DIV2_Val (divide by 2)PMC_MCKR_MDIV_PCK_DIV3_Val (divide by 3)PMC_MCKR_MDIV_PCK_DIV4_Val (divide by 4) Host Clock prescaler selection.
This type is intended to be configured using the device family pack (DFP) field macros for the Host Clock prescaler setting.
PMC_MCKR_PRES_CLK_* macros, for example:PMC_MCKR_PRES_CLK_1_Val (no division)PMC_MCKR_PRES_CLK_2_Val (divide by 2)PMC_MCKR_PRES_CLK_4_Val (divide by 4)PMC_MCKR_PRES_CLK_8_Val (divide by 8)PMC_MCKR_PRES_CLK_16_Val (divide by 16)PMC_MCKR_PRES_CLK_32_Val (divide by 32)PMC_MCKR_PRES_CLK_64_Val (divide by 64)PMC_MCKR_PRES_CLK_3_Val (divide by 3) Main RC Oscillator frequency selection.
This type is intended to be configured using the device family pack (DFP) field macros for the Main RC Oscillator frequency setting.
CKGR_MOR_MOSCRCF_* macros, for example:CKGR_MOR_MOSCRCF_4_MHz_Val (4 MHz)CKGR_MOR_MOSCRCF_8_MHz_Val (8 MHz)CKGR_MOR_MOSCRCF_12_MHz_Val (12 MHz) Programmable Clock source selection.
This type is intended to be configured using the device family pack (DFP) field macros for the Programmable Clock source selection.
PMC_PCK_CSS_* macros, for example:PMC_PCK_CSS_SLOW_CLK_Val (Slow Clock)PMC_PCK_CSS_MAIN_CLK_Val (Main Clock)PMC_PCK_CSS_PLLA_CLK_Val (PLLA Clock)PMC_PCK_CSS_UPLL_CLK_Val (UPLL Clock)PMC_PCK_CSS_MCK_Val (Master Clock) | uint32_t CLOCK_GetPeripheralChannelFreq | ( | uint32_t | peripheral_id, |
| PMC_PERIPH_CLK_SOURCE | clock_source ) |
Gets the frequency of the peripheral clock channel.
| peripheral_id | Peripheral ID selection from PID2 to PID127. |
| clock_source | The clock source for the peripheral (PMC_PERIPH_CLK_SOURCE). |
| void PMC_ConfigureProgrammableClock | ( | uint32_t | clock_id, |
| PMC_PCK_CLKSS | clock_source, | ||
| uint8_t | prescaler ) |
Configures a programmable clock with the specified source and prescaler.
| clock_id | The programmable clock identifier (PCK0 = 0, PCK1 = 1 etc.). |
| clock_source | The clock source selection for the programmable clock (PMC_PCK_CLKSS). |
| prescaler | The prescaler value to divide the selected clock source. Range : 0 to 255, where the division factor is (prescaler + 1). |
| void PMC_DisableGenericClock | ( | uint32_t | peripheral_id | ) |
Disables the Generic Clock for the specified peripheral.
| peripheral_id | Peripheral ID selection from PID2 to PID127. |
| void PMC_DisableInterrupt | ( | PMC_INT_SOURCE | source_msk | ) |
Disables the specified PMC interrupt source(s).
| source_msk | The interrupt source mask to disable (PMC_INT_SOURCE). |
| void PMC_DisableMainRCOsc | ( | void | ) |
Disables the Main RC Oscillator.
| None. |
| void PMC_DisablePeripheralClock | ( | uint32_t | peripheral_id | ) |
Disables the clock for the specified peripheral.
| peripheral_id | Peripheral ID selection from PID2 to PID127. |
| void PMC_DisableProgrammableClock | ( | uint32_t | clock_id | ) |
Disables the specified programmable clock output.
| clock_id | The programmable clock identifier (PCK0 = 0, PCK1 = 1 etc.). |
| void PMC_EnableGenericClock | ( | uint32_t | peripheral_id, |
| PMC_GCLKCSS | clock_source, | ||
| uint32_t | gclkdiv ) |
Enables and configures the Generic Clock for the specified peripheral.
| peripheral_id | Peripheral ID selection from PID2 to PID127. |
| clock_source | The Generic Clock source selection value (PMC_GCLKCSS). |
| gclkdiv | Generic clock is the selected clock period divided by GCLKDIV + 1. GCLKDIV must not be changed while the peripheral selects GCLKx (e.g., bit rate, etc.) |
| void PMC_EnableInterrupt | ( | PMC_INT_SOURCE | source_msk | ) |
Enables the specified PMC interrupt source(s).
| source_msk | The interrupt source mask to enable (PMC_INT_SOURCE). |
| void PMC_EnableMainCrystalOsc | ( | uint32_t | startup_time, |
| bool | bypass_mode ) |
Enables the Main Crystal Oscillator with specified startup time and mode.
| startup_time | Number of SLOW_CLK cycles multiplied by 8 for the main crystal oscillator startup time. |
| bypass_mode | Set to true to enable bypass mode (external stable clock source), false for crystal oscillator mode. Ensure that an external (stable) clock is connected on XIN. |
| void PMC_EnableMainRCOsc | ( | void | ) |
Enables the Main RC Oscillator.
| None. |
| void PMC_EnablePeripheralClock | ( | uint32_t | peripheral_id | ) |
Enables the clock for the specified peripheral.
| peripheral_id | Peripheral ID selection from PID2 to PID127. |
| void PMC_EnableProgrammableClock | ( | uint32_t | clock_id | ) |
Enables the specified programmable clock output.
| clock_id | The programmable clock identifier (PCK0 = 0, PCK1 = 1 etc.). |
| uint32_t PMC_GetMainClockFreq | ( | uint32_t | slow_clk_freq | ) |
Calculates the frequency of the Main Clock based on the count value and the slow clock frequency.
| slow_clk_freq | The frequency of the slow clock (in Hz). |
| uint32_t PMC_GetMainClockFreqCount | ( | void | ) |
Gives the number of cycles of the clock selected by the bit CCSS within 16 SLOW_CLK periods.To calculate the frequency of the measured clock: fSELCLK = (MAINF x fSLOW_CLK)/16 , where frequency is in MHz.
| None. |
| uint32_t PMC_GetPLLAFreq | ( | void | ) |
Gets the current frequency of the PLLA clock.
| None. |
| bool PMC_HostClockIsReady | ( | void | ) |
Checks if the Host Clock (MAIN_CLK) is ready.
| None. |
| bool PMC_InterruptFlagIsSet | ( | PMC_INT_SOURCE | source_msk | ) |
Checks if the specified PMC interrupt flag is set.
| source_msk | The interrupt source mask to check (PMC_INT_SOURCE). |
| bool PMC_MainClockFreqIsReady | ( | void | ) |
Checks if the Main Clock frequency measurement is ready.
| None. |
| bool PMC_MainCrystalOscIsReady | ( | void | ) |
Checks if the Main Crystal Oscillator is ready.
| None. |
| bool PMC_MainRCOscIsReady | ( | void | ) |
Checks if the Main RC Oscillator is ready.
| None. |
| bool PMC_PLLAClockIsLocked | ( | void | ) |
Checks if the PLLA is locked and ready.
| None. |
| bool PMC_ProgrammableClockIsReady | ( | uint32_t | clock_id | ) |
Checks if the specified programmable clock is ready.
| clock_id | The programmable clock identifier (PCK0 = 0, PCK1 = 1 etc.). |
| void PMC_SetCallbackHandler | ( | PMC_CALLBACK | callback | ) |
Registers a callback function for PMC interrupt events.
| callback | Pointer to the callback function to be registered. |
| void PMC_SetCounterClockSource | ( | uint32_t | clock_source | ) |
Selects the clock source for the Main Clock frequency counter.
| clock_source | The clock source selection value for the counter. 0 = Main RC Oscillator, 1 = Main Crystal Oscillator. |
| void PMC_SetHostClockDivider | ( | PMC_MCKR_DIV | divider_value | ) |
Sets the divider value for the Host Clock.
| divider_value | The divider value to further divide the Host Clock (PMC_MCKR_DIV). |
| void PMC_SetHostClockPrescaler | ( | PMC_MCKR_PRESCALAR | prescaler_value | ) |
Sets the prescaler value for the Host Clock.
| prescaler_value | The prescaler value to divide the Host Clock (PMC_MCKR_PRESCALAR). |
| void PMC_SetHostClockSource | ( | PMC_MCKR_CLKSS | clock_source | ) |
Selects the clock source for the Host Clock.
| clock_source | The clock source selection value for the Host Clock (PMC_MCKR_CLKSS). |
| void PMC_SetMainClockSource | ( | uint32_t | clock_source | ) |
Selects the source for the MAINCK clock line.
| clock_source | The clock source selection value for MAINCK Line. Select between Main RC Oscillator or Main Crystal Oscillator. |
| void PMC_SetMainRCOscFreq | ( | PMC_MOSCRCF | freq_sel_value | ) |
Sets the frequency of the Main RC Oscillator.
| freq_sel_value | The frequency selection value for the Main RC Oscillator (PMC_MOSCRCF). |
| void PMC_SetPLLAClock | ( | uint32_t | mula, |
| uint32_t | diva, | ||
| uint32_t | plla_count ) |
Configures the PLLA clock with specified multiplier, divider, and count values.
| mula | The PLL multiplier value. PLLCK frequency is the PLLA input frequency multiplied by MULA + 1. Range : 1 to 62. If 0, PLLA is disabled. |
| diva | PLLA Front End Divider. When DIVA is 1, the divider is bypassed. Range : 1 to 63. If 0, PLLA is disabled. |
| plla_count | number of SLOW_CLK cycles before the LOCKA bit is set in PMC_SR after CKGR_PLLAR is written. Default is 0x3FU. IMPORTANT: Make sure the Flash Wait States are configured properly before changing the CPU clock frequency. |
|
extern |
System core clock frequency. This global variable holds the current core (CPU) clock frequency in Hertz. Update the value with SystemCoreClockUpdate() whenever the core clock is changed.