setfreq for new 28X1

leftyretro

New Member
In anticipation of my 28X1 arriving (soon I hope!) I would like a little help on understanding external resonator Vs the Setfreq command. The new manual2 states that the yet to be released X2 uses a 4X PLL so that external resonators need to be 4 times slower then that actual clock speed desired. Does the X1 also share this 4X PLL or is an external resonator a one to one relationship?

I plan on using an external crystal oscillator module and would like to run my 28X1 at 16mhz, so I need to know if I use a 4mhz or 16 mhz external oscillator. Also after a power up reset does the 28X1 use the internal 4 mhz clock and automatically switch to an external oscillator if present, or does one have to start their user program with 'Setfreq EM16' command? What happens automatically and what happens only via commands is not real clear to me yet.

Thanks for any clairfication anyone can supply.

Lefty


Edited by - retrolefty on 13/05/2007 01:34:58
 

womai

Senior Member
The X1's are based on 16F series Microchipdevices which do not have an internal PLL that could multiply the resonator frequency. So in a nutshell, 28X1 and 40X1 run at the resonator frequency (16 MHz for a 16 MHz resonator), while the 18F-series based X2 parts will run on 4 times the resonator frequency (i.e. 16 MHz with a 4 MHz resonator).

Wolfgang
 

hippy

Technical Support
Staff member
My understanding is that the X1 will select the internal 4MHz oscillator after reset and will stay with that until a SETFREQ changes it.

As Wolfgang says, there's no PLL on the X1 so to get 16MHz operation use a 16MHz crystal and issue a SETFREQ EM16.

I'm not sure what the difference is between SETFREQ EM4, EM8, EM16 etc for an X1 because the actual operating speed is set by the crystal not the SETFREQ command. Presumably the SETFREQ parameter is used within the Firmware to adjust on-chip peripheral settings so commands which do timing match the speed of operation.

On the X2 I believe it is the same, except the PLL is always enabled and the crystal has to be a quarter of the desired operating frequency; for 16MHz operation, use a 4MHz crystal and issue a SETFREQ EM16.

I had thought it possible to use the PLL with the internal oscillator on the X2 allowing 16/32MHz without a crystal, but a closer reading of the 18F2420 datasheet suggests that's not so, and there appears to be no chance of re-programming the PICmicro Configuration Words to allow that.
 

hippy

Technical Support
Staff member
noesisdg : <i>Any rumours as to what PICs the X2s will use? </i>

28X2 = PIC18F2420
40X2 = PIC18F4420

From <i>firmware.txt </i> in the Programming Editor installation directory.
 

Bob Elton

New Member
I'm confused (not difficult).
If the X2 starts on internal osc until told otherwise, why can't you set the PLLEN bits for PLL with intosc? (Asuming we're talking about 2420/2520 here)
Not that its a bad idea to make sure PLL is only working with an extrnal osc - for the sake of accuracy.
 

hippy

Technical Support
Staff member
That was my thought, figure 2-8 of the 18F2420 datasheet shows PLL can be used with INTOSC, and what I'd relied on, but there's a caveat in the main text -

<i>2.6.4 PLL IN INTOSC MODES

The PLL is available when the device is configured to use the internal oscillator block as its primary clock source (FOSC3:FOSC0 = 1001 or 1000) ... If ... these conditions are not met, the PLL is disabled. </i>

My reading of that is, because FOSC is set for HSPLL as the primary clock source then PLL is not available for INTOSC use. The datasheet is marked &quot;preliminary&quot; so I'll see if there's a later one for download.

It seems odd to me that PLL cannot be used regardless of FOSC setting, but I suspect it's got something to do with actual chip layout and complexity which the block diagram doesn't reveal.
 

Bob Elton

New Member
Yes, I had read that bit too - but I now see the situation re HSPLL config. done at f/w loading time.
This all sounds very appealing.

I hope Rev-Ed remind people about Microchips recommended max of 40MHz with PLL (i.e. xtal 10MHz).

Edited by - bobelton on 13/05/2007 13:32:48
 

Technical

Technical Support
Staff member
X1 does not have a PLL so for 16MHz use 16MHZ resonator and command 'setfreq em16'. It is important to use the correct setfreq command for external resonator (em8, em16, em20 etc) as certain commands need to know what the external resonator is (e.g. servo command now operates at both 4MHz internal and 16MHz external).

X2 has a PLL on external resonator only - so you can use physical 4, 8 or 10MHz resonator to give you operating speed of 16, 32 or 40MHz. The internal resonator does not use PLL and so gives you 4 or 8MHz as with X1.
 
Top