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.
Bookmarks