Page 1 of 1

PIC33EP256MC502

Posted: Mon Jun 27, 2022 2:07 pm
by rndmotecfi
Hi,

How to change CLKDIV register values from PIC33EP256MC502 ?

Re: PIC33EP256MC502

Posted: Wed Jun 29, 2022 9:59 am
by BenR
Hello,

This is how we configure the clock for our dsPIC E-block board. You could do something similar using a C icon at the start of your program.

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);

Hopefully it helps.