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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/03/04 15:24
Read: times


 
#61847 - RE: Fastest 16bit INC/DEC
Responding to: ???'s previous message
hi,
well, are you ready to pay some money for quick 16-bit INC/DEC? If yes so I can offer you a way to do such options with two machine cycles. Yes! (=
Instead software optimization you need to use hardware. Take C52 or other chip which has timer2. Keep free pins P1.1 (T2) and P1.2 (T2EX) (better: connect them to 5V via external pull-up resistors).
Now the software:
; fastest INC for 16-bit value located in TL2/TH2:
; it needs to be configured/preset as follow:
	ORL	P1,#00000011b		; count up
	MOV	T2CON,#00001110b	; external event counter
	MOV	T2MOD,#00000001b	; direction control via T2EX
	MOV	RCAP2H,#0x00		; overflow
	MOV	RCAP2L,#0x00		;	  reload value
; start value
	MOV	TH2,#0x12
	MOV	TL2,#0x34

; here all you need to increment TH2/TL2
	CLR	P1.0
	SETB	P1.0
; ----

; fastest DEC for 16-bit value located in TL2/TH2:
; it needs to be configured/preset as follow:
	SETB	P1.0			; T2 pin
	CLR	P1.1			; count down
	MOV	T2CON,#00001110b	; external event counter
	MOV	T2MOD,#00000001b	; direction control via T2EX
	MOV	RCAP2H,#0xFF		; overflow
	MOV	RCAP2L,#0xFF		;	  reload value
; start value
	MOV	TH2,#0x12
	MOV	TL2,#0x34
; ----

; here all you need to decrement TH2/TL2
	CLR	P1.0
	SETB	P1.0
It`s all. Please note that it has not been tested with real hardware; anyway it should work and takes only two machine cycles.
P.S. When you need some more always think with nonstandard way! (=

Good days!


List of 10 messages in thread
TopicAuthorDate
Fastest 16bit INC/DEC            01/01/70 00:00      
   RE: Fastest 16bit INC/DEC            01/01/70 00:00      
      RE: Fastest 16bit INC/DEC            01/01/70 00:00      
         RE: Fastest 16bit INC/DEC            01/01/70 00:00      
            RE: Fastest 16bit INC/DEC            01/01/70 00:00      
               RE: Fastest 16bit INC/DEC            01/01/70 00:00      
                  RE: Fastest 16bit INC/DEC            01/01/70 00:00      
                     RE: Fastest 16bit INC/DEC            01/01/70 00:00      
                        RE: Fastest 16bit INC/DEC            01/01/70 00:00      
   RE: Fastest 16bit INC/DEC            01/01/70 00:00      

Back to Subject List