PIC校准内部RC振荡器
Recently,Microchiphasintroducedaseriesofnew
PIC16andPIC18PICmicro
®
microcontrollersthathave
anon-boardInternalRCOscillator,capableof
eightfrequenciesfrom31kHzto8MHz.These
microcontrollersincludethefollowingdevices:
•PIC16F818/819
•PIC16F87/88
•PIC18F1X20
•PIC18F2220/2320/4220/4320
TheinternalRCoscillatorisconfiguredandtunedby
theOSCCONandOSCTUNEregisters,respectively.
TheOSCCONregistersetsthefrequencyandcontains
theIOFSbit,whichindicateswhenthefrequencyhas
stabilizedafterafrequencychangeintheOSCCON
register.OSCTUNEisresponsiblefortuningthefre-
quencywithinarangeof+/-12percentontheselected
frequency.Theupperrangeoftuningis01h-1Fhand
thelowerrangeis20h-3Fh,withcenterfrequencyat
00h.Itisrecommendedtoconsultthedevicedata
sheetforfurtherdetails.
Theassemblycodeincludedinthisapplicationnote
(seeAppendixA)isonlyapplicableforaPIC16F819
microcontroller;however,withminorchanges,thecode
canbeportedovertothedeviceslistedabove.Having
aninternalRCoscillatoreliminatestheneedforcapac-
itorsandanexternalcrystal,resultinginproduction
costsavings.
Youmaybewondering,“Whywoulditbenecessaryto
calibratetheinternaloscillatorifitissupposedtocome
fromthefactoryalreadycalibrated?”Eventhoughthe
internaloscillatorisfactorycalibratedat25°C,temper-
aturevariationsintheoperatingenvironmentmustbe
considered.Sinceachangeinfrequency,aslittleas
twotothreepercent,cancorruptserialcommunication,
theinformationpresentedinthisapplicationnotecan
helpyouavoidthisissuebyallowingfrequency
calibrationovertemperature.AN244InternalRCOscillatorCalibrationTheabilitytocalibratetheinternaloscillatormeansthatAuthor:ChrisValentiaknowntime-basemustbeestablishedasareferenceMicrochipTechnologyInc.point.Thistime-basewillbederivedfroma32.768kHzclockcrystalconnectedtoTimer1(seeFigure1).OtherINTRODUCTIONfixedtime-basesthatcanbeusedareACline