Hello Nandakumar,
Correct me if I am wrong, but you seem to have done little assembly coding before - there are numerous fundamental errors in your program structure and detail that suggest this. You would need to gain understanding of basic structure, and particularly the way interrupt processing works within the MCU, before trying to utilise the input capture processing. If you have not already done so, I would suggest you examine simple sample programs supplied with CW, such as LED flashing routines, etc. to see how an assembly program should be structured.
The following is a very basic outline of an absolute assembly program framework, with one ISR shown.
; Specify basic include files -
; Register names and definitions for MCU type, etc
INCLUDE "DERIVATIVE.INC"
********************************************
; Allocate RAM variables:
ORG RAM ; Start of RAM block
VAR1: DS 1 ; Byte variable allocated
VAR2: DS 2 ; Word variable allocated
********************************************
ORG ROMSTART ; Start location for code
START: ; Beginning of initialisation code
; Initialise stack pointer
; Initialise CONFIG, I/O, timer, etc.
CLI ; Enable interrupts
MAINLOOP:
; Reset COP timer
; Main loop processing
JMP MAINLOOP ; Loop always
********************************************
; Sub-routines called by main loop, etc.
********************************************
; Interrupt service routines (ISRs)
TMPC0_ISR: ; Timer Ch 0 interrupt service
PSHH ; Usually necessary
; ISR processing
; Clear interrupt flag(s)
PULH ; Restore previous value
RTI ; Exit from ISR
********************************************
; Setup interrupt vectors: ORG $FFF6 ; Timer Ch0 vector
DC.W TMPC0_ISR
; Other vectors
ORG $FFFE ; Reset vector
DC.W START
See if you can fit your code into this basic framework. To answer your specific question - you need to set up a counter that is incremented each time you enter the ISR. Alternatively, you might utilise a single bit flag that is cleared within the main loop, and set the next time the ISR executes. The ISR would first test the flag to see if it is already set, or not. Incidently, never use a STOP instruction unless you have set up a means of waking the MCU. I would not use it within an ISR.
Regards,
Mac
Message Edited by bigmac on 2006-09-18 12:24 AM