cycling all the ports for testing

Status
Not open for further replies.

MrDEB

Well-Known Member
been along time but trying to recall using swordfish basic cycling all the ports on
tried
for x = 0 to 7
portc.(x) = 1
but it won't compile
Have used similar but can't locate.
I tried
TRUSC = 1
BUT DOSENT SEEM TO WORK
an easy method to test all the ports
 
Without complete code, hard to say. First, is x declared as a byte/integer/word, or is it a real value. Real variables won't work as index counters.
Second, have you declared portc as an OUTPUT. Not sure if that compiler auto-sets it, or you have to declare it.
Try the code without the "()", that is portc.x = 1
Another syntax could be portc.Bits(x)=1

If those don't work, try the HIGH(portc.x) or HIGH (portc.Bits(x))

Good luck
 
Last edited:
Code:
dim x as byte

// make all portc outputs
TRISC = 0

PORTC = 0
for x = 0 to 7
    PORTC.bits(x) = 1
next
will set them sequentially to '1' leaving the previous one high.

If you only want one at a time use
Code:
    PORTC = 1 << x
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…