12.07.2015 Views

PIC18F to PIC24F Migration: An Overview - Microchip

PIC18F to PIC24F Migration: An Overview - Microchip

PIC18F to PIC24F Migration: An Overview - Microchip

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

INTERNAL RC OSCILLATORS (INTOSC/FRCAND INTRC/LPRC)The internal oscilla<strong>to</strong>rs for <strong>PIC18F</strong> devices withnanoWatt Technology and <strong>PIC24F</strong> devices are virtuallyidentical, except in name. Both feature two independentinternal oscilla<strong>to</strong>rs, an efficient 31 kHz oscilla<strong>to</strong>r and anaccurate, high-speed 8 MHz oscilla<strong>to</strong>r. Both architecturesuse a configurable postscaler, driven by the 8 MHzsource, <strong>to</strong> provide a range of clock frequencies, from31 kHz <strong>to</strong> 4 MHz (as well as the undivided 8 MHzoutput). Both architectures allow software selection fromthe 31 kHz or 8 MHz oscilla<strong>to</strong>rs <strong>to</strong> provide the 31 kHzsource for various system features. Both clock systemspermit tuning of the 8 MHz source through a nominalrange of ±12%.The differences here are minor. For <strong>PIC18F</strong> devices,the internal 31 kHz and 8 MHz sources are generallyreferred <strong>to</strong> as INTOSC and INTRC. For <strong>PIC24F</strong>devices, they are known as the Fast RC (FRC) andLow-Power RC (LPRC) oscilla<strong>to</strong>rs. INTOSC/FRC tuningis accomplished with 5 tuning bits (TUN4:TUN0) in<strong>PIC18F</strong> devices; <strong>PIC24F</strong> devices use 6 tuning bits(TUN5:TUN0) for finer resolution. Finally, the defaultvalue on Reset for the 8 MHz postscaler is 1 MHz for<strong>PIC18F</strong> devices and 4 MHz for <strong>PIC24F</strong> devices.PLL FREQUENCY MULTIPLIER<strong>PIC18F</strong> and <strong>PIC24F</strong> devices both support a 4x PLLfrequency multiplier for use with select clock sources.In all cases, the PLL provides a stable output only whenthe input frequency is between 4 and 10 MHz. Theoperation of the PLL differs substantially between thetwo architectures.For most <strong>PIC18F</strong> devices incorporating nanoWattTechnology, the PLL is au<strong>to</strong>matically enabled forspecific, primary oscilla<strong>to</strong>r configurations and is alwaysoperational. All devices can use the HS oscilla<strong>to</strong>r withthe PLL; select later devices also allow the use of thePLL with the EC mode. These are distinct primaryoscilla<strong>to</strong>r configurations. If the user wishes <strong>to</strong> disable thePLL, the device must be reprogrammed and reconfigured.If the internal oscilla<strong>to</strong>r block is selected as thedevice’s default oscilla<strong>to</strong>r, the PLL is made availablewhen the INTOSC postscaler is configured for an outpu<strong>to</strong>f 4 or 8 MHz. In these cases, the PLL can be selectivelyenabled under software control with the PLLEN controlbit (OSCTUN).For <strong>PIC24F</strong> devices, the PLL is always available undersoftware control. It is available for all primary oscilla<strong>to</strong>rmodes, as well as FRC or FRCDIV operation (as longas a postscaler output of at least 4 MHz is selected). Touse the PLL, it is only necessary <strong>to</strong> perform a clockswitch <strong>to</strong> one of the PLL Clock modes. Once a PLLmode is selected, the state of the PLL’s output stabilityis indicated by the flag bit, LOCK (OSCCON).When the bit is set, the PLL output is stable.CLOCK SWITCHINGClock switching differs significantly between <strong>PIC18F</strong>and <strong>PIC24F</strong> devices. Conceptually, both architectureshave three categories of oscilla<strong>to</strong>rs: primary (externalcomponents connected <strong>to</strong> OSC pins), secondary(external crystal connected <strong>to</strong> T1OSC or SOSC pins)and internal RC. <strong>PIC18F</strong> devices permit the definitionof one and only one primary oscilla<strong>to</strong>r type used duringdevice configuration. This is the oscilla<strong>to</strong>r that is alwaysused when on device power-up and Reset. Thereafter,the device can switch between primary, secondary andinternal oscilla<strong>to</strong>r sources, under software control, bywriting <strong>to</strong> the SCS1:SCS0 bits. Once a primaryoscilla<strong>to</strong>r is defined, it cannot be changed unless thedevice is reprogrammed.For <strong>PIC24F</strong> devices, any one of the three major clocksources can be configured as the default start-up oscilla<strong>to</strong>r;users are no longer confined <strong>to</strong> just the primaryoscilla<strong>to</strong>r sources. During run time, the device canswitch between any of the available oscilla<strong>to</strong>r modesunder software control. This means, that among otherthings, it is possible <strong>to</strong> switch between a Primary Clockmode and its PLL counterpart while the application isrunning. It is also possible <strong>to</strong> start the device using theTimer1 or LPRC oscilla<strong>to</strong>r, rather than switch <strong>to</strong> thosesources after Reset or power-up (as was required in<strong>PIC18F</strong> implementations of nanoWatt Technology). Infact, it is possible <strong>to</strong> completely disable the primaryoscilla<strong>to</strong>r source in <strong>PIC24F</strong> devices; something thatcannot be done on the <strong>PIC18F</strong> architecture.This increased flexibility makes clock switching on<strong>PIC24F</strong> devices a more complex sequence. The newoscilla<strong>to</strong>r is selected with the NOSC2:NOSC0 bits andby setting the Oscilla<strong>to</strong>r Switch Enable bit, OSWEN. Toprevent unintended changes, <strong>PIC24F</strong> devices also usean additional safety interlock that requires an unlocksequence <strong>to</strong> write each byte of the OSCCON register.<strong>PIC24F</strong> unlocks the high or low byte for one instructionafter two specific literals are written <strong>to</strong> the high or lowbyte of OSCCON. <strong>An</strong> instruction counter ensures theunlock sequence is performed within a maximumnumber of instructions and remains unlocked for oneinstruction cycle. Because these sequences are sotime critical, the unlock sequences are done with anassembly language routine. When the NOSC bitsmatch the COSC bits, or the OSWEN bit is clear, theclock switch has been completed successfully.Because the New Oscilla<strong>to</strong>r Select bits, NOSC, andOscilla<strong>to</strong>r Switch Enable bit, OSWEN (OSCCON),reside in opposite halves of OSCCON, two unlocksequences are needed <strong>to</strong> request a system clockswitch. For examples of the OSCCON unlocksequences, refer <strong>to</strong> the specific device data sheet.© 2006 <strong>Microchip</strong> Technology Inc. DS39764A-page 21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!