Bar Logo 3.8/7.6 kw Totem pole Demonstration Application (Part-No. (not specified))
 
Content
     
Loading...
Searching...
No Matches
clock.c
Go to the documentation of this file.
1
17/*
18© [2024] Microchip Technology Inc. and its subsidiaries.
19
20 Subject to your compliance with these terms, you may use Microchip
21 software and any derivatives exclusively with Microchip products.
22 You are responsible for complying with 3rd party license terms
23 applicable to your use of 3rd party software (including open source
24 software) that may accompany Microchip software. SOFTWARE IS ?AS IS.?
25 NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS
26 SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT,
27 MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
28 WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
29 INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY
30 KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF
31 MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE
32 FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S
33 TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT
34 EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR
35 THIS SOFTWARE.
36*/
37
38// Section: Includes
39#include <xc.h>
40#include <stdint.h>
41#include "../clock.h"
42
44{
45 /*
46 Input frequency : 8.00 MHz
47 Clock source : External Oscillator with PLL
48 System frequency (Fosc) : 180.00 MHz [(8.00 MHz / 1) * 90 / 2 / 2 = 180.00 MHz]
49 PLL VCO frequency (Fvco) : 720.00 MHz [(8.00 MHz / 1) * 90 = 720.00 MHz]
50 PLL output frequency (Fpllo) : 360.00 MHz [(8.00 MHz / 1) * 90 / 2 = 360.00 MHz]
51 PLL VCO divider frequency (Fvcodiv) : 180.00 MHz [720.00 MHz / 4 = 180.00 MHz]
52 Clock switching enabled : true
53 Clock source when device boots : FRC Oscillator
54 Auxiliary clock source : FRC Oscillator
55 Auxiliary clock input frequency : 8.00 MHz
56 Auxiliary clock PLL output frequency (AFpllo) : 8.00 MHz
57 */
58 // RCDIV FRC/1; PLLPRE 1:1; DOZE 1:8; DOZEN disabled; ROI disabled;
59 CLKDIV = 0x3001;
60 // PLLDIV 90;
61 PLLFBD = 0x5A;
62 // TUN Center frequency;
63 OSCTUN = 0x0;
64 // PLLPOST 1:2; VCODIV FVCO/4; POST2DIV 1:1;
65 PLLDIV = 0x21;
66 // ENAPLL disabled; FRCSEL FRC Oscillator; APLLPRE 1:1;
67 ACLKCON1 = 0x101;
68 // APLLFBDIV 150;
69 APLLFBD1 = 0x96;
70 // APSTSCLR 1:4; APOST2DIV 1:1; AVCODIV FVCO/4;
71 APLLDIV1 = 0x41;
72 // CANCLKEN enabled; CANCLKSEL FPLLO; CANCLKDIV Divide by 9;
73 CANCLKCON = 0x8208;
74 // ROEN disabled; DIVSWEN disabled; ROSLP disabled; ROSEL ; OE disabled; ROSIDL disabled;
75 REFOCONL = 0x0;
76 // RODIV 0;
77 REFOCONH = 0x0;
78 // ROTRIM 0;
79 REFOTRIMH = 0x0;
80 // IOLOCK disabled;
81 RPCON = 0x0;
82 // ADC1MD enabled; T1MD enabled; U2MD enabled; U1MD enabled; SPI2MD enabled; SPI1MD enabled; QEIMD enabled; PWMMD enabled; I2C1MD enabled; C1MD enabled;
83 PMD1 = 0x0;
84 // CCP2MD enabled; CCP1MD enabled; CCP4MD enabled; CCP3MD enabled; CCP7MD enabled; CCP8MD enabled; CCP5MD enabled; CCP6MD enabled;
85 PMD2 = 0x0;
86 // CRCMD enabled; I2C2MD enabled;
87 PMD3 = 0x0;
88 // REFOMD enabled;
89 PMD4 = 0x0;
90 // DMA1MD enabled; DMA2MD enabled; DMA3MD enabled; DMA0MD enabled; DMA5MD enabled; DMA4MD enabled;
91 PMD6 = 0x0;
92 // PTGMD enabled; CMP1MD enabled;
93 PMD7 = 0x0;
94 // DMTMD enabled; CLC3MD enabled; BIASMD enabled; CLC4MD enabled; SENT1MD enabled; CLC1MD enabled; CLC2MD enabled; SENT2MD enabled;
95 PMD8 = 0x0;
96 // CF no clock failure; NOSC PRIPLL; CLKLOCK unlocked; OSWEN Switch is Complete;
97 __builtin_write_OSCCONH((uint8_t) (0x03));
98 __builtin_write_OSCCONL((uint8_t) (0x01));
99 // Wait for Clock switch to occur
100 while (OSCCONbits.OSWEN != 0);
101 while (OSCCONbits.LOCK != 1);
102}
103
105{
106 return ACLKCON1bits.APLLCK;
107}
108
bool CLOCK_AuxPllLockStatusGet(void)
Returns Auxiliary PLL status.
Definition clock.c:104
void CLOCK_Initialize(void)
Initializes all the INTERNAL OSCILLATOR sources and clock switch configurations.
Definition clock.c:43