| Action
P1 and P3 are special
function registers that are treated as variables.
Syntax
Px = var
var = Px
Remarks
x The number of the
port. (1 or 3). P3.6 can't be used with an AT89C2051!
Var The variable to retrieve or to set.
Note that other processors can have additional 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 variable in BASCOM.
ACC = 0 'will reset
the accumulator for example
See hardware for a
more detailed description of the ports.
Example
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
|