
Chapter 6
6.5 I/O Port Applications
The EM60000 series provide one 8-bit input port (Port 1) and one 8-bit I/O port
(Port 2) with pull-low/wake-up function. furthermore, it also provides two
additional general-purpose I/O ports (Port3 and 4), and one output port (Port5).
Refer to the
Parts List
in Section 1.4 of Chapter 1, for different I/O port
configurations of each device.
The pull-low and wake-up functions are controlled by R8 (Port & WDT Control
Register). Because the reset initial value of R8 is “0,” you can modify the value
of R8 and change Port 1 and Port 2 configurations.
For the bi-directional ports (Ports 2, 3, and 4), they are configured as input ports
during a reset. You can change the I/O configuration by writing “0” or “1” to
IOCD ~ IOCF. As the pin status of I/O ports are unknown after power-on reset,
you must write an initial value to the port before it is configured as output. This
will prevent an ambiguous output signal from transpiring, especially when
output port is used to control external devices, like motor or LED.
6.5.1 Example - Input Pin Polling and Configuring Output Port
;--------------------------------------------------------------
; The example demonstrates input pin polling and output port.
; The system clock Fosc = 4MHz.
; Procedure:
;
1.set initial value(Port 2, 3: output port)
;
2. detect p1 or not input(input pin polling)
;
if p1.0=1 -> p3.0 output 1
;
p1.1=1 -> p3.1 output 1
;
p1.2=1 -> p3.2 output 1
;
p1.3=1 -> p3.3 output 1
;
else go to 2.(input pin polling)
;--------------------------------------------------------------
ORG 0x0000
JMP POWERON
; go to power-on procedure
ORG 0x0010
; power-on reset procedure
POWERON: MOV A, @0x40
MOV 0x08, A
; enable Port 1 pull-low, disable
Port 2 pull-low/wakeup, disable
WDT
CLR 0x0B
; write 0 to port 1
CLR 0x0C
; write 0 to port 2
CLR 0x0D
; write 0 to port 3
MOV A, @0
IOW 0x0D
; set port 2 as output port
IOW 0x0E
; set port 3 as output port
80
•
Software Application
EM60000Series User’s Manual
Содержание EM60000 series
Страница 8: ...Contents viii Contents EM60000 Series User s Manual ...
Страница 24: ...Chapter 2 16 Architecture EM60000 Series User s Manual ...
Страница 54: ...Chapter 4 46 Special Function Control EM60000Series User s Manual ...
Страница 80: ...Chapter 5 72 Instruction Set EM60000Series User s Manual ...