18F Code Snippet - PLL, Speed your PIC up by 4

Developed with the
Swordfish
compiler
Please have a look at the
PIC
Transition Guide for more information on setting up other PIC's
The fastest a 16F
PIC micro can run is 5 Million Instructions Per Second (MIPS), almost every 18F
PIC micro can run at 10 MIPS, some more. Here's an extract from an 18F
datasheet;
"The HSPLL mode makes use of the HS mode
oscillator
for frequencies up to 10 MHz. A PLL then multiplies the
oscillator output frequency by 4 to produce an internal
clock frequency up to 40 MHz."
But how exactly to we
enable this PLL feature so our PIC can run 4 times faster? Its simple with a
higher language Development suit like Swordfish,
Device = 18F458
Clock = 40
Config OSC = HSPLL
// Start Of Program...
The above code is simply the start of the
program. OSC = HSPLL enables the High Speed
(HS) PLL feature, but there are some limitations to take into account.
Remember that the PIC
usually
executes an instruction once every 4 oscillator cycles, with PLL, it can be
reduced t a 1:1, that is, one oscillation = 1 instruction. With this in
mind, and the PIC's max speed (10 MIPS), the greatest external crystal
that can be used is 10Mhz. If you compared the speed to a PIC running
normally, it would be that of a PIC running with a 40Mhz crystal. That is
why the Clock setting is declared as
40Mhz, allowing the compiler
to generate the right delays etc when required.
Some 18F PIC's can operate at 48Mhz (12
MIPS), check the datasheet for more information about the PIC your using.

 | Site Tutorial Index |
|  | 16F PIC Examples |
|  | 18F PIC Examples |
| |  | 7 Segment Displays |
| |  | 7 Segment Displays |
| |  | RS232 and UART |
| |  | Code Snippets |
| | |  | Internal Timers |
| | |  | Interrupts |
|  | Handy Tips |