PIC33EP256MC502
Posted: Mon Jun 27, 2022 2:07 pm
Hi,
How to change CLKDIV register values from PIC33EP256MC502 ?
How to change CLKDIV register values from PIC33EP256MC502 ?
Code: Select all
//Setup configuration for 70MIPs using 8MHz Crystal
PLLFBD = 68; // M=70
CLKDIVbits.PLLPOST = 0; // N1=2
CLKDIVbits.PLLPRE = 0; // N2=2
OSCTUN = 0; //Tune FRC oscillator, if FRC is used
//Disable Watch Dog Timer
RCONbits.SWDTEN = 0;
// Clock switching to incorporate PLL
__builtin_write_OSCCONH(0x03); // Initiate Clock Switch to Primary
// Oscillator with PLL (NOSC=0b011)
__builtin_write_OSCCONL(0x01); // Start clock switching
while(OSCCONbits.COSC != 0b011);
// Wait for Clock switch to occur
while(OSCCONbits.LOCK != 1);
//USB H/W initialization for 70 MIPs
ACLKCON3 = 0x24C1;
ACLKDIV3 = 0x7;
// Wait for PLL to lock
ACLKCON3bits.ENAPLL = 1;
while(ACLKCON3bits.APLLCK != 1);