multiple ports ===> one symbol?


Closed Thread
Results 1 to 5 of 5
  1. #1
    PICMAN's Avatar
    PICMAN Guest

    Default multiple ports ===> one symbol?

    does this work

    ___

    symbol rout = porta.0: porta.1

    ___

    desired effect = when adressing ROUT , exact change on two givin ports rather then one
    example
    ___
    rout = 1
    ___

    desired effect
    a.0 goes high
    a.1 goes high
    Last edited by PICMAN; - 6th March 2005 at 01:18.

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


    Did you find this post helpful? Yes | No

    Default

    NOP. If you want to set PORTA.0 & PORTA.1 to 1

    PORTA=PORTA | 3

    where | is a bitwise OR

    to CLEAR the same pins

    PORTA=PORTA & $FC
    Steve

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

  3. #3
    PICMAN's Avatar
    PICMAN Guest


    Did you find this post helpful? Yes | No

    Default

    am i to understand
    bitwise = 1100 0000 to set port a.0 and a.1

    i am not familiar with term bitwise,

    whats the 3 do ?

    is this what you meant

    porta=porta 11000000 3.

    is there a comand in picbasic manual i can refrance for examples , ie look up pulsin , and get syntax explained


    i can also SYMBOL them both seprate and activate them in one line as follows.

    __
    symbol a.0 = FLTS
    symbol a.1 = RLTS

    'next code line jumps to activating
    flts: rlts = 1
    'or is it corect this way
    flts = 1 : rlts = 1
    ___

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

  5. #5
    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, 16:33
  2. 16f877 and ps/2 keyboard error???
    By boraciner in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th July 2009, 09: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, 20:43
  4. STATUS re-curtain W
    By zugvogel1 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th February 2005, 16:21
  5. Reading multiple ports
    By Rob Martin in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th May 2004, 18: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