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

init_fosc.c
1 /*
2 * File: init_fosc.c
3 * Author: M91406
4 *
5 * Created on July 8, 2019, 1:55 PM
6 */
7
8
9 #include <xc.h>
10 #include <stdint.h>
11 #include <stdbool.h>
12
13 #include "config/init/init_fosc.h"
14 #include "p33c_osc.h"
15
16 #define TIMEOUT_LIMIT 5000 // timeout counter maximum
17
18 /***********************************************************************************
19 * @fn uint16_t sysFosc_Initialize(void)
20 * @ingroup clock-initialization
21 * @brief System oscillator initialization
22 * @return unsigned integer
23 * 0=failure
24 * 1=success
25 *
26 * @details
27 * This function initializes the internal 8 MHz RC oscillator as the main
28 * oscillator and initializes the PLL to operate the CPU at maximum performance
29 * of 100 MHz instruction cycle.
30 *
31 **********************************************************************************/
32 volatile uint16_t sysFosc_Initialize(void)
33 {
34 volatile uint16_t retval=1;
35
36 retval = p33c_OscFrc_DefaultInitialize(CPU_SPEED_100_MIPS);
37
38 return(retval);
39
40 }
41
42 /***********************************************************************************
43 * @fn uint16_t sysAclk_Initialize(void)
44 * @ingroup clock-initialization
45 * @brief Initializes the auxiliary clock of the device
46 * @return unsigned integer (0=failure, 1=success)
47 *
48 * @details
49 * This function initializes the auxiliary PLL for operating ADC and PWM module
50 * at maximum performance at an input clock of 500 MHz. Each peripheral module
51 * may use additional frequency scalers and multipliers to further convert this
52 * frequency.
53 *
54 **********************************************************************************/
55 volatile uint16_t sysAclk_Initialize(void) {
56
57 volatile uint16_t retval=1;
58
59 retval &= p33c_OscAuxClk_DefaultInitialize(AFPLLO_500_MHZ);
60
61 return(retval);
62 }
63
64 // end of file
65