Page 1 of 1
FRC CLOCK PROBLEM for DSPIC33EP128MC502
Posted: Mon Apr 04, 2016 2:36 pm
by JustinS
I have problem with setting DSPIC33EP128MC502 to work with 120MHz.
Below I've included my code and my Project Settings. I would be grateful for any help.
Re: FRC CLOCK PROBLEM for DSPIC33EP128MC502
Posted: Wed Apr 06, 2016 5:44 pm
by Benj
I have some known working code for this.
I'll try and remember to dig it out for you tonight.
Re: FRC CLOCK PROBLEM for DSPIC33EP128MC502
Posted: Fri Apr 08, 2016 12:25 pm
by Benj
This code works for me, adjust the timings as needed.
Code: Select all
//Setup configuration for 138.1875MHz or 69MIPs using 7.37MHz Internal Osc
PLLFBD = 73;// M=75
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(0x01);// Initiate Clock Switch to FRC
// Oscillator with PLL (NOSC=0b011)
__builtin_write_OSCCONL(0x01);// Start clock switching
while(OSCCONbits.COSC != 0b001);
// Wait for Clock switch to occur
while(OSCCONbits.LOCK != 1);
You also need the right config settings for it to work.

- Config.jpg (185.65 KiB) Viewed 5188 times
Re: FRC CLOCK PROBLEM for DSPIC33EP128MC502
Posted: Mon Apr 11, 2016 11:16 am
by JustinS
Thank you very much! You're a life saver
