Digital Power Starter Kit 3 Firmware
dsPIC33C Buck Converter Voltage Mode Control Example

Public functions of the OSC PRAL driver. More...

+ Collaboration diagram for Public Functions:

Functions

volatile uint16_t p33c_OscFrc_DefaultInitialize (volatile enum CPU_SPEED_DEFAULTS_e cpu_speed)
 Initializes the major oscillator and the PLL module step by step by using clock switching in software. Each step is tested and verified. PLL settings here are pulled from pre-defined settings set for default CPU speeds from 40 MIPS to 100 MIPS. More...
 
volatile uint16_t p33c_OscFrc_Initialize (volatile enum CLKDIV_FRCDIVN_e frc_div, volatile enum OSCTUN_TUN_e frc_tune)
 Initializes the internal RC oscillator divider and tuning register. More...
 
volatile uint16_t p33c_OscAuxClk_Initialize (volatile struct AUXOSC_CONFIG_s aux_clock_config)
 Initializes the auxiliary clock and its PLL module step by step in software. Each step is tested and verified. More...
 
volatile uint16_t p33c_OscAuxClk_DefaultInitialize (volatile enum AUX_PLL_DEFAULTS_e afpllo_frequency)
 Initializes the auxiliary clock and its PLL module step by step in software. Each step is tested and verified. More...
 
volatile uint16_t p33c_Osc_GetFrequencies (volatile uint32_t main_osc_frequency)
 This routine reads all oscillator related SFRs recalculating the various frequencies across clock domains. These frequencies are broadcasted in the global data structure 'system_frequencies'. More...
 

Detailed Description

Public functions of the OSC PRAL driver.

This is the detailed description of public functions of the OSC PRAL driver

Function Documentation

◆ p33c_Osc_GetFrequencies()

uint16_t p33c_Osc_GetFrequencies ( volatile uint32_t  main_osc_frequency)

This routine reads all oscillator related SFRs recalculating the various frequencies across clock domains. These frequencies are broadcasted in the global data structure 'system_frequencies'.

smpsOSC_GetFrequencies()


Parameters
main_osc_frequencyFrequency of external oscillator frequency in [Hz] of type unsigned integer. Set to '0' if no external oscillator is used.
Returns
unsigned integer 0 = reading oscillator settings failed 1 = reading oscillator settings successfully

Microchip's 16-Bit devices offer multiple clock sources to clock the CPU. This routine reads the most recent, oscillator related Special Function Registers (SFR) and determines the recently active main clock and its frequency and calculates the resulting clock frequencies of other clock domains.

The results are broadcasted through the 'system_frequencies' data structure which is globally accessible in user code and can be used to calculate other oscillator dependent settings such as timer periods or baud rates of communication interfaces

Please note: The contents of data structure 'system_frequencies' is NOT updated automatically. It is recommended to call the function 'osc_get_frequencies' in user code every time after clock settings have been modified.

Definition at line 418 of file p33c_osc.c.

◆ p33c_OscAuxClk_DefaultInitialize()

uint16_t p33c_OscAuxClk_DefaultInitialize ( volatile enum AUX_PLL_DEFAULTS_e  afpllo_frequency)

Initializes the auxiliary clock and its PLL module step by step in software. Each step is tested and verified.

Parameters
afpllo_frequencyAuxiliary PLL output frequency of type enum AUX_PLL_DEFAULTS_e
Returns
0 = unspecified clock failure detected 1 = clock switch successful 2 = clock switch failed 4 = currently selected clock differs from selected clock source 8 = PLL didn't lock in within given time frame

The auxiliary clock is generated by a separate PLL module, which is driven from one of the main clock signals or PLL outputs. This auxiliary clock can be used to drive ADCs, PWM, DACs and other peripherals. Each of them might have individual requirements. Please refer to the specific peripheral sections in the device data sheet to learn how to configure the auxiliary clock.

Definition at line 352 of file p33c_osc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ p33c_OscAuxClk_Initialize()

uint16_t p33c_OscAuxClk_Initialize ( volatile struct AUXOSC_CONFIG_s  aux_clock_config)

Initializes the auxiliary clock and its PLL module step by step in software. Each step is tested and verified.

Parameters
aux_clock_configAuxiliary oscillator configuration of type struct AUXOSC_CONFIG_s
Returns
0 = unspecified clock failure detected 1 = clock switch successful 2 = clock switch failed 4 = currently selected clock differs from selected clock source 8 = PLL didn't lock in within given time frame

The auxiliary clock is generated by a separate PLL module, which is driven from one of the main clock signals or PLL outputs. This auxiliary clock can be used to drive ADCs, PWM, DACs and other peripherals. Each of them might have individual requirements. Please refer to the specific peripheral sections in the device data sheet to learn how to configure the auxiliary clock.

Definition at line 301 of file p33c_osc.c.

+ Here is the caller graph for this function:

◆ p33c_OscFrc_DefaultInitialize()

uint16_t p33c_OscFrc_DefaultInitialize ( volatile enum CPU_SPEED_DEFAULTS_e  cpu_speed)

Initializes the major oscillator and the PLL module step by step by using clock switching in software. Each step is tested and verified. PLL settings here are pulled from pre-defined settings set for default CPU speeds from 40 MIPS to 100 MIPS.

Parameters
cpu_speedCPU speed setting of type enum CPU_SPEED_DEFAULTS_e
Returns
unsigned integer 0 = unspecified clock failure detected 1 = clock switch successful 2 = clock switch failed 4 = currently selected clock differs from selected clock source 8 = PLL didn't lock in within given time frame

Microchip's 16-Bit devices offer a safe 2-step start-up mode, using the internal FRC during power up, followed by a user defined switch-over to the desired oscillator. Though this can also be done in hardware automatically, this software-version of the switch-over offers a better solution to verify each step and enables the user to implement some error handling in the case of failure. This function can be used to select a new oscillator at runtime. Each configuration step will be verified before the next step is performed.

Note
If a oscillator switch-over is performed, additional settings in the _FOSCSEL and _FOSC registers of the configuration bits may be required

Definition at line 62 of file p33c_osc.c.

+ Here is the caller graph for this function:

◆ p33c_OscFrc_Initialize()

uint16_t p33c_OscFrc_Initialize ( volatile enum CLKDIV_FRCDIVN_e  frc_div,
volatile enum OSCTUN_TUN_e  frc_tune 
)

Initializes the internal RC oscillator divider and tuning register.

Parameters
frc_divInternal RC Oscillator frequency divider of type enum CLKDIV_FRCDIVN_e
frc_tuneInternal RC Oscillator tuning register value of type enum OSCTUN_TUN_e
Returns
0 = unspecified clock failure detected 1 = clock switch successful 2 = clock switch failed 4 = currently selected clock differs from selected clock source 8 = PLL didn't lock in within given time frame

Microchip's 16-Bit devices offer a safe 2-step start-up mode, using the internal FRC during power up, followed by a user defined switch-over to the desired oscillator. Though this can also be done in hardware automatically, this software-version of the switch-over offers a better solution to verify each step and enables the user to implement some error handling in the case of failure. This function can be used to select a new oscillator at runtime. Each configuration step will be verified before the next step is performed.

Note
If a oscillator switch-over is performed, additional settings in the _FOSCSEL and _FOSC registers of the configuration bits may be required

Definition at line 138 of file p33c_osc.c.