DIR
Previous  Next

Syntax:    
    DIR port.bit {IN | OUT} (Individual Form)
    DIR port {IN | OUT | DirectionByte} (Entire Port Form)

Explanation:
The DIR command is used to set the direction of the ports of the PIC chip. The individual form sets the direction of one pin at a time, whereas the entire port form will set all bits in a port.

In the individual form, specify the port and bit (ie. PORTB.4), then the direction, which is either IN or OUT.

The entire port form is similiar to the TRIS instruction offered by some PIC chips. To use it, give the name of the port (ie. PORTA), and then a byte is to be written into the TRIS variable. This form of the command is for those who are familiar with the PIC chip's internal architecture.

For 10/12 series chips, use the entire port form. Specify "GPIO" or "IO" as the port.

Example:
    'This program sets PORTA bits 0 and 1 to in, and the rest to out.
    'It also sets all of PORTB to output, except for B1.
    'Individual form is used for PORTA:
    DIR PORTA.0 IN
    DIR PORTA.1 IN
    DIR PORTA.2 OUT
    DIR PORTA.3 OUT
    DIR PORTA.4 OUT
    DIR PORTA.5 OUT
    DIR PORTA.6 OUT
    DIR PORTA.7 OUT
    'Entire port form used for B:
    DIR PORTB b'00000010'

    'Entire port form used for C:
    DIR PORTC IN
This site hosted for free by:
SourceForge.net Logo