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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/08/03 15:14
Read: times


 
#50285 - 89c52 as counter for rotary encoder
Please Experts,
I am facing a bit of problem with code.I have a three
byte no, 2 bytes from T2 and a third as highb. The
count increments or decrements as desired, but does not goto highb. while dec, the no. is not converting
to sign mag. as planned. 7218 feeds 8 common anode displays.here is the code-

.equ topb, 07h
.equ highb, 06h
.equ medb, 05h
.equ lowb, 04h
.equ resb3, 0ch
.equ resb2, 0dh
.equ resb1, 0eh
.equ resb0, 0fh
.equ count, 03h
.equ bit3, 0e3h
.equ bit7, 0e7h
.equ D0, 17h
.equ D1, 16h
.equ D2, 15h
.equ D3, 14h
.equ D4, 13h
.equ D5, 12h
.equ D6, 11h
.equ D7, 10h
.equ signbit, 21h

.org 0000h
sjmp start

.org 0003h ; intr0 will be trig. by power low
; save count to serial eprom
reti

.org 000bh ; acall keyscan will come here
reti ; 16 times per sec

.org 0013h ; intr1
; ????
reti

start: mov sp, #7fh
mov 0c9h, #01h ; DCEN=1 for u/d counting
mov 0c8h, #0eh ; T2CON-c/t2,Tr2,EXEN2-all 1
mov tmod, #01 ; timer0 in mode1
setb TR0 ; run timer0
mov ie, #0a5h ; en all intrs.ET2=1
mov lowb, #00h ; initialise no.
mov medb, #00h
mov highb, #00h
mov topb, #00h

wait: mov lowb, 0cch ; read store-TL2,TH2
mov medb, 0cdh
jb TF2, check ; check for overflow/underflow
go_on: acall binbcd ; these routines work
acall unpack
acall show
sjmp wait

check: clr TF2
cpl p3.7 ; blink to show activity
mov a, medb ; check for overflow/underflow
jb acc.7, negative; if underflo,no.is NEGATIVE
inc highb ; if overflow =inc highb
sjmp go_on

negative: dec highb ; if underflow =dec highb
mov a, highb ; check highb for underflo or
cjne a,#0ffh, go_on ; overflow
setb signbit ; underflow = convert from 2's comp
mov a, lowb ; to sign/ magnitude
cpl a
inc a
mov lowb, a
mov a, medb
cpl a
addc a, #00h
mov medb, a
mov a, highb
cpl a
addc a, #00h
mov highb, a
cpl p3.6 ; blink to show activity
sjmp go_on
the program goes to sign mag converter as shown by
blinking leds, but no conversion.
Please help.
Monder


List of 5 messages in thread
TopicAuthorDate
89c52 as counter for rotary encoder            01/01/70 00:00      
   RE: 89c52 as counter for rotary encoder            01/01/70 00:00      
      RE: 89c52 as counter for rotary encoder            01/01/70 00:00      
         RE: 89c52 as counter for rotary encoder            01/01/70 00:00      
   RE: 89c52 as counter for rotary encoder            01/01/70 00:00      

Back to Subject List