multiple ports ===> one symbol?


Closed Thread
Results 1 to 5 of 5

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    O.k. let's make it simple
    when you define a byte(8 bits) in binary like this
    a=%00000011

    it set the bit 0 and 1 to 1. It's the same as a=3 in decimal

    bitwise operation
    working with bits in a byte or ar word sized variable...

    a=%00000011

    PORTA=%11111100

    so if you do a bitwise OR ( or |) operation with PORTA and a

    PORTA | a

    the result will be %11111111

    in your case you don't want to affect the other pins. If you want to set A.0 and A.1 of PORTA
    PORTA=PORTA | %00000011
    OR
    PORTA=PORTA | 3

    case you want to clear A.0 and A.1 you must use btwise AND
    PORTA=PORTA & &11111100 'in binary
    OR
    PORTA=PORTA & $FC 'in Hexadecimeal
    OR
    PORTA=PORTA & 252 ' in decimal

    Do you know how logical operation works? If not, the fast way to learn is to run 'calc' in windows. Select the scientic view and Voila... you'll be able to test your bitwise operations. OR see this link

    Yeah Ralph... i know (inside joke here)

    you'll find all those bitwise operator at the begining of your PBP manual.

    You can also use symbol for that... i prefer use VAR... i'm coming old and i have my old method.

    Code:
    TRISA=0 'set PORTA as output to all pins
    FLTS VAR PORTA.0
    RLTS VAR PORTA.1
    
    FLTS=1 ' set PORTA.0 to 1
    RLTS=1 ' set PORTA.1 to 1
    Steve

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

  2. #2
    PICMAN's Avatar
    PICMAN Guest


    Did you find this post helpful? Yes | No

    Default

    ok now i understand that perfectly, thnx man,

    theres no need to trisa is there,, 2 ports on port a are input for pulsin, but i like your VAR solution, i hear SYMBOL is not wise to get into habbit of using

    "its hard to understand the story if you only read 2/3 of the book"
    hehe the pros and cons of reverse engenering

Similar Threads

  1. Can't get ADC to loop
    By TravisM in forum mel PIC BASIC
    Replies: 2
    Last Post: - 11th October 2009, 15:33
  2. 16f877 and ps/2 keyboard error???
    By boraciner in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th July 2009, 08:14
  3. How to drive 7 segment using multiple ports?
    By guess79 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 19:43
  4. STATUS re-curtain W
    By zugvogel1 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th February 2005, 15:21
  5. Reading multiple ports
    By Rob Martin in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th May 2004, 17:22

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