EasyManua.ls Logo

Maxim Integrated MAX32660 - Page 121

Maxim Integrated MAX32660
195 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
MAX32660 User Guide
Maxim Integrated Page 121 of 195
10.11 Capture/Compare Mode (111b)
In Capture/Compare mode, the timer starts counting after the first external timer input transition occurs. The transition, a
rising edge or falling edge on the input signal, is set using the TMRn_CN.tpol bit.
Each subsequent transition, after the first transition of the timer input signal, captures the TMRn_CNT value, writing it to
the TMRn_PWM register (capture event). When a capture event occurs, a timer interrupt is generated, the TMRn_CNT
value is reset to 0x0000 0001, and the timer resumes counting.
If no capture event occurs, the timer counts up to the TMRn_CMP value. At the end of the cycle where the TMRn_CNT
equals the TMRn_CMP value, a timer interrupt is generated, the TMRn_CNT value is reset to 0x0000 0001, and the timer
resumes counting.
10.11.1 Timer Period
The timer period ends when the selected transition occurs on the timer pin, or on the clock cycle following
TMRn_CNT = TMRn_CMP.
The timer peripheral automatically performs the following actions at the end of the timer period:
If the end of the timer period was caused by a transition on the timer pin:
1. The value in TMRn_CNT is copied to TMRn_PWM.
2. TMRn_CNT is reset to 0x0000 0001. The timer remains enabled and continues incrementing.
3. The timer interrupt bit, TMRn_INT.irq, is set. A Timer IRQ is generated, if enabled.
4. If the end of the timer period was caused by a transition on the timer pin:
a. TMRn_CNT is reset to 0x0000 0001.
b. The timer remains enabled and continues incrementing.
5. The timer interrupt bit TMRn_INT.irq will be set. An interrupt is generated, if enabled.
10.11.2 Configuration
Configure the timer for Capture/Compare mode by doing the following:
1. Set TMRn_CN.ten = 0 to disable the timer.
2. Set TMRn_CN.tmode to 111b to select Capture/Compare mode.
3. Set TMRn_CN.pres3:TMRn_CN.pres to set the prescaler that determines the timer frequency.
4. Configure the timer pin:
a. Configure the pin as a timer input and configure the electrical characteristics as needed.
b. Set TMRn_CN.tpol to select the positive edge (TMRn_CN.tpol = 0) or negative edge (TMRn_CN.tpol = 0)
transition causes the capture event.
5. If using the timer interrupt, enable the interrupt and set the interrupt priority.
6. Write an initial value to TMRn_CNT, if desired. This effects only the first period; subsequent timer periods always
reset TMRn_CNT= 0x0000 0001.
7. Set TMRn_CN.ten to 1 to enable the timer. Counting starts after the fir
interrupt is generated by the first transition of the input signal.
In Capture/Compare mode, the elapsed time from the timer start to the capture event is calculated using the following
equation:
Equation 10-9: Capture Mode Elapsed Time

 


󰇛

󰇜

Table of Contents

Related product manuals