18F PIC Transition Guide
There are a lot of different PIC's available to the
consumer, it is something that Microchip do evidently different
compared to other companies - product ranges are not discontinued -
there is continual support and silicon revisions.
The above is one driving factor to the diversity of
PIC micro's, the other is the consumer demand for diversity toward
hardware peripherals (such as USB, USART, I2C, PWM, SPI etc..)
This guide is designed to help you get started with
Swordfish with the popular 18F PIC micro's. Its just basic
program requirements to take into consideration when changing
between devices (in particular the config settings). If you have a
device you would like to see added to the list -
please let me know
18F2550 and 18F4550 (8Mhz Internal Oscillator)
-
The internal oscillator must be configured before other "Include"
files are specified, or else long program delays will be
experienced. To rectify this, I made my own
User
Library and always Include it first to ensure it is the first
code executed on program start.
Device = 18F2550
Clock = 8
Config FOSC = INTOSCIO_EC
Include "INTOSC8.bas"
18F2550 and 18F4550 (USB, Main Clock @ 48Mhz)
-
When using USB, connect a 20Mhz clock and setup the beginning of the
program as follows;
// device and clock...
Device = 18F4550
Clock = 48
// 20Mhz crystal, 48Mhz internal (FS USB)
Config
PLLDIV = 5,
CPUDIV = OSC1_PLL2,
USBDIV = 2,
FOSC = HSPLL_HS,
VREGEN = ON
-
I also use a similar approach when setting up the PIC for 12 MIPS
(48Mhz) use in programs
18F2520 and
18F4520 Internal Oscillator/PLL
-
Similar to the 18Fx550 PIC's, where the use of an external
User
Library is utilised to ensure the PIC is instantly operating at
full speed (8Mhz)
Device = 18F4520
Clock = 8
Config OSC = INTIO67 // Use the Internal Oscillator
Include "INTOSC8.bas"
-
To enable PLL on the internal oscillator (32Mhz), simply add the OSCTUNE.6 =
1 setting as soon as possible in your code (keep in mind that your
PIC will be running at 8Mhz until it is enabled)
Device = 18F4520
Clock = 32
Config OSC = INTIO67 // Use the Internal Oscillator
Include "INTOSC8.bas"
OSCTUNE.6 = 1
18F2520 and 18F4520 High Speed PLL (40Mhz)
-
High Speed PLL with a 10Mhz External Crystal can be achieved by
doing the following;
Device = 18F458
Clock = 40
Config OSC = HSPLL

 | 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 |