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 CCS Technical Support

XT PLL issue ?

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



Joined: 31 Jan 2009
Posts: 59

View user's profile Send private message

XT PLL issue ?
PostPosted: Sat Jun 18, 2011 11:04 am     Reply with quote

Hi all
i have the following problem

i have PIC18F2550 with :
Code:

#include <18F2550.h>
#device *=16
#device adc=10
#FUSES NOWDT,XTPLL,FCMEN,NOPUT,NOBROWNOUT,MCLR
#use delay(clock=12 000 000,RESTART_WDT)

#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)


#int_TIMER0
void TIMER0_isr (void) {

}

void main () {
   setup_wdt ( WDT_OFF );
   setup_timer_0 ( RTCC_INTERNAL | RTCC_DIV_64 );
   setup_timer_1 ( T1_DISABLED );
   setup_timer_2 ( T2_DISABLED, 0, 1 );
   //   enable_interrupts(INT_TIMER0);
   //   enable_interrupts(GLOBAL);


   while (true)

      printf ( "this is working !!! \n\r" );
   delay_ms ( 10 );

}



i have XT clock on board of 12Mhz,
i want to enable PLL to this so it will have 48Mhz, do i have to put
Code:
use_delay(48 000 000)
or just leave it
Code:
use_delay(12 000 000)
with that XTPLL FUSE


and another strange thing
i have my serial port from pc set to 9600 baud and it outputs ok taking into consideration that pic has baud=115200 .. how is this possible ?
i think that is from XT ?
noyz



Joined: 31 Jan 2009
Posts: 59

View user's profile Send private message

PostPosted: Sat Jun 18, 2011 11:42 am     Reply with quote

it seems that the clock is actually 1 000 000
i've changed Xtal and the clock value is the same..
i think it is blocked on internal clock use.. only..
normaly when you touch the both pins of xtal with hand.. the mcu stops..
but it doesn't;
what do you suggest ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sun Jun 19, 2011 2:22 am     Reply with quote

First thing to understand. On the 2550, _the PLL is always enabled_.....
It is used for the USB. XT/HSPLL, says take the CPU clock from the USB PLL source, rather than from the direct crystal route.
Now if your external crystal is 12MHz, you _must_ use HSPLL, not XTPLL. The later enables the low power oscillator, designed for operation to 4MHz max. At 12MHz, you need the HS oscillator.
Then, the PLL, _must_ be fed with 4MHz. So you need PLL3, to say 'divide the incoming clock by 3' to give 4MHz. The PLL won't run if fed with frequencies much different from 4MHz.
You have 'FCMEN' enabled. This means 'if the primary oscillator fails, fall back to the internal oscillator'. Because you have the XTAL/PLL setup wrong, this is what is happening, and why you are seeing 1MHz, and putting your finger near the CPU crystal pins has no effect.
The clock statement, must be set to the frequency the CPU is actually clocked at, not the crystal frequency.

Code:

#include <18F2550.h>
//#device *=16 Only needed on PIC16 devices
#device adc=10
#FUSES NOWDT,HSPLL,PLL3,FCMEN,NOPUT,NOBROWNOUT,MCLR,CPUDIV1
#use delay(clock=48MHz,RESTART_WDT) //Much simpler to use MHz.


Best Wishes
noyz



Joined: 31 Jan 2009
Posts: 59

View user's profile Send private message

PostPosted: Tue Jun 21, 2011 1:11 am     Reply with quote

i don't understand where is the calculation for cpu = 48 mhz..
i understood that it is neccesary to have pll activated, and it must be fed with 4 mhz..
so 12 / 3 =4mhz

and CPU .. how it is calculated ?

12 /3 * 12 = 48 :-?

pll clock * hspll = cpu clock ?
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