How can I use for next like PORTB.MYVARIABLE ???


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Jul 2005
    Posts
    65


    Did you find this post helpful? Yes | No

    Lightbulb

    tou can make it that way:

    Code:


    TRISB = 0
    INTCON = 0

    X VAR BYTE

    FOR X = 0 TO 7
    PORTB.0[X] = 1
    PAUSE 500
    PORTB.0[X] = 0
    PAUSE 500
    NEXT X

    END
    Last edited by crematory; - 2nd September 2005 at 17:35.

  2. #2
    Join Date
    Oct 2005
    Posts
    35


    Did you find this post helpful? Yes | No

    Question Port Pin Steering Variable

    Hello,

    Following the thread above, the code below does not work unless the value of k is made a constant as in: SOUND PORTC.5,[115,120,113,118]. I have never been able to use a variable to steer outputs to a specific pin. Any ideas?


    pic16f8783

    'sound on pin k port c

    TRISC= %00000000
    k var byte


    start:
    k=5
    SOUND PORTC.0[k],[115,120,113,118]
    GOTO START



    "I don't know, Marge. Trying is the first step towards failure."

  3. #3


    Did you find this post helpful? Yes | No

    Default

    You should be able to use:

    sound x,[115,120,113,118]

    Where is x is between 0-15 with PORTA.0 being 0 and PORTC.7 being 15.

  4. #4
    Join Date
    Oct 2005
    Posts
    35


    Did you find this post helpful? Yes | No

    Thumbs up

    WOOHOO!

    Thanks, yes that works, but I have never seen it written that ports A and C are linked and addressed this way. So then, PortC.5 is 13? I never would have thought of this. Is that only for the sound command? What about the addressing for port B.







    "Asleep at the switch? I wasn't asleep, I was drunk."

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    It's all in the PBP Manual, section 4.11 Pins...

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts