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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/01/04 16:06
Read: times


 
#73480 - RE: 4th solution :)
Responding to: ???'s previous message
Let me try...
This approach was extremely wasteful on ports because I had nothing else to attach to these ports anyway (would be unused otherwise) and wanted to save every cycle I could in software. For example there's no bitwise XOR command in '52 so I applied a hardware one instead of writing the few lines of code that would perform it, I abuse the port bits 2 and 3 as storage and use bits 4-7 to zero the readout values. Still it's almost 30us per count. The microcontroller polls -one- new interrupt meantime but anything more will be lost.

Ok, now bash me for all the newbie mistakes I have made :)






ORG 0003h               ; vector IE0 - INT0
        PUSH    ACC
        PUSH    PSW
        SJMP    EN1     
;(...)

EN1:
        MOV     A,E1P   ; P0 or P2 - pick current values
        JB      P,E1_L1 ; Sanity Check - odd number of bits set
        INC     EB1     ; error counter, diagnostics.
        POP     PSW
        POP     ACC
        RETI            ; False alarm
E1_L1:  
        MOV     PSW,#098h       ; bank 3, rest insignificant
        JB      E1DIR,INC_E1    ; B XOR A' i.e. on P3.0 
;DEC_E1:
        DEC     R3
        CJNE    R3,#0FFh,E1_L2  ; Underflow, DEC16bit
        DEC     R2
        SJMP    E1_L2
INC_E1:
        INC     R3
        CJNE    R3,#00,E1_L2
        INC     R2
E1_L2:  SETB    TAINT1          ; Set Taint Bit
        RL      A               ; 
        RL      A               ; B'=B, A'=A, B=0, A=0
        ORL     A,#03h          ; allow read of A,B
        MOV     E1P,A
        POP     PSW
        POP     ACC
        RETI



List of 25 messages in thread
TopicAuthorDate
Problem in Reading Encoder            01/01/70 00:00      
   RE: Problem in Reading Encoder            01/01/70 00:00      
   RE: Problem in Reading Encoder            01/01/70 00:00      
   RE: Problem in Reading Encoder            01/01/70 00:00      
   RE: Problem in Reading Encoder            01/01/70 00:00      
      RE: Problem in Reading Encoder            01/01/70 00:00      
         RE: Problem in Reading Encoder            01/01/70 00:00      
            RE: Problem in Reading Encoder            01/01/70 00:00      
               RE: Problem in Reading Encoder            01/01/70 00:00      
         RE: Problem in Reading Encoder            01/01/70 00:00      
            RE: Problem in Reading Encoder            01/01/70 00:00      
               RE: Problem in Reading Encoder            01/01/70 00:00      
                  RE: Problem in Reading Encoder            01/01/70 00:00      
         RE: Problem in Reading Encoder            01/01/70 00:00      
            RE: Problem in Reading Encoder            01/01/70 00:00      
               RE: Problem in Reading Encoder            01/01/70 00:00      
                  RE: Problem in Reading Encoder            01/01/70 00:00      
      4th solution :)            01/01/70 00:00      
         RE: 4th solution :)            01/01/70 00:00      
            RE: 4th solution :)            01/01/70 00:00      
               RE: 4th solution :)            01/01/70 00:00      
                  RE: 4th solution :)            01/01/70 00:00      
                  RE: 4th solution :)            01/01/70 00:00      
                     RE: 4th solution :)            01/01/70 00:00      
   RE: Problem in Reading Encoder            01/01/70 00:00      

Back to Subject List