differences using high- low or 0 1


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2005
    Posts
    32

    Default differences using high- low or 0 1

    Hi!

    what are the differences between this code has the same function but in the first instance the code is longer than 4bytes?

    SYMBOL led =PORTA.4
    HIGH led
    PAUSE 1000
    LOW led

    SYMBOL led =PORTA.4
    led=1
    PAUSE 1000
    led=0

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


    Did you find this post helpful? Yes | No

    Default

    It is my understanding that HIGH/LOW sets the TRIS

    0/1 needs to have the TRIS set before hand.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    Dave is correct. The High/Low commands perform a PortX.y = 1/0, and also set the TrisX =

    They are for...
    • a) BS2 code compatibility,
    • b) idiot-proofing the compiler--which is a subset of a), really, as a helpful tool for newbies,
    • c) when you are regularly toggling back & forth between input & output,
    • d) you have extra code space you are trying to fill up, and

    Unless you are alternating input/output, or you only set the pin once, they take twice the code space as a direct pin setting. For output pins often accessed, I prefer to toggle the sfr's directly, because...
    • a) you can set multiple bits at a time. i.e. TrisA = COMMUNICATE, (or for more symbol-happy people, PortA_IO_Directions = COMMUNICATE) for when your device is plugged into the pc.
    • b) you can set the output state to a helpful symbol--which also comes in handy when you are developing the h/w, and aren't sure if you'll be wiring things active high or active low. For instance, LED1 = LED_ON is more helpful in code reading than Low LED1.
    • c) it's shorter.
    • d) I've learned to distrust compilers for stuff this simple. (Case in point: ALL compilers [including PBP] screwed up the a/d port selection bits on the 16f88x pics when they first came out.)
    • e) if you are the one always setting the Tris fsr manually, you'll never be surprised when it changes.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Default

    Hi, Tenaja

    you forgot it is a very good way to mask the " RMW issues " of the 10/12/16F series ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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