172
Rabbit 3000 Microprocessor User’s Manual
20.3 Operation
20.3.1 Input-Capture Channel
The following steps explain how to set up an Input Capture channel.
1. Configure Timer A8 via TAT8R to provide the desired Input Capture clock.
2. Configure ICTxR to provide the desired start/stop operation and conditions.
3. Configure ICSxR to select the input pins for the start and stop conditions.
4. Reset the counter by writing to ICCSR.
20.3.2 Handling Interrupts
The following steps explain how an interrupt is used.
1. Write the vector to the interrupt service routine to the internal interrupt table
2. Configure the Input Capture Control/Status Register (ICCSR) to select events that will
generate an interrupt.
3. Configure the Input Capture Control Register (ICCR) to select the interrupt priority
(note that interrupts will be enabled once this value is set; this step should be done last).
The following actions occur within the interrupt service routine.
If needed, the current counter value can be read from ICLxR and LCMxR (reading
from ICLxR latches the value of ICLxR, so ICLxR should always be read first)
If the counter is expected to roll over, determine if that is why the interrupt occurred by
reading the status bits in ICCSR and adjusting any software counters accordingly
The interrupt request should be cleared by reading from ICCSR
20.3.3 Example ISR
A sample interrupt handler is shown below.
ic_isr::
push af
ioi ld a, (ICCSR)
; clear the interrupt request and get status
; determine which interrupts have occurred
; if rollover, perform any necessary software counter adjustments here
; read counter values
pop af
ipres
ret