EM73866 is an advanced single chip CMOS 4-bit micro-controller. It contains 8K-byte ROM, 500-nibble RAM,
4-bit ALU, 13-level subroutine nesting, 22-stage time base, two 12-bit timer/counters for the kernel function.
EM73866 also contains 6 interrupt sources, 2 input port, 7 bidirection ports, Max LCD display (32x4), built-in
watch-dog-timer and high speed Timer/Counter.
EM73866 has plentiful operating modes (SLOW, IDLE, STOP) intended to reduce the power consumption.
Instruction set: 107 powerful instructions.
Instruction cycle time : Up to 2us for 4 MHz (high speed clock).
ROM capacity: 8192 X 8 bits.
RAM capacity: 500 X 4 bits.
Input port: 2 ports (P0, P2), P0(0..3), P2 (0..3), IDLE/STOP releasing function are available
Bidirection port: 7 ports (P1, P3, P4, P5, P6, P7, P8). P4.1 is shared with HTC external input.
12-bit timer/counter: Two 12-bit timer/counters are programmable for timer, event counter and pulse width
Built-in watch-dog-timer : It is available by mask option.
Built-in time base counter : 22 stages.
Built-in high Speed Timer/Counter : Could be timer, melody out or pulse width measurement.
Subrountine nesting: Up to 13 levels.
normal current push-pull
high current push-pull
NMOS open-drain
PMOS open-drain
* This specification are subject to be changed without notice.
12.29.1999
2
Page 3
EM73866
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
PIN DESCRIPTIONS
Symbol Pin-typeFunction
P3(0,1)/SEG(30,31) I/O-O2-bit bidirection I/O pins are shared with LCD segment pin
mask option :segment pin
low current push-pull
normal current push-pull
open-drain
P3(2,3), P6(0,1) I/O-N4-bit bidirection I/O pins
mask option :low current push-pull
normal current push-pull
open-drain
P4.0/SOUND/WAKEUP8 I/O-R11-bit bidirection I/O with inverse sound output and IDLE/STOP
releasing function.
mask option :wakeup disable, low current push-pull
wakeup disable, normal current push-pull
wakeup disable, high current push-pull
wakeup disable, open-drain
wakeup disable, SOUND
wakup enable, low current push-pull
wakeup enable, normal current push-pull
P4.1(TRGH)/WAKEUP9 I/O-R11-bit bidirection I/O with HTC output and IDLE/STOP releasing
function.
mask option :wakeup disble, low current push-pull
wakeup disable, normal current push-pull
wakeup disable, high current push-pull
wakeup disable, NMOS open-drain
wakeup disable, PMOS open-drain
wakeup enable, low current push-pull
wakeup enable, normal current push-pull
P4(2,3)/WAKEUP(10,11) I/O-R12-bit bidirection I/O pins with IDLE/STOP releasing function
mask option :wakeup disble, low current push-pull
wakeup disable, normal current push-pull
wakeup disable, high current push-pull
wakeup disable, NMOS open-drain
wakeup disable, PMOS open-drain
wakeup enable, low current push-pull
wakeup enable, normal current push-pull
P5(0..3)/WAKEUP(12..15) I/O-S4-bit bidirection I/O pins with IDLE/STOP releasing function
mask option :wakeup disable, low current push-pull
wakeup disable, normal current push-pull
wakeup disable, open-drain
wakeup enable, low current push-pull
wakeup enable, normal current push-pull
P7.0/TRGA/WAKEUPDI/O-S2-bit bidirection I/O pins with timer/counterA, B external intput and
P8.1/TRGB/WAKEUPBIDLE/STOP releasing function
mask option :wakeup disable, low current push-pull
wakeup disable, normal current push-pull
wakeup disable, open-drain
wakeup enable, low current push-pull
wakeup enable, normal current push-pull
* This specification are subject to be changed without notice.
12.29.1999
3
Page 4
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
PIN DESCRIPTIONS
Symbol Pin-typeFunction
P8.0(INT1)/WAKEUPAI/O-S2-bit bidirection I/O pins with interrupt 0, 1 external intput and
P8.2(INT0)/WAKEUPCIDLE/STOP releasing function
mask option :wakeup disable, low current push-pull
wakeup disable, normal current push-pull
wakeup disable, open-drain
wakeup enable, low current push-pull
wakeup enable, normal current push-pull
COM(0..3)--LCD common pins
SEG(0..29)--LCD segment pins
V1, V2, V3, V
RLC
--LCD bias pins
EM73866
FUNCTION DESCRIPTIONS
PROGRAM ROM ( 8K X 8 bits )
8 K x 8 bits program ROM contains user's program and some fixed data.
The basic structure of the program ROM may be categorized into 5 partitions.
1. Address 0000h: Reset start address.
2. Address 0002h - 000Ch : 6 kinds of interrupt service routine entry addresses.
3. Address 000Eh - 0086h : SCALL subroutine entry address, only available at 000Eh, 0016h, 001Eh, 0026h, 002Eh,
0036h, 003Eh, 0046h, 004Eh, 0056h, 005Eh, 0066h, 006Eh, 0076h, 007Eh, 0086h.
Subroutine call entry address
designated by [LCALL a]
instruction
Data table for
[LDAX],[LDAXI]
instruction
DP is a 12-bit data register that stores the program ROM address as pointer for the ROM code data.
User has to initially load ROM address into DP with instructions "STADPL", and "STADPM, STADPH",
then then to obtain the lower nibble of ROM code data by instruction "LDAX" and higher nibble by instruction
"LDAXI"
PROGRAM EXAMPLE: Read out the ROM code of address 1777h by table-look-up instruction.
A total 500-nibble data RAM is available from address 000 to 1FFh. DATA RAM includes the zero page region,
stacks and data areas.
* This specification are subject to be changed without notice.
12.29.1999
5
Page 6
EM73866
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
:
:
:
:
:
:
:
:
:
Increment
Level 0
Level 4
Level 8
Level 12
Zero-page
Level 1
Level 5
Level 9
Level 2
Level 6
Level 10
Increment
Level 3
Level 7
Level 11
Bank 0
Bank 1
Address
000h - 00Fh
010h - 01Fh
020h - 02Fh
0C0h - 0CFh
0D0h - 0DFh
0E0h - 0EFh
0F0h - 0F3h
100h - 10Fh
110h - 11Fh
1F0h - 1FFh
ZERO- PAGE:
From 000h to 00Fh is the zero-page location. It is used as the zero-page address mode pointer for the
instruction of "STD #k,y; ADD #k,y; CLR y,b; CMP k,y".
PROGRAM EXAMPLE: To write immediate data "07h" to RAM [03] and to clear bit 2 of RAM [0Eh].
STD#07h, 03h; RAM[03] ← 07h
CLR0Eh,2; RAM[0Eh]
← 0
2
STACK:
There are 13 (maximum) stack levels that user can use for subroutine (including interrupt and CALL).
User can assign any level be the starting stack by providing the level number to stack pointer (SP).
When an instruction (CALL or interrupt) is invoked, before enter the subroutine, the previous PC address
is saved into the stack until returned from those subroutines, the PC value is restored by the data saved in stack.
SPECIAL PURPOSE REGISTER:
The instruction concerning with "Timer/counter", "Data Pointer" and "Stack Pointer" at instruction table 14
be sure the RAM bank must be set in Bank0.
DATA AREA:
Except the area used by user's application, the whole RAM can be used as data area for storing and loading
general data.
ADDRESSING MODE
The 500 nibble data memory consists of two banks (bank 0 and bank 1). There are 244x4 bits (address
000h~0F3h) in bank 0 and 256x4 bits (address 100h~1FFh) in bank 1.
* This specification are subject to be changed without notice.
12.29.1999
6
Page 7
EM73866
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
The bank is selected by P9.3. When P9.3 is cleared to "0", the bank 0 is selected. When P9.3 is set to "1", the bank
1 is selected.
There are 3 addressing mode to access the data memory, namely -
(1) Indirect addressing mode:
The address in the certain bank is specified by the HL registers.
P9.3HRLR
RAM address
PROGRAM EXAMPLE: Load the data of RAM address "143h" to RAM address "032h".
The address is the lower 4 bits code of the second byte in the instruction field.This kind of instructions are
only available for the zero page. Area in bank0, even the P9.3 is set.
xxxxxxxx
instruction field
yyyy
RAM address
0
PROGRAM EXAMPLE: Write immediate "0Fh" to RAM address "005h".
STD#0Fh, 05h; RAM[05h]← 0Fh
* This specification are subject to be changed without notice.
0000
yyyy
12.29.1999
7
Page 8
EM73866
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
PROGRAM COUNTER (8K ROM)
Program counter ( PC ) is composed by a 13-bit counter, which indicates the next executed address for the
instruction of program ROM instruction.
For BRANCH and CALL instructions, PC is changed by instruction indicated. PC can only indicate the address
from 0000h-1FFFh.
Condition: SF=1; PC ← a ( branch condition satisified )
PCaaaaaaaaaaaa a
SF=0 ; PC ← PC + 3 ( branch condition not satisified )
PCOriginal PC value + 3
(2) Subrountine instruction:
SCALL a
Object code: 1110 nnnn
Condition : PC ← a ; a=8n+6 ; n=1..Fh ; a=86h, n=0
PC00000aaaaa aaa
* This specification are subject to be changed without notice.
12.29.1999
8
Page 9
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
LCALL a
Object code: 0100 0aaa aaaa aaaa
Condition: PC ← a
PC00aaaaaaaaaa a
RET
Object code: 0100 1111
Condition: PC ← STACK[SP]; SP + 1
PCThe return address stored in stack
RT I
Object code: 0100 1101
Condition : FLAG. PC ← STACK[SP]; EI ← 1; SP + 1
PCThe return address stored in stack
EM73866
(3) Interrupt acceptance operation:
When an interrupt is accepted, the original PC is pushed into stack and interrupt vector will be loaded into
PC,The interrupt vectors are as following:
INT0 (External interrupt from P8.2)
PC0000000000010
TRGH (High speed counter interrupt)
PC0000000000100
TRGA (Timer A overflow interrupt)
PC0000000000110
TRGB (Time B overflow interrupt)
PC0000000001000
TBI (Time base interrupt)
PC0000000001010
INT1 (External interrupt from P8.0)
PC0000000001100
(4) Reset operation:
PC000000000000 0
* This specification are subject to be changed without notice.
12.29.1999
9
Page 10
EM73866
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
(5) Other operations:
For 1-byte instruction execution: PC + 1
For 2-byte instruction execution: PC + 2
For 3-byte instruction execution: PC + 3
ACCUMULATOR
Accumulator is a 4-bit data register for temporary data. For the arithematic, logic and comparative opertion
.., ACC plays a role which holds the source data and result.
FLAGS
There are 3 kinds of flag, CF ( Carry flag ), ZF ( Zero flag ), SF ( Status flag ), these 3 1-bit flags are affected
by the arithematic, logic and comparative .... operation.
All flags will be put into stack when an interrupt subrountine is served, and the flags will be restored after
RTI instruction executed.
(1) Carry Flag ( CF )
The carry flag is affected by following operation :
a. Addition : CF as a carry out indicator, when the addition operation has a carry-out, CF will be "1", in
another word, if the operation has no carry-out, CF will be "0".
b. Subtraction : CF as a borrow-in indicator, when the subtraction operation must has a borrow-in, the CF
will be "0", in another word, if no borrow-in, CF will be "1".
c. Comparision : CF is as a borrow-in indicator for Comparision operation as the same as subtraction
operation.
d. Rotation : CF shifts into the empty bit of accumulator for the rotation and holds the shift out data after
rotation.
e. CF test instruction : For TFCFC instruction, the content of CF sends into SF then clear itself "0".
For TTSFC instruction, the content of CF sends into SF then set itself "1".
(2) Zero Flag ( ZF )
ZF is affected by the result of ALU, if the ALU operation generate a "0" result, the ZF will be "1", otherwise,
the ZF will be "0".
(3) Status Flag ( SF )
The SF is affected by instruction operation and system status.
a. SF is initiated to "1" for reset condition.
b. Branch instruction is decided by SF, when SF=1, branch condition will be satisified, otherwise, branch
condition will not be satisified by SF = 0.
PROGRAM EXAMPLE:
Check following arithematic operation for CF, ZF, SF
* This specification are subject to be changed without notice.
The arithematic operation of 4-bit data is performed in ALU unit. There are 2 flags can be affected by the
result of ALU operation, ZF and SF. The operation of ALU can be affected by CF only.
ALU STRUCTURE
ALU supported user arithematic operation function, including : addition, subtraction and rotaion.
DATA BUS
ALU
ZF CF SF
ALU FUNCTION
(1) Addition:
For instruction ADDAM, ADCAM, ADDM #k, ADD #k,y .... ALU supports additional function.
The additional operation can affect CF and ZF. For additional operation, if the result is "0", ZF will be
"1", otherwise, not equal "0", ZF will be "0". When the addition operation has a carry-out, CF will be "1",
otherwise, CF will be "0".
EXAMPLE:
OperationCarryZero
3+4=700
7+F=610
0+0=001
8+8=011
(2) Subtraction:
For instruction SUBM #k, SUBA #k, SBCAM, DECM... ALU supports user subtraction function. The
subtraction operation can affect CF and ZF, For subtraction operation, if the result is negative, CF will
be "0", it means a borrow out, otherwise, if the result is positive, CF will be "1". For ZF, if the result
of subtraction operation is "0", the ZF will be "1", otherwise, ZF will be "1".
* This specification are subject to be changed without notice.
There are two kinds of rotation operation, one is rotation left, the other is rotation right.
RLCA instruction rotates Acc value to left, shift the CF value into the LSB bit of Acc and the shift out data
will be hold in CF.
MSBLSB
ACC
CF
RRCA instruction operation rotates Acc value to right, shift the CF value into the MSB bit of Acc and the
shift out data will be hold in CF.
MSBLSB
ACC
CF
PROGRAM EXAMPLE: To rotate Acc right and shift a "1" into the MSB bit of Acc.
TTCFS; CF ← 1
RRCA; rotate Acc right and shift CF=1 into MSB.
HL REGISTER
HL register are two 4-bit registers, they are used as a pair of pointer for the address of RAM memory and also
2 independent temporary 4-bit data registers. For some instruction, L register can be a pointer to indicate the
pin number (Port4).
HL REGISTER STRUCTURE
3 2 1 0
3 2 1 0
H REGISTER
* This specification are subject to be changed without notice.
L REGISTER
12.29.1999
12
Page 13
HL REGISTER FUNCTION
(1) For instruction : LDL #k, LDH #k, THA, THL, INCL, DECL, EXAL, EXAH, HL register used as a
temporary register.
PROGRAM EXAMPLE: Load immediate data "5h" into L register, "Dh" into H register.
LDL #05h;
LDH #0Dh;
(2) For instruction LDAM, STAM, STAMI.., HL register used as a pointer for the address of RAM memory.
PROGRAM EXAMPLE: Store immediate data #Ah into RAM of address 35h.
LDL #5h;
LDH #3h;
STDMI #0Ah; RAM[35] ← Ah
(3) For instruction : SELP, CLPL, TFPL, L regieter be a pointer to indicate the bit of I/O port.
EM73866
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
When LR = 0 indicate P4.0
PROGRAM EXAMPLE: To set bit 0 of Port4 to "1"
LDL #00h;
SEPL ; P4.0 ← 1
STACK POINTER (SP)
Stack pointer is a 4-bit register which stores the present stack level number.
Before using stack, user must set the SP value first, CPU will not initiate the SP value after reset condition.
When a new subroutine is accepted, the SP will be decreased one automatically, in another word, if
returning from a subroutine, the SP will be increased one.
The data transfer between ACC and SP is by instruction of "LDASP" and "STASP". When "LDASP" and
"STASP" are used, Port 9.3 must be set to 0.
DATA POINTER (DP)
Data pointer is a 12-bit register which stores the address of ROM can indicate the ROM code data
specified by user (refer to data ROM).
When "LDADPL", "LDADPM" and "LDADPH" are used, Port 9.3 must be set to 0.
CLOCK AND TIMING GENERATOR
The clock generator is supported by a dual clock system, the clock source comes from crystal (resonator)
or RC oscillation for both high or low frequency osc. are decided by mask option.
CLOCK GENERATOR STRUCTURE
There are two clock generator for system clock control. P14 is the status register for the CPU status. P16,
P19 and P22 are the system clock mode control ports.
* This specification are subject to be changed without notice.
12.29.1999
13
Page 14
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
Mask option for choose Crystal or RC oscillator
EM73866
XIN
XOUT
LXIN
LXOUT
High-frequency
generator
Low-frequency
generator
Mask option for choose Crystal or RC oscillator
Crystal connection or
(
Res=100K for high frequency osc
fc
fs
LXIN/XIN
LXOUT/XOUT
/ Res=1M for slow frequency osc)
System clock
mode control
System control
Res
RC connection
P14
P16
P19
P22
LXIN/XIN
LXOUT/XOUT
SYSTEM CLOCK MODE CONTROL
The system clock mode controller can start or stop the high-frequency and low-frequency clock oscillator
and switch between these two basic clocks. EM73866 has four operation modes (NORMAL, SLOW, IDLE
and STOP operation modes).
* This specification are subject to be changed without notice.
12.29.1999
14
Page 15
EM73866
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
NORMAL OPERATION MODE
The 4-bit µc is in the NORMAL operation mode when the CPU is reseted. This mode is a dual clock system
(high-frequency and low-frequency clocks oscillating). It can be changed to SLOW or STOP operation
mode by the command register (P22 or P16).
LCD display and high speed timer/counter with melody output are available for the NORMAL operation
mode.
SLOW OPERATION MODE
The SLOW operation mode is a single clock system (low-frequency clock oscillating). It can be changed to
the DUAL operation mode by the command register (P22), STOP operation mode by P16 and IDLE
operation mode by P19.
LCD display and high speed timer/counter with melody output are available for the SLOW operation
mode.
32 1 0 Initial value : 0000
P22
*SOM
SOMLow-frequencyWith low-frequency double
0002^3/LXIN RC solw to normal 2^3/LXIN RC solw to normal
0012^4/LXIN RC solw to normal 2^4/LXIN RC solw to normal
010 2^11/LXIN X'tal slow to normal2^11/LXIN X'tal slow to normal
011 2^12/LXIN X'tal slow to normal2^12/LXIN X'tal slow to normal
1** normal to slownormal to slow
P1432 10 Initial value : *000
*WKSLFS CPUS
LFSLow-frequency statusCPUSCPU status
0LXIN source is not stable0NORMAL operation mode
1LXIN source is stable1SLOW operation mode
WKSWakeup status
0Wakeup not by internal timer
1Wakeup by internal timer
Port14 is the status register for CPU. P14.0 (CPU status) and P14.1 (Low-frequency status) are read-only
bits. p14.2 (wakeup status) will be set to "1" when CPU is wake-up by internal timer. P14.2 will be cleared
to "0" when user out data to P14.
IDLE OPERATION MODE
The IDLE operation mode suspends all SLOW operations except for the low-frequency clock and LCD
driver. It retains the internal status with low power consumption without stopping the clock function and
LCD display.
LCD display is available for the IDLE operation mode. The IDLE operation mode will be wakeup and
return to the SLOW operation mode by the internal timing generator or I/O pins ( P0(0..3)/WAKEUP(0..3),
P2(0..3)/WAKEUP(4..7), P4(0..3)/WAKEUP(8..11), P5(0..3)/WAKEUP(12..15), P7.0/WAKEUPD or P8
(0..2)/WAKEUP(A..C) ).
* This specification are subject to be changed without notice.
10P0(0..3), P2(0..3), P4(0..3), P5(0..3), P7.0, P8(0..2) pin input and 0.5
sec signal (0.25 sec with frequency Double)
11P0(0..3), P2(0..3), P4(0..3), P5(0..3), P7.0, P8(0..2) pin input and 15.
625 ms signal (7.8 ms with frequency Double)
STOP OPERATION MODE
The STOP operation mode suspends system operation and holds the internal status immediately before the
suspension with low power consumption. This mode will be released by reset or I/O pins (P0(0..3)/, P2 (0..
3), P4(0..3), P5(0..3), P7.0 or P8(0..2)).
LCD display and high speed timer/counter with melody output are disabled in STOP mode.
Initial value : 0000 P16 3 2 1 0
SWWT Set wake up
*
Stop wake up time ( go to NORMAL )
1 0 0 2^9/XIN for RC osc.
1 1 1 2^19/XIN for Crystal osc.
*
*
1 0 1 2^10/XIN for RC osc.
*
1 1 0 2^18/XIN for Crystal osc.
*
TIME BASE INTERRUPT (TBI )
The time base can be used to generate a fixed frequency interrupt. There are 8 kinds of frequencies can be
selected by setting P25.
P25 3210
initial value : 0000
Interrupt Rate
P25Low-frequencyWith low-frequency double
NORMAL modeSLOW modeNORMAL mode SLOW mode
0 0 x x disabledisabledisabledisable
0 1 0 0 LXIN / 2
* This specification are subject to be changed without notice.
12.29.1999
16
Page 17
EM73866
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
TIMER / COUNTER (TIMERA, TIMERB)
Timer/counters can support user three special functions:
1. Even counter
2. Timer.
3. Pulse-width measurement.
These three functions can be executed by 2 timer/counter independently.
For timerA, the counter data is saved in timer register TAH, TAM, TAL, which user can set counter initial
value and read the counter value by instruction "LDATAH(M,L), STATAH(M,L)" and timer register is
TBH, TBM, TBL and W/R instruction "LDATBH (M,L), STATBH (M,L)".
The basic structure of timer/counter is composed by two same structure counter, these two counters can be
set initial value and send counter value to timer register, P28 and P29 are the command ports for timerA
and timer B, user can choose different operation mode and different internal clock rate by setting these two
ports. When timer/counter overflow, it will generate a TRGA(B) interrupt request to interrupt control unit.
INTERRUPT CONTROL
TRGB request
12 BIT COUNTER
EVENT COUNTER CONTROL
TIMER CONTROL
PULSE-WIDTH MEASUREMENT
CONTROL
TMSBIPSB
P8.1/
TRGB
MUX
internal clock
high speed timer/counter
P7.0/
TRGA
internal clock
TRGA request
12 BIT COUNTER
EVENT COUNTER CONTROL
TIMER CONTROL
PULSE-WIDTH MEASUREMENT
P28
CONTROL
TMSA
DATA BUS
IPSA
P29
TIMER/COUNTER CONTROL
P8.1/TRGB, P7.0/TRGA are the external timer inputs for timerB and timerA, they are used in event
counter and pulse-width measurement mode.
Timer/counter command port: P28 is the command port for timer/counterA and P29 is for the timer/
counterB.
Port 28
3 2 1 0
TMSA IPSA
Initial state: 0000
TIMER/COUNTER MODE SELECTION
TMSA (B) Function description
0 0 Stop
0 1 Event counter mode
Port 29
3 2 1 0
TMSB
Initial state: 0000
IPSB
1 0 Timer mode
1 1 Pulse width measurement mode
* This specification are subject to be changed without notice.
NORMAL modeSLOW modeNORMAL modeSLOW mode
0 0Depend on high speed timer/counterDepend on high speed timer/counter
0 1LXIN/2
1 0LXIN/2
1 1LXIN/213 HzLXIN/213 HzLXIN/212 HzLXIN/212 Hz
3
HzReservedLXIN/22 HzReserved
7
HzLXIN/27 HzLXIN/26 HzLXIN/26 H z
INTERNAL PULSE-RATE SELECTION
5
HzLXIN/25 HzLXIN/24 HzLXIN/24 Hz
9
HzLXIN/29 HzLXIN/28 HzLXIN/28 Hz
EM73866
TIMER/COUNTER FUNCTION
Timer/counter A can be programmable for timer, event counter and pulse width measurement. Each timer/
counter can execute any one of these functions independly.
EVENT COUNTER MODE
For event counter mode, timer/counter increases one at any rising edge of P8.1/TRGB for timerB (P7.0/
TRGA for timer A). When timerB (timerA) counts overflow, it will give interrupt control an interrupt request
TRGB (TRGA).
P8.1/TRGB (P7.0/TRGA)
TimerB (TimerA) value nn+1n+2n+3n+4n+5n+6
PROGRAM EXAMPLE: Enable timerA with P28
LDIA#0100B ;
OUTAP28; Enable timerA with event counter mode
TIMER MODE
For timer mode, timer/counter increase one at any rising edge of internal pulse. User can choose 4 kinds of
internal pulse rate by setting IPSB for timerB (IPSA for timerA).
When timer/counter counts overflow, TRGB (TRGA) will be generated to interrupt control unit.
Internal pulse
TimerB (TimerA )value
nn+1n+2n+3n+4n+5n+6n+7
* This specification are subject to be changed without notice.
12.29.1999
18
Page 19
EM73866
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
PROGRAM EXAMPLE: To generate TRGA interrupt request after 60 ms with system clock LXlN=32KHz
NOTE:The preset value of timer/counter register is calculated as following procedure.
Internal pulse rate: LXIN/2
3
; LXIN = 32KHz
The time of timer counter count one = 23 /LXIN = 8/32768=0.244ms
The number of internal pulse to get timer overflow = 60 ms/ 0.244ms = 245.901= 0F6H
The preset value of timer/counter register = 1000H - 0F6H = 0F0AH
PULSE WIDTH MEASUREMENT MODE
For the pulse width measurement mode, the counter only incresed by the rising edge of internal pulse rate
as external timer/counter input (P8.1/TRGB, P7.0/TRGA ), interrupt request will be generated as soon as
timer/counter count overflow.
P8.1/TRGB(P8.3/TRGA)
Internal pulse
TimerB(TimerA) value
nn+1n+2n+3n+4n+5
PROGRAM EXAMPLE: Enable timerA by pulse width measurement mode.
LDIA#1100b ;
OUTAP28; Enable timerA with pulse width measurement mode.
HIGH SPEED TIMER/COUNTER
EM73866 has one 8-bit high speed timer/counter (HTC). It supports three special functions : auto load timer,
melody output and pulse width measurement modes. The HTC is available for the NORMAL and SLOW
operation mode.
The HTC can be set initial value and send counter value to counter registers (P11 and P10), P31 is the
command port for HTC, user can choose different operation mode and different internal clockrate by setting
the port. The timer/counter increase one at the rising edge of internal pulse. The HTC can generate an overflow
interrupt (HTCI) when it overflows. The HTCI cannot be generated when the HTC is in the melody mode
or disabled.
* This specification are subject to be changed without notice.
12.29.1999
19
Page 20
EM73866
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
P4.0/SOUND
P4.1/TRGH
Output data
mask option
F
HTC
P31(3,2)
P31(1,0)
XIN
Ö2
Input data
P31 is the command register of the 8-bit high speed timer/counter.
P11 and P10 are the counter registers of the 8-bit high speed timer/counter. P10 is the lower nibble
register and P11 is the higher nibble register. (HT is the value of counter registers.)
P11 3210P103210Initial value : 0000 0000 (HT)
Higher nibble registerLower nibble register
* This specification are subject to be changed without notice.
12.29.1999
20
Page 21
EM73866
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
** F
=[(XIN/2X)/(100H-HT)]/2, HT=0~255
HTC
** Example : LXIN=32K Hz, HIPS=01, HT=11110000B=0F0H.
The value of 8-bit binary up counter can be presetted by P10 and P11. The value of registers can loaded into
the HTC when the counter starts counting or occurs overflow. If user write value to the registers before the
next overflow occurs, the preset value can be changed.
The preset value will be changed when users output the different data to P10 and P11.
The count value of HTC can be read from P10 and P11. The value is unstable when user read the value during
counting. Thus, user must disable the counter before reading the value.
The P4.0/SOUND and SOUND pins will output the squre wave in the melody mode. When the CPU is not
in the melody mode, the P4.0/SOUND is high and SOUND is low.
The P4.1/RGH pin will be the input pin in the pulse width measurement mode. User must output high to P4.1/
TRGH and then it can be the HTC external input pin. When the HTC is disabled, the P4.1 pin is a normal I/
O pin.
INTERRUPT FUNCTION
There are 6 interrupt sources, 2 external interrupt sources, 4 internal interrupt sources. Multiple
interrupts are admitted according the priority.
TypeInterrupt sourcePriorityInterruptInterruptProgram ROM
EM73866 can directly drive the liquid crystal display (LCD) and has max. 32 segment and 4 common output pins.
There are total 32 x 4 dots can be display. The VRLC pin is the LCD driver power input, there is the voltage
of (VCC-VRLC) to LCD.
CONTROL OF LCD DRIVER
The LCD driver control command register is P27. When LDC is 00, the LCD is disabled and changes the duty
only. When LDC is 01, the LCD is blanking, the COM pins are inactive and the SEG pins continuously output
the display data. When LDC is 11, the LCD driver enables, the power switch is turned on and it cannot off
forever except the CPU is reseted or sleeping. User must enable the LCD driver by self when the CPU is waked
up.
Port27
3 2 1 0Initial value : 0000
LDCDUTY
LDCLCD display controlDUTYDriving method selectFrame frequency
There are four kinds of driving methods can be selected by DUTY (P27.0~P27.1). Ther are two waveform
types, but for the reason of the number of voltage transition point in type A is greater than type B, so type B
gets a better display performance. The driving waveforms type A and B of LCD driver are as below :
* This specification are subject to be changed without notice.
* This specification are subject to be changed without notice.
12.29.1999
24
Page 25
EM73866
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
WATCH-DOG-TIMER (WDT)
Watch-dog-timer can help user to detect the malfunction (runaway) of CPU and give system a timeup signal every
certain time. User can use the time up signal to give system a reset signal when system is fail.
This function is available by mask option. If the mask option of WDT is enabled, it will stop counting when CPU
is reseted or in the STOP operation mode.
The basic structure of Watch-Dog-Timer control is composed by a 4-stage binary counter and a control unit.
The WDT counter counts for a certain time to check the CPU status, if there is no malfunction happened, the
counter will be cleared and continue counting. Otherwise, if there is a malfunction happened, the WDT control
will send a WDT signal (low active) to reset CPU. The WDT checking period is assign by P21 (WDT command
port).
WDT counter
LXIN/2
counter clear request
13
0
12
WDT control
3
RESET pin
mask option
P21
WDT
command port
P21 is the control port of watch-dog-timer, and the WDT time up signal is connected to RESET.
Port 213210Initial value :0000
CWC** WDT
CWCClear watchdog timer counter
0Clear counter then return to 1
1Nothing
WDTSET WATCH-DOG-TIMER DETECT TIME
Low-frequencyWith low-frequency double
03 x 213/LXIN = 3 x 213/32K Hz = 0.75 sec3 x 212/LXIN = 3 x 212/32K Hz = 0.375 sec
17 x 213/LXIN = 7 x 213/32K Hz = 1.75 sec7 x 212/LXIN = 7 x 212/32K Hz = 0.875 sec
* This specification are subject to be changed without notice.
12.29.1999
25
Page 26
EM73866
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
PROGRAM EXAMPLE
13
To enable WDT with 7x2
LDIA#0001B
OUTA P 21; set WDT detection time and clear WDT counter
:
:
RESETTING FUNCTION
When CPU in normal working condition and RESET pin holds in low level for three instruction cycles at least,
then CPU begins to initialize the whole internal states, and when RESET pin changes to high level, CPU begins
to work in normal condition.
The CPU internal state during reset condition is as following table :
/LXIN detection time.
Hardware condition in RESET stateInitial value
Program counter0000h
Status flag01h
Interrupt enable flip-flop ( EI )00h
MASK0 ,1, 2, 300h
Interrupt latch ( IL )00h
P10, 11,14, 16, 19, 21, 22, 25, 27, 28, 29, 3100h
P1, 3, 4, 5, 6, 7, 80Fh
Both oscillatorStart oscillation
The RESET pin is a hysteresis input pin and it has a pull-up resistor available by mask option.
The simplest RESET circuit is connect RESET pin with a capacitor to V
and a diode to VDD.
SS
RESET
* This specification are subject to be changed without notice.
12.29.1999
26
Page 27
EM73866
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
EM73866 I/O PORT DESCRIPTION :
PortInput functionOutput functionNote
0EInput port , wakeup function
1EInput portE Output port
2EInput port , wakeup function -3EInput portE Output port, shared with segment
4EInput port , wakeup functionE Output port
5EInput port , wakeup functionE Output port, P4.0/SOUND, P4.1(TRGH)
6EInput portE Output port
7EInput port, wakeup functionE Output port, P7.0(TRGA)
8EInput port, wakeup functionE Output port,P8.0(INT1),P8.1(TRGB),P8.2(INT1)
9-- -10--I High speed Timer/Counter RegisterLow nibble
11--I High speed Timer/Counter RegisterHigh nibble
12-- -13-- -14ICPU statusI Clear P14.0 to 0
15-- -16I STOP mode control register
17 -18 -19I IDLE mode control register
20 -21I WDT control register
22I Slow mode control register
23 -24 -25I Timebase control register
26 -27I LCD control register
28I Timer/counter A control register
29I Timer/counter B control register
30 -31I HTC control register
E : External port
I : Internal port
* This specification are subject to be changed without notice.
* This specification are subject to be changed without notice.
12.29.1999
29
Page 30
RESET PIN TYPE
TYPE RESET-A
EM73866
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
RESET
OSCILLATION PIN TYPE
TYPE OSC-A TYPE OSC-B
XIN
XOUT
TYPE OSC-H1 (Low frequency) TYPE OSC-H2 (High frequency)
VDD
1Mohm
LXIN
mask option
Crystal
Osc.
RC Osc.
10Kohm
VDD
OSC
LXIN
Crystal
Osc.
LXOUT
RC Osc.
INPUT PIN TYPE
TYPE INPUT-K
positive
input data
WAKEUP
mask option
: mask option
edge
detector
negative
edge
detector
I/O PIN TYPE
TYPE I/O-NTYPE I/O-O
: mask option
* This specification are subject to be changed without notice.
TYPE I/O-N
: mask option
path B
path A
Output
data
latch
Input
data
Output
data
Special function
output
12.29.1999
30
Page 31
4-BIT MICRO-CONTROLLER FOR LCD PRODUCT
TYPE I/O-QTYPE I/O-R1
EM73866
: mask option
path B
path A
TYPE I/O-Q
WAKEUP function
mask option
Output
data
latch
Input
data
Output
data
Special function
output
TYPE I/O-STYPE I/O-Z
Special function
path B
path A
TYPE I/O-N
WAKEUP function
mask option
SEL
Output
data
latch
control input
Input
data
TYPE I/O-Q
Output
data
Path A :For set and clear bit of port instructions, data goes through path A from output data latch to CPU.
Path B :For input and test instructions, data from output pin go through path B to CPU and the output data latch
will be set to high.
path B
path A
: mask option
Output
data
latch
S
R
Special function
output
Input
data
Power-on
reset
Output
data
* This specification are subject to be changed without notice.