Is it allowed to change pin reference within a subroutine?


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Jun 2016
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Is it allowed to change pin reference within a subroutine?

    pic 18F2620

    Owin portB.5 ,0,[strDta\9] (works!)

    Owin 5 ,0,[strDta\9] (works!)

    mypin var byte
    mypin=5
    Owin mypin ,0,[strDta\9] (doesn't work!)


    Not very elegant but this way it works!

    Code:
        One_W1  var PortB.5
        One_W2  var PortB.6
        One_W3  var PortB.7
    
        if CIndex = 1 Then 
        owout One_W1,1,[$CC,$44]     
        owout One_W1,1,[$CC,$BE]     
        owin One_W1,0,[STR Dta\9]     
        endif
        
        if CIndex = 2 Then 
        owout One_W2,1,[$CC,$44]     
        owout One_W2,1,[$CC,$BE]     
        owin One_W2,0,[STR Dta\9]    
        endif
        
        if CIndex = 3 Then 
        owout One_W3,1,[$CC,$44]     
        owout One_W3,1,[$CC,$BE]     
        owin One_W3,0,[STR Dta\9]     
        endif
    Alberto

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,651


    Did you find this post helpful? Yes | No

    Default Re: Is it allowed to change pin reference within a subroutine?

    well that should have worked. i don't have one of those chips handy to try any thing.
    maybe the manual is incorrect and pin must be a constant not a var.
    but it says everywhere (or a variable that contains a number 0 15 ) not just that command


    you can always stick them all on the one wire and use the
    MATCH ROM [55h] command rather than skip rom [CCh]
    Warning I'm not a teacher

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,651


    Did you find this post helpful? Yes | No

    Default Re: Is it allowed to change pin reference within a subroutine?

    if CIndex = 1 Then
    owout One_W1,1,[$CC,$44]
    you realise of course the ow device takes 750mS or so to complete the conversion
    before the read scratch pad can occur or you can poll the busy state


    owout One_W1,1,[$CC,$BE]
    owin One_W1,0,[STR Dta\9]
    Warning I'm not a teacher

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Is it allowed to change pin reference within a subroutine?

    In following this thread I have to ask, Why are you not using 1 wire? Why are all of the devices on separate pins? It would make your code so much easier.
    Dave Purola,
    N8NTA
    EN82fn

Similar Threads

  1. Replies: 8
    Last Post: - 21st March 2015, 17:21
  2. 10F222 Wake on pin change
    By AvionicsMaster1 in forum PBP3
    Replies: 11
    Last Post: - 9th January 2014, 19:14
  3. Reference a port pin from a variable
    By JimAvanti in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th February 2012, 20:18
  4. Interrupt-on-Change-pin!
    By PICante in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 11th February 2009, 20:22
  5. HELP !!! How change the voltage of a pin ????
    By stormdacta in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 21st August 2007, 20:55

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