PreviousNext
Direction
Help > Peripherals > IO > Direction

This command sets the direction of the individual IO pins of the individual ports. Additionally, the same command can be used to set up weak pull-ups at the pins where available. See the datasheet of the PIC MCU for a description of IO ports.

 

The correctness of the embedded subcommands (port + mask + value) is not checked before but during their execution. If an error is detected during the execution of the subcommands the execution is aborted. If the invalid port number is specified the ERROR_DATA is returned. If the length of the very last subcommand is not 3 bytes, the error is not returned.

 

Request

NADR

PNUM

PCMD

HWPID

0

1

2

n × 3

n × 3 + 1

n × 3 + 2

NADR

0x09

0x00

?

Port0

Mask0

Value0

Portn

Maskn

Valuen

 

n [0,17]          Number of subcommands minus 1.

Port                  a. Specifies port to setup a direction to. 0x00=TRISA, 0x01=TRISB, …(predefined symbols PNUM_IO_TRISx) or

b. Specifies port to setup a pull-up. 0x10=WPUA, 0x11=WPUB, … (predefined symbols PNUM_IO_WPUx)

Mask                Masks pins of the port.

Value                a. Actual direction bits for the masked pins. 0=output, 1=input., … or

                        b. Pull-up state. 0=disabled, 1=enabled.

 

Error codes

ERROR_DATA      Invalid Port value.

 

Response

 

The general response to writing request with STATUS_NO_ERROR Error code.