PDA

View Full Version : Variable sharing. Not sure how to describe this.



jmgelba
- 12th April 2011, 04:31
Would this be feasible?

IOUT = POT.lowbyte

IOUT must only be changed by push button increments and decrements. If they are made equal any change made to POT.lowbyte would change IOUT. How do I get this to work one way only?

mackrackit
- 13th April 2011, 11:37
Not clear to me what you want.
You say

IOUT must only be changed by push button increments and decrements.

and/or

any change made to POT.lowbyte would change IOUT

???

How do I get this to work one way only?

Which way do you want??

jmgelba
- 13th April 2011, 18:00
IOUT gets changed with a pushbutton input, either increased or decreased. I need to display that value on an LCD and also send that value out to a digital pot.
I need to make sure that IOUT is only changed with the pressing of the pushbuttons, and I also need to make sure POT.lowbyte is always the same as IOUT.

POT is 16bit and I wanted to know if I could load the 8 bit IOUT into POT.lowbyte.

mackrackit
- 14th April 2011, 11:54
Maybe something like this


POT_ROUTINE:
IF BUTT1 =1 THEN IOUT = 1
IF BUTT2 = 1 THEN IOUT = 0
POT = IOUT
RETURN

Bruce
- 14th April 2011, 15:29
You're going to have issues with a variable named POT since this is a PBP command, and reserved, but if you just want to alias the low byte in a word var, then use something like this;

ADPOT VAR WORD
IOUT VAR ADPOT.BYTE0 ' this is just an alias to the low byte in ADPOT.

Any value you place in IOUT will be placed in ADPOT.LOWBYTE. And whatever value is in ADPOT.LOWBYTE will also be in IOUT since it's the same RAM address as the low byte in ADPOT . It's in the manual...;o)