port handle


Closed Thread
Results 1 to 7 of 7

Thread: port handle

  1. #1
    Join Date
    Nov 2007
    Location
    sri lanka
    Posts
    24

    Default port handle

    dear
    i want to write something like this
    go_sub1:
    go_sub2:
    go_sub3:

    go_sub1:
    high porta.0
    goto main

    go_sub2:
    high portb.1
    goto main

    go_sub3:
    high portb.2
    goto main

    my pboblem is program goto first go_sub0: then high portb.0 then program goto go_sub1: then high portb.1 but low portb.0.
    please write me example for this i want to do portb.0 stay on high with second step.
    thank you

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: port handle

    go_sub1:
    high porta.0
    goto main
    But you are using PORTA in your code.
    Post your actual code and we will see what can be done.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Nov 2007
    Location
    sri lanka
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: port handle

    dear sir
    i have some mistake
    iwant to handle portA

    go_sub1:
    go_sub2:
    go_sub3:

    go_sub1:
    high porta.0
    goto main

    go_sub2:
    high porta.1
    goto main

    go_sub3:
    high porta.2
    goto main

  4. #4
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default Re: port handle

    When performing bit write operations on PIC16s, this is something you have to watch out for.

    Reading the PORTx register reads the status of the pins, whereas writing to it will write to the PORT latch. All write operations are read-modify-write operations. Therefore, a write to a port implies that the port pins are read, this value is modified and then written to the PORT data latch.
    Why pay for overpriced toys when you can have
    professional grade tools for FREE!!!

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: port handle

    Many chips have analog funtions on PORTA, did you turn the ADC off?
    http://www.picbasic.co.uk/forum/showthread.php?t=561
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Nov 2007
    Location
    sri lanka
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: port handle

    use 16f877a
    Adc off
    can u help me.with example
    thank you

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: port handle

    Did you get the main program structure working?

    If it still acts funny, it's probably because the GOTO MAIN in the subroutines always goes back to the top of the program. Only SUB1 will get executed.

    What about something like this?

    Code:
    GOTO MAIN              ' Skip over subroutines
    
    Sub1:
    high portB.0
    RETURN
    
    Sub2:
    high portB.1
    RETURN
    
    Sub3:
    high portB.2
    RETURN
    
    MAIN:
      GOSUB Sub1
      GOSUB Sub2
      GOSUB Sub3
    END
    I would recommend starting with Port B for your testing. You can use Port A later once you have a simple program working.

    Robert

Similar Threads

  1. 18F2520 - problem configuring fuse for port B as digital port.
    By hwhisperer in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th October 2010, 12:41
  2. PIC16F887 cant handle HIGH and LOW?
    By xobx in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 16th October 2007, 05:46
  3. How to tell which PICs can handle 16 bit variables?
    By MikeTamu in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st August 2005, 09:44
  4. How many serial ports can 1 PIC handle?
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd March 2005, 05:34
  5. Duplicating port input to port output
    By lwindridge in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th April 2004, 22:43

Members who have read this thread : 1

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