CMSIS-Driver_PIC32CZ-MC70  
Peripheral Library (PLIB) Documentation
 
Loading...
Searching...
No Matches
PMC Interface

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.
 

Description

Driver API for PMC (plib_pmc.h)

Macro Definition Documentation

◆ PMC_SLOW_CLK_FREQ

#define PMC_SLOW_CLK_FREQ   (32768U)

◆ PMC_UPLL_CLK_FREQ

#define PMC_UPLL_CLK_FREQ   (32768U)

Typedef Documentation

◆ PMC_CALLBACK

PMC_CALLBACK

Callback function type for PMC interrupt events.

Parameters
int_status_regThe value of the PMC interrupt status register at the time of the interrupt.

◆ PMC_GCLKCSS

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.

Valid values
Use one of the 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_INT_SOURCE

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.

Valid values
Use the appropriate PMC_IER_*_Msk or PMC_IDR_*_Msk mask macros from the DFP. Multiple interrupt sources can be combined using bitwise OR operation.

◆ PMC_MCKR_CLKSS

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.

Valid values
Use one of the 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)

◆ PMC_MCKR_DIV

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.

Valid values
Use one of the 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)

◆ PMC_MCKR_PRESCALAR

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.

Valid values
Use one of the 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)

◆ PMC_MOSCRCF

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.

Valid values
Use one of the 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)

◆ PMC_PCK_CLKSS

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.

Valid values
Use one of the 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)

Enumeration Type Documentation

◆ PMC_PERIPH_CLK_SOURCE

Peripheral clock source selection.

Specifies the clock source for peripherals in the Power Management Controller.

Enumerator
PMC_PERIPH_CLK_SOURCE_HOST_CLK 

Host clock (MAIN_CLK) source

PMC_PERIPH_CLK_SOURCE_GCLK 

Generic clock (GCLK) source

Function Documentation

◆ CLOCK_GetPeripheralChannelFreq()

uint32_t CLOCK_GetPeripheralChannelFreq ( uint32_t peripheral_id,
PMC_PERIPH_CLK_SOURCE clock_source )

Gets the frequency of the peripheral clock channel.

Parameters
peripheral_idPeripheral ID selection from PID2 to PID127.
clock_sourceThe clock source for the peripheral (PMC_PERIPH_CLK_SOURCE).
Returns
The calculated frequency of the peripheral clock channel (in Hz). Returns 0 if the clock is not enabled.

◆ PMC_ConfigureProgrammableClock()

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.

Parameters
clock_idThe programmable clock identifier (PCK0 = 0, PCK1 = 1 etc.).
clock_sourceThe clock source selection for the programmable clock (PMC_PCK_CLKSS).
prescalerThe prescaler value to divide the selected clock source. Range : 0 to 255, where the division factor is (prescaler + 1).
Returns
None.

◆ PMC_DisableGenericClock()

void PMC_DisableGenericClock ( uint32_t peripheral_id)

Disables the Generic Clock for the specified peripheral.

Parameters
peripheral_idPeripheral ID selection from PID2 to PID127.
Returns
None.

◆ PMC_DisableInterrupt()

void PMC_DisableInterrupt ( PMC_INT_SOURCE source_msk)

Disables the specified PMC interrupt source(s).

Parameters
source_mskThe interrupt source mask to disable (PMC_INT_SOURCE).
Returns
None.

◆ PMC_DisableMainRCOsc()

void PMC_DisableMainRCOsc ( void )

Disables the Main RC Oscillator.

Parameters
None.
Returns
None.

◆ PMC_DisablePeripheralClock()

void PMC_DisablePeripheralClock ( uint32_t peripheral_id)

Disables the clock for the specified peripheral.

Parameters
peripheral_idPeripheral ID selection from PID2 to PID127.
Returns
None.

◆ PMC_DisableProgrammableClock()

void PMC_DisableProgrammableClock ( uint32_t clock_id)

Disables the specified programmable clock output.

Parameters
clock_idThe programmable clock identifier (PCK0 = 0, PCK1 = 1 etc.).
Returns
None.

◆ PMC_EnableGenericClock()

void PMC_EnableGenericClock ( uint32_t peripheral_id,
PMC_GCLKCSS clock_source,
uint32_t gclkdiv )

Enables and configures the Generic Clock for the specified peripheral.

Parameters
peripheral_idPeripheral ID selection from PID2 to PID127.
clock_sourceThe Generic Clock source selection value (PMC_GCLKCSS).
gclkdivGeneric 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.)
Returns
None.

◆ PMC_EnableInterrupt()

void PMC_EnableInterrupt ( PMC_INT_SOURCE source_msk)

Enables the specified PMC interrupt source(s).

Parameters
source_mskThe interrupt source mask to enable (PMC_INT_SOURCE).
Returns
None.

◆ PMC_EnableMainCrystalOsc()

void PMC_EnableMainCrystalOsc ( uint32_t startup_time,
bool bypass_mode )

Enables the Main Crystal Oscillator with specified startup time and mode.

Parameters
startup_timeNumber of SLOW_CLK cycles multiplied by 8 for the main crystal oscillator startup time.
bypass_modeSet 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.
Returns
None.

◆ PMC_EnableMainRCOsc()

void PMC_EnableMainRCOsc ( void )

Enables the Main RC Oscillator.

Parameters
None.
Returns
None.

◆ PMC_EnablePeripheralClock()

void PMC_EnablePeripheralClock ( uint32_t peripheral_id)

Enables the clock for the specified peripheral.

Parameters
peripheral_idPeripheral ID selection from PID2 to PID127.
Returns
None.

◆ PMC_EnableProgrammableClock()

void PMC_EnableProgrammableClock ( uint32_t clock_id)

Enables the specified programmable clock output.

Parameters
clock_idThe programmable clock identifier (PCK0 = 0, PCK1 = 1 etc.).
Returns
None.

◆ PMC_GetMainClockFreq()

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.

Parameters
slow_clk_freqThe frequency of the slow clock (in Hz).
Returns
The calculated frequency of the Main Clock (in Hz).

◆ PMC_GetMainClockFreqCount()

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.

Parameters
None.
Returns
The current Main Clock frequency count value.

◆ PMC_GetPLLAFreq()

uint32_t PMC_GetPLLAFreq ( void )

Gets the current frequency of the PLLA clock.

Parameters
None.
Returns
The calculated frequency of the PLLA clock (in Hz).

◆ PMC_HostClockIsReady()

bool PMC_HostClockIsReady ( void )

Checks if the Host Clock (MAIN_CLK) is ready.

Parameters
None.
Returns
true if the Host Clock is ready and stable, false otherwise.

◆ PMC_InterruptFlagIsSet()

bool PMC_InterruptFlagIsSet ( PMC_INT_SOURCE source_msk)

Checks if the specified PMC interrupt flag is set.

Parameters
source_mskThe interrupt source mask to check (PMC_INT_SOURCE).
Returns
true if the interrupt flag is set, false otherwise.

◆ PMC_MainClockFreqIsReady()

bool PMC_MainClockFreqIsReady ( void )

Checks if the Main Clock frequency measurement is ready.

Parameters
None.
Returns
true if the Main Clock frequency measurement is ready, false otherwise.

◆ PMC_MainCrystalOscIsReady()

bool PMC_MainCrystalOscIsReady ( void )

Checks if the Main Crystal Oscillator is ready.

Parameters
None.
Returns
true if the Main Crystal Oscillator is stable and ready, false otherwise.

◆ PMC_MainRCOscIsReady()

bool PMC_MainRCOscIsReady ( void )

Checks if the Main RC Oscillator is ready.

Parameters
None.
Returns
true if the Main RC Oscillator is stable and ready, false otherwise.

◆ PMC_PLLAClockIsLocked()

bool PMC_PLLAClockIsLocked ( void )

Checks if the PLLA is locked and ready.

Parameters
None.
Returns
true if PLLA is locked and stable, false otherwise.

◆ PMC_ProgrammableClockIsReady()

bool PMC_ProgrammableClockIsReady ( uint32_t clock_id)

Checks if the specified programmable clock is ready.

Parameters
clock_idThe programmable clock identifier (PCK0 = 0, PCK1 = 1 etc.).
Returns
true if the programmable clock is ready and stable, false otherwise.

◆ PMC_SetCallbackHandler()

void PMC_SetCallbackHandler ( PMC_CALLBACK callback)

Registers a callback function for PMC interrupt events.

Parameters
callbackPointer to the callback function to be registered.
Returns
None.

◆ PMC_SetCounterClockSource()

void PMC_SetCounterClockSource ( uint32_t clock_source)

Selects the clock source for the Main Clock frequency counter.

Parameters
clock_sourceThe clock source selection value for the counter. 0 = Main RC Oscillator, 1 = Main Crystal Oscillator.
Returns
None.

◆ PMC_SetHostClockDivider()

void PMC_SetHostClockDivider ( PMC_MCKR_DIV divider_value)

Sets the divider value for the Host Clock.

Parameters
divider_valueThe divider value to further divide the Host Clock (PMC_MCKR_DIV).
Returns
None.

◆ PMC_SetHostClockPrescaler()

void PMC_SetHostClockPrescaler ( PMC_MCKR_PRESCALAR prescaler_value)

Sets the prescaler value for the Host Clock.

Parameters
prescaler_valueThe prescaler value to divide the Host Clock (PMC_MCKR_PRESCALAR).
Returns
None.

◆ PMC_SetHostClockSource()

void PMC_SetHostClockSource ( PMC_MCKR_CLKSS clock_source)

Selects the clock source for the Host Clock.

Parameters
clock_sourceThe clock source selection value for the Host Clock (PMC_MCKR_CLKSS).
Returns
None.

◆ PMC_SetMainClockSource()

void PMC_SetMainClockSource ( uint32_t clock_source)

Selects the source for the MAINCK clock line.

Parameters
clock_sourceThe clock source selection value for MAINCK Line. Select between Main RC Oscillator or Main Crystal Oscillator.
Returns
None.

◆ PMC_SetMainRCOscFreq()

void PMC_SetMainRCOscFreq ( PMC_MOSCRCF freq_sel_value)

Sets the frequency of the Main RC Oscillator.

Parameters
freq_sel_valueThe frequency selection value for the Main RC Oscillator (PMC_MOSCRCF).
Returns
None.

◆ PMC_SetPLLAClock()

void PMC_SetPLLAClock ( uint32_t mula,
uint32_t diva,
uint32_t plla_count )

Configures the PLLA clock with specified multiplier, divider, and count values.

Parameters
mulaThe PLL multiplier value. PLLCK frequency is the PLLA input frequency multiplied by MULA + 1. Range : 1 to 62. If 0, PLLA is disabled.
divaPLLA Front End Divider. When DIVA is 1, the divider is bypassed. Range : 1 to 63. If 0, PLLA is disabled.
plla_countnumber 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.
Returns
None.

Variable Documentation

◆ SystemCoreClock

uint32_t SystemCoreClock
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.