CMSIS-Driver_PIC32CM-PL  
Peripheral Library (PLIB) Documentation
 
Loading...
Searching...
No Matches
GCLK Interface

Driver API for GCLK (plib_gclk.h) More...

Typedefs

typedef uint32_t GCLK_GENERATOR_ID
 GCLK Generator identifier.
 
typedef uint32_t GCLK_PERIPHERAL_CHANNEL_ID
 GCLK Peripheral Channel identifier.
 
typedef uint32_t GCLK_SOURCE
 GCLK generator clock source identifier.
 

Enumerations

enum  GCLK_GENERATOR_ID_ENUM
 Select a specific Generic Clock Generator in the GCLK module. More...
 
enum  GCLK_DIVIDE_TYPE { GCLK_DIVISION_INTEGER = GCLK_GENCTRL_DIVSEL_DIV1_Val , GCLK_DIVISION_POWER_OF_TWO_PLUS_ONE = GCLK_GENCTRL_DIVSEL_DIV2_Val }
 Specifies the method used to divide the clock source frequency for a GCLK generator. More...
 
enum  GCLK_PERIPHERAL_CHANNEL_ID_ENUM
 Select a specific Peripheral control in the GCLK module. More...
 
enum  GCLK_SOURCE_ENUM
 GCLK generator clock source selection. More...
 

Functions

void GCLK_Initialize (void)
 Initializes the GCLK module.
 
bool GCLK_GetGeneratorControlSyncStatus (GCLK_GENERATOR_ID generator_id)
 Checks synchronization status of a GCLK generator control register.
 
void GCLK_SetGeneratorSource (GCLK_GENERATOR_ID generator_id, GCLK_SOURCE source)
 Sets the clock source for a specified GCLK generator. Before changing the source in GENERATOR 0, ensure that the ONDEMAND feature of the source is enabled.
 
uint32_t GCLK_GetGeneratorSource (GCLK_GENERATOR_ID generator_id)
 Gets the clock source for a specified GCLK generator.
 
void GCLK_SetDivisionParameters (GCLK_GENERATOR_ID generator_id, uint16_t divide_factor, GCLK_DIVIDE_TYPE divide_type, bool improve_duty_cycle)
 Sets the division factor and type for a GCLK generator.
 
uint32_t GCLK_GetDivideType (GCLK_GENERATOR_ID generator_id)
 Returns the division type for a specified GCLK generator.
 
uint16_t GCLK_GetDivideFactor (GCLK_GENERATOR_ID generator_id)
 Returns the division factor for a specified GCLK generator.
 
void GCLK_SetOutputOffValue (GCLK_GENERATOR_ID generator_id, uint32_t output_off_value)
 Sets the output value when the GCLK generator is off.
 
void GCLK_SetOutputEnable (GCLK_GENERATOR_ID generator_id, bool output_enable)
 Enables or disables output for a GCLK generator.
 
void GCLK_EnableStandbyRun (GCLK_GENERATOR_ID generator_id)
 Enables GCLK generator operation in standby mode.
 
void GCLK_DisableStandbyRun (GCLK_GENERATOR_ID generator_id)
 Disables GCLK generator operation in standby mode.
 
void GCLK_GeneratorEnable (GCLK_GENERATOR_ID generator_id)
 Enables the specified GCLK generator.
 
void GCLK_GeneratorDisable (GCLK_GENERATOR_ID generator_id)
 Disables the specified GCLK generator.
 
void GCLK_SetPeripheralChannelGenSrc (GCLK_PERIPHERAL_CHANNEL_ID channel_id, GCLK_GENERATOR_ID generator_id)
 Assigns a GCLK generator to a peripheral channel.
 
void GCLK_EnablePeripheralChannel (GCLK_PERIPHERAL_CHANNEL_ID channel_id)
 Enables a GCLK peripheral channel.
 
void GCLK_PeripheralChannelDisable (GCLK_PERIPHERAL_CHANNEL_ID channel_id)
 Disables a GCLK peripheral channel.
 
bool GCLK_PeripheralChannelIsEnabled (GCLK_PERIPHERAL_CHANNEL_ID channel_id)
 Checks if a GCLK peripheral channel is enabled.
 
void GCLK_EnablePeripheralChannelWriteLock (GCLK_PERIPHERAL_CHANNEL_ID channel_id)
 Enables write lock for a GCLK peripheral channel.
 

Description

Driver API for GCLK (plib_gclk.h)

Typedef Documentation

◆ GCLK_GENERATOR_ID

GCLK Generator identifier.

Accepts GCLK_GENERATOR_* enum values (GCLK_GENERATOR_0 through GCLK_GENERATOR_8, device-dependent availability) or raw uint32_t values for generators not present in the enum.

Example usage:

GCLK_SetGeneratorSource(GCLK_GENERATOR_0, GCLK_SRC_OSC48M);
GCLK_GeneratorEnable(GCLK_GENERATOR_0);
void GCLK_SetGeneratorSource(GCLK_GENERATOR_ID generator_id, GCLK_SOURCE source)
Sets the clock source for a specified GCLK generator. Before changing the source in GENERATOR 0,...
void GCLK_GeneratorEnable(GCLK_GENERATOR_ID generator_id)
Enables the specified GCLK generator.

◆ GCLK_PERIPHERAL_CHANNEL_ID

GCLK Peripheral Channel identifier.

Each peripheral requiring a GCLK is connected to a peripheral channel (PCHCTRL[m]) in the Generic Clock Controller (GCLK).

The value of a peripheral channel identifier is defined by the device DFP and must be one of the DFP-provided macros, for example:

  • EIC_GCLK_ID
  • SERCOM0_GCLK_ID_CORE
  • TC0_GCLK_ID
  • EVSYS_GCLK_ID_0
Note
Always use the *_GCLK_ID_* macros from the device header file. Do NOT use raw numeric values.

Example Mapping:

 Datasheet Name              DFP Macro To Use
 --------------------------- --------------------------
 GCLK_EIC                   EIC_GCLK_ID
 GCLK_TC0                   TC0_GCLK_ID
 GCLK_SERCOM0_CORE          SERCOM0_GCLK_ID_CORE
 GCLK_EVSYS_CHANNEL0        EVSYS_GCLK_ID_0
GCLK_SetPeripheralChannelGenSrc(SERCOM0_GCLK_ID_CORE,
GCLK_GENERATOR_0);
void GCLK_SetPeripheralChannelGenSrc(GCLK_PERIPHERAL_CHANNEL_ID channel_id, GCLK_GENERATOR_ID generator_id)
Assigns a GCLK generator to a peripheral channel.

◆ GCLK_SOURCE

GCLK generator clock source identifier.

Each GCLK generator can select a clock source. The value of the clock source is defined by the device DFP and must be one of the GCLK_GENCTRL_SRC_*_Val macros, for example:

  • GCLK_GENCTRL_SRC_OSCHF_Val
  • GCLK_GENCTRL_SRC_XOSC_Val
  • GCLK_GENCTRL_SRC_OSC48M_Val
  • GCLK_GENCTRL_SRC_FDPLL96M_Val
Note
Users must not define custom values. Only macros provided by the device DFP are supported.

Enumeration Type Documentation

◆ GCLK_DIVIDE_TYPE

Specifies the method used to divide the clock source frequency for a GCLK generator.

Enumerator
GCLK_DIVISION_INTEGER 

Integer division: fGCLK = fSRC / DIV

GCLK_DIVISION_POWER_OF_TWO_PLUS_ONE 

Power-of-two-plus-one division: fGCLK = fSRC / 2^(DIV+1)

◆ GCLK_GENERATOR_ID_ENUM

Select a specific Generic Clock Generator in the GCLK module.

◆ GCLK_PERIPHERAL_CHANNEL_ID_ENUM

Select a specific Peripheral control in the GCLK module.

◆ GCLK_SOURCE_ENUM

GCLK generator clock source selection.

Function Documentation

◆ GCLK_DisableStandbyRun()

void GCLK_DisableStandbyRun ( GCLK_GENERATOR_ID generator_id)

Disables GCLK generator operation in standby mode.

Parameters
generator_idThe GCLK generator to configure.
Returns
None.

◆ GCLK_EnablePeripheralChannel()

void GCLK_EnablePeripheralChannel ( GCLK_PERIPHERAL_CHANNEL_ID channel_id)

Enables a GCLK peripheral channel.

Parameters
channel_idThe peripheral channel to enable.
Returns
None.

◆ GCLK_EnablePeripheralChannelWriteLock()

void GCLK_EnablePeripheralChannelWriteLock ( GCLK_PERIPHERAL_CHANNEL_ID channel_id)

Enables write lock for a GCLK peripheral channel.

Parameters
channel_idThe peripheral channel to lock.
Returns
None.

◆ GCLK_EnableStandbyRun()

void GCLK_EnableStandbyRun ( GCLK_GENERATOR_ID generator_id)

Enables GCLK generator operation in standby mode.

Parameters
generator_idThe GCLK generator to configure.
Returns
None.

◆ GCLK_GeneratorDisable()

void GCLK_GeneratorDisable ( GCLK_GENERATOR_ID generator_id)

Disables the specified GCLK generator.

Parameters
generator_idThe GCLK generator to disable.
Returns
None.

◆ GCLK_GeneratorEnable()

void GCLK_GeneratorEnable ( GCLK_GENERATOR_ID generator_id)

Enables the specified GCLK generator.

Parameters
generator_idThe GCLK generator to enable.
Returns
None.

◆ GCLK_GetDivideFactor()

uint16_t GCLK_GetDivideFactor ( GCLK_GENERATOR_ID generator_id)

Returns the division factor for a specified GCLK generator.

Parameters
generator_idThe GCLK generator to query.
Returns
The current division factor of the specified generator.

◆ GCLK_GetDivideType()

uint32_t GCLK_GetDivideType ( GCLK_GENERATOR_ID generator_id)

Returns the division type for a specified GCLK generator.

Parameters
generator_idThe GCLK generator to query.
Returns
The current division type of the specified generator.

◆ GCLK_GetGeneratorControlSyncStatus()

bool GCLK_GetGeneratorControlSyncStatus ( GCLK_GENERATOR_ID generator_id)

Checks synchronization status of a GCLK generator control register.

Parameters
generator_idThe GCLK generator ID to check.
Returns
true if synchronization is ongoing for the selected generator, false otherwise.

◆ GCLK_GetGeneratorSource()

uint32_t GCLK_GetGeneratorSource ( GCLK_GENERATOR_ID generator_id)

Gets the clock source for a specified GCLK generator.

Parameters
generator_idThe GCLK generator to query.
Returns
The value of SRC register bits of the specified generator.

◆ GCLK_Initialize()

void GCLK_Initialize ( void )

Initializes the GCLK module.

Parameters
None.
Returns
None.

◆ GCLK_PeripheralChannelDisable()

void GCLK_PeripheralChannelDisable ( GCLK_PERIPHERAL_CHANNEL_ID channel_id)

Disables a GCLK peripheral channel.

Parameters
channel_idThe peripheral channel to disable.
Returns
None.

◆ GCLK_PeripheralChannelIsEnabled()

bool GCLK_PeripheralChannelIsEnabled ( GCLK_PERIPHERAL_CHANNEL_ID channel_id)

Checks if a GCLK peripheral channel is enabled.

Parameters
channel_idThe peripheral channel to check.
Returns
true if the channel is enabled, false otherwise.

◆ GCLK_SetDivisionParameters()

void GCLK_SetDivisionParameters ( GCLK_GENERATOR_ID generator_id,
uint16_t divide_factor,
GCLK_DIVIDE_TYPE divide_type,
bool improve_duty_cycle )

Sets the division factor and type for a GCLK generator.

Parameters
generator_idThe GCLK generator to configure.
divide_factorThe division factor to set.
divide_typeThe division selection type to set.
improve_duty_cycleSet to true to enable improved duty cycle, false to disable.
Returns
None.

◆ GCLK_SetGeneratorSource()

void GCLK_SetGeneratorSource ( GCLK_GENERATOR_ID generator_id,
GCLK_SOURCE source )

Sets the clock source for a specified GCLK generator. Before changing the source in GENERATOR 0, ensure that the ONDEMAND feature of the source is enabled.

Parameters
generator_idThe GCLK generator to configure.
sourceThe clock source to select for the generator.
Returns
None.

◆ GCLK_SetOutputEnable()

void GCLK_SetOutputEnable ( GCLK_GENERATOR_ID generator_id,
bool output_enable )

Enables or disables output for a GCLK generator.

Parameters
generator_idThe GCLK generator to configure.
output_enableSet to true to enable output, false to disable.
Returns
None.

◆ GCLK_SetOutputOffValue()

void GCLK_SetOutputOffValue ( GCLK_GENERATOR_ID generator_id,
uint32_t output_off_value )

Sets the output value when the GCLK generator is off.

Parameters
generator_idThe GCLK generator to configure.
output_off_valueValue to set when the generator is off (0 or 1) .
Returns
None.

◆ GCLK_SetPeripheralChannelGenSrc()

void GCLK_SetPeripheralChannelGenSrc ( GCLK_PERIPHERAL_CHANNEL_ID channel_id,
GCLK_GENERATOR_ID generator_id )

Assigns a GCLK generator to a peripheral channel.

Parameters
channel_idThe peripheral channel to configure.
generator_idThe GCLK generator to assign to the channel.
Returns
None.