S32 SDK
Peripheral Clock Control (PCC)

Detailed Description

This module covers Peripheral Clock Control module functionality.

PCC HAL provides the API for reading and writing register bit-fields belonging to the PCC module. Clock selection for most modules is controlled by PCC. The clock to each module can be individually gated on and off using PCC.

The PCC hal component allows application to configure these peripheral clocking options:

This is an example to write a peripheral clock configuration:

Count of peripheral clock user configurations
#define NUM_OF_CONFIGURED_PERIPHERAL_CLOCKS_0 5U
Peripheral clocking configuration 0
peripheral_clock_config_t peripheralClockConfig0[NUM_OF_CONFIGURED_PERIPHERAL_CLOCKS_0] = {
{
.peripheral = PCC_FLEXTMR3_CLOCK,
.clkGate = true,
.clkSrc = CLK_SRC_FIRC,
.frac = 0, N/A
.divider = 0, N/A
},
{
.peripheral = PCC_LPTMR0_CLOCK,
.clkGate = true,
.clkSrc = CLK_SRC_SOSC,
.frac = MULTIPLY_BY_TWO,
.divider = DIVIDE_BY_FOUR,
},
{
.peripheral = PCC_SIM0_CLOCK,
.clkGate = true,
.clkSrc = 0, N/A
.frac = 0, N/A
.divider = 0, N/A
},
{
.peripheral = PCC_PORTA_CLOCK,
.clkGate = true,
.clkSrc = 0, N/A
.frac = 0, N/A
.divider = 0, N/A
},
{
.peripheral = PCC_SCG0_CLOCK,
.clkGate = true,
.clkSrc = 0, N/A
.frac = 0, N/A
.divider = 0, N/A
},
};
pcc_config_t pccConfig =
{
.peripheralClocks = peripheralClockConfig0, Peripheral clock control configurations
.count = NUM_OF_CONFIGURED_PERIPHERAL_CLOCKS_0, Number of the peripheral clock control configurations
};
write peripheral clocking configuration

For higher-level functionality, use the Clock Manager driver.

Data Structures

struct  peripheral_clock_config_t
 PCC peripheral instance clock configuration. Implements peripheral_clock_config_t_Class. More...
 
struct  pcc_config_t
 PCC configuration. Implements pcc_config_t_Class. More...
 

Enumerations

enum  peripheral_clock_source_t {
  CLK_SRC_OFF = 0x00U, CLK_SRC_SOSC = 0x01U, CLK_SRC_SIRC = 0x02U, CLK_SRC_FIRC = 0x03U,
  CLK_SRC_SPLL = 0x06U
}
 PCC clock source select Implements peripheral_clock_source_t_Class. More...
 
enum  peripheral_clock_frac_t { MULTIPLY_BY_ONE = 0x00U, MULTIPLY_BY_TWO = 0x01U }
 PCC fractional value select Implements peripheral_clock_frac_t_Class. More...
 
enum  peripheral_clock_divider_t {
  DIVIDE_BY_ONE = 0x00U, DIVIDE_BY_TWO = 0x01U, DIVIDE_BY_THREE = 0x02U, DIVIDE_BY_FOUR = 0x03U,
  DIVIDE_BY_FIVE = 0x04U, DIVIDE_BY_SIX = 0x05U, DIVIDE_BY_SEVEN = 0x06U, DIVIDE_BY_EIGTH = 0x07U
}
 PCC divider value select Implements peripheral_clock_divider_t_Class. More...
 

Variables

const uint16_t clockNameMappings [CLOCK_NAME_COUNT]
 Clock name mappings Constant array storing the mappings between clock names and peripheral clock control indexes. If there is no peripheral clock control index for a clock name, then the corresponding value is PCC_INVALID_INDEX. More...
 

System Clock.

void PCC_HAL_SetPeripheralClockConfig (PCC_Type *const base, const pcc_config_t *const config)
 Set the peripheral clock configuration. More...
 
static void PCC_HAL_SetClockMode (PCC_Type *const base, const clock_names_t clockName, const bool isClockEnabled)
 Enables/disables the clock for a given peripheral. For example, to enable the ADC0 clock, use like this: More...
 
static void PCC_HAL_SetClockSourceSel (PCC_Type *const base, const clock_names_t clockName, const peripheral_clock_source_t clockSource)
 Selects the clock source for a given peripheral For example, to select the FIRC source for ADC clock, use like this: More...
 
static void PCC_HAL_SetFracValueSel (PCC_Type *const base, const clock_names_t clockName, const peripheral_clock_frac_t fracValue)
 Selects the fractional value for a given peripheral For example, to configure MULTIPLY_BY_ONE as fractional value for WDOG, use like this: More...
 
static void PCC_HAL_SetDividerValueSel (PCC_Type *const base, const clock_names_t clockName, const peripheral_clock_divider_t divValue)
 Selects the divider value for a given peripheral For example, to configure DIVIDE_BY_ONE as divider value for WDOG, use like this: More...
 
static bool PCC_HAL_GetClockMode (const PCC_Type *const base, const clock_names_t clockName)
 Gets the clock gate control mode. More...
 
static peripheral_clock_source_t PCC_HAL_GetClockSourceSel (const PCC_Type *const base, const clock_names_t clockName)
 Gets the selection of a clock source for a specific peripheral. More...
 
static peripheral_clock_frac_t PCC_HAL_GetFracValueSel (const PCC_Type *const base, const clock_names_t clockName)
 Gets the selection of the fractional value for a specific peripheral. More...
 
static peripheral_clock_divider_t PCC_HAL_GetDividerSel (const PCC_Type *const base, const clock_names_t clockName)
 Gets the selection of the divider value for a specific peripheral. More...
 
static bool PCC_HAL_GetPeripheralMode (const PCC_Type *const base, const clock_names_t clockName)
 Tells whether a given peripheral is present or not. More...
 

Enumeration Type Documentation

PCC divider value select Implements peripheral_clock_divider_t_Class.

Enumerator
DIVIDE_BY_ONE 
DIVIDE_BY_TWO 
DIVIDE_BY_THREE 
DIVIDE_BY_FOUR 
DIVIDE_BY_FIVE 
DIVIDE_BY_SIX 
DIVIDE_BY_SEVEN 
DIVIDE_BY_EIGTH 

Definition at line 141 of file pcc_hal.h.

PCC fractional value select Implements peripheral_clock_frac_t_Class.

Enumerator
MULTIPLY_BY_ONE 
MULTIPLY_BY_TWO 

Definition at line 131 of file pcc_hal.h.

PCC clock source select Implements peripheral_clock_source_t_Class.

Enumerator
CLK_SRC_OFF 
CLK_SRC_SOSC 
CLK_SRC_SIRC 
CLK_SRC_FIRC 
CLK_SRC_SPLL 

Definition at line 118 of file pcc_hal.h.

Function Documentation

static bool PCC_HAL_GetClockMode ( const PCC_Type *const  base,
const clock_names_t  clockName 
)
inlinestatic

Gets the clock gate control mode.

Parameters
[in]basepcc base pointer
[in]clockNameis the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK
Returns
the clock gate control mode
  • false : Clock is disabled
  • true : Clock is enabled Implements PCC_HAL_GetClockMode_Activity

Definition at line 405 of file pcc_hal.h.

static peripheral_clock_source_t PCC_HAL_GetClockSourceSel ( const PCC_Type *const  base,
const clock_names_t  clockName 
)
inlinestatic

Gets the selection of a clock source for a specific peripheral.

Parameters
[in]basepcc base pointer
[in]clockNameis the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK
Returns
the clock gate control mode
  • PCC_CLK_SRC_OFF : Clock is disabled
  • PCC_CLK_SRC_SOSC : OSCCLK - System Oscillator Bus Clock
  • PCC_CLK_SRC_SIRC : SCGIRCLK - Slow IRC Clock
  • PCC_CLK_SRC_FIRC : SCGFIRCLK - Fast IRC Clock
  • PCC_CLK_SRC_SPLL : SCGPCLK - System PLL clock Implements PCC_HAL_GetClockSourceSel_Activity

Definition at line 431 of file pcc_hal.h.

static peripheral_clock_divider_t PCC_HAL_GetDividerSel ( const PCC_Type *const  base,
const clock_names_t  clockName 
)
inlinestatic

Gets the selection of the divider value for a specific peripheral.

Parameters
[in]basepcc base pointer
[in]clockNameis the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK
Returns
the divider value
  • PCC_DIVIDE_BY_ONE : Divide by 1
  • PCC_DIVIDE_BY_TWO : Divide by 2
  • PCC_DIVIDE_BY_THREE : Divide by 3
  • PCC_DIVIDE_BY_FOUR : Divide by 4
  • PCC_DIVIDE_BY_FIVE : Divide by 5
  • PCC_DIVIDE_BY_SIX : Divide by 6
  • PCC_DIVIDE_BY_SEVEN : Divide by 7
  • PCC_DIVIDE_BY_EIGTH : Divide by 8 Implements PCC_HAL_GetDividerSel_Activity

Definition at line 518 of file pcc_hal.h.

static peripheral_clock_frac_t PCC_HAL_GetFracValueSel ( const PCC_Type *const  base,
const clock_names_t  clockName 
)
inlinestatic

Gets the selection of the fractional value for a specific peripheral.

Parameters
[in]basepcc base pointer
[in]clockNameis the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK
Returns
the fractional value
  • PCC_MULTPCCnLY_BY_ONE : Fractional value is zero
  • PCC_MULTPCCnLY_BY_TWO : Fractional value is one Implements PCC_HAL_GetFracValueSel_Activity

Definition at line 476 of file pcc_hal.h.

static bool PCC_HAL_GetPeripheralMode ( const PCC_Type *const  base,
const clock_names_t  clockName 
)
inlinestatic

Tells whether a given peripheral is present or not.

Parameters
[in]basepcc base pointer
[in]clockNameis the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK
Returns
is the value that tells whether the peripheral is present or not
  • false : Peripheral is not present
  • true : Peripheral is present Implements PCC_HAL_GetPeripheralMode_Activity

Definition at line 572 of file pcc_hal.h.

static void PCC_HAL_SetClockMode ( PCC_Type *const  base,
const clock_names_t  clockName,
const bool  isClockEnabled 
)
inlinestatic

Enables/disables the clock for a given peripheral. For example, to enable the ADC0 clock, use like this:

1 PCC_HAL_SetClockMode(PCC, PCC_ADC0_CLOCK, true);
Parameters
[in]basepcc base pointer
[in]clockNameis the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK
[in]isClockEnabledis the value of the command that enables/disables the clock Implements PCC_HAL_SetClockMode_Activity

Definition at line 230 of file pcc_hal.h.

static void PCC_HAL_SetClockSourceSel ( PCC_Type *const  base,
const clock_names_t  clockName,
const peripheral_clock_source_t  clockSource 
)
inlinestatic

Selects the clock source for a given peripheral For example, to select the FIRC source for ADC clock, use like this:

1 PCC_HAL_SetClockSourceSel(PCC, PCC_ADC0_CLOCK, CLK_SRC_FIRC);
Parameters
[in]basepcc base pointer
[in]clockNameis the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK
[in]clockSourceis the clock source to use for a given peripheral Implements PCC_HAL_SetClockSourceSel_Activity

Definition at line 257 of file pcc_hal.h.

static void PCC_HAL_SetDividerValueSel ( PCC_Type *const  base,
const clock_names_t  clockName,
const peripheral_clock_divider_t  divValue 
)
inlinestatic

Selects the divider value for a given peripheral For example, to configure DIVIDE_BY_ONE as divider value for WDOG, use like this:

1 PCC_HAL_SetDividerValueSel(PCC, PCC_WDOG_CLOCK, DIVIDE_BY_ONE);
Parameters
[in]basepcc base pointer
[in]clockNameis the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK
[in]divValueis the divider value to use for a given peripheral Implements PCC_HAL_SetDividerValueSel_Activity

Definition at line 348 of file pcc_hal.h.

static void PCC_HAL_SetFracValueSel ( PCC_Type *const  base,
const clock_names_t  clockName,
const peripheral_clock_frac_t  fracValue 
)
inlinestatic

Selects the fractional value for a given peripheral For example, to configure MULTIPLY_BY_ONE as fractional value for WDOG, use like this:

1 PCC_HAL_SetFracValueSel(PCC, PCC_WDOG_CLOCK, MULTIPLY_BY_ONE);
Parameters
[in]basepcc base pointer
[in]clockNameis the name of the peripheral clock must be one of the following values (see the clock_names_t type from S32K144_clock_names.h) PCC_DMA0_CLOCK PCC_MPU0_CLOCK ... PCC_LPUART3_CLOCK
[in]fracValueis the fractional value to use for a given peripheral Implements PCC_HAL_SetFracValueSel_Activity

Definition at line 307 of file pcc_hal.h.

void PCC_HAL_SetPeripheralClockConfig ( PCC_Type *const  base,
const pcc_config_t *const  config 
)

Set the peripheral clock configuration.

This function sets the peripheral configuration.

Parameters
[in]baseRegister base address for the PCC instance.
[in]configPointer to the configuration.

Definition at line 56 of file pcc_hal.c.

Variable Documentation

const uint16_t clockNameMappings[CLOCK_NAME_COUNT]

Clock name mappings Constant array storing the mappings between clock names and peripheral clock control indexes. If there is no peripheral clock control index for a clock name, then the corresponding value is PCC_INVALID_INDEX.

Definition at line 43 of file pcc_hal.c.