Positron Compiler Documentation

Output (PinOutput)

Positron16 · Revision 1.1.3.5 · PDF pages 185–186

Output Port or Port.Pin or Pin Number

or

PinOutput Port or Port.Pin or Pin Number

Makes the specified Port or Port.Pin an output. The name PinOutput can also be used instead of the name Output. They both work exactly the same but make the source code a little clearer to read and follow.

Port must be the name of a Port. Port.Pin must be a Port.Pin constant declaration. Pin Number can be any variable or constant holding 0 to the amount of I/O pins on the device. A value of 0 will be PORTA.0, if present, 1 will be PORTA.1, 8 will be PORTB.0 etc…

  Output PORTA.0               ' Make pin-0 of PORTA an output
   Output PORTA                 ' Make all of PORTA an output
  Output 0                    ' Make pin-0 of PORTA an output
  Output 16                    ' Make pin-0 of PORTB an output
  PinOutput PORTB.0           ' Make pin-0 of PORTB an output
' Flash each of the pins on PORTB
'
   Device = 24HJ128GP502       ' Select the device to compile for
   Declare Xtal = 16

   Dim PinNumber as Byte

   High PORTB
   For PinNumber = 16 to 31    ' Create a loop for the pin to flash
     PinOutput PinNumber       ' Set the pin as an output
     DelayMs 500              ' Delay so that it can be seen
     PinInput PinNumber        ' Set the pin as an input
     DelayMs 500              ' Delay so that it can be seen
   Next

An Alternative method for making a particular pin an output is by directly modifying the TRIS: -

TRISB.0 = 0        ' Make bit-0 of PORTB an output

All of the pins on a port may be set to output by setting the whole TRIS register at once: -

TRISB = %0000000000000000   ' Set all of PORTB to outputs

In the above examples, setting a TRIS bit to 0 makes the pin an output, and conversely, setting the bit to 1 makes the pin an input.

The name “PinOutput” can also be used to replace the command Output, and this, sometimes, makes the BASIC code a little clearer to read. PinOutput and Output perform exactly

View original PDF page 185Open page in PDFOriginal PDF page 185

the same task.

See also : PinClear, High, Low, Input, PinMode, LoadPin, PinSet.

View original PDF page 186Open page in PDFOriginal PDF page 186