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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/09/03 22:39
Read: times


 
#50373 - RE: 3 bit binary counter
Responding to: ???'s previous message
Yes it is very wasy to do this. It is necessary to code it properly so that you do not conflict the alternate port bits of the Port 0 with the three that are being used as the 3 bit counter. It is best for this project to assign the three bits of port 0 so that they match the bit order of the counter bits. In a 3 bit counter you have a low, middle and a high bit. The low, middle and high will be easiest handled if you were to assign them in that order to port bit numbers n, n+1 and n+2 in that order.

Let us make a presumption that following this idea you assign the three bits to Port 0 on bits 3,4 & 5. Bit 3 to be the low bit of the counter and bit 5 to be the high bit of the counter. Here is sample code you can put into your interrupt routine to increment these three bits on the port.
    ...
    push   b
    mov    a, P0        ;get the present port 0 value
    add    a, #008H     ;add in a 1 at the low bit pos
    anl    a, #038h     ;mask the count to just 3 bits
    mov    b, a         ;save copy of count
    mov    a, P0        ;make copy of alternate bits
    anl    a, #0C7H
    orl    a, b         ;merge new count into a alternates
    mov    P0, a        ;set port 0 to new bits
    pop    b 
    ...    




Michael Karas


List of 8 messages in thread
TopicAuthorDate
3 bit binary counter            01/01/70 00:00      
   RE: 3 bit binary counter            01/01/70 00:00      
      RE: 3 bit binary counter            01/01/70 00:00      
   RE: 3 bit binary counter            01/01/70 00:00      
      RE: 3 bit binary counter            01/01/70 00:00      
      RE: 3 bit binary counter            01/01/70 00:00      
   RE: what is Aspire?            01/01/70 00:00      
      RE: what is Aspire?            01/01/70 00:00      

Back to Subject List