PIC33EP256MC502

Post here to discuss any new features, components, chips, etc, that you would like to see in Flowcode.
Post Reply
rndmotecfi
Posts: 5
http://meble-kuchenne.info.pl
Joined: Mon Jan 25, 2021 11:28 am
Been thanked: 1 time

PIC33EP256MC502

Post by rndmotecfi »

Hi,

How to change CLKDIV register values from PIC33EP256MC502 ?
Attachments
pic33ep256mc502.PNG
pic33ep256mc502.PNG (94.41 KiB) Viewed 994 times

BenR
Matrix Staff
Posts: 1706
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: PIC33EP256MC502

Post 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.

Post Reply