4 measure duty cycle rep, 4 measure duty cycle repeatedly -13, Maxq family user’s guide – Maxim Integrated MAXQ Family User Manual
Page 91: 4 measure duty cycle repeatedly

9-13
MAXQ Family User’s Guide
9.3.4 Measure Duty Cycle Repeatedly
To measure the duty cycle of the signal seen on the T2P input pin, Timer 2 could be configured for a single-shot delayed run with both
edges defined for capture. The CPRL2 bits should be configured to 1 to request reloads on each edge. To prevent reloads on one of
the edges, gating should be enabled. The T2POL[0] bit specifies which edge starts/ends the capture cycle and which edge does not
have a reload associated with it.
; ------------------ Reset State: T2R = T2V = T2C = 0000h ------------------------
MOVE T2CFG, #00000110b
; T2CI
=0
(sysclk/N input)
; T2DIV[2:0]
=000
(/1)
; T2MD
=0 (16-bit)
; CCF[1:0]
=11 (both
edges)
; C/T2
=0 (timer/capture)
MOVE T2CNA, #10101111b
; ET2
=1
(enable Timer 2 ints)
; T2OE[0]
=0
(input)
; T2POL[0]
=1
(no reload on rising edge
;
single-shot start/end on falling edge)
; TR2L:TR2
=01
(start timer 2 on single shot condition)
; CPRL2
=1
(reload on capture edge)
; SS2
=1
(single-shot mode)
; G2EN
=1
(gating enabled)
; ------------------ TCC2 Interrupt : LOW TIME=T2C
;------------------- TCC2 Interrupt : PERIOD = T2C
T2P PIN
CODE EXECUTION:
POINT A
CODE EXECUTION:
POINT B
1A
3A
1B
3B
2A
2B
EVENTS:
1A: FALLING EDGE CAUSES CAPTURE/RELOAD; SINGLE-SHOT CAPTURE CYCLE BEGINS.
2A: RISING EDGE CAUSES CAPTURE; LOW TIME = T2C.
3A: FALLING EDGE CAUSES CAPTURE/RELOAD; SINGLE-SHOT CAPTURE CYCLE ENDS; PERIOD = T2C. TIMER CONTINUES TO OPERATE
SINCE TR2 = 1, ALLOWING THE NEXT LOW TIME/PERIOD TO BE MEASURED.
1B–3B: SAME SEQUENCE AS 1A–3A, EXCEPT THAT THE SINGLE-SHOT CAPTURE CYCLE DOES NOT BEGIN UNTIL THE FIRST FALLING EDGE IS DETECTED.
Figure 9-7. Timer 2 Application Example—Measure Duty Cycle
Maxim Integrated