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.
FRC CLOCK PROBLEM for DSPIC33EP128MC502
-
- Flowcode v5 User
- Posts: 40
- Joined: Wed Sep 12, 2012 1:59 pm
- Has thanked: 1 time
- Been thanked: 7 times
FRC CLOCK PROBLEM for DSPIC33EP128MC502
- Attachments
-
- Clipboard01.jpg
- (204.71 KiB) Downloaded 1852 times
-
- DSPIC33EP128MC502fc-test.fcfx
- Project code.
- (4.4 KiB) Downloaded 314 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: FRC CLOCK PROBLEM for DSPIC33EP128MC502
I have some known working code for this.
I'll try and remember to dig it out for you tonight.
I'll try and remember to dig it out for you tonight.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: FRC CLOCK PROBLEM for DSPIC33EP128MC502
This code works for me, adjust the timings as needed.
You also need the right config settings for it to work.
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);
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel