Truncated match.
PICList
Thread
'Using a variable to clear a bit => Shadow'
1999\05\10@091953
by
paulb
Mik Kim wrote:
> Also, don't use bit operations on PORT. Instead of bcf, you might do
> movf PORTB, W
> movwf tempB
> bcf tempB, 0 ;must use literal as bit position
> movf tempB, W
> movwf PORTB
You've got the wrong idea on this one, I'm afraid. Your "solution" is
no better than the simple "bcf PORTB,0".
The danger here is that the port may read as something other than what
you write to the output register, for various reasons. So, you *don't*
read it at all (unless you want to read an input). Your "tempB" above
is called a "shadow register", initialized to begin with and again with
what you want PORTB to be at any given time. I.e.:
start
movlw initial_value ; constant
movwf tempB ; into shadow
movwf PORTB ; and "real"
; somewhere amidst the code
...
bcf tempB, 0 ; adjust the shadow; bit 0 cleared here
movf tempB, W ; and transfer
movwf PORTB ; to "real"
--
Cheers,
Paul B.
More... (looser matching)
- Last day of these posts
- In 1999
, 2000 only
- Today
- New search...