PortA , PortB


Closed Thread
Results 1 to 18 of 18

Thread: PortA , PortB

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Edit: nevermind... too late
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi DiGGi,

    What has been said to you in the last few replies has been correct. If you want to get real basic here you can read porta like this:

    Peek PortA, B0 Read PortA and put results in Variable B0
    If Bit0 = 1 then task 1 'Reads PortA pin 0, if 1 then goto task 1
    If Bit1 = 1 then task 2 'Reads PortA pin 1, if 1 then goto task 2
    If Bit2 = 0 then task 3 'Reads PortA pin 2, if 1 then goto task 3

    This is really the basic way I started. You can do the BITWISE operations like Paul was showing you also. Whatever you are comfortable with.

    Variable B0 now represents a reading of the pins on PortA. you can now look at each pin individually.

    Do you have a copy of the PBC manual? If not goto www.melabs.com and download a copy. There is a 2 page explanation on PEEK and a small explanation of POKE.

    BobK

  3. #3
    DiGGi's Avatar
    DiGGi Guest


    Did you find this post helpful? Yes | No

    Default

    thx

    i read that manual allready. And found the Bitx command. But i haven't time to test it yet. I'll tiy it later. And let you know if it works or not.

    Dirk

  4. #4
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by BobK
    ...If you want to get real basic here you can read porta like this:

    Peek PortA, B0 Read PortA and put results in Variable B0
    If Bit0 = 1 then task 1 'Reads PortA pin 0, if 1 then goto task 1
    If Bit1 = 1 then task 2 'Reads PortA pin 1, if 1 then goto task 2
    If Bit2 = 0 then task 3 'Reads PortA pin 2, if 1 then goto task 3

    ...
    Bob,
    Nice addition - your approach is certainly easier and faster to write. Utilizing the fact that Bit0, Bit1, etc. are predifeined as the bits of B0 is the better approach for straightforward (i.e., normal) operations. Thanks for adding - now Dirk has lots of options. If it were me, I would skip the bitwise stuff and use what Bob has above.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  5. #5
    DiGGi's Avatar
    DiGGi Guest


    Did you find this post helpful? Yes | No

    Default workin

    hi,

    my prog i working by using Peek and Bit0, Bit1 ...

    Thanks for your help!

    Diggi

Similar Threads

  1. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 19:52
  2. 16F628A - Stops if release power switch.
    By dene12 in forum General
    Replies: 16
    Last Post: - 14th February 2009, 07:57
  3. shifting problem
    By helmut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 31st August 2007, 06:11
  4. Output PIC module
    By freelancebee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th September 2005, 20:10
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 5th May 2005, 23:29

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