View previous topic :: View next topic |
Author |
Message |
Abdulla M.A.
Joined: 28 Mar 2010 Posts: 30 Location: Baghdad, Iraq
|
Using PLL of PIC18F4550 |
Posted: Tue Jan 11, 2011 9:11 am |
|
|
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
|
|
Posted: Tue Jan 11, 2011 10:09 am |
|
|
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
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Tue Jan 11, 2011 3:28 pm |
|
|
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
|
|
Posted: Fri Jan 14, 2011 3:09 am |
|
|
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: 19539
|
|
Posted: Fri Jan 14, 2011 3:23 am |
|
|
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: 1615 Location: Central Illinois, USA
|
|
Posted: Fri Jan 14, 2011 10:40 am |
|
|
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 |
|
|
|