Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/19/04 08:20
Read: times


 
#76155 - RE: debouncing code using vertical counters
Responding to: ???'s previous message
Actually: I managed to make the code even a bit leaner: now it only needs 12 instructions, as opposed to the PIC code's 13 :-P


			$pagewidth(132)
			$nopaging
			$mod51
			$debug(vercount.abs)
			$nolist
			$list

			dseg

CtrA:			ds 1
CtrB:			ds 1
Dbnce:			ds 1

			cseg

			org  	000h
BEGIN:			ljmp 	100H

			org  	100H

			mov 	CtrA,#0
			mov 	CtrB,#0
			mov	Dbnce,#1
			mov	a,#1

Start:			mov 	a,CtrB		;increment the vertical counter
			xrl     CtrA,a		;A+:= A XOR B
			xrl     CtrB,#0ffh	;B+:=  NOT (B)

			mov 	a,p1		;Has the input data changed ?
			xrl     a,Dbnce		;a 1 in the accu means difference

			anl 	CtrA,a		;clear counter on no difference
			anl	CtrB,a

			cpl	a		;(a 0 in the accu means difference)
			orl	a,CtrA
			orl	a,CtrB		;a 0 in the accu means difference
						;AND timer overflowed => Change Dbnce
			cpl	a		;(a 1 in the accu means change Dbnce)
			xrl	Dbnce,a		;Effect the changes

			jmp 	start

			end



And if I may be so bold, as a comment on your original code, you are sampling p1 TWICE in the same code. This is not advisable, as the value may change between the samples.


List of 12 messages in thread
TopicAuthorDate
debouncing code using vertical counters            01/01/70 00:00      
   RE: debouncing code using vertical count            01/01/70 00:00      
      RE: debouncing code using vertical count            01/01/70 00:00      
   RE: debouncing code using vertical counters            01/01/70 00:00      
      RE: debouncing code using vertical count            01/01/70 00:00      
   RE: debouncing code using vertical counters            01/01/70 00:00      
      RE: debouncing code using vertical count            01/01/70 00:00      
         RE: debouncing code using vertical count            01/01/70 00:00      
   RE: debouncing code using vertical counters            01/01/70 00:00      
      RE: debouncing code using vertical count            01/01/70 00:00      
      RE: debouncing code using vertical counters            01/01/70 00:00      
   RE: debouncing code using vertical counters            01/01/70 00:00      

Back to Subject List