Quote Originally Posted by isaac
Hi Bruce / sayzer....
...using a word variable to control the 16bits below
How to i go about this? Is it possible ?...

I do not think you can drive the ports or port pins directly by using alias on them via a the bits of a WORD or BYTE variable.


For example,

MYPORT VAR WORD

PORTA.1 VAR MYPORT.0 is an incorrect arrangement.

MYPORT.0 VAR PORTA.1 is also incorrect.

PORTB VAR MYPORT.HighByte incorrect.

PORTA VAR MYPORT incorrect


But,
PORTB = MYPORT

or

PORTB = MYPORT.HighByte or PORTB = MYPORT.LowByte can be ok!



But anyway, in addition to the link that Bruce posted, here I posted an example with the port pins you listed.

See if it is what you needed.

Code:
'Assuming you have the ports set up.

Loop    VAR BYTE
MYPORT  VAR WORD
MYPORT = 0
GOSUB DriveMeCrazy  'Pull all pins low.


Start:
        
        FOR LOOP = 0 TO 15

            MYPORT.0[LOOP] = 1          'HIGH
            GOSUB DriveMeCrazy

            PAUSE 1000                  'Give it a pause as an example.
            
            MYPORT.0[LOOP] = 0          'LOW
            GOSUB DriveMeCrazy
            
        NEXT LOOP
        
        
        GOTO START


    
DriveMeCrazy:

    PORTB.7 = MYPORT.15
    PORTB.6 = MYPORT.14
    PORTB.5 = MYPORT.13
    PORTB.4 = MYPORT.12
    PORTB.3 = MYPORT.11
    PORTB.2 = MYPORT.10
    PORTB.1 = MYPORT.9
    PORTB.0 = MYPORT.8  'From here to above, "PORTB = MYPORT.HighByte" may also be ok.
    PORTA.0 = MYPORT.7  
    PORTA.1 = MYPORT.6
    PORTA.2 = MYPORT.5
    PORTA.3 = MYPORT.4
    PORTD.0 = MYPORT.3
    PORTD.1 = MYPORT.2
    PORTD.2 = MYPORT.1
    PORTD.3 = MYPORT.0
    
    RETURN