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

PLL 40MHz

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



Joined: 04 Aug 2006
Posts: 98

View user's profile Send private message

PLL 40MHz
PostPosted: Thu Nov 02, 2006 6:37 am     Reply with quote

Hello

Currently I'm using an 18F2525 with a 20MHz crystal (20/4=5MHz internal clock).

I want to make the PIC as fast as it can go. If I use a 10MHz crystal and enable PLL, I can get 40MHz correct? And is this equal to a 10MHz internal PIC clock because 40/4=10?

If so, I am wondering how to do this. I set the H4 fuse and enabled the PLL bit in the OSCTUNE byte, but my PIC ends up behaving really slow... obviously there is something wrong - I don't know how to setup the PLL mode properly. Can someone help?

Thanks
Ttelmah
Guest







PostPosted: Thu Nov 02, 2006 7:26 am     Reply with quote

In a sense, yes, but I disagree with your terminology. Smile

The internal clock, is 40Mhz. The _instruction clock_ is then 10MHz. This is important, since some things like the PLL, can access the 'raw' internal clock.

You do not need to touch OSCTUNE. When using the HSPLL (H4), the PLL is enabled in hardware. PLLEN in OSCTUNE, is only used, when working with the _internal_ oscillator. If you look at the oscillator block diagram (Figure 2-8 in the data sheet), it shows how this works. Turning this bit 'on', with HSPLL selected, is not legitimate, and is probably resulting in an unexpected clock behaviour.

Best Wishes
jma_1



Joined: 08 Feb 2005
Posts: 147
Location: Wisconsin

View user's profile Send private message

PostPosted: Thu Nov 02, 2006 7:36 am     Reply with quote

Greetings,

I would set up the oscillator as listed below, but I would check that the configuration register is setup correctly according to the HSPLL mode of the datasheet. CCS does not use this wording in their #fuses.

For a 40 MHz frequency using a 10 MHz crystal:
#use delay(clock=40000000)
#fuses H4

If you view the fuses with the windows IDE version, it lists 'H4' as the 4X pll option.

Hopefully this helps. If not, double check that your oscillator is really switching at the right frequency. High frequency oscillators and bread boards do not always play nice together.

Cheers,
JMA
sjbaxter



Joined: 26 Jan 2006
Posts: 141
Location: Cheshire, UK

View user's profile Send private message Visit poster's website

PostPosted: Thu Nov 02, 2006 7:58 am     Reply with quote

Remember .... the H4 fuse won't actually any effect until you program the PIC then CYCLE the PIC's power !! so don't worry if you don't see any speed improvements straight away.
_________________
Regards,
Simon.
theteaman



Joined: 04 Aug 2006
Posts: 98

View user's profile Send private message

PostPosted: Thu Nov 02, 2006 3:44 pm     Reply with quote

Wow you guys are really helpful, thanks for the replies! Very Happy Smile Just one more question (probably gonna sound stupid now)... what do you mean by cycling the power of the PIC?

Last edited by theteaman on Thu Nov 02, 2006 3:47 pm; edited 2 times in total
newguy



Joined: 24 Jun 2004
Posts: 1908

View user's profile Send private message

PostPosted: Thu Nov 02, 2006 3:46 pm     Reply with quote

Turn it off & back on.
theteaman



Joined: 04 Aug 2006
Posts: 98

View user's profile Send private message

PostPosted: Thu Nov 02, 2006 3:47 pm     Reply with quote

thanks, i had a feeling it was that Smile
theteaman



Joined: 04 Aug 2006
Posts: 98

View user's profile Send private message

PostPosted: Wed Nov 08, 2006 5:06 am     Reply with quote

Code:

#use delay(clock=40000000)
#fuses NOWDT, WDT128, H4, NOPROTECT, NOIESO, NOBROWNOUT, BORV21, PUT, NOCPD, NOSTVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOEBTR, NOCPB, NOEBTRB, NOWRTC, NOWRTB, NOFCMEN, NOXINST, NOPBADEN, NOLPT1OSC, NOMCLR


Hi again. When I use the above code with a 10MHz crystal, I get a really slow operation, ie. the delay_ms function delays alot longer than it should..... could there be any conflicting fuses with the H4?

Thanks
btklister



Joined: 16 Jul 2009
Posts: 14

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 5:04 pm     Reply with quote

It also happens to me, anyone knows where is the problem? It only happens if it was used delay funcions, in normal code like
Code:

while(1)
{
   output_high(pin_b1);
   output_low(pin_b1);
}

no problems are detected.
My configuration is:
Code:

#include <18F46K20.h>

#device adc=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES H4                      //High speed osc with HW enabled 4X PLL
#FUSES PUT                      //Power Up Timer
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOPBADEN                 //PORTB pins are configured as digital I/O on RESET
#FUSES NOLPT1OSC                //Timer1 configured for higher power operation
#FUSES NOHFOFST                 //High Frequency INTRC waits until stable before clocking CPU
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(oscillator=10Mhz, clock=40Mhz)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 5:31 pm     Reply with quote

This is the wrong thread for that type of PIC. See this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=46828&start=5
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