View Full Version : How to assign this variable?
circuitpro
- 24th January 2011, 23:17
In an application, I have wired the lower 4 bits of PORTF to control the inputs of a multiplexer. Right now I have assigned the variable like this:
MUX VAR PORTF
but really, it's only the lower 4 bits. How can I specify that in my declaration?
mackrackit
- 25th January 2011, 00:32
Look at section 4.10 in the manual.
mister_e
- 25th January 2011, 00:34
There's no specific variable type for that. Usually a Shadow register & some BYTEWise operation solve many issue. Something around ....
MUX VAR PORTF
S VAR BYTE
S = (MUX & $F0) | ValueToWrite
MUX = SWhen dealing with port, you may want to avoid successive bit modification to avoid RMW effect.
To read a PORT it's easier
MUX VAR PORTF
S VAR BYTE
S = MUX & $0F
circuitpro
- 25th January 2011, 00:42
I see how I can isolate the lower 4 bits of a port and READ from them
anyvar = PORTF & $0f
but don't know how that pertains to a WRITE. Is that what you mean?
circuitpro
- 25th January 2011, 00:44
thank you mister_e.
mister_e
- 25th January 2011, 00:48
Sorry I'd edit the post while you replied. Seems you got the idea though ;)
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.