|
|
View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jan 07, 2007 2:22 pm |
|
|
Here is a test program that runs the 18F4550 at 20 MHz, with a 20 MHz
crystal. I tested this with PCH vs. 3.249 on a PicDem2-Plus board.
Code: |
#include <18F4550.h>
#fuses HS, NOWDT, PUT, BROWNOUT, NOLVP
#use delay(clock=20000000)
//====================================
void main()
{
// Blink an LED on pin B0.
while(1)
{
output_high(PIN_B0);
delay_ms(500);
output_low(PIN_B0);
delay_ms(500);
}
} |
|
|
|
Ttelmah Guest
|
|
Posted: Sun Jan 07, 2007 3:51 pm |
|
|
Kamal wrote: | What is the difference between HS and HSPLL ??
Is it that the PIC4550 does not support XTALs greater than 10Mhz .. will it support a 20Mhz XTAL ?
Also, as you can see, I am changing the PWM freq very fast (every 300ms)... is this reason for the PIC to behave erratically ? |
The fuses on these chips are terrifying!.
HSPLL, has a different meaning, than HSPLL on most other chips. When selected, it means 'use the USB PLL circuit'. This takes a 4MHz frequency, and multiplies it to generate 96MHz. Now the frequency fed into this circuit is determined by the PLL prescaler, which is set by the 'PLL5' fuse, to be /5. So these two fuses together, mean take the incoming clock, divide it by 5, then multiply it up to give 96MHz!.
Now the USB frequency, is then divided by the CPUDIV fuse, to generate the clock fed to the CPU. The value for this fuse is divided by a further 2, when used with the USB clock. So HSPLL, PLL5, CPUDIV1, gives a CPU, at 48Mhz. Table 2-3 of the data sheet, the fourth value down for the 20Mhz input option.
So, the clock frequency is wrong for the fuses as given (should be 48000000), but the fuses as given, are OK for the chip.
Best Wishes |
|
|
Kamal
Joined: 11 Feb 2006 Posts: 12
|
|
Posted: Sun Jan 07, 2007 7:57 pm |
|
|
PCM programmer wrote: | Here is a test program that runs the 18F4550 at 20 MHz, with a 20 MHz
crystal. I tested this with PCH vs. 3.249 on a PicDem2-Plus board.
Code: |
#include <18F4550.h>
#fuses HS, NOWDT, PUT, BROWNOUT, NOLVP
...
|
|
Allright .. the number of fuses you used here are not terrifying and you used the HS fuse instead of the HSPLL fuse...
I don;t want to use the USB Peripheral inside 4550, so do I have to use the HSPLL and related fuses or will simply HS do ?
I just wanna drive an HBridge (so need PWM for that), read a few switches and use the ADC.
What fuses I really need ?
Someone should write a document on all these fuses... the Microchip datasheet also is terrifying regarding these fuses ! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jan 07, 2007 8:23 pm |
|
|
Quote: |
I don't want to use the USB Peripheral inside 4550.
I just wanna drive an HBridge (so need PWM for that), read a few switches and use the ADC.
|
It looks like you just want to use this PIC as if it's an 18F452.
In that case, use the fuses as shown in my test program. |
|
|
Kamal
Joined: 11 Feb 2006 Posts: 12
|
|
Posted: Sun Jan 07, 2007 8:35 pm |
|
|
PCM programmer wrote: |
It looks like you just want to use this PIC as if it's an 18F452.
In that case, use the fuses as shown in my test program. |
Ok.. so the 18F452 is 4550 sans the USB Peripheral ?
Is the PLL only for USB ? If I want to run the 4550 at 48Mhz can I do away with the XTAL and use the PLL ?
How stable will it's performance be ?
Why at all use the XTAL if the PLL is equally effective, if I do not have any specific reason to run at a lower freq, can I just use the PLL and run at 48Mhz without worrying about stability and reliability ?
Thanks PCM programmer for clearing my previous doubts ! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jan 07, 2007 9:10 pm |
|
|
Your original question was how to run at 20 MHz. Now you want to
run with the PLL. You'll have to wait until Monday for that answer,
when I can test it in hardware. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jan 08, 2007 11:53 am |
|
|
Actually, Ttelmah told you what you needed to do. I didn't look at his
post closely until this morning. You can figure out how to setup the
oscillator by looking at the block diagram of the clock circuit in the
18F4550 data sheet. This is on page 24 (page 26 in the Acrobat reader).
Here is a test program. I tested it on a PicDem2-Plus board with PCH
vs. 3.249. This is with a 20 MHz crystal.
Code: | #include <18F4550.h>
#fuses HSPLL, PLL5, CPUDIV1, NOWDT, PUT, BROWNOUT, NOLVP
#use delay(clock=48000000)
//=================================
void main()
{
// Blink an LED on Pin B0.
while(1)
{
output_high(PIN_B0);
delay_ms(500);
output_low(PIN_B0);
delay_ms(500);
}
} |
|
|
|
Guest
|
|
Posted: Mon Jan 08, 2007 7:54 pm |
|
|
PCM programmer wrote: | Your original question was how to run at 20 MHz. Now you want to
run with the PLL. You'll have to wait until Monday for that answer,
when I can test it in hardware. |
PCM programmer,
First, I thank you for solving my original timing problem. I am getting excellent performance right now.
I asked the question on PLL just out of curiosity - not a neccessity. It's is not my primary objective.
What I want to know is if the PLL is as stable as the crystal in terms of timing.
If so, I don't think it makes sense to hook up a Crystal in the first place, if the PLL is as stable as a XTAL, since it costs money and takes up board space too.
That's what I need clarification on. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jan 09, 2007 12:25 pm |
|
|
Quote: | What I want to know is if the PLL is as stable as the crystal in terms of timing. |
Download the 18F4550 data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/39632c.pdf
Go to page 381 (page 383 in the Acrobat Reader).
Look at this section:
TABLE 28-9: PLL CLOCK TIMING SPECIFICATIONS
It has the jitter specifications for the PLL.
I can't find any specs on jitter when using a crystal in HS mode, etc.
I searched the whole Microchip website (using Google).
Quote: |
If so, I don't think it makes sense to hook up a Crystal in the first place,
if the PLL is as stable as a XTAL, since it costs money and takes up board
space too. |
The PLL requires an external crystal or oscillator. Look at page 24
of the data sheet (page 26 in the Acrobat reader), at this diagram:
FIGURE 2.1: PIC18F2455/2550/4455/4550 CLOCK DIAGRAM
It shows that the 96 MHz PLL source comes only from the "Primary
oscillator" pins. You must connect an external crystal or oscillator
to those pins, to provide the PLL a clock signal.
I suspect that you are confusing the Internal RC Oscillator with the PLL.
These are completely different sections in the Clock Diagram.
Go to page 383 in the Acrobat Reader and look at this table for
specifications of the Internal oscillator:
TABLE 28-10: AC CHARACTERISTICS: INTERNAL RC ACCURACY
For more on the Internal RC Oscillator, go to page 29 in the
Acrobat reader and read this section:
2.2.5.3 Internal Oscillator Output Frequency and Drift |
|
|
Ttelmah Guest
|
|
Posted: Tue Jan 09, 2007 4:12 pm |
|
|
PCM programmer hs already covered it pretty thoroughly. The key line, is the end of the first paragraph in section 2.2.5 in the data sheet:
"If the USB peripheral is not used, the internal oscillator may eliminate the need for external oscillator circuits on the OSC1 and/or the OSC2 pins". Note the key part about the USB. The internal oscillator, is _not_ accurate enough to meet the USB requirements, and hence it is not routed to this part of the circuit...
The clock timings for USB, require the device clocks, to be within 0.05%. You may well be suprised by how many devices on the market actually fail in this, when they are taken outside the 'room temperature' enviroment!. The internal oscillator typically manages +/-1%, but in some cases may well be well outside this. Not even close to good enough...
Fortunately, the clock jitter in the PLL, does not effect the actual timing accuracy, and once divided down to feed the USB circuitry, causes no problems.
Best Wishes |
|
|
|
|
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
|