How about:Originally Posted by peterdeco1
TRISA=%11110001
if porta.4 = 0 then porta.1=1
if porta.5 = 0 then porta.2=1
if porta.6 = 0 then porta.3=1
or even shorter:
TRISA=%11110001
porta.1= ~porta.4
porta.2= ~porta.5
porta.3= ~porta.6
How about:Originally Posted by peterdeco1
TRISA=%11110001
if porta.4 = 0 then porta.1=1
if porta.5 = 0 then porta.2=1
if porta.6 = 0 then porta.3=1
or even shorter:
TRISA=%11110001
porta.1= ~porta.4
porta.2= ~porta.5
porta.3= ~porta.6
regards
Ralph
_______________________________________________
There are only 10 types of people:
Those who understand binary, and those who don't ...
_______________________________________________
Gday Ralph
The problem Peter is trying to overcome is explained in the bottom para of his initial post, and is the same one i hit.
When doing the same function multiple times, it is more efficient to build a subroutine. However, if one of the "variables" in that subroutine is a port, yr stuffed.
By referencing the reqd port the way described, you can set a std integer variable before entering the subroutine, thus bypassing the problem.
However, it doesnt always work ( according to Melanie ). But it does work for simple on/off type stuff.
Andrew
Andrew, that's absolutely right,Originally Posted by anj
but if you don't let us know what the SUB requires as input and what it
deliveres as output,
we cant offer much help.
regards
Ralph
_______________________________________________
There are only 10 types of people:
Those who understand binary, and those who don't ...
_______________________________________________
Gday Ralph
As per Peters original request
Having been down the track he went down, i understood his post as meaning he currently had a routine that he would have to copy three times unless he could pass by reference, a port as a variable ( which you cant do ).If I copy the routine and have 3 of them for a.1, a.2, a.3 I run out of code space.
As such all other inputs/outputs were irrelevant at the time, just how to ref a port.
If he has other probs with his routines, i dont know, i merely advised of a different method i have used to get around referencing ports in subroutines.
Andrew
Bookmarks