Hi,
How to change CLKDIV register values from PIC33EP256MC502 ?
PIC33EP256MC502
-
- Posts: 5
- http://meble-kuchenne.info.pl
- Joined: Mon Jan 25, 2021 11:28 am
- Been thanked: 1 time
-
- Matrix Staff
- Posts: 1760
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 447 times
- Been thanked: 607 times
Re: PIC33EP256MC502
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.
Hopefully it helps.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel