Freescale单片机_增强型定时器模块_第1页
Freescale单片机_增强型定时器模块_第2页
Freescale单片机_增强型定时器模块_第3页
Freescale单片机_增强型定时器模块_第4页
Freescale单片机_增强型定时器模块_第5页
已阅读5页,还剩38页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

EnhancedCaptureTimerModule,ReferenceManual,ECT_16B8CBlockUserGuide(EnhancedCaptureTimer16bbufferedReg.Timerlab-outputs1to8channelsofPWMoutofPortTorg$4000main:;useallchannelsasoutputcomparefunction;disabletimer,operateinwait,continueinBDM;fastclearenables;enableclearofOCnwhenmatchonallchannels;disableInterrupts;disablepull-ups,normaldrive,TCNTresetbyOC7;setprescalertodivide-by-4;settheOC7tobeanoutputport;enableOC7tosettheoutputcomparepinstohigh;OC7istheperiodofthePWM;OC0ishighfor32clocks;OC1ishighfor64clocks;OC2ishighfor128clocks;OC3ishighfor256clocks;OC4ishighfor512clocks;OC5ishighfor1024clocks;OC6ishighfor2048clocks;readytogo,nowenablethetimerloop:;waithere,InputCaptureFunction,Compare/CaptureUnit16-bitFreeRunningCounter,16-bitInputCaptureLatch,StatusFlagissetuponcapture,InterruptRequesttoCPU,Edge,EdgeSelectASTATUSFLAGISSET.2.ANINTERRUPTISGENERATEDTOCPU,IFEnabled.,InputCapture,IC7-IC0(2of3),B2,B1,B0,4.TCTL3,C7FC6FC5FC4FC3FC2FC1FC0F,C7IC6IC5IC4IC3IC2IC1IC0I,2.TFLG1,3.TMSK1,1.TC7TC0,EDG7BEDG7AEDG6BEDG6AEDG5BEDG5AEDG4BEDG4A,5.TCTL4,EDG3BEDG3AEDG2BEDG2AEDG1BEDG1AEDG0BEDG0A,RST:00000000,RST:00000000,RST:00000000,RST:00000000,$000E,$000C,$000A,$000B,AddressOffset$0010-$0011-$001E-$001F,-,COMPARE/CAPTUREFLAGSWrite1toClearInterruptFlag,COMPARE/CAPTUREMASK0=InterruptRequestMasked1=InterruptRequestEnabled,InputCapture,IC7-IC0(3of3),INTERRUPTS:,TOCLEARINTERRUPT,WRITE1TOICxFBITINTFLG1,DONOTUSEBITMANIPULATIONINSTRUCTIONS(SINCERM/WOPERATION),IC7IC0VECTORSAREUSED.,RESETCONDITIONS:,INPUTCAPTUREFUNCTIONSAREDISCONNECTEDFROMINPUT,CAPTUREPINS,INTERRUPTSAREDISABLED,FLAGBITSARECLEARED,FORINPUTCAPTURESIC7IC0,InputCaptureFlowChart,END,START,EDGEIS,DETECTED,EDGxB,EDGxA,0,1,0,0,0,1,1,1,RISING,EDGE?,FALLING,EDGE?,PUTTIMER,VALUEINTICx;,SETFLAG,ICxF,Y,Y,N,N,ICxI=1?,N,ASSERT,INTERRUPT,Y,IC/OCSelect,IOS7IOS6IOS5IOS4IOS3IOS2IOS1IOS0,TIOS-TIMERINPUTCAPTURE/OUTPUTCOMPARESELECTREGISTER,IOSx=1SELECTOCFUNCTION=0SELECTICFUNCTION,RST:00000000,$0000,TIMERENABLE1-CLOCKSCOUNTERENABLE0-CLOCKSCOUNTERDISABLE,TSCR-TIMERSYSTEMCONTROLREGISTER,RST:00,$0006,TENTSWAITSFRZTFFCAReserved,TSWAI-TIMERSTOPINWAIT0=NORMALOPERATION1=DISABLETIMERINWAITMODE,TSBCK-TIMERSTOPINDEBUGMODE0=DONOTSTOP1=DISABLETIMERINDEBUGMODE,TFFCA-TIMERFASTFLAGCLEARENABLE0=TIMERFLAGCLEARINGNORMALLY1=AREADFORIC,AWRITEOFOCREGISTERCAUSESCORRESPONDINGCHANNELFLAGTOCLEAR,TimerInputCaptureLab,WritearoutinetomeasuretheperiodofasquarewaveonTC1.TheroutineusestheInputCapturetomeasuretheperiodfromonerisingedgetothenext.Usesoftwarepollingroutine,non-Interrupt-driven.Assumesystemclockis25MHZ,settheTimerprescalertodivideby4.,1.LoadXregisterwithregisterblockaddress2.Configurechannel1forinputcapture(writeTIOS)3.SetTCTL4tocapturerisingedgeonchannel1.4.DisableCh1InterruptsinTMSK25.Enableandstarttimer6.ReadTimerstatusregisterintoAccumulator7.ClearTimerCh1statusflagC1F.8.WaithereuntilC1Fisset,elsegoto9.9.LoadcapturedvalueintoAccumulatorD.10.StoreDtoRaminTIME111.ClearC1Fbywritinga1toit12.WaithereuntilC1Fisset,elsegoto13.13.LoadcapturedvalueintoAccumulatorD.14.SubtractTIME1fromD15.StoreDtoRaminDIFFlocation.16.Returnfromsubroutine,TIME1EQU$1200ADDRESSOFTIME1DIFFEQU$1202ADDRESSOFDIFFERENCEORG$4000PROGRAMBEGINSHERE,PulseAccumulator,USEFULFOR:,1.EVENTCOUNTING,2.GATEDTIMEACCUMULATION,DESCRIPTION:,IFPULSEACCUMULATIONISEnabled,THENHCS12,RESPONDSTOEDGESONPAIBYINCREMENTINGTHE,8OR16-BITPULSEAccumulatorCOUNTER.,EVENTCOUNTINGMODE:,INPUTEDGESONPAIINCREMENTTHE8/16-BITCOUNTER,GATEDTIMEACCUMULATIONMODE:,THE8/16-BITCOUNTERISINCREMENTEDBYANE/64,CLOCKIFEnabledBYTHELASTEDGEONPAI,IFTHESPECIFIEDEDGEOCCURS,THEN:,1.THEPULSEAccumulatorFLAGBITISSET,INADDITION,THEFOLLOWINGMAYOCCUR:,1.THECOUNTERMAYBEINCREMENTED,2.THEPULSEAccumulatorOVERFLOWBITMAYSET,3.ANINTERRUPTISGENERATEDTOCPU,IFEnabled.,PulseAccumulator,EventCounterModePulseaccumulatorisaneventcounter.AneventisaprescribedexternalpulseappliedtotherelativeMCUpin.Eachpulseincrementsthevalueofthepulseaccumulatorregister.Triggereventcanbeconfiguredasarisingorafallingedge.,GatedAccumulationModePulseaccumulatorisaneventlengthcounter.CounterrecordsthelengthofapulseappliedontherelativeMCUpin.TheMCUinternalbusclockisdividedby64andappliedtothepulseaccumulatorforthedurationoftheexternalevent.Triggereventisconfigurableasalogichigheventoralogiclowevent.,PULSE,+1,COUNT!,EVENT,ECLK/64,PulseAccumulatorBlockDiagram,PIN,TCxPINLogic,DIVby64,ControlReg.,+,8/16BITCNTR,LATCH,POLARITYCONTROL,PTx,IRQ,DATABUS,Note1:PTxmaybeusedasPulseAccumulator,InputCaptureorOutputComparepin.WherePTx=PT0-PT3,SELECTEDCLOCK,DelayCounter,EdgeDetector,000000DLY1DLY0,Bit76543210,DLYCT-DelayCounterControlRegister,DLY1:0-DelayCounterValues00=Disabled01=256MClocks10=512MClocks11=1024MClocks,AddressOffset$0029,Note2:DelayCounterproducesaPulseatpresetclockcountiftheleveloftheinputsignalistheoppositeofthelevelbeforethetransition.,PARegisters(1of2),PACN3PACN2PACN1PACN0,AddressOffset$0022$0023$0024$0025$0028$0032$0033$0034$0035,PA3HPA2HPA1HPA0H,PAxEN-PAxEnable,PAxH-UsedtolatchPAxwhenenabledPA3H-PA0HRegistersarereadonly,PulseAccumulatorHoldingRegisters,ICPAR-InputControlpulseAccumulatorRegister,PulseAccumulatorCountRegisters,PARegisters(2of2),PACTL-PAControlRegister,PAOVI-PAOverflowInterruptEnable1=PAOInterruptEnabled0=PAOInterruptDisabled,PAI-PAInputInterruptEnable1=PAIInterruptEnabled0=PAIInterruptDisabled,PinAction,ClockSelection,PAEN-PAEnable1=PulseAccumulatorEnabled0=PulseAccumulatorDisabled,PAOVF-PulseAccumulatorOverflowFlagPAIF-PulseAccumulatorInputFlagSetswhenPAoverflowsfrom$FFto$00SetswhentheprogrammedtransitionisdetectedonPAPin.,PAFLG-PAInterruptFlagRegister,AddressOffset$0020,AddressOffset$0021,PulseAccumulator,-Pulseaccumulatorisdisabled,-Eventcountermode,-Fallingedges(eventcountermode)orPAIhighenables,(gatedtimeaccumulationmode),-Interruptsaredisabled,-Flagbitsarecleared,Interrupts:ForPulseAccumulatorInputandPulseAccumulatorOverflow.,ToclearInterruptwritea1toPAIForPAOVFbitsinTFLG2.,Donotusebitmanipulationinstructions(sinceRM/Woperation).,PulseAccumulatororPulseAccumulatorOverflowvectorused,Resetconditions:,PulseAccumulatorModes,ECTLatch&QueueModes,ECTLatchMode,LatchMode:LATQ=1ModulusDown-CountercausesICx&PAxregisterstotransfertotheircorrespondingholdingregisterswhenCounterreaches$0000,orwhenDown-Counteriswrittenwith$0000.Inthismode,ICregistersaretransferredtotheirholdingregisterwhenICLATbitiswrittenintheMCCTLregister,ECTQueueMode,QueueMode:LATQ=0AnInputCapturexEventcausestheICregistertotransfertocorrespondingHoldingregisterx,andnewcapturedvalueiswrittentocorrespondingICregister.ThismodealsocausesthePAxtotransfertoitscorrespondingholdingregisterwhenICholdingregisterxisread.ModulusDown-CounterinthismodemayonlybeusedtogenerateperiodicInterrupts.,ModulusDown-Counter,Binarydown-counter.Fullcontrolovercountstartvalue.Applicationsinaccurateeventtiming-usedtogenerateperiodicflagsandinterrupts.Runsindependentlyofmastertimer.Clockeddirectlyfromthebusclockthroughadedicatedprescaler.Canbesettogenerateflags/interruptsatadiscretetimefromactivation,orsettoreloadthecountstartvalueuponreaching$0000(periodicmodulusmode).,LOAD,COUNTDOWNTOZERO,PERFORMACTION,ECTInterruptGeneration,ECThasthirteendiscreteinterruptvectors-Noneedtocontinuallypollcriticalstatusflags.Interruptsallowdelegationandoptimisationofcoreuse.Extremelyflexible.Examplesofinterruptusage:Launchroutinesatreal-timefixedintervals.Performreal-timeperiodmeasurement.Countingofhigh-frequencyevents.,COREUNUSEDBYECT,EnhancedCapture,FeaturesonECTmoduleinadditiontostandardTIMmodule:-16-bitbufferregistersonfourinputcapturechannels.Four8-bit/two16-bitpulseaccumulators.16-bitmodulusdown-counterwith4-bitprescaler.Fouruserselectabledelaycountersforincreasednoiseimmunity.Maintimerprescalerextendedto7-bit.,MasterTimer,InputCaptureRegister,HoldingRegister,ModulusCounterRegisters,MCFLG-ModulusDown-CounterFlagRegister,MCCNT-ModulusDown-CounterCountRegister,AddressOffset$0036,37,MCCTL-ModulusDown-CounterControlRegister,AddressOffset$0026,AddressOffset$0027,MCZI-ModulusCounterInterruptEnableMODMC-ModulusModeEnable1=CounterisloadedwithlastvaluewrittentoModulusCountRegister.0=Countercountsoncefromvaluewrittentoitandwillstopat$0000.RDMCL-ReadModulusDownCounterLoad1=ReadsofCounterreturnsthecontentsoftheLoadRegister.0=ReadofCounterreturnscurrentvalueofthepresentcount.ICLAT-InputCaptureForceLatchActionWhenLatchModeisenabled,write1tothisbitcausesIC3-IC0andtheircorrespondingPulseAccumulatorstobelatchedintotheirassociateholdingregisters.,FLMC-ForceLoadRegisterintoModulusCounterbywriting1tothisbitMCEN-ModulusDown-CounterEnable1=ModulusCounterEnabled.0=ModulusCounterDisabled.MCPR1:0-ModulusCounterPrescalerSelect00=Div/101=Div/410=Div/811=Div/16,MCZF-ModulusCounterUnderflowInterruptFlag.ThisFlagissetwhenModulusCounterreaches$0000.Write1toclear.,POLF3:0-FirstInputCapturePolarityStatus1=InputCapturexwascausedbyrisingedge.0=InputCapturexwascausedbyfallingedge.Wherex=IC3-IC0.,ModulusDown-CountermaybeusedtogenerateperiodicInterrupts.ItcanalsobeusedtolatchICandPAregisterstotheirholdingregisters.,ECTControlRegisters,SHxyShareInputactionofInputCaptureChannelsxandy1=Thechannelinputxcausesthesameactiononthechannely.Theportpinxandthecorrespondingedgedetectorisusedtobeactiveonthechannely.0=NormaloperationTFMODTimerFlag-settingModeAllowsatimerInterrupttobegeneratedaftercapturingtwovaluesinthecaptureandholdingregistersinsteadofgeneratinganInterruptforeverycapture.1=IfinQueuemode,timerflagsC3F-C0Faresetwhenalatchonthecorrespondingholdingregisteroccurs.0=C3F-C0FarewhenavalidedgeoccursoncorrespondingICtimerpin.,PACMX-8-BitpulseAccumulatorMaxCount1=WhenPAreachesthevalue$FF,itwillnotincrementfurther.0=PAwilloverflowto$00.Note:ForPACMX=1,whencountisreadas$FF,itindicateacountof255ormore.BUFEN-ICBufferEnable1=IC&PAHoldingRegistersareenabled.0=IC&PAHoldingRegistersaredisabled.LATQ=InputControlLatchorQueueModeEnable1=Latchmodeisenabled.0=QueueModeisenabled.,ICSYS-InputControlSystemRegister,AddressOffset$002B,NOVWx-NoInputCaptureOverwriteThesecontrolbitspreventanoverwritetotheICxregistersuntilreadorlatchedintheholdingregister1=TherelatedICo

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论