Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

cycling all the ports for testing

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
 

Latest threads

New Articles From Microcontroller Tips

Back
Top