The EM78451 is an 8-bit microprocessor designed and developed with low-power and high speed CMOS
technology. Its operation kernel is implemented with RISC-like architecture. and is available in the mask
ROM version. This device is equipped with the Serial Peripheral Interface (SPI) function and an
easy-implemented RS-232. The EM78451 is very suitable for the wired communication. Only 58
easy-to-learn instructions are needed and the user’s program can be emulated with EMC In-Circuit
Emulator (ICE).
This specification is subject to change without prior notice. 2002/03/01
1
2. FEATURES
• Operating voltage range: 2.3V~5.5V.
• Operating temperature range: 0°C~70°C.
• Operating frequency rang (base on2 clocks ):
* Crystal mode: DC~20MHz at 5V, DC~8MHz at 3V, DC~4MHz at 2.3V.
* RC mode: DC~4MHz at 5V, DC~4MHz at 3V, DC~4MHz at 2.3V.
• Low power consumption:
* Less then 3 mA at 5V/4MHz
EM78451
MASK ROM
* Typically 10 µA during sleep mode
• Serial Peripheral Interface (SPI) available.
• 4K × 13 bits on chip ROM (EM78451).
• 11 special function registers.
• 140× 8 bits on chip general-purposed registers.
• 5 bi-directional I/O ports (35 I/O pins).
• 3 LED direct sinking pins with internal serial resistors.
• Built-in RC oscillator with external serial resistor, ±10% variation.
• Built-in power-on reset.
• Five stacks for subroutine nesting.
• 8-bit real time clock/counter (TCC) with overflow interrupt.
• Two machine clocks or four machine clocks per instruction cycle.
• Power down mode.
• Programmable wake up from sleep circuit on I/O ports.
This specification is subject to change without prior notice. 2002/03/01
2
• Four types of interrupts.
* External interrupt (/INT).
* SPI transmission completed interrupt.
* TCC overflow interrupt.
* Timer1 comparator match interrupt.
EM78451
MASK ROM
This specification is subject to change without prior notice. 2002/03/01
3
3. PIN ASSIGNMENT
driving pin with internal serial resistor is used as output and is
high by software,
* General bi-directional I/O port. All of its pins can be pulled-high * *
EM78451
MASK ROM
VSS
INT
DATA
CLK
P90
P91
SDI/P92
SDO/P93
SCK/P94
SS/P95
P50
P51
P52
P53
P54
P55
P56
P57
P80
P81
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
40
OSCO
39
R-OSCI
38
VDD
37
P70
36
P71
35
P72
34
P67
33
P66
32
P65
31
P64
30
P63
29
EM78451AP/WM
P62
28
P61
27
P60
26
P87
25
P86
24
P85
23
P84
22
P83
21
P82
P91
SDI/P92
SDO/P93
SCK/P94
SS/P95
P50
P51
P52
P53
P54
DATA
INT
CLK
VSS
4443424140393837363534
1
2
3
4
5
6
7
8
9
10
11
EM78451AQ
121314151617181920
P55
P80
P57
P56
OSCO
R-OSCI
NC
P81
VDD
P82
NCNCNC
21
P83
P85
P84
P70
22
P86
Fig. 1 Pin assignment
Table 1 Pin description
Symbol Pin No. Type Function Description
R-OSCI 39 I
* In XTAL mode: Crystal input; In internal C, external R mode: 56K
ohm±5% pull high for 1.8432MHz.
OSCO 40 O * In XTAL mode: Crystal output; In RC mode: Instruction clock output.
* General bi-directional I/O port. All of its pins can be pulled-high by
P90~P95 5~10 I/O
software.
* P90 and P91 are pin-change wake up pins.
* General bi-directional I/O port. All of its pins can be pulled-high by
P80~P87 19~26 I/O
software.
* P80 and P81 are also used as the R-option pins.
P70~P72 37~35 I/O
CLK 4 I/O
* LED directsoftware defined.
* By connecting P74 and P76 together.
* P74 can be pulled-high by software and it is also a pin-change wake up
pin.
* P76 can be defined as an open-drain output.
* By connecting P75 and P77 together.
DATA 3 I/O
* P75 can be pulled-high by software and it is also a pin-change wake up
pin.
* P77 can be defined as an open-drain output.
P60~P67 27~34 I/O
P50~P57 11~18 I/O
* General bi-directional port. All of its pins can be pulled-
and pin-change wake up pins.
33
P71P90
32
P72
31
P67
30
P66
29
P65
28
P64
27
P63
26
P62
25
P61
24
P60
23
P87
This specification is subject to change without prior notice. 2002/03/01
4
Individually by software.
triggered pin. The function of interrupt triggers at the
SDI 7 I/O * Serial data in for SPI
SDO 8 I/O * Serial data out for SPI.
SCK 9 I/O * Serial clock for SPI.
/SS 10 I/O * /Slave select for SPI.
falling edge. Users can enable it by software. The internal pull-up resistor
is around 50K ohm.
EM78451
MASK ROM
This specification is subject to change without prior notice. 2002/03/01
5
4. FUNCTION DESCRIPTION
EM78451
MASK ROM
Oscillator/
Timming
Control
Sleep
&
Wake Up
Control
WDT
Time-out
P
P
5
5
0
1
IOC5
R5
P
P
5
5
2
3
P
5
4
Prescaler
R1(TCC)
P
P
P
5
5
5
5
6
7
WDT Timer
/INT
Interrupt
Control
RAM
R4
IOC6
R6
P
P
P
P
P
P
P
6
0
P
6
6
6
6
6
6
6
1
2
3
4
5
6
7
IOC7
P
7
0
ROM
Instruction
Register
Instruction
Decoder
DATA & CONTROL BUS
R7
P
P
7
7
1
2
Fig. 2 Functional Block Diagram
P C
STACK 1
STACK 2
STACK 3
STACK 4
STACK 5
ALU
ACCR3
TMR1
IOC8
R8
P
P
P
P
P
P
P
8
0
P
8
8
8
8
8
8
8
1
2
3
4
5
6
7
IOC9
R9
P
P
P
P
9
0
P
P
9
9
9
5
9
4
3
2
5
1
/
/
/
/
S
S
S
/
D
C
D
S
O
K
I
S
SPI
ENGIN
4.1 Operational Registers
1. R0 (Indirect Address Register)
R0 is not a physically implemented register. It is used as an indirect addressing pointer. Any
instruction using R0 as register actually accesses data pointed by the RAM Select Register (R4).
2. R1 (TCC)
• Increased by the instruction cycle clock.
• Written and read by program as any other register.
3. R2 (Program Counter) & Stack
• R2 and the hardware stacks are 12 bits wide.
• The structure is depicted in Fig. 3.
This specification is subject to change without prior notice. 2002/03/01
6
EM78451
MASK ROM
• Generates 4K × 13 on-chip ROM addresses to the relative programming instruction codes. One
program page is 1024 words long.
• All the R2 bits are set to "1"s as a RESET condition occurs.
• "JMP" instruction allows direct loading of the lower 10 program counter bits. Thus, "JMP" allows
jump to any location on one page.
• "CALL" instruction loads the lower 10 bits of the PC, and then PC+1 is pushed into the stack. Thus,
the subroutine entry address can be located anywhere within a page.
• "RET" ("RETL k", "RETI") instruction loads the program counter with the contents at the top of stack.
• "MOV R2, A" allows the loading of an address from the "A" register to the lower 8 bits of PC, and the
ninth and tenth bits (A8~A9) of PC are cleared.
• "ADD R2, A" allows a relative address be added to the current PC, and the ninth and tenth bits of PC
are cleared.
• Any instruction that is written to R2 (e.g. "ADD R2, A", "MOV R2, A", "BC R2,6",⋅⋅⋅⋅⋅) (except "TBL")
will cause the ninth and tenth bits (A8~A9) of PC to be cleared. Thus, the computed jump is limited
to the first 256 locations of any program page.
• "TBL" allows a relative address be added to the current PC (R2+A→R2), and contents of the ninth
and tenth bits (A8~A9) of PC are not changed. Thus, the computed jump can be on the second (or
third, 4th) 256 locations on one program page.
• In case of EM78451, the most significant bit (A10,A11) will be loaded with the content of bit PS0
~PS1 in the status register (R3) upon the execution of a "JMP", "CALL", or any other instructions
which write to R2.
• All instructions are single instruction cycle (fclk/2 or fclk/4) except for the instruction that would
change the contents of R2. Such instruction will need one more instruction cycle.
PCA11A10 A9A8 A7 ~ A0
00
01
10
11
000
3FF
400
7FF
800
BFF
C00
FFF
Page 0
Page 1
Page 2
Page 3
CALL
RET
RETL
RETI
001:Hareware interrupt location
002:Software interrupt (INT instruction) location
FFF:Reset location
Stack 1
Stack 2
Stack 3
Stack 4
Stack 5
Fig. 3 Program counter organization
This specification is subject to change without prior notice. 2002/03/01
7
EM78451
MASK ROM
4. R3 (Status Register)
7 6 5 4 3 2 1 0
GP PS1 PS0 T P Z DC C
• Bit 0 (C) Carry flag
• Bit 1 (DC) Auxiliary carry flag
• Bit 2 (Z) Zero flag. Set to "1" if the result of an arithmetic or logic operation is zero.
• Bit 3 (P) Power down bit. Set to 1 during power on or by a "WDTC" command and reset to 0 by a
"SLEP" command.
• Bit 4 (T) Time-out bit. Set to 1 with the "SLEP" and the "WDTC" commands, or during power up and
reset to 0 with WDT timeout.
• Bits 5 (PS0) ~ 6 (PS1) Page select bits. PS0~PS1 are used to pre-select a program memory page.
When executing a "JMP", "CALL", or other instructions which causes the program counter to be
changed (e.g. MOV R2, A), PS0~PS1 are loaded into the 11th and 12th bits of the program counter
where it selects one of the available program memory pages. Note that RET (RETL, RETI)
instruction does not change the PS0~PS1 bits. That is, the return will always be to the page from
where the subroutine was called, regardless of the current setting of PS0~PS1 bits. PS1 bit is not
used (read as "0") and cannot be modified in EM78451.
• SWB7~SWB0 are the 8-bit data that wait for transmission through SPI.
10. RC (SPIS: SPI Status Register)
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
0x0C SPIS/RC
• TM1IF (bit 4):
1 = In timer1 mode, receiving completed, and an interrupt occurs if enabled.
0 = In timer1 mode, receiving not completed yet, and an interrupt does not occur.
• OD3 (bit 3): Open Drain Control bit
1 = Open-Drain enable for SDO,
0 = Open-Drain disable for SDO.
-- -- -- TM1IF OD3 OD4 RBFIF RBF
• OD4 (bit 2): Open-Drain Control bit
1 = Open-Drain enable for SCK,
0 = Open-Drain disable for SCK.
• RBFIF (bit 1): Read Buffer Full Interrupt flag
1 = Receive is finished, SPIRB is fully exchanged, and an interrupt occur if enable.
0 = Receive is not finish yet; SPIRB is not already fully exchanged.
• RBF (bit 0): Read Buffer Full flag
1 = Receiving completed; SPIRB is fully exchanged.
0 = Receiving not completed yet; and SPIRB has not fully exchanged.
11. RD (SPIC: SPI Control Register)
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
0x0D SPIC/RD CES SPIE SRO SSE - SBRS2 SBRS1 SBRS0
• CES (bit 7): Clock Edge Select bit
1 = Data shifts out on falling edge, and shifts in on rising edge. Data is on hold during the high level.
0 = Data shifts out on rising edge, and shifts in on falling edge. Data is on hold during the low level.
• SPIE (bit 6): SPI Enable bit
This specification is subject to change without prior notice. 2002/03/01
10
EM78451
MASK ROM
1= Enable SPI mode
0= Disable SPI mode
• SRO (bit 5): SPI Read Overflow bit
1 = A new data is received while the previous data is still being held in the SPIB register. In this
situation, the data in SPIS register will be destroyed. To avoid setting this bit, users had better read
SPIRB register even if only the transmission is implemented.
0 = No overflow.
<Note>: This can only occur in slave mode.
• SSE (bit 4): SPI Shift Enable bit
1 = Start to shift, and keep on 1 while the current byte is still being transmitted.
0 = Reset as soon as the shifting is complete, and the next byte is ready to shift.
<Note>: This bit will reset to 0 at every one-byte transmission by the hardware
• SBRS (bit 2~bit 0): SPI Baud Rate Select bits
SPI baud rate table is illustrated in the SPI section of this specification.
12. RE (TMR1: Timer1 register)
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
• PWP7~PWP0 is bit set of pulse width preset in advance for the desired baud clock width.
14. R20~R3E (General Purpose Register)
• RA~R1F, and R20~R3E (including Banks 0~3) are general-purpose registers.
15. R3F (Interrupt Status Register)
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
0x3F ISR/R3F - - - - TM1IF SPIIF EXIF TCIF
• Bit 0 (TCIF) TCC timer overflow interrupt flag. Set as TCC overflow; flag cleared by software.
• Bit 1 (EXIF) External interrupt flag. Set by falling edge on /INT pin, flag cleared by software
• Bit 2 (SPIIF) SPI interrupt flag. Set by completion of data transmission, flag cleared by software.
• Bit 3 (TM1IF) Timer1 interrupt flag. Set by the comparator at Timer1 application, flag cleared by
software.
This specification is subject to change without prior notice. 2002/03/01
11
• Bits 2~7 are not used and read as “0”.
• "1" means interrupt request, "0" means non-interrupt.
• R3F can be cleared by instruction, but cannot be set by instruction.
• IOCF is the interrupt mask register.
• Note that to read R3F will result of "logic AND" of R3F and IOCF.
4.2 Special Purpose Registers
1. A (Accumulator)
• Internal data transfer, or instruction operand holding.
• A non-addressable register.
2. CONT (Control Register)
EM78451
MASK ROM
7 6 5 4 3 2 1 0
/PHEN /INT - - PAB PSR2 PSR1 PSR0
• Bit 7 (/PHEN) I/O pin pull-high enable flag.
0: For P60~P67, P74~P75 and P90~P95, the pull-high function is enabled.
1: The pull-high function is disabled.
• Bit 6 (INT) An interrupt enable flag cannot be written by the CONTW instruction.
0: interrupt masked by the DISI instruction.
1: interrupt enabled by the ENI or RETI instruction.
• Bits 0~3, and 7 of the CONT register are readable and writable.
3. IOC5 ~ IOC9 (I/O Port Control Register)
This specification is subject to change without prior notice. 2002/03/01
12
EM78451
MASK ROM
• "1" put the relative I/O pin into high impedance, while "0" put the relative I/O pin as output.
• Both P74 and P76 should not be defined as output pins at the same time, This also applies to both
P75 and P77.
• Only the lower 6 bits of the IOC9 register are used.
4. IOCC (T1CON: Timer1 control register)
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
0x0C T1CON/IOCC 0 0 0 0 0 TM1E TM1P1 TM1P0
• TM1E (bit2): Timer1 Function Enable bit
1 = Enable timer1 function.
0 = Disable timer1 function as default.
• TM1P (bit1~bit0): Timer1 Prescaler bit
Timer1 prescaler table for FOSC will be illustrated in the Section on Timer1 in later pages.
5. IOCD (Pull-high Control Register)
7 6 5 4 3 2 1 0
S7 - - - /PU9 /PU8 /PU6 /PU5
• The default values of /PU5, /PU6, /PU8, and /PU9 are one which means the pull-high function is
disabled.
• /PU6 and /PU9 are “AND” gating with /PHEN, that is, when each one is written as“0,” pull high is
enabled.
• S7 defines the driving ability of the P70-P72.
0: Normal output.
1: Enhance the driving ability of LED.
6. IOCE (WDT Control Register)
7 6 5 4 3 2 1 0
- ODE WDTE SLPC ROC - - /WUE
• Bit 0 (/WUE) Control bit used to enable the wake-up function of P60~P67, P74~P75, and P90~P91.
0: Enable the wake-up function.
1: Disable the wake-up function.
The /WUE bit can be read and written.
• Bit 3 (ROC) ROC is used for the R-option. Setting ROC to "1" will enable the status of R-option pins
(P80, P81) to be read by the controller. Clearing ROC will disable the R-option function. Otherwise,
the R-option function is introduced. Users must connect the P81 pin or/and P80 pin to VSS by a
This specification is subject to change without prior notice. 2002/03/01
13
EM78451
MASK ROM
560KΩ external resistor (Rex). If Rex is connected/disconnected with VDD, the status of P80 (P81)
will be read as "0"/"1" (refer to Fig. 7(b)). The ROC bit can be read and written.
• Bit 4 (SLPC) This bit is set by hardware at the falling edge of wake-up signal and is cleared in
software. SLPC is used to control the oscillator operation. The oscillator is disabled (oscillator is
stopped, and the controller enters the SLEEP2 mode) on the high-to-low transition and is enabled
(the controller is awakened from SLEEP2 mode) on low-to-high transition. In order to ensure the
stable output of the oscillator, once the oscillator is enabled again, there is a delay for approximately
18 ms (oscillator start-up timer (OST)) before the next program instruction is executed. The OST is
always activated by wake-up from sleep mode whether the Code Option bit ENWDT is "0" or not.
After waking up, the WDT is enabled if Code Option ENWDT is "1". The block diagram of SLEEP2
mode and wake-up caused by input triggered is depicted in Fig. 5. The SLPC bit can be read and
written.
• Bit 5 (WDTE) Control bit used to enable Watchdog timer.
The WDTE bit can be used only if ENWDT, the CODE Option bit, is "1". If the ENWDT bit is "1", then
WDT can be disabled/enabled by the WDTE bit.
0: Disable WDT.
1: Enable WDT.
The WDTE bit is not used if ENWDT, the CODE Option bit ENWDT, is "0". That is, if the ENWDT bit
is "0", WDT is always disabled no matter what the WDTE bit is.
The WDTE bit can be read and written.
• Bit 6 (ODE) Open-drain control bit.
0: Both P76 and P77 are normally I/O pins.
1: Both P76 and P77 pins have the open-drain function inside.
The ODE bit can be read and written.