Indexing mixed port pins
In addition to Bruce's nice examples, and in connection with Melanie's explanations, mixed port pins can be driven in a sequence with the code below. The code is for demonstration purposes and quite easy to figure out.
Code:
TRISA = %00000000
TRISB = %00000000
TRISC = %00000000
TRISD = %00000000
TRISE = %00000000
ADCON1 = %00000000
PORTA = 0
PORTB = 0
PORTC = 0
PORTD = 0
PORTE = 0
MYPORT VAR BYTE
LOOP var BYTE
'======Say you have to drive
'these pins in a sequence. They are all mixed.
RelayA VAR PORTA.1
RelayB var PORTA.3
RelayC var PORTB.5
RelayD var PORTC.0
RelayE var PORTD.2
RelayF var PORTD.4
RelayG var PORTE.0
MYPORT=0
Start:
for loop=1 to 7
myport.0[loop]=1 'High
gosub driveport
pause 1000
myport.0[loop]=0 'Low
gosub driveport
next loop
goto start
DrivePort:
RELAYA = myport.1
RELAYB = MYPORT.2
RELAYC = MYPORT.3
RELAYD = MYPORT.4
RELAYE = MYPORT.5
RELAYF = MYPORT.6
RELAYG = MYPORT.7
return
END
Hope it can be some help to some members.
Regards.
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Bookmarks