| ??? 05/23/06 13:42 Modified: 05/23/06 13:51 Read: times |
#116921 - Capture registers Responding to: ???'s previous message |
Michael said:
let's say an interrupt has arrived and the value of timer2 has been saved into CT01...
org800Bh (Adress of Timer Interrupt SFR) mov r0,#30h ;30 moved into indirect adressable register0 mov @r0,CT0I ;capture copied to 30h reti The count ot timer2 is captured in CTL0# and CTH0#, with the adresses ACH and CCH (remember, timer2 is a 16bit counter!). So, you need to save these registers in the ISR (interrupt sub routine). You can also set a flag in the ISR to show the main program, that a capture event has occured. Michael said:
but how to go on now?
now i've to move the capture again away from 30h, because if the next capture arrives, 30h will be erased too... The main program knows two captured values: The old and new one. When the main program notices, that a new one has arrived (with the help of flag bit) then it moves the last new one to the address of old one and the actual new one to the address of new one. It also resets the flag. Now the main program builds the difference and displays the result. Afterwards the main program looks again for the flag being set and again does what I wrote above, if so. Kai |



