12.07.2015 Views

MC80F7708 - abov.co.kr

MC80F7708 - abov.co.kr

MC80F7708 - abov.co.kr

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

<strong>MC80F7708</strong>12. TIMER / COUNTERTimer/Event Counter <strong>co</strong>nsists of prescaler, multiplexer, 8-bit timer data register, 8-bit <strong>co</strong>unter register, mode register,input capture register and Comparator as shown in Figure12-4. And the PWM high register for PWM is <strong>co</strong>nsistedseparately.The timer/<strong>co</strong>unter has seven operating modes.- 8 Bit Timer/Counter Mode- 8 Bit Capture Mode- 8 Bit Compare Output Mode- 16 Bit Timer/Counter Mode- 16 Bit Capture Mode- 16 Bit Compare Output Mode- PWM ModeIn the “timer” function, the register is increased every internalclock input. Thus, one can think of it as <strong>co</strong>unting internalclock input. Since a least clock <strong>co</strong>nsists of 2 andmost clock <strong>co</strong>nsists of 2048 oscillator periods, the <strong>co</strong>untrate is 1/2 to 1/2048 of the oscillator frequency in Timer0.And Timer1 can use the same clock source too. In addition,Timer1 has more fast clock source (1/1 to 1/8).In the “<strong>co</strong>unter” function, the register is increased in responseto a 0-to-1 (rising edge) transition at its <strong>co</strong>rrespondingexternal input pin EC0 (Timer 0).In addition the “capture” function, the register is increasedin response external or internal clock interrupt same withtimer/<strong>co</strong>unter function. When external interrupt edge input,the <strong>co</strong>unt register is captured into capture data registerTMx.Timer3 is shared with “PWM” function and Timer2 isshared with “Compare output” function.Example 1:Example 3:LDM IEDS,#XXXX_XX01BSET1 T0ELDM PSR0,#X1XX_XXXXB ;AS INT0EI:::SET1 T0E ;ENABLE TIMER 0SET1 INT0E ;ENABLE EXT. INT0EI:Timer 0 = 8-bit timer mode, 8ms interval at 4MHzTimer 1 = 8-bit timer mode, 4ms interval at 4MHzTimer0 = 8-bit event <strong>co</strong>unterTimer2 = 8-bit capture mode, 2us sampling <strong>co</strong>unt.LDM SCMR,#0 ;Main clock modeLDM TDR0,#249LDM TDR0,#0FFH ;don’t careLDM TM0,#0001_0011BLDM TM0,#1FH ;event <strong>co</strong>unterLDM TDR1,#124LDM R0IO,#1XXX_XX1XB ;R07, R01 inputLDM TM1,#0000_1111BLDM IEDS,#XXXX_01XXB ;FALLINGSET1 T0ELDM PSR0,#1XXX_XX1XB;INT1,EC0SET1 T1ELDM TDR2,#0FFHEILDM TM2,#0010_1011B ;2us:::SET1 T0E ;ENABLE TIMER 0SET1 T2E ;ENABLE TIMER 1SET1 INT1E;ENABLE INT1EI:X: don’t care.Example 2:Timer0 = 16-bit timer mode, 0.5s at 4MHzExample 4:Timer0 = 16-bit capture mode, 8us sampling <strong>co</strong>unt. at 4MHzLDM SCMR,#0 ;Main clock modeLDM TDR0,#23HLDM TDR0,#0FFHLDM TDR1,#0F4HLDM TDR1,#0FFHLDM TM0,#0FH ;F MAIN /32, 8usLDM TM0,#2FHLDM TM1,#5FHLDM TM1,#4CHX: don’t care.44 December 3, 2012 Ver 1.21

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

Saved successfully!

Ooh no, something went wrong!