Transcription of TMS320x2802x, 2803x Piccolo Enhanced Capture Module (eCAP
1 TMS320F2802x,2803xPiccoloEnhancedCapture (eCAP)ModuleReferenceGuideLiteratureNumb er:SPRUFZ8 AMay2009 RevisedOctober20092 SPRUFZ8A May2009 RevisedOctober2009 SubmitDocumentationFeedbackCopyright 2009, - - - TimeDifference(Delta) - TimeDifference(Delta) - SimplePWMG eneration(IndependentChannel/s).. May2009 RevisedOctober2009 TableofContentsSubmitDocumentationFeedba ckCopyright 2009, (TSCTR)..1610 CounterPhaseControlRegister(CTRPHS)..161 1 Capture -1 Register(CAP1)..1612 Capture -2 Register(CAP2)..1613 Capture -3 Register(CAP3)..1714 Capture -4 Register(CAP4)..1715 ECAPC ontrolRegister1 (ECCTL1)..1716 ECAPC ontrolRegister2 (ECCTL2)..1817 ECAPI nterruptEnableRegister(ECEINT)..2118 ECAPI nterruptFlagRegister(ECFLG)..2219 ECAPI nterruptClearRegister(ECCLR)..2220 ECAPI nterruptForcingRegister(ECFRC).. May2009 RevisedOctober2009 SubmitDocumentationFeedbackCopyright 2009, (TSCTR) (CTRPHS) (CAP1) (CAP2) (CAP3) (CAP4) (ECCTL1) (ECCTL2) (ECEINT) (ECFLG) (ECCLR) (ECFRC) May2009 RevisedOctober2009 ListofTablesSubmitDocumentationFeedbackC opyright 2009,TexasInstrumentsIncorporatedPreface SPRUFZ8A May2009 RevisedOctober2009 ReadThisFirstTheenhancedcapture (eCAP ) ,2803xPiccolo EnhancedCapture (eCAP ) Type0 ,28xxxDSPP eripheralReferenceGuide(SPRU566) fora listofalldeviceswitha eCAPmoduleofthesametype,todeterminethedi fferencesbetweenthetypes,andfora ,2803xPiccolo devicesandrelatedsupporttoolsandcanbedow nloadedfromtheTIwebsite( ).
2 DataManuals SPRS523 TMS320F28020,TMS320F28021,TMS320F28022,T MS320F28023,TMS320F28026,TMS320F28027 PiccoloMicrocontrollersDataManualcontain sthepinout,signaldescriptions, TMS320F28020,TMS320F28021,TMS320F28022,T MS320F28023,TMS320F28026, TMS320F28032,TMS320F28033,TMS320F28034,T MS320F28035 PiccoloMicrocontrollersDataManualcontain sthepinout,signaldescriptions, TMS320F28032,TMS320F28033,TMS320F28034, 'sGuides SPRU430 TMS320C28xCPUandInstructionSetReferenceG uidedescribesthecentralprocessingunit(CP U)andtheassemblylanguageinstructionsofth eTMS320C28xfixed-pointdigitalsignalproce ssors(DSPs).It SPRUFN3 TMS320x2802xPiccoloSystemControlandInter ruptsReferenceGuidedescribesthevariousin terruptsandsystemcontrolfeaturesofthe280 2xmicrocontrollers(MCUs).SPRUGL8 TMS320x2803xPiccoloSystemControlandInter ruptsReferenceGuidedescribesthevariousin terruptsandsystemcontrolfeaturesofthe280 3xmicrocontrollers(MCUs).SPRU566 TMS320x28xx,28xxxDSPP eripheralReferenceGuidedescribestheperip heralreferenceguidesofthe28xdigitalsigna lprocessors(DSPs).
3 SPRUGO0 TMS320x2803xPiccoloBootROMR eferenceGuidedescribesthepurposeandfeatu resofthebootloader(factory-programmedboo t-loadingsoftware) May2009 RevisedOctober2009 SubmitDocumentationFeedbackCopyright 2009, TMS320x2802xPiccoloBootROMR eferenceGuidedescribesthepurposeandfeatu resofthebootloader(factory-programmedboo t-loadingsoftware) TMS320x2803xPiccoloControlLawAccelerator (CLA)ReferenceGuidedescribestheoperation oftheControlLawAccelerator(CLA).SPRUGE2 TMS320x2803xPiccoloLocalInterconnectNetw ork(LIN)ModuleReferenceGuidedescribesthe operationoftheLocalInterconnectNetwork(L IN) TMS320x2803xPiccoloEnhancedQuadratureEnc oderPulse(eQEP)ReferenceGuidedescribesth eoperationoftheEnhancedQuadratureEncoder Pulse(eQEP) Module ,whichis usedforinterfacingwitha linearorrotaryincrementalencodertogetpos ition,direction,andspeedinformationfroma rotatingmachinein TMS320x2803xPiccoloEnhancedControllerAre aNetwork(eCAN)ReferenceGuidedescribesthe operationoftheEnhancedControllerAreaNetw ork(eCAN)whichusesestablishedprotocoltoc ommunicateseriallywithothercontrollersin TMS320x2802x, 2803xPiccoloAnalog-to-Digit alConverter(ADC)andComparatorReferenceGu idedescribeshowtoconfigureandusetheon-ch ipADCmodule,whichis a TMS320x2802x, 2803xPiccoloEnhancedPulseWi dthModulator(ePWM)ModuleReferenceGuidede scribesthemainareasoftheenhancedpulsewid thmodulatorthatincludedigitalmotorcontro l,switchmodepowersupplycontrol,UPS(unint erruptiblepowersupplies)
4 , TMS320x2802x, 2803xPiccoloHigh-Resolution PulseWidthModulator(HRPWM)describestheop erationofthehigh-resolutionextensiontoth epulsewidthmodulator(HRPWM).SPRUGH1 TMS320x2802x, 2803xPiccoloSerialCommunica tionsInterface(SCI) TMS320x2802x, 2803xPiccoloEnhancedCapture (eCAP) TMS320x2802x, 2803xPiccoloSerialPeriphera lInterface(SPI)ReferenceGuidedescribesth eSPI- a high-speedsynchronousserialinput/output( I/O)port- thatallowsa serialbitstreamofprogrammedlength(onetos ixteenbits) TMS320x2802x, 2803xPiccoloInter-Integrate dCircuit(I2C)ReferenceGuidedescribesthef eaturesandoperationoftheinter-integrated circuit(I2C) SPRU513 'sGuidedescribestheassemblylanguagetools (assemblerandothertoolsusedtodevelopasse mblylanguagecode),assemblerdirectives,ma cros,commonobjectfileformat, TMS320C28xOptimizingC/C++ 'sGuidedescribestheTMS320C28x C/C++ ++ TMS320C28xInstructionSetSimulatorTechnic alOverviewdescribesthesimulator,availabl ewithintheCodeComposerStudioforTMS320C20 00 IDE,thatsimulatestheinstructionsetoftheC 28x ,TMS320C28x, May2009 RevisedOctober2009 ReadThisFirstSubmitDocumentationFeedback Copyright 2009,TexasInstrumentsIncorporatedReferen ceGuideSPRUFZ8A May2009 RevisedOctober2009 EnhancedCapture (eCAP )ModuleTheenhancedCa pture (eCAP )moduleis essentialin applicablefortheeCAPfoundontheTMS320x280 2x,2803xPiccolo ,ROM-based, : Speedmeasurementsofrotatingmachinery( ,toothedsprocketssensedviaHallsensors) Elapsedtimemeasurementsbetweenpositionse nsorpulses Periodanddutycyclemeasurementsofpulsetra insignals Decodingcurrentorvoltageamplitudederived fromdutycycleencodedcurrent/voltagesenso rsTheeCAPmoduledescribedin thisguideincludesthefollowingfeatures.
5 4-eventtime-stampregisters(each32bits) Edgepolarityselectionforuptofoursequence dtime-stampcaptureevents Interruptoneitherofthefourevents Singleshotcaptureofuptofoureventtime-sta mps Continuousmodecaptureoftime-stampsin a four-deepcircularbuffer Absolutetime-stampcapture Difference(Delta)modetime-stampcapture Allaboveresourcesdedicatedtoa singleinputpin Whennotusedin capturemode,theECAP modulecanbeconfiguredasa ,oneeCAPchannelhasthefollowingindependen tkeyresources: Dedicatedinputcapturepin 32-bittimebase(counter) 4 x 32-bittime-stampcaptureregisters(CAP1-CA P4) 4-stagesequencer(Modulo4counter)thatissy nchronizedtoexternalevents,ECAP pinrising/fallingedges. Independentedgepolarity(rising/fallinged ge)selectionforall4 events Inputcapturesignalprescaling(from2-62) One-shotcompareregister(2bits)tofreezeca pturesafter1 to4 time-stampevents Controlforcontinuoustime-stampcapturesus inga 4-deepcircularbuffer(CAP1-CAP4)scheme Interruptcapabilitiesonanyofthe4 captureevents8 EnhancedCapture (eCAP )ModuleSPRUFZ8A May2009 RevisedOctober2009 SubmitDocumentationFeedbackCopyright 2009,TexasInstrumentsIncorporatedCounter ( timer )SyncIn32 CAP1 regCAP2 regCAP4 regCAP3 regInterrupt I/FECAPxINTS equencingEdge detectionEdge polarityPrescaleECAP xpinNote.
6 Same pindepends onoperatingmodeCounter ( timer )SyncIn32 CapturemodeAPWM modePeriod reg(active) ( CAP1 )Compare reg(active) ( CAP2 )Period reg(shadow) ( CAP3 )(shadow) ( CAP4 )Compare regInterrupt I/FECAPxINTPWMC ompare single-channelPWMgenerator(with32bitcapa bilities)whenit is count-upmode,providinga time-baseforasymmetricalpulsewidthmodula tion(PWM) ,respectively,whileCAP3andCAP4registersb ecometheperiodandcaptureshadowregisters, is a high-levelviewofboththecaptureandauxilia rypulse-widthmodulator(APWM) singlepinis ,it is aninput;in APWM mode,it is ,writinganyvaluetoCAP1/CAP2activeregiste rsalsowritesthesamevaluetothecorrespondi ngshadowregistersCAP3 May2009 RevisedOctober2009 EnhancedCapture (eCAP )ModuleSubmitDocumen tationFeedbackCopyright 2009,TexasInstrumentsIncorporatedTSCTR(c ounter 32 bit)RSTCAP1(APRD active)LDCAP2(ACMP active)LDCAP3(APRD shadow)LDCAP4(ACMP shadow)LDContinuous /OneshotCapture ControlLD1LD2LD3LD43232 PRD [0 31]CMP [0 31]CTR [0 31]ECAPxInterruptTriggerandFlagcontrolto PIECTR=CMP3232323232 ACMP shadowEventPrescaleCTRPHS(phase register 32 bit)SYNCOutSYNCInEventqualifierPolaritys electPolarityselectPolarityselectPolarit yselectCTR=PRDCTR_OVF4 PWMcomparelogicCTR [0 31]PRD [0 31]CMP [0 31]CTR=CMPCTR=PRDCTR_OVFOVFAPWM modeDelta modeSYNC4 Capture eventsCEVT[1:4]APRD shadow3232 MODE SELECTECCTL2 [ SYNCI_EN, SYNCOSEL, SWSYNC]ECCTL2[CAP/APWM]Edge Polarity SelectECCTL1[CAPxPOL]ECCTL1[EVTPS]ECCTL1 [ CAPLDEN, CTRRSTx]ECCTL2 [ RE ARM, CONT/ONESHT, STOP_WRAP]Registers.
7 ECEINT, ECFLG, ECCLR, Aninputcapturesignal(pulsetrain)canbepre scaledbyN = 2-62(inmultiplesof2) showsa functionaldiagramandFigure4 (eCAP)ModuleSPRUFZ8A May2009 RevisedOctober2009 SubmitDocumentationFeedbackCopyright 2009,TexasInstrumentsIncorporated01/n5 ECCTL1[EVTPS]prescaler [5 bits](counter)By passEvent prescalerECAPx pin(from GPIO)PSoutECAPxPSoutdiv 2 PSoutdiv 4 PSoutdiv 6 PSoutdiv 8 PSoutdiv prescalevalueof1 is chosen( [13:9]= 0,0,0,0,0) Fourindependentedgepolarity(risingedge/f allingedge)selectionMUXesareused,onefore achcaptureevent. Eachedge(upto4)is eventqualifiedbytheModulo4sequencer. Theedgeeventis TheMod4(2bit)counteris incrementedviaedgequalifiedevents(CEVT1- CEVT4). TheMod4countercontinuescounting(0->1->2- >3->0)andwrapsaroundunlessstopped. A 2-bitstopregisteris usedtocomparetheMod4counteroutput, May2009 RevisedOctober2009 EnhancedCapture (eCAP )ModuleSubmitDocumen tationFeedbackCopyright 2009,TexasInstrumentsIncorporatedCEVT1 CEVT2 CEVT3 CEVT4 One shotcontrol logicStopCLKRSTM odulo 4counter2 Mod_eqStop value (2b)ECCTL2[STOP_WRAP]ECCTL2[RE ARM]ECCTL2[CONT/ONESHT]0 1322:4 (zero) ,theeCAPmodulewaitsfor1-4(definedbystop- value)captureeventsbeforefreezingboththe Mod4counterandcontentsofCAP1-4registers( ,time-stamps).
8 (tozero)theMod4counterandpermitsloadingo fCAP1-4registersagain,providingtheCAPLDE N bitis ,theMod4countercontinuestorun(0->1->2->3 ->0,theone-shotactionis ignored,andcapturevaluescontinuetobewrit tentoCAP1-4in a ,andis phaseregisteris providedtoachievesynchronizationwithothe rcounters,viaa usefulin APWM modewhena phaseoffsetbetweenmodulesis ,anoptiontoresetthe32-bitcounteris capturedfirst,thenit is resetto0 (eCAP)ModuleSPRUFZ8A May2009 RevisedOctober2009 SubmitDocumentationFeedbackCopyright 2009,TexasInstrumentsIncorporatedSYNCICT R=PRDD isableDisableSync outselectECCTL2[SYNCOSEL]SYNCOECCTL2[SWS YNC]SYNCECCTL2[SYNCI_EN]CTRPHSLD_CTRPHSC LKTSCTR(counter 32b)RSTOVFSYSCLKD elta modeCTR OVFCTR[31 0] ,CTR[0-31]andareloaded( ,captureatime-stamp) ,thisbitis cleared(loadingis inhibited)automaticallywhena stopconditionoccurs, ,respectively,in (APRDandACMP) (CEVT1-CEVT4,CTROVF)orAPWM events(CTR=PRD,CTR= CMP).A counteroverflowevent(FFFFFFFF->00000000) is alsoprovidedasaninterruptsource(CTROVF). )
9 Thecaptureeventsareedgeandsequencerquali fied( ,orderedin time)bythepolarityselectandMod4gating, (fromtheeCAPxmodule) (CEVT1,CEVT2,CEVT3,CEVT4,CNTOVF,CTR=PRD, CTR=CMP) (ECEINT)is (ECFLG)indicatesif anyinterrupteventhasbeenlatchedandcontai nstheglobalinterruptflagbit(INT).Aninter ruptpulseis generatedtothePIEonlyif anyoftheinterrupteventsareenabled,thefla gbitis 1,andtheINTflagbitis (ECCLR) (ECFRC).Thisis May2009 RevisedOctober2009 EnhancedCapture (eCAP )ModuleSubmitDocumen tationFeedbackCopyright 2009,TexasInstrumentsIncorporatedPRDEQC learSetLatchCEVT1 ECFRCECCLRECFLGECEINTECCLRECEINTSetClear LatchCEVT2 ECFRCECFLGECCLRECCLRC learECEINTL atchSetECFLGECEINTSetClearLatchECFRCCEVT 4 CEVT3 ECFRCECFLGECFRCECCLRECEINTSetECEINTECFLG L atchClearLatchSetCMPEQECFRCECCLRECCLRC learECFLGECEINTC learLatchSetECFRCCTROVFECFLG010 Generateinterruptpulse wheninput= :TheCEVT1,CEVT2,CEVT3,CEVT4flagsareonlya ctivein capturemode(ECCTL2[CAP/APWM==0]).TheCTR= PRD,CTR=CMPflagsareonlyvalidin APWM mode(ECCTL2[CAP/APWM==1]).
10 CNTOVF flagis validin ,thislogicinhibits(locksout)anyshadowloa dingofCAP1orCAP2fromAPRDandACMP registers, ,shadowloadingis activeandtwochoicesarepermitted: Immediate- APRDorACMP aretransferredtoCAP1orCAP2immediatelyupo nwritinga newvalue. Onperiodequal, ,CTR[31:0]= PRD[31:0]14 EnhancedCapture (eCAP )ModuleSPRUFZ8A May2009 RevisedOctober2009 SubmitDocumentationFeedbackCopyright 2009,TexasInstrumentsIncorporatedAPRDTSC TRFFFFFFFFACMP0000000 CAPWMx(o/p pin)OntimeOff : Thetime-stampcounterbusis madeavailableforcomparisonvia2 digital(32-bit)comparators. WhenCAP1/2registersarenotusedin capturemode,theircontentscanbeusedasPeri odandComparevaluesin APWM mode. Doublebufferingis achievedviashadowregistersAPRDandACMP(CA P3/4).Theshadowregistercontentsaretransf erredovertoCAP1/2registerseitherimmediat elyupona write,orona CTR= PRDtrigger. InAPWM mode,writingtoCAP1/CAP2activeregisterswi llalsowritethesamevaluetothecorrespondin gshadowregistersCAP3 Duringinitialization, , ,duringrun-time, (APWMPOL==0)is asfollows:CMP = 0x00000000,outputlow for durationof period(0% duty)CMP = 0x00000001,outputhigh1 cycleCMP = 0x00000002,outputhigh2 cyclesCMP = PERIOD,outputhighexceptfor 1 cycle(<100%duty)CMP = PERIOD+1,outputhighfor completeperiod(100%duty)CMP > PERIOD+1,outputhighfor completeperiodThebehaviorofAPWM activelowmode(APWMPOL==1)is asfollows:CMP = 0x00000000,outputhighfor durationof period(0% duty)CMP = 0x00000001,outputlow 1 cycleCMP = 0x00000002,outputlow 2 cyclesCMP = PERIOD,outputlow exceptfor 1 cycle(<100%duty)CMP = PERIOD+1,outputlow for completeperiod(100%duty)CMP > PERIOD+1,outputlow for completeperiod15 SPRUFZ8A May2009 RevisedOctober2009 EnhancedCapture (eCAP )ModuleSubmitDocumen tationFeedbackCopyright 2009,TexasInstrumentsIncorporatedCapture Module - (TSCTR)310 TSCTRR/W-0 LEGEND:R/W= Read/Write;R = Readonly.
