CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

dspic33f PLL & frequency tuning...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mohammad3d



Joined: 28 Mar 2009
Posts: 17

View user's profile Send private message Send e-mail

dspic33f PLL & frequency tuning...
PostPosted: Sat Apr 11, 2009 2:26 am     Reply with quote

Hi All,

I found this result when working on dspic33f micro with CCS C compiler.
I try to get 40 MIPS performane with dspic33fj256GP710.
But, when you use XT or HS oscillator with PLL (#fuses HS, PR_PLL),
CCS consider default value of PIC micro for PLL setting.
This means in follow equation(see EQUATION 8-2: FOSC CALCULATION
in dsPIC33FJXXXGPX06/X08/X10 Data Sheet, page 136):

FOSC = FIN* (M/N1*N2)
M=50,N1=2,N2=4
and if you using 10Mhz crustal for FIN :
FOSC=10000000*(50/2*4)=62500000 Hz
and in FCY = FOSC/2 equation:
FCY=62500000/2=31250000(~31 MIPS)

In this status you get only 31 MIPS of micro .
For get maximum performance of dspic33f I modify oscillator setting
manually as follow:
First define special register in CCS as follow(for dspic33fj256GP710):
Code:

#word OSCCON   = 0X0742 //OSCILLATOR CONTROL REGISTER
#word CLKDIV   = 0X0744 //CLOCK DIVISOR REGISTER
#word PLLFBD   = 0X0746//PLL FEEDBACK DIVISOR REGISTER

#bit CLKDIV0=CLKDIV.0//‘N1’, PLL prescaler ->N1=2
#bit CLKDIV1=CLKDIV.1
#bit CLKDIV2=CLKDIV.2
#bit CLKDIV3=CLKDIV.3
#bit CLKDIV6=CLKDIV.6//‘N2’, PLL prescaler ->N2=2
#bit CLKDIV7=CLKDIV.7
#bit CLKDIV11=CLKDIV.11//DOZE Mode Enable bit
#bit CLKDIV12=CLKDIV.12//Processor Clock Reduction Select bits->1:1
#bit CLKDIV13=CLKDIV.13
#bit CLKDIV14=CLKDIV.14

#bit OSCCON8=OSCCON.8
#bit OSCCON9=OSCCON.9
#bit OSCCON10=OSCCON.10

*************************************************************
Second Modify this registers to custom value in main():
*************************************************************
CLKDIV0=0;//‘N1’, PLL prescaler ->N1=2
CLKDIV1=0;
CLKDIV2=0;
CLKDIV3=0;
CLKDIV6=0;//‘N2’, PLL prescaler ->N2=2
CLKDIV7=0;
CLKDIV11=1;//DOZE Mode Enable bit
CLKDIV12=0;//Processor Clock Reduction Select bits->1:1
CLKDIV13=0;
CLKDIV14=0;
OSCCON8=1;//Primary oscillator (XT, HS, EC) with PLL
OSCCON9=1;
OSCCON10=0;

PLLFBD=0b000011110;//‘M’, PLL multiplier->M=32

with this setting you have:
FOSC=10000000*(32/2*2)=80000000Hz
FCY=80000000/2=40000000(40 MIPS)

I test it and this setting work very well.
In next step I try to over clocking dspic33f to get higher performance.
I increase "PLLFBD" register to 0b000100111(M=41) and micro work well but
I have some problem with "#use delay(clock=X)" that just work
until "Clock=98Mhz". You can test this over clocking with different M value
and "#use delay(clock=X)". Then check result with square wave output and see time of execution on oscilloscope.

Best regards,
Mohammad Kouchekzadeh.
Guest








PostPosted: Sat Apr 11, 2009 8:33 am     Reply with quote

it will do the calulations

setup_oscillator(OSC_INTERNAL,80000000); = 40 mips

or

setup_oscillator( OSC_CRYSTAL, 2000000, 8000000); = 40 mips
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group