the isr counts edges , an indented re has 4 edges per indent . you would expect to increment counter by 4
don't forget the display routine and the isr are asynchronous .
if you are trying to count indents then
Code:cnt_f var bit Main: PAUSE 10 IF cnt_f THEN gosub get_cnt: DEBUG DEC counter,13,10 ENDIF GOTO Main enc_isr: ev=ev<<2 ;shift last reading into position ev=ev|((portb&48)>>4) ;read enc pins 4,5 mask off others then combine this reading with last reading LOOKUP (ev&15),[0,255, 1, 0, 1, 0, 0, 255, 255, 0, 0, 1, 0, 1, 255, 0],tmp;lookup the decision matrix if tmp then ; decide to inc , dec or ignore if tmp.7 then cnt=cnt-1 cnt_f=1 else cnt=cnt+1 cnt_f=1 endif endif intcon.0=0 ; clean up and exit @ INT_RETURN get_cnt : intcon.3=0 counter=cnt/4 cnt_f=0 intcon.3=1 return




Bookmarks