Sure, this is way better, but still not exactly what I want. Since it utilizes loop and constant subroutine calls. I want to have defined the array in the beginning of the code, and access it as needed.
Sure, this is way better, but still not exactly what I want. Since it utilizes loop and constant subroutine calls. I want to have defined the array in the beginning of the code, and access it as needed.
So are you looking to . . .
AC5 var PORTC.5
AC4 var PORTC.4
AC3 var PORTB.3
AC2 var PORTB.1
AC1 var PORTB.5
AC = %00010101
and then have the listed ports go high according to the declaration above?
If SO try AC = ~~%00010101
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Perhaps I misunderstood your inquiry; it is difficult with so little explanation...
Perhaps you mean:
'DEFINE ARRAY
AC var bit[7]
'ASSIGN ALIAS
SYMBOL AC[5] = PORTC.5
SYMBOL AC[4] = PORTC.4
.
SYMBOL AC[1] = PORTB.5
'LOOP THRU VALUES
FOR LOOP = 5 to 1 STEP -1
AC[LOOP] = Some assigned bit value
Next LOOP
Of course, the bit array may be expanded to include as many elements as you need and you may SYMBOL each element to any port or single bit variable you like to access them through a loop - which need not begin at the first element nor continue through the last.
You mention ARRAYWRITE, but if the answer was there you would certainly have seen that in the manual, yes?
Yes, I want to put different port names into array, so when needed, I can read or address them sequentally.
So what I want to do, I'll write a code in some imaginary basic, a bit short code that will do a running led light:
DIM LEDS(3) 'define array with 3 entries
LET LEDS(1)=PORTA.2
LET LEDS(2)=PORTB.3
LET LEDS(3)=PORTC.1 'enter data into array
FOR A=1 TO 3
HIGH LEDS(A)' make pin high
pause 500 ' wait some time
LOW LEDS(A) 'make pin low
NEXT A
So I wrote it in this way, but it does not works:
Code:AC VAR BIT[5] AR VAR BIT[7] AC[5]=PORTC.5 AC[4]=PORTC.4 AC[3]=PORTB.3 AC[2]=PORTB.1 AC[1]=PORTB.5 AR[1]=PORTB.6 AR[2]=PORTC.7 AR[3]=PORTB.2 AR[4]=PORTB.0 AR[5]=PORTB.4 AR[6]=PORTB.7 AR[7]=PORTC.6 'make all leds connected to ports on. low ac[1] low ac[2] low ac[3] low ac[4] low ac[5] high ar[1] high ar[2] high ar[3] high ar[4] high ar[5] high ar[6] high ar[7] 'but it does not works 'but it works with code below low PORTB.3 HIGH PORTC.7 end
Hi
It doesn't work that way, it won't work that way and it can't work that way.
When you do AR VAR BIT[7] you are reserving space in RAM for 7 consecutive bits. You can't them simultanously mirror each bit in RAM to a ANOTHER adress (which the ports are) - it won't and can't work.
Aliases must all point to the SAME location, likeIn the above case AR[2] and myBit are the one and same memory location, ie. two names for the same location, you can't do it the other way around. Ie you can't have one name for two locations which is basically what you're trying to do.Code:AR VAR BIT[7] myBit VAR AR[2]
When you doYou are reading the state of PORTB.6 and store the result of that in AR[1].Code:AR VAR BIT[7] AR[1]=PORTB.6
The only way I know of that is similar to what you're trying is to use a port offsets and a lookup table.
/Henrik.
Bookmarks