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

Using PLL of PIC18F4550

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Abdulla M.A.



Joined: 28 Mar 2010
Posts: 30
Location: Baghdad, Iraq

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

Using PLL of PIC18F4550
PostPosted: Tue Jan 11, 2011 9:11 am     Reply with quote

Hi guys,
I would like to get a square wave of 40MHZ frequency from portb, pin0.
is this a correct program?? BTW, H4 option did not work with me.

Code:
#include <18f4550.h>
#use delay (clock=10000000)
#fuses PLL4,nowdt,nocpd,nolvp,nomclr,nodebug

#byte portb=0xF81
#bit led=portb.0

main()
{
   set_tris_b(0x00);
   while(1)
   {
      led=1;
      led=0;
   }
}   


Abdulla
_________________
"A scientist can discover a new star, but he cannot make one. He would have to ask an engineer to do that."
"For an optimist the glass is half full, for a pessimist it's half empty, and for an engineer is twice bigger than necessary."
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Jan 11, 2011 10:09 am     Reply with quote

Quote:
I would like to get a square wave of 40MHZ frequency from portb, pin0.

That's impossible. The loop takes 4 instruction cycles an executes at 3 MHz with maximum 18F4550 CPU frequency.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jan 11, 2011 2:26 pm     Reply with quote

Quote:
BTW, H4 option did not work with me.

This thread has sample code that shows how to use HSPLL mode to
make the 18F4550 run at 48 MHz from a 20 MHz crystal.
http://www.ccsinfo.com/forum/viewtopic.php?t=42223
Ttelmah



Joined: 11 Mar 2010
Posts: 19307

View user's profile Send private message

PostPosted: Tue Jan 11, 2011 3:28 pm     Reply with quote

H4, would not work, since the 4550, does not have a 4*PLL.

It has a programmable divider, followed by a 24* PLL (which feeds the USB circuitry), followed by dividers that allow it to be connected to operate the CPU.
The only way to run the 4550, at 40MHz, is with an external 40MHz clock.

As said though, you won't get anywhere near 40Mhz. A PIC at 40Mhz, is a 10MIPS processor. Most C instructions take several machine instructions to execute. The only way to get a signal at or above the instruction rate, is to use the PWM. You could get a clock up to 12MHz, with the PIC running at 48MHz, with this.

Best Wishes
Abdulla M.A.



Joined: 28 Mar 2010
Posts: 30
Location: Baghdad, Iraq

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

PostPosted: Fri Jan 14, 2011 3:09 am     Reply with quote

That's meaning the max. frequency for PWM I can getting from 4550 with
crystal of 48MHZ is 12MHZ, is there any PIC can giving me more
frequencies???
thankx

Abdulla
_________________
"A scientist can discover a new star, but he cannot make one. He would have to ask an engineer to do that."
"For an optimist the glass is half full, for a pessimist it's half empty, and for an engineer is twice bigger than necessary."
Ttelmah



Joined: 11 Mar 2010
Posts: 19307

View user's profile Send private message

PostPosted: Fri Jan 14, 2011 3:23 am     Reply with quote

The PIC24 family generally clock to 64MHz (16MIPS), while the PIC30's, go to 120MHz (30MIPS). Different code and compilers (PCD does the former). Maximum PWM rate, is normally the same as the instruction rate.

However you are not going to be able to 'do' anything significant with such a waveform, except 'generate' it. Far better if you want (for example) a controllable external frequency, to use a chip designed for this. There are a number of frequency synthesiser chips on the market, and some examples of controlling these with a PIC, have been posted in the past here.

Best Wishes
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Fri Jan 14, 2011 10:40 am     Reply with quote

Ttelmah wrote:
The PIC24 family generally clock to 64MHz (16MIPS),


Funny, I was just revisiting these last night.

Slight correction: the PIC24 series usually runs a Fcy of Fosc/2 where the PIC24F's have a max Fosc of 32MHz (Fcy=16MHz or ~ 16MIPS) and the 24H series has a max Fosc of 80Mhz with the same Fcy rules of /2 (40MHz or about 40MIPS)


http://ww1.microchip.com/downloads/en/DeviceDoc/39754g.pdf


-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
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