|
AN101
|
Product:
80C52 BASIC
|
|
Reading
80C52 Port 3 Bits |
Date:
7/28/99 |
Introduction:
While
BASIC-52 allows you to access Port 1 bits directly through BASIC, it does
not allow direct access of the Port 3 bits available on many of the
Micromint boards and modules |
|
Background:
Port 3 is an 8 bit bi-directional I/O port with internal pullups.
Port Pin
Alternaye Function
P3.0
RXD (serial input port)
P3.1
TXD (serial output port)
P3.2
*INT0 (external interrupt 0)
P3.3
*INT1 (external interrupt 1)
P3.4
T0 (timer 0 external input)
P3.5
T1 (timer 1 external input)
P3.6
*WR (external Data Memory write strobe)
P3.7
RD (external Data Memory read strobe) |
|
Program
Listing: Example
1: Waiting for a bit to be set or cleared BASIC-52
program Assembly
routine xxxxh
Label1: JB P3.x, Label1 ;Loop until bit is set or xxxxh
Label1: JNB P3.x,Label1 ;Loop until bit is cleared Example
2: Return the state of a bit to BASIC-52 BASIC-52
program Assembly
routine Xxxxh
Label1: JB P3.x, B_SET ;Test the bit, jump if set B_SET:
MOV 20h, #1 ;Store 1 if set Once
you are back in the BASIC program use the following line to read what was
stored: IF
DBY(20h)=0 THEN PRINT "P3.x = Low" ELSE PRINT "P3.x =
High" |