PORT , P1, P3

Top  Previous  Next


P1 and P3 are special function registers that are treated as variables.




Px = var

var = Px





The number of the port. (1 or 3). P3.6 can't be used with an AT89C2051!


The variable to retrieve or to set.


Note that other processors can have more ports such as P0, P2, P4 etc.

When you select the proper .DAT file you can also use these ports as variables.

In fact you can use any SFR as a byte variable in BASCOM.


ACC = 0  'will reset the accumulator for example


See hardware for a more detailed description of the ports.



Dim A As Byte , B1 As Bit

A = P1                                   'get value from port 1

A = A Or 2                               'manipulate it

P1 = A                                   'set port 1 with new value

P1 = &B10010101                           'use binary notation

P1 = &HAF                                 'use hex notation

B1 = P1.1                                 'read pin 1.1

P1.1 = 0                                 'set it to 0