![](http://datasheet.mmic.net.cn/30000/MC68307CFG16_datasheet_2368698/MC68307CFG16_146.png)
Dual Timer Module
6-10
MC68307 USER’S MANUAL
MOTOROLA
Note that the interrupt service routine does not check which event bit is set as the cause of
the interrupt. A more robust system would do this, and indeed a timer channel could have
both interrupt sources enabled.
* Enable timer 2 input pin in port B control register
OR.W
#$0080,PBCNT(A5)
; TIN2 pin dedicated
* Capture on TIN2 +ve edge using system clock as clock source
* Get captured timer word in register D5
* Counter free-running
* Disable interrupt for reference
* Enable interrupt on capture on +ve TIN2 edge
* Prescaler: divide by 1
MOVE.W #RST+ICLK01+CE01,TMR2(A5); value=$0043
....
INT_T2:ANDI.B #CAP,TER2(A5)
; clear CAP event bit
MOVE.W TCR2(A5),D5
; Process the interrupt
RTE
6.4.4 Watchdog Usage Example
The first example shows how to disable the watchdog after system reset if it is not required.
Note that if a RESET instruction is executed, the timer module is reset, and so the watchdog
is enabled again.
* Disable watchdog timer forever
MOVE.W #$0000,WRR(A5)
; clear WRR EN bit
The second example shows setting the watchdog timer to timeout every 10mS unless it is
periodically reset by software. The watchdog is clocked by the system clock divided by 16,
and there is a fixed 8-bit prescaler, so the resulting clock count value increments every
0.24576mS for a 16.67 MHz system clock.
The watchdog reference register is programmed to match on a compare value of 40, to give
an approximate 10mS timeout. Note that the least significant bit of the counter is not com-
pared and the corresponding reference register bit must be 1 to enable the watchdog.
* Program watchdog for 10mS timeout
MOVE.W #$0029,WRR(A5)
; enable = 1, timeout = 40
....
MOVE.W D0,WCR
; tickle watchdog counter
Note that it does not matter what data value is written to the WCR to keep it from timing out.
The example uses D0 as the source, since it results in the fastest executing instruction. (The
CLR instruction on a 68000 reads the location before clearing it.)