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


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    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."

  2. #2


    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.

  3. #3
    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."

  4. #4
    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