SYNCMOS SM59R09A5L25

SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
FOSVOS TEL: 021-58998693
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Description .......................................................................................................................................................................... 3
Features .............................................................................................................................................................................. 3
Pin Configuration ................................................................................................................................................................ 4
Block Diagram..................................................................................................................................................................... 8
Pin Description .................................................................................................................................................................... 9
Special Function Register (SFR) ...................................................................................................................................... 11
Function Description ......................................................................................................................................................... 15
1.
General Features ..................................................................................................................................................... 15
1.1.
Embedded Flash ......................................................................................................................................... 15
1.2.
IO Pads ....................................................................................................................................................... 15
1.3.
2T/1T Selection ........................................................................................................................................... 15
1.4.
RESET ........................................................................................................................................................ 16
1.4.1.
Hardware RESET function ............................................................................................................. 16
1.4.2.
Software RESET function .............................................................................................................. 16
1.4.3.
Time Access Key register (TAKEY)................................................................................................ 16
1.4.4.
Software Reset register (SWRES) ................................................................................................. 16
1.4.5.
Example of software reset ............................................................................................................. 17
1.5.
Clocks ......................................................................................................................................................... 17
2.
Instruction Set .......................................................................................................................................................... 18
3.
Memory Structure ..................................................................................................................................................... 22
3.1.
Program Memory ........................................................................................................................................ 22
3.2.
Data Memory............................................................................................................................................... 24
3.2.1.
Data memory - lower 128 byte (00h to 7Fh) .................................................................................. 24
3.2.2.
Data memory - higher 128 byte (80h to FFh) ................................................................................ 25
3.2.3.
Data memory - Expanded 2048 bytes ($0000 to $07FF) .............................................................. 25
4.
CPU Engine ............................................................................................................................................................. 26
4.1.
Accumulator ................................................................................................................................................ 26
4.2.
B Register ................................................................................................................................................... 26
4.3.
Program Status Word .................................................................................................................................. 27
4.4.
Stack Pointer ............................................................................................................................................... 27
4.5.
Data Pointer ................................................................................................................................................ 27
4.6.
Data Pointer 1 ............................................................................................................................................. 28
4.7.
Internal RAM control register ...................................................................................................................... 28
4.8.
Interface control register ............................................................................................................................. 28
5.
GPIO ........................................................................................................................................................................ 30
6.
Multiplication Division Unit (MDU) ............................................................................................................................ 32
6.1.
Operating registers of the MDU .................................................................................................................. 32
6.2.
Operation of the MDU ................................................................................................................................. 33
6.2.1.
First phase: loading the MDx registers, x = 0~5: ........................................................................... 33
6.2.2.
Second phase: executing calculation. ........................................................................................... 33
6.2.3.
Third phase: reading the result from the MDx registers. ............................................................... 34
6.3.
Normalizing ................................................................................................................................................. 34
6.4.
Shifting ........................................................................................................................................................ 34
7.
Timer 0 and Timer 1 ................................................................................................................................................. 35
7.1.
Timer/counter mode control register (TMOD) ............................................................................................. 35
7.2.
Timer/counter control register (TCON) ....................................................................................................... 36
8.
Timer 2 and Capture/Compare Unit ......................................................................................................................... 37
8.1.
Timer 2 function........................................................................................................................................... 39
8.1.1.
Timer mode .................................................................................................................................... 39
8.1.2.
Event counter mode ....................................................................................................................... 39
8.1.3.
Gated timer mode .......................................................................................................................... 39
8.1.4.
Reload of Timer 2 ........................................................................................................................... 39
8.2.
Compare function ........................................................................................................................................ 39
8.2.1.
Compare Mode 0 ........................................................................................................................... 40
8.2.2.
Compare Mode 1 ........................................................................................................................... 40
8.3.
Capture function .......................................................................................................................................... 41
8.3.1.
Capture Mode 0 ............................................................................................................................. 41
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
1
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
8.3.2.
Capture Mode 1 ............................................................................................................................. 41
Serial interface 0 and 1 ............................................................................................................................................ 42
9.1.
Serial interface 0 ......................................................................................................................................... 43
9.1.1.
Mode 0 ........................................................................................................................................... 43
9.1.2.
Mode 1 ........................................................................................................................................... 44
9.1.3.
Mode 2 ........................................................................................................................................... 44
9.1.4.
Mode 3 ........................................................................................................................................... 45
9.2.
Serial interface 1 ......................................................................................................................................... 45
9.2.1.
Mode A ........................................................................................................................................... 45
9.2.2.
Mode B ........................................................................................................................................... 46
9.3.
Multiprocessor communication of Serial Interface 0 and 1 ......................................................................... 46
9.4.
Baud rate generator .................................................................................................................................... 46
9.4.1.
Serial interface 0 modes 1 and 3 ................................................................................................... 46
9.4.2.
Serial interface 1 modes A and B ................................................................................................... 47
9.5.
Clock source for baud rate .......................................................................................................................... 47
10.
Watchdog timer ............................................................................................................................................... 48
11.
Interrupt ........................................................................................................................................................... 51
12.
Power Management Unit ................................................................................................................................. 56
12.1.
Idle mode ................................................................................................................................................ 56
12.2.
Stop mode ............................................................................................................................................... 56
13.
Pulse Width Modulation (PWM) ...................................................................................................................... 57
14.
IIC function ...................................................................................................................................................... 60
15.
SPI function ..................................................................................................................................................... 64
16.
KBI – Keyboard Interface ................................................................................................................................ 68
17.
LVI – Low Voltage Interrupt ............................................................................................................................. 71
18.
10-bit Analog-to-Digital Converter (ADC) ........................................................................................................ 72
19.
In-System Programming (Internal ISP) ........................................................................................................... 75
19.1.
ISP service program ............................................................................................................................... 75
19.2.
Lock Bit (N) ............................................................................................................................................. 75
19.3.
Program the ISP Service Program ......................................................................................................... 76
19.4.
Initiate ISP Service Program................................................................................................................... 76
19.5.
ISP register – TAKEY, IFCON, ISPFAH, ISPFAL, ISPFD and ISPFC .................................................... 76
20.
RTC(Real Time Clock) function ....................................................................................................................... 79
21.
OPA/Comparator ............................................................................................................................................. 83
Operating Conditions ........................................................................................................................................................ 86
DC Characteristics ............................................................................................................................................................ 86
OPA / Comparator Characteristics .................................................................................................................................... 88
9.
FOSVOS TEL: 021-58998693
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
2
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Production List
Features
SM59R16A5L25, SM59R16A5C25
SM59R09A5L25, SM59R09A5C25
SM59R05A5L25, SM59R05A5C25
Description
The SM59R16A5 is a 1T (one machine cycle per clock)
single-chip 8-bit microcontroller. It has 64K-byte
embedded Flash for program, and executes all ASM51
instructions fully compatible with MCS-51.
SM59R16A5 contains 2KB on-chip RAM, more than 46
GPIOs (LQFP-48 package type), various serial interfaces
and many peripheral functions as described below. It can
be programmed via writers. Its on-chip ICE is convenient
for users in verification during development stage.
The high performance of SM59R16A5 can achieve
complicated manipulation within short time. About one
third of the instructions are pure 1T, and the average
speed is 8 times of traditional 8051, the fastest one
among all the 1T 51-series.Its excellent EMI and ESD
characteristics are advantageous for many different
applications.
Ordering Information
SM59R16A5ihhkL yymmv
i: process identifier {L = 2.7V ~ 3.6V, C = 4.5V ~ 5.5V}
hh: working clock in MHz {25}
k: package type postfix {as table below }
L:PB Free identifier
{No text is Non-PB free,”P” is PB free}
yy: year
mm: month
v: version identifier{ A, B,…}
Postfix
P
J
Q
V
Package
40L PDIP
44L PLCC
44L PQFP
48L LQFP
Pin / Pad Configuration
Page 4
Page 5
Page 6
Page 7





























FOSVOS TEL: 021-58998693
Operating Voltage: 4.5V ~ 5.5V or 2.7V ~ 3.6V
High speed architecture of 1 clock/machine cycle
(1T), runs up to 25MHz
1T/2T modes are software programmable on the fly
Instruction-set compatible with MCS-51
64K/36K/20KBytes on-chip flash program memory.
External RAM addresses up to 64K bytes.
Standard 12T interface for external RAM access.
256 bytes RAM as standard 8052, plus 2K bytes
on-chip expandable RAM
Dual 16-bit Data Pointers (DPTR0 & DPTR1)
Two serial peripheral interfaces in full duplex mode
(UART0 & UART1),
Additional Baud Rate Generator for Serial 0.
Three 16-bit Timers/Counters. (Timer 0 , 1, 2)
38 GPIOs(PDIP 40),42 GPIOs(PLCC 44/PQFP
44),46 GPIOs(LQFP 48),GPIOs can select four
Type(quasi-bidirectional、push-pull、open drain、
input-only),default is quasi-bidirectional(pull-up)
External interrupt 0,1 with four priority levels
Programmable watchdog timer (WDT)
One IIC interface (Master/Slave mode)
One SPI interface (Master/Slave mode)
4-channel PWM on port 2 or port 4 (default)
4-channel 16-bit compare /capture /load functions
8-channel 10-bit analog-to-digital converter (ADC)
On-Chip OPA/Comparator
Real Time Clock with individual 32K crystal oscillator
On–chip flash memories support ISP/IAP/ICP and
EEPROM functions.
ISP service program space configurable in N*256 byte
(N=0 to 16) size.
On-chip in-circuit emulator (ICE) function with
On-Chip Debugger(OCD)
EMI reduction mode (ALE output inhibited).
Fast multiplication-division unit (MDU) : 16*16,
32/16, 16/16, 32-bit L/R shifting and 32-bit
normalization
Keyboard interface (KBI) on port 0 or port 2 (default)
for eight more interrupts.
LVI/LVR
Enhanced user code protection
Power management unit for idle and power down
modes
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
3
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Pin Configuration
1
40
VDD
CC1/T2EX/ADC1/P1.1
2
39
P0.0/AD0/KBI0
RXD1/ADC2/P1.2
3
38
P0.1/AD1/KBI1
CC2/TXD1/ADC3/P1.3
4
37
P0.2/AD2/KBI2
CC3/SS/ADC4/P1.4
5
36
P0.3/AD3/KBI3
MOSI/ADC5/P1.5
6
35
P0.4/AD4/KBI4
IIC_SCL/MISO/ADC6/P1.6
7
34
P0.5/AD5/KBI5
IIC_SDA/SPI_CLK/ADC7/P1.7
8
33
P0.6/AD6/KBI6
P4.7/RESET(default)
9
32
P0.7/AD7/KBI7
RXD0/P3.0
10
31
OCI_SDA/P4.6
TXD0/P3.1
11
30
ALE/P4.5
INT0/P3.2
12
29
OCI_SCL/P4.4
INT1/P3.3
13
28
P2.7/A15/KBI7/Op0Out/PWM3
T0/P3.4
14
27
P2.6/A14/KBI6/Op0PIn/PWM2
T1/P3.5
15
26
P2.5/A13/KBI5/Op0NIn/PWM1
X32OUT/WR/P3.6
16
25
P2.4/A12/KBI4/Op1PIn/PWM0
X32IN/RD/P3.7
17
24
P2.3/A11/KBI3/Op1NIn/CC3
X32OUT/P5.4/XTAL2
18
23
P2.2/A10/KBI2/Op1Out/CC2
X32IN/P5.5/XTAL1
19
22
P2.1/A9/KBI1/CC1
VSS
20
21
P2.0/A8/KBI0/CC0
SyncMOS
yymmv
(40L PDIP Top View)
SM59R16A5ihhPP
CC0/T2/ADC0/P1.0
Notes:
1. The pin Reset/P4.7 factory default is Reset, user must keep this pin at low during power-up. User can configure it to
GPIO (P4.7) by a flash programmer.
2. To avoid accidentally entering ISP-Mode(refer to section 16.4), care must be taken not asserting pulse signal at P3.0
during power-up while P2.6、P2.7、P4.3 are set to high.
3. To apply ICP function, OSI_SDA/P4.6 and OCI_SCL/P4.7 must be set to Bi-direction mode if they are configured as
GPIO in system.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
4
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
22
23
24
25
26
27
28
SS/IIC_SCL/CC0/PWM0/P4.0
CC0/KBI0/A8/P2.0
CC1/KBI1/A9/P2.1
CC2/Op1Out/KBI2/A10/P2.2
CC3/Op1NIn/KBI3/A11/P2.3
PWM0/Op1PIn/KBI4/A12/P2.4
39
P0.3/AD3/KBI3
21
38
P0.2/AD2/KBI2
20
37
P0.1/AD1/KBI1
19
36
P0.0/AD0/KBI0
18
P0.6/AD6/KBI6
P0.7/AD7/KBI7
35
VDD
SM59R16A5
ihhJP
yymmv
(44L PLCC Top View)
P0.5/AD5/KBI5
OCI_SDA/P4.6
34
11
10
9
8
SyncMOS
P0.4/AD4/KBI4
P4.1/PWM1/CC1/IIC_SDA/MOSI
33
P4.2/PWM2/CC2/RXD1/MISO
40
ALE/P4.5
32
P1.0/ADC0/T2/CC0
41
OCI_SCL/P4.4
31
P1.1/ADC1/T2EX/CC1
42
P2.7/A15/KBI7/Op0Out/PWM3
30
P1.2/ADC2/RXD1
43
P2.6/A14/KBI6/Op0PIn/PWM2
29
P1.3/ADC3/TXD1/CC2
44
7
1
VSS
T1/P3.5
2
X32IN/P5.5/XTAL1
T0/P3.4
3
X32OUT/P5.4/XTAL2
INT1/P3.3
4
X32IN/RD/P3.7
INT0/P3.2
5
X32OUT/WR/P3.6
TXD0/P3.1
12
SPI_CLK/TXD1/CC3/PWM3/P4.3
13
RXD0/P3.0
14
P4.7/RESET(default)
15
IIC_SDA/SPI_CLK/ADC7/P1.7
16
IIC_SCL/MISO/ADC6/P1.6
6
17
MOSI/ADC5/P1.5
P1.4/ADC4/SS/CC3
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
P2.5/A13/KBI5/Op0NIn/PWM1
FOSVOS TEL: 021-58998693
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
5
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
P0.4/AD4/KBI4
P0.5/AD5/KBI5
P0.6/AD6/KBI6
P0.7/AD7/KBI7
OCI_SDA/P4.6
P4.1/PWM1/CC1/IIC_SDA/MOSI
ALE/P4.5
OCI_SCL/P4.4
P2.7/A15/KBI7/Op0Out/PWM3
P2.6/A14/KBI6/Op0PIn/PWM2
P2.5/A13/KBI5/Op0NIn/PWM1
32
31
30
29
28
27
26
25
24
23
11
T1/P3.5
CC3/SS/ADC4/P1.4
44
(44L PQFP/LQFP Top
View)
10
43
T0/P3.4
CC2/TXD1/ADC3/P1.3
9
42
INT1/P3.3
RXD1/ADC2/P1.2
8
41
INT0/P3.2
CC1/T2EX/ADC1/P1.1
7
40
TXD0/P3.1
CC0/T2/ADC0/P1.0
SPI_CLK/TXD1/CC3/PWM3/P4.3
39
6
MISO/RXD1/CC2/PWM2/P4.2
SM59R16A5
ihhQ(U)P
yymmv
5
38
RXD0/P3.0
VDD
4
37
P4.7/RESET(default)
KBI0/AD0/P0.0
SyncMOS
3
36
IIC_SDA/SPI_CLK/ADC7/P1.7
KBI1/AD1/P0.1
2
35
IIC_SCL/MISO/ADC6/P1.6
KBI2/AD2/P0.2
1
34
MOSI/ADC5/P1.5
KBI3/AD3/P0.3
33
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
22
P2.4/A12/KBI4/Op1PIn/PWM0
21
P2.3/A11/KBI3/Op1NIn/CC3
20
P2.2/A10/KBI2/Op1Out/CC2
19
P2.1/A9/KBI1/CC1
18
P2.0/A8/KBI0/CC0
17
P4.0/PWM0/CC0/IIC_SCL/SS
16
VSS
15
XTAL1/X32IN/P5.5
14
XTAL2/X32OUT/P5.4
13
P3.7/RD/X32IN
12
P3.6/WR/X32OUT
FOSVOS TEL: 021-58998693
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
6
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
P0.4/AD4/KBI4
P0.5/AD5/KBI5
P0.6/AD6/KBI6
P0.7/AD7/KBI7
OCI_SDA/P4.6
P4.1/PWM1/CC1/IIC_SDA/MOSI
ALE/P4.5
OCI_SCL/P4.4
P2.7/A15/KBI7/Op0Out/PWM3
P2.6/A14/KBI6/Op0PIn/PWM2
P2.5/A13/KBI5/Op0NIn/PWM1
P5.1
35
34
33
32
31
30
29
28
27
26
25
11
12
T0/P3.4
T1/P3.5
48
10
P5.2
INT1/P3.3
47
9
CC3/SS/ADC4/P1.4
INT0/P3.2
46
8
CC2/TXD1/ADC3/P1.3
TXD0/P3.1
45
7
RXD1/ADC2/P1.2
SPI_CLK/TXD1/CC3/PWM3/P4.3
44
RXD0/P3.0
CC1/T2EX/ADC1/P1.1
6
43
P4.7/RESET(default)
CC0/T2/ADC0/P1.0
5
42
IIC_SDA/SPI_CLK/ADC7/P1.7
MISO/RXD1/CC2/PWM2/P4.2
SM59R16A5
IhhVP
yymmv
(48L LQFP Top View)
4
VDD
41
SyncMOS
3
KBI0/AD0/P0.0
40
IIC_SCL/MISO/ADC6/P1.6
KBI1/AD1/P0.1
39
2
38
MOSI/ADC5/P1.5
KBI2/AD2/P0.2
1
37
P5.3
KBI3/AD3/P0.3
36
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
24
P5.0
23
P2.4/A12/KBI4/Op1PIn/PWM0
22
P2.3/A11/KBI3/Op1NIn/CC3
21
P2.2/A10/KBI2/Op1Out/CC2
20
P2.1/A9/KBI1/CC1
19
P2.0/A8/KBI0/CC0
18
P4.0/PWM0/CC0/IIC_SCL/SS
17
VSS
16
XTAL1/X32IN/P5.5
15
XTAL2/X32OUT/P5.4
14
P3.7/RD/X32IN
13
P3.6/WR/X32OUT
FOSVOS TEL: 021-58998693
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
7
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
XTAL2
XTAL1
ADC0
ADC1
ADC2
ADC3
ADC4
ADC5
ADC6
ADC7
IIC_SCL
IIC_SDA
SPI_MISO
SPI_MOSI
SPI_CLK
SPI_SS
X32IN
X32OUT
UART
0/1
PWM0
PWM1
PWM2
PWM3
MAX810
Op0PIn/Op1PIn
Op0NIn/Op1NIn
Op0Out/Op1Out
RESET
TXD0/1
RXD0/1
Block Diagram
Op0/Cmp0
Op1/Cmp1
PWM
ADC
IIC
SPI
RTC
SRAM
2KBytes
CPU
SRAM
256Bytes
Flash 64KBytes
MDU
Watchdog
Port 0
Port 0
Port 1
Port 1
Port 2
Port 2
Port 3
Port 3
Port 4
Port 4
Port 5
Port 5
Timer 0/1
T0
T1
Interrupt
ALE
WR
RD
ICE
ICP
CC0~CC3
T2
T2EX
OCI_SDA
OCI_SCL
Interface control
Timer2
& CCU
FOSVOS TEL: 021-58998693
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
8
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Pin Description
40L
PDIP
44L
PLCC
44L
PQFP
48L
LQFP
Symbol
I/O
1
39
42
P4.2/PWM2/CC2/
RXD1/MISO
I/O
1
2
40
43
2
3
41
44
3
4
42
45
P1.2/ADC2/RXD1
I/O
4
5
43
46
P1.3/ADC3/TXD1/
CC2
I/O
5
6
44
47
P1.0/ADC0/T2/C
C0
P1.1/ADC1/T2EX/
CC1
I/O
I/O
48
1
P1.4/ADC4/SS/C
C3
P5.2
P5.3
I/O
I/O
P1.5/ADC5/MOSI
I/O
I/O
6
7
1
2
7
8
2
3
8
9
3
4
9
10
4
5
10
11
5
6
P3.0/RXD0
I/O
12
6
7
P4.3/PWM3/CC3/
TXD1/SPI_CLK
I/O
11
13
7
8
P3.1/TXD0
I/O
12
13
14
15
14
15
16
17
8
9
10
11
9
10
11
12
I/O
I/O
I/O
I/O
16
18
12
13
P3.2/#INT0
P3.3/#INT1
P3.4/T0
P3.5/T1
P3.6/#WR/X32OU
T
17
19
13
14
P3.7/#RD/X32IN
I/O
P1.6/ADC6/MISO/
IIC_SCL
P1.7/ADC7/SPI_
CLK/IIC_SDA
RESET(default)/P
4.7
XTAL2/X32OUT/P
5.4
XTAL1/X32IN/P5.
19
21
15
16
5
20
22
16
17
VSS
P4.0/PWM0/CC0/
23
17
18
IIC_SCL/SS
P2.0
21
24
18
19
/A8/KBI0/CC0
Specifications subject to change without notice contact
ISSFD-M047
18
20
14
15
I/O
I/O
I/O
I/O
Description
Bit 2 of port 4 & PWM Channel 2 & Timer 2 compare/capture
Channel 2 & Serial interface channel 1 receive data & SPI
interface Serial Data Master Input or Slave Output pin
Bit 0 of port 1 & ADC input channel 0 & Timer 2 external
input clock & Timer 2 compare/capture Channel 0
Bit 1 of port 1 & ADC input channel 1 & Timer 2 capture
trigger & Timer 2 compare/capture Channel 1
Bit 2 of port 1 & ADC input channel 2 & Serial interface
channel 1 receive data
Bit 3 of port 1 & ADC input channel 3 & Serial interface
channel 1 transmit data or receive clock in mode 0 & Timer 2
compare/capture Channel 2
Bit 4 of port 1 & ADC input channel 4 & SPI interface Slave
Select pin & Timer 2 compare/capture Channel 3
Bit 2 of port 5
Bit 3 of port 5
Bit 5 of port 1 & ADC input channel 5 & SPI interface Serial
Data Master Output or Slave Input pin
Bit 6 of port 1 & ADC input channel 6 & SPI interface Serial
Data Master Input or Slave Output pin & IIC SCL pin
Bit 7 of port 1 & ADC input channel 7 & SPI interface Clock
pin & IIC SDA pin
Reset pin(default)& Bit 7 of port 4
Bit 0 of port 3 & Serial interface channel 0 receive/transmit
data
Bit 3 of port 4 & PWM Channel 3 & Timer 2 compare/capture
Channel 3 & Serial interface channel 1 transmit data or
receive clock in mode 0 & SPI interface Clock pin
Bit 1 of port 3 & Serial interface channel 0 transmit data or
receive clock in mode 0
Bit 2 of port 3 & External interrupt 0
Bit 3 of port 3 & External interrupt 1
Bit 4 of port 3 & Timer 0 external input
Bit 5 of port 3 & Timer 1 external input
Bit 6 of port 3 & external memory write signal & 32KHz
crystal output
Bit 7 of port 3 & external memory read signal & 32KHz
crystal input
O
Crystal output & 32KHz crystal output & bit4 of port 5
I
Crystal input & 32KHz crystal input & bit5 of port 5
I
Power supply
Bit 0 of port 4 & PWM Channel 0 & Timer 2 compare/capture
I/O
Channel 0 & IIC SCL pin & SPI interface Slave Select pin
Bit 0 of port 2 & Bit 8 of external memory address & KBI
I/O
interrupt 0 & Timer 2 compare/capture Channel 0
your sales representatives for the most recent information.
9
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
40L
PDIP
44L
PLCC
44L
PQFP
48L
LQFP
22
25
19
20
P2.1
/A9/KBI1/CC1
I/O
23
26
20
21
P2.2/A10/KBI2/O
p1Out/CC2
I/O
24
27
21
22
P2.3/A11/KBI3/Op
1NIn/CC3
I/O
25
28
22
23
24
25
Symbol
P2.4/A12/KBI4/O
p1Pin/PWM0
P5.0
P5.1
P2.5/A13/KBI5/O
p0NIn/PWM1
P2.6/A14/KBI6/O
p0Pin/PWM2
P2.7/A15/KBI7/O
p0Out/PWM3
I/O
I/O
I/O
I/O
26
29
23
26
27
30
24
27
28
31
25
28
29
32
26
29
OCI_SCL/P4.4
I/O
30
33
27
30
ALE/P4.5
I/O
34
28
31
P4.1/PWM1/CC1/
IIC_SDA/MOSI
I/O
31
35
29
32
OCI_SDA/P4.6
I/O
32
36
30
33
P0.7/AD7/KBI7
I/O
33
37
31
34
P0.6/AD6/KBI6
I/O
34
38
32
35
P0.5/AD5/KBI5
I/O
35
39
33
36
P0.4/AD4/KBI4
I/O
36
40
34
37
P0.3/AD3/KBI3
I/O
37
41
35
38
P0.2/AD2/KBI2
I/O
38
42
36
39
P0.1/AD1/KBI1
I/O
39
43
37
40
P0.0/AD0/KBI0
I/O
40
44
38
41
VDD
I/O
I/O
I/O
I
Description
Bit 1 of port 2 & Bit 9 of external memory address & KBI
interrupt 1 & Timer 2 compare/capture Channel 1
Bit 2 of port 2 & Bit 10 of external memory address & KBI
interrupt 2 & Op1 output & Timer 2 compare/capture
Channel 2
Bit 3 of port 2 & Bit 11 of external memory address & KBI
interrupt 3 & Op1 Negative Input & Timer 2 compare/capture
Channel 3
Bit 4 of port 2 & Bit 12 of external memory address & KBI
interrupt 4 & Op1 Positive Input & PWM Channel 0
Bit 0 of port 5
Bit 1 of port 5
Bit 5 of port 2 & Bit 13 of external memory address & KBI
interrupt 5 & Op0 Negative Input & PWM Channel 1
Bit 6 of port 2 & Bit 14 of external memory address & KBI
interrupt 6 & Op0 Positive Input & PWM Channel 2
Bit 7 of port 2 & Bit 15 of external memory address & KBI
interrupt 7 & Op0 Output & PWM Channel 3
On-Chip Instrumentation Clock I/O pin of ICE and ICP
functions & Bit 4 of port 4
Address latch enable & Bit 5 of port 4
Bit 1 of port 4 & PWM Channel 1 & Timer 2 compare/capture
Channel 1 & IIC SDA pin & SPI interface Serial Data Master
Output or Slave Input pin
On-Chip Instrumentation Command and data I/O pin
synchronous to OCI_SCL in ICE and ICP functions & Bit 6 of
port 4
Bit 7 of port 0 & Bit 7 of external memory address/ data &
KBI interrupt 7
Bit 6 of port 0 & Bit 6 of external memory address/ data &
KBI interrupt 6
Bit 5 of port 0 & Bit 5 of external memory address/ data &
KBI interrupt 5
Bit 4 of port 0 & Bit 4 of external memory address/ data &
KBI interrupt 4
Bit 3 of port 0 & Bit 3 of external memory address/ data &
KBI interrupt 3
Bit 2 of port 0 & Bit 2 of external memory address/ data &
KBI interrupt 2
Bit 1 of port 0 & Bit 1 of external memory address/ data &
KBI interrupt 1
Bit 0 of port 0 & Bit 0 of external memory address/ data &
KBI interrupt 0
Power supply
FOSVOS TEL: 021-58998693
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
10
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Special Function Register (SFR)
A map of the Special Function Registers is shown as below:
Hex\Bin
X000
X001
X010
X011
X100
X101
X110
Cmp0CO
N
OpPin
X111
Cmp1CO
N
TAKEY
Bin/Hex
F8
IICS
IICCTL
IICA1
IICA2
IICRWD
IICS2
F0
B
SPIC1
SPIC2
SPITXD
SPIRXD
SPIS
E8
E0
P4
ACC
MD0
ISPFAH
MD1
ISPFAL
MD2
ISPFD
MD3
ISPFC
MD4
MD5
LVC
ARCON
SWRES
EF
E7
D8
P5
P3M0
P3M1
P4M0
P4M1
P5M0
P5M1
DF
D0
PSW
CCEN2
P0M0
P0M1
P1M0
P1M1
P2M0
P2M1
D7
C8
C0
T2CON
IRCON
CCCON
CCEN
CRCL
CCL1
CRCH
CCH1
TL2
CCL2
TH2
CCH2
B8
IEN1
IP1
S0RELH
S1RELH
PWMD0H
B0
P3
PWMD2H
PWMD2L
PWMD3H
PWMD3L
PWMC
A8
A0
IEN0
P2
IP0
S0RELL
ADCC1
ADCC2
ADCDH
98
S0CON
S0BUF
IEN2
S1CON
S1BUF
S1RELL
90
P1
AUX
AUX2
KBLS
KBE
88
80
Hex\Bin
TCON
P0
X000
TMOD
SP
X001
TL0
DPL
X010
TL1
DPH
X011
TH0
DPL1
X100
PWMMDH PWMMDL
CCL3
CCH3
FF
F7
CF
C7
PWMD1L
BF
WDTC
WDTK
B7
ADCDL
ADCCS
KBF
RTCADD
R
KBD
RTCDAT
A
IRCON2
AF
A7
TH1
DPH1
X101
RCON
X110
IFCON
PCON
X111
PWMD0L PWMD1H
9F
97
8F
87
Bin/Hex
Note: Special Function Registers reset values and description for SM59R16A5
Register
Location
P0
SP
80h
81h
Reset
value
FFh
07h
DPL
DPH
DPL1
DPH1
82h
83h
84h
85h
00h
00h
00h
00h
Data Pointer 0 low byte
Data Pointer 0 high byte
Data Pointer 1 low byte
Data Pointer 1 high byte
RCON
PCON
TCON
TMOD
86h
87h
88h
89h
00h
40h
00h
00h
Internal RAM control register
Power Control
Timer/Counter Control
Timer Mode Control
TL0
TL1
TH0
TH1
IFCON
8Ah
8Bh
8Ch
8Dh
8Fh
00h
00h
00h
00h
00h
Timer 0, low byte
Timer 1, low byte
Timer 0, high byte
Timer 1, high byte
Interface control register
Description
Port 0
Stack Pointer
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
11
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
P1
90h
Reset
value
FFh
AUX
91h
00h
Auxiliary register
AUX2
92h
00h
Auxiliary register 2
KBLS
93h
00h
Keyboard level selector Register
KBE
94h
00h
Keyboard input enable Register
KBF
95h
00h
Keyboard interrupt flag Register
KBD
96h
00h
Keyboard interface De-bounce control register
IRCON2
97h
00h
Interrupt Request Control Register 2
S0CON
98h
00h
Serial Port 0, Control Register
S0BUF
99h
00h
Serial Port 0, Data Buffer
IEN2
9Ah
00h
Interrupt Enable Register 2
S1CON
9Bh
00h
Serial Port 1, Control Register
Register
Location
Description
Port 1
S1BUF
9Ch
00h
Serial Port 1, Data Buffer
S1RELL
9Dh
00h
Serial Port 1, Reload Register, low byte
RTCADDR
9Eh
00h
RTC Addr Register
RTCDATA
9Fh
00h
RTC Data Register
P2
A0h
FFh
Port 2
IEN0
A8h
00h
Interrupt Enable Register 0
IP0
A9h
00h
Interrupt Priority Register 0
S0RELL
AAh
00h
Serial Port 0, Reload Register, low byte
ADCC1
ABh
00h
ADC Control 1 Register
ADCC2
ACh
00h
ADC Control 2 Register
ADCDH
ADh
00h
ADC data high byte
ADCDL
AEh
00h
ADC data low byte
ADCCS
AFh
00h
ADC clock select
P3
B0h
FFh
Port 3
PWMD2H
B1h
00h
PWM channel 2 data high byte
PWMD2L
B2h
00h
PWM channel 2 data low byte
PWMD3H
B3h
00h
PWM channel 3 data high byte
PWMD3L
B4h
00h
PWM channel 3 data low byte
PWMC
B5h
00h
PWM control register
WDTC
B6h
04h
Watchdog timer control register
WDTK
B7h
00h
Watchdog timer refresh key.
IEN1
B8h
00h
Interrupt Enable Register 1
IP1
B9h
00h
Interrupt Priority Register 1
S0RELH
BAh
00h
Serial Port 0, Reload Register, high byte
S1RELH
BBh
00h
Serial Port 1, Reload Register, high byte
PWMD0H
BCh
00h
PWM channel 0 data high byte
PWMD0L
BDh
00h
PWM channel 0 data low byte
PWMD1H
BEh
00h
PWM channel 1 data high byte
PWMD1L
BFh
00h
PWM channel 1 data low byte
IRCON
C0h
00h
Interrupt Request Control Register
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
12
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Register
Location
CCEN
C1h
Reset
value
00h
CCL1
C2h
00h
Compare/Capture Register 1, low byte
CCH1
C3h
00h
Compare/Capture Register 1, high byte
CCL2
C4h
00h
Compare/Capture Register 2, low byte
CCH2
C5h
00h
Compare/Capture Register 2, high byte
CCL3
C6h
00h
Compare/Capture Register 3, low byte
CCH3
C7h
00h
Compare/Capture Register 3, high byte
T2CON
C8h
00h
Timer 2 Control
Description
Compare/Capture Enable Register
CCCON
C9h
00h
Compare/Capture Control
CRCL
CAh
00h
Compare/Reload/Capture Register, low byte
CRCH
CBh
00h
Compare/Reload/Capture Register, high byte
TL2
CCh
00h
Timer 2, low byte
TH2
CDh
00h
Timer 2, high byte
PWMMDH
CEh
00h
PWM Max Data Register, high byte.
PWMMDL
CFh
FFh
PWM Max Data Register, low byte.
PSW
D0h
00h
Program Status Word
CCEN2
D1h
00h
Compare/Capture Enable 2 register
P0M0
D2h
00h
Port 0 output mode 0
P0M1
D3h
00h
Port 0 output mode 1
P1M0
D4h
00h
Port 1 output mode 0
P1M1
D5h
00h
Port 1 output mode 1
P2M0
D6h
00h
Port 2 output mode 0
P2M1
D7h
00h
Port 2 output mode 1
P5
P3M0
P3M1
D8h
DAh
DBh
3Fh
00h
00h
Port 5
Port 3 output mode 0
Port 3 output mode 1
P4M0
DCh
00h
Port 4 output mode 0
P4M1
DDh
00h
Port 4 output mode 1
P5M0
DEh
00h
Port 5 output mode 0
P5M1
DFh
00h
Port 5 output mode 1
ACC
E0h
00h
Accumulator
ISPFAH
E1h
FFh
ISP Flash Address-High register
ISPFAL
E2h
FFh
ISP Flash Address-Low register
ISPFD
E3h
FFh
ISP Flash Data register
ISPFC
E4h
00h
ISP Flash control register
LVC
E6h
20h
Low voltage control register
SWRES
E7h
00h
Software Reset register
P4
E8h
FFh
Port 4
MD0
E9h
00h
Multiplication/Division Register 0
MD1
EAh
00h
Multiplication/Division Register 1
MD2
EBh
00h
Multiplication/Division Register 2
MD3
ECh
00h
Multiplication/Division Register 3
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
13
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
EDh
Reset
value
00h
Multiplication/Division Register 4
EEh
00h
Multiplication/Division Register 5
ARCON
EFh
00h
Arithmetic Control Register
B
F0h
00h
B Register
SPIC1
F1h
08h
SPI control register 1
SPIC2
F2h
00h
SPI control register 2
SPITXD
F3h
00h
SPI transmit data buffer
SPIRXD
F4h
00h
SPI receive data buffer
Register
Location
MD4
MD5
Description
SPIS
F5h
40h
SPI status register
OpPin
F6h
00h
Op/Comparator Pin Select register
TAKEY
F7h
00h
Time Access Key register
IICS
F8h
00h
IIC status register
IICCTL
F9h
04h
IIC control register
IICA1
FAh
A0h
IIC channel 1 Address 1 register
IICA2
FBh
60h
IIC channel 1 Address 2 register
IICRWD
FCh
00h
IIC channel 1 Read / Write Data buffer
IICS2
FDh
00h
IIC status2 register
Cmp0CON
FEh
00h
Comparator_0 Control register
Cmp1CON
FFh
00h
Comparator_1 Control register
FOSVOS TEL: 021-58998693
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
14
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Function Description
1. General Features
SM59R16A5 is an 8-bit micro-controller。All of its functions and the detailed meanings of SFR will be given in the following
sections。
1.1.
Embedded Flash
The program can be loaded into the embedded 64KB/36KB/20KB Flash memory via writer or In-System Programming
(ISP)。
1.2.
IO Pads
The SM59R16A5 has six I/O ports: Port 0, Port 1, Port 2, Port 3, Port 4, and Port 5. Ports 0, 1, 2, 3, 4 are 8-bit ports and
Port 5 is a 6-bit port. These are: quasi-bidirectional (standard 8051 port outputs), push-pull, open drain, and input-only. As
description in section 5。
The OCI_SCL、ALE、OCI_SDA and RESET can be configured as I/O ports P4.4、P4.5、P4.6 and P4.7 by writer or in ISP
mode.
The XTAL2 and XTAL1 can be configured as I/O ports P5.4 and P5.5 by writer or in ISP mode, when the on-chip
RC-Oscillator is set to main system clock source.
All the pins on P0 ~ P5 are with slew rate adjustment to reduce EMI. The other way to reduce EMI is to disable the ALE
output if unused. This is selected by its SFR. The IO pads can withstand 4KV ESD in human body mode guaranteeing the
SM59R16A5’s quality in high electro-static environments.
1.3.
2T/1T Selection
The conventional 52-series MCUs are 12T, i.e., 12 oscillator clocks per machine cycle. SM59R16A5 is a 2T or 1T MCU,
i.e., its machine cycle is two-clock or one-clock. In the other words, it can execute one instruction within two clocks or
only one clock. The difference between 2T mode and 1T mode are given in the example in Fig. 1-1.
Fig. 1-1(a): The waveform of internal instruction signal in 2T mode
Fig. 1-1(b): The waveform of internal instruction signal in 1T mode
The default is in 2T mode, and it can be changed to 1T mode if IFCON [7] (at address 8Fh) is set to high any time. Not
every instruction can be executed with one machine cycle. The exact machine cycle number for all the instructions are
given in the next section.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
15
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
1.4.
1.4.1.
RESET
Hardware RESET function
SM59R16A5 provides on-chip hardware RESET mechanism, the reset duration is programmable by writer or ISP。
Internal Reset time
25ms (default)
200ms
100ms
50ms
16ms
8ms
4ms
1.4.2.
Software RESET function
SM59R16A5 provides one software reset mechanism to reset whole chip. To perform a software reset, the firmware must
write three specific values 55h, AAh and 5Ah sequentially to the TAKEY register to enable the Software Reset register
(SWRES) write attribute. After SWRES register obtain the write authority, the firmware can write FFh to the SWRES
register. The hardware will decode a reset signal that “OR” with the other hardware reset. The SWRES register is
self-reset at the end of the software reset procedure.
Mnemonic
TAKEY
SWRES
1.4.3.
Description
Time Access Key
register
Software Reset
register
Direct
Bit 7
Bit 6
Bit 5
Bit 4
Software Reset function
Bit 3
Bit 2
Bit 1
Bit 0
RESET
F7h
TAKEY [7:0]
00H
E7h
SWRES [7:0]
00H
Time Access Key register (TAKEY)
Mnemonic: TAKEY
7
6
5
4
3
TAKEY [7:0]
2
1
Address: F7H
0
Reset
00H
Software reset register (SWRES) is read-only by default; software must write three specific values
55h, AAh and 5Ah sequentially to the TAKEY register to enable the SWRES register write attribute. That
is:
MOV TAKEY, #55h
MOV TAKEY, #AAh
MOV TAKEY, #5Ah
1.4.4.
Software Reset register (SWRES)
Mnemonic: SWRES
7
6
5
4
3
SWRES [7:0]
2
1
Address: E7H
0
Reset
00H
SWRES [7:0]: Software reset register bit. These 8-bit is self-reset at the end of the reset procedure.
SWRES [7:0] = FFh, software reset.
SWRES [7:0] = 00h ~ FEh, MCU no action.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
16
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
1.4.5.
Example of software reset
MOV TAKEY, #55h
MOV TAKEY, #AAh
MOV TAKEY, #5Ah ; enable SWRES write attribute
MOV SWRES, #FFh ; software reset MCU
1.5.
Clocks
The default clock is the external crystal. This clock is used during the initialization stage. The major work of the
initialization stage is to determine the clock source used in normal operation.
The internal clock sources are from the on-chip RC-Oscillator with programmable frequency outputs as table 1-1,the
clock source can set by writer or ICP。
Table 1-1: Selection of clock source
Clock source
external crystal(default)
24MHz from internal OSC
20MHz from internal OSC
16MHz from internal OSC
12MHz from internal OSC
8MHz from internal OSC
4MHz from internal OSC
2MHz from internal OSC
1MHz from internal OSC
When RTC enabled, an external 32768Hz crystal may be connected on P3.6/P3.7 or XTAL1/XTAL2 according to user’s
configuration.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
17
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
2. Instruction Set
All SM59R16A5 instructions are binary code compatible and perform the same functions as they do with the industry
standard 8051. The following tables give a summary of the instruction set cycles of the SM59R16A5 Microcontroller core.
Mnemonic
ADD A,Rn
Table 2-1: Arithmetic operations
Description
Add register to accumulator
Code
28-2F
ADD A,direct
Add direct byte to accumulator
ADD A,@Ri
Bytes
1
Cycles
1
25
2
2
Add indirect RAM to accumulator
26-27
1
2
ADD A,#data
ADDC A,Rn
Add immediate data to accumulator
Add register to accumulator with carry flag
24
38-3F
2
1
2
1
ADDC A,direct
Add direct byte to A with carry flag
35
2
2
ADDC A,@Ri
Add indirect RAM to A with carry flag
36-37
1
2
ADDC A,#data
SUBB A,Rn
Add immediate data to A with carry flag
Subtract register from A with borrow
34
98-9F
2
1
2
1
SUBB A,direct
Subtract direct byte from A with borrow
95
2
2
SUBB A,@Ri
Subtract indirect RAM from A with borrow
96-97
1
2
SUBB A,#data
INC A
INC Rn
Subtract immediate data from A with borrow
Increment accumulator
Increment register
94
04
08-0F
2
1
1
2
1
2
INC direct
Increment direct byte
05
2
3
INC @Ri
Increment indirect RAM
06-07
1
3
INC DPTR
DEC A
Increment data pointer
Decrement accumulator
A3
14
1
1
1
1
DEC Rn
Decrement register
18-1F
1
2
DEC direct
Decrement direct byte
15
2
3
DEC @Ri
MUL AB
Decrement indirect RAM
Multiply A and B
16-17
A4
1
1
3
5
DIV
Divide A by B
84
1
5
DA A
Decimal adjust accumulator
D4
1
1
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
18
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Mnemonic
ANL A,Rn
Table 2-2: Logic operations
Description
AND register to accumulator
Code
58-5F
ANL A,direct
AND direct byte to accumulator
ANL A,@Ri
ANL A,#data
ANL direct,A
Bytes
1
Cycles
1
55
2
2
AND indirect RAM to accumulator
56-57
1
2
AND immediate data to accumulator
AND accumulator to direct byte
54
52
2
2
2
3
ANL direct,#data
AND immediate data to direct byte
53
3
4
ORL A,Rn
OR register to accumulator
48-4F
1
1
ORL A,direct
ORL A,@Ri
OR direct byte to accumulator
OR indirect RAM to accumulator
45
46-47
2
1
2
2
ORL A,#data
OR immediate data to accumulator
44
2
2
ORL direct,A
OR accumulator to direct byte
42
2
3
ORL direct,#data
XRL A,Rn
OR immediate data to direct byte
Exclusive OR register to accumulator
43
68-6F
3
1
4
1
XRL A,direct
Exclusive OR direct byte to accumulator
65
2
2
XRL A,@Ri
Exclusive OR indirect RAM to accumulator
66-67
1
2
XRL A,#data
Exclusive OR immediate data to accumulator
64
2
2
XRL direct,A
XRL direct,#data
Exclusive OR accumulator to direct byte
Exclusive OR immediate data to direct byte
62
63
2
3
3
4
CLR A
Clear accumulator
E4
1
1
CPL A
Complement accumulator
F4
1
1
RL A
RLC A
Rotate accumulator left
Rotate accumulator left through carry
23
33
1
1
1
1
RR A
Rotate accumulator right
03
1
1
RRC A
Rotate accumulator right through carry
13
1
1
SWAP A
Swap nibbles within the accumulator
C4
1
1
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
19
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Mnemonic
MOV A,Rn
MOV A,direct
Table 2-3: Data transfer
Description
Move register to accumulator
Move direct byte to accumulator
Code
E8-EF
E5
Bytes
1
2
Cycles
1
2
MOV A,@Ri
MOV A,#data
MOV Rn,A
MOV Rn,direct
Move indirect RAM to accumulator
Move immediate data to accumulator
Move accumulator to register
Move direct byte to register
E6-E7
74
F8-FF
A8-AF
1
2
1
2
2
2
2
4
MOV Rn,#data
MOV direct,A
MOV direct,Rn
MOV direct1,direct2
Move immediate data to register
Move accumulator to direct byte
Move register to direct byte
Move direct byte to direct byte
78-7F
F5
88-8F
85
2
2
2
3
2
3
3
4
MOV direct,@Ri
MOV direct,#data
MOV @Ri,A
MOV @Ri,direct
Move indirect RAM to direct byte
Move immediate data to direct byte
Move accumulator to indirect RAM
Move direct byte to indirect RAM
86-87
75
F6-F7
A6-A7
2
3
1
2
4
3
3
5
MOV @Ri,#data
Move immediate data to indirect RAM
76-77
2
3
MOV DPTR,#data16
Load data pointer with a 16-bit constant
90
3
3
MOVC A,@A+DPTR
Move code byte relative to DPTR to accumulator
93
1
3
MOVC A,@A+PC
MOVX A,@Ri
Move code byte relative to PC to accumulator
Move external RAM (8-bit addr.) to A
83
E2-E3
1
1
3
3
MOVX A,@DPTR
MOVX @Ri,A
MOVX @DPTR,A
PUSH direct
Move external RAM (16-bit addr.) to A
Move A to external RAM (8-bit addr.)
Move A to external RAM (16-bit addr.)
Push direct byte onto stack
E0
F2-F3
F0
C0
1
1
1
2
3
4
4
4
POP direct
XCH A,Rn
XCH A,direct
XCH A,@Ri
XCHD A,@Ri
Pop direct byte from stack
Exchange register with accumulator
Exchange direct byte with accumulator
Exchange indirect RAM with accumulator
Exchange low-order nibble indir. RAM with A
D0
C8-CF
C5
C6-C7
D6-D7
2
1
2
1
1
3
2
3
3
3
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
20
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Mnemonic
ACALL addr11
Table 2-4: Program branches
Description
Absolute subroutine call
Code
xxx11
LCALL addr16
Long subroutine call
RET
RETI
AJMP addr11
Bytes
2
Cycles
6
12
3
6
from subroutine
22
1
4
from interrupt
Absolute jump
32
xxx01
1
2
4
3
LJMP addr16
Long iump
02
3
4
SJMP rel
Short jump (relative addr.)
80
2
3
JMP @A+DPTR
JZ rel
Jump indirect relative to the DPTR
Jump if accumulator is zero
73
60
1
2
2
3
JNZ rel
Jump if accumulator is not zero
70
2
3
JC rel
Jump if carry flag is set
40
2
3
JNC
JB bit,rel
Jump if carry flag is not set
Jump if direct bit is set
50
20
2
3
3
4
JNB bit,rel
Jump if direct bit is not set
30
3
4
JBC bit,direct rel
Jump if direct bit is set and clear bit
10
3
4
CJNE A,direct rel
Compare direct byte to A and jump if not equal
B5
3
4
CJNE A,#data rel
CJNE Rn,#data rel
Compare immediate to A and jump if not equal
Compare immed. to reg. and jump if not equal
B4
B8-BF
3
3
4
4
CJNE @Ri,#data rel
Compare immed. to ind. and jump if not equal
B6-B7
3
4
DJNZ Rn,rel
Decrement register and jump if not zero
D8-DF
2
3
DJNZ direct,rel
NOP
Decrement direct byte and jump if not zero
No operation
D5
00
3
1
4
1
Mnemonic
CLR C
Table 2-5: Boolean manipulation
Description
Clear carry flag
Code
C3
CLR bit
Clear direct bit
C2
Bytes
1
Cycles
1
2
3
SETB C
Set carry flag
D3
1
1
SETB bit
CPL C
Set direct bit
Complement carry flag
D2
B3
2
1
3
1
CPL bit
Complement direct bit
B2
2
3
ANL C,bit
AND direct bit to carry flag
82
2
2
ANL C,/bit
ORL C,bit
AND complement of direct bit to carry
OR direct bit to carry flag
B0
72
2
2
2
2
ORL C,/bit
OR complement of direct bit to carry
A0
2
2
MOV C,bit
Move direct bit to carry flag
A2
2
2
MOV bit,C
Move carry flag to direct bit
92
2
3
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
21
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
3. Memory Structure
The SM59R16A5 memory structure follows general 8052 structure. It is integrate the expanded 2KB data memory and
64KB program memory.
3.1.
Program Memory
The SM59R16A5 has 64KB on-chip flash memory which can be used as general program memory or EEPROM, on which
include up to 4K byte specific ISP service program memory space. The address range for the 64K byte is $0000 to $FFFF.
The address range for the ISP service program is $F000 to $FFFF. The ISP service program size can be partitioned as N
blocks of 256 byte (N=0 to 16). When N=0 means no ISP service program space available, total 64K byte memory used
as program memory. When N=1 means address $FF00 to $FFFF reserved for ISP service program. When N=2 means
memory address $FE00 to $FFFF reserved for ISP service program…etc. Value N can be set and programmed into
SM59R16A5 by the writer or ICP. It can be used to record any data as EEPROM. The procedure of this EEPROM
application function is described in the section 19 on internal ISP.
ISP service
Program space,
Up to 4K
64K Program
Memory space
FFFF
FF00
FE00
FD00
FC00
FB00
FA00
F900
F800
F700
F600
F500
F400
F300
F200
F100
F000
N=0
N=1
N=2
N=3
N=4
N=5
N=6
N=7
N=8
N=9
N=10
N=11
N=12
N=13
N=14
N=15
N=16
0000
Fig. 3-1: SM59R16A5 programmable Flash
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
22
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
ISP service
Program space,
Up to 4K
FFFF
FF00
FE00
FD00
FC00
FB00
FA00
F900
F800
F700
F600
F500
F400
F300
F200
F100
F000
N=0
N=1
N=2
N=3
N=4
N=5
N=6
N=7
N=8
N=9
N=10
N=11
N=12
N=13
N=14
N=15
N=16
8000
7FFF
32K Program
Memory space
0000
Fig. 3-2 : SM59R09A5 programmable Flash
ISP service
Program space,
Up to 4K
FFFF
FF00
FE00
FD00
FC00
FB00
FA00
F900
F800
F700
F600
F500
F400
F300
F200
F100
F000
N=0
N=1
N=2
N=3
N=4
N=5
N=6
N=7
N=8
N=9
N=10
N=11
N=12
N=13
N=14
N=15
N=16
4000
3FFF
16K Program
Memory space
0000
Fig. 3-3 : SM59R05A5 programmable Flash
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
23
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
3.2.
Data Memory
The SM59R16A5 has 2K + 256Bytes on-chip SRAM, 256 Bytes of it are the same as general 8052 internal memory
structure while the expanded 2KBytes on-chip SRAM can be accessed by external memory addressing method ( by
instruction MOVX.)
Fig 3-2 (a):External memory access as read
Fig 3-2 (b):External memory access as write
07FF
FF
FF
Higher 128 Bytes (Accessed by
indirect addressing mode only)
SFR (Accessed by direct addressing
mode only)
80
Expanded 2K Bytes
(Accessed by direct external
addressing mode by
instruction MOVX)
80
7F
Lower 128 Bytes (Accessed by direct
& indirect addressing mode )
0000
00
Fig. 3-3: RAM architecture
3.2.1.
Data memory - lower 128 byte (00h to 7Fh)
Data memory 00h to FFh is the same as 8052.
The address 00h to 7Fh can be accessed by direct and indirect addressing modes.
Address 00h to 1Fh is register area.
Address 20h to 2Fh is memory bit area.
Address 30h to 7Fh is for general memory area.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
24
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
3.2.2.
Data memory - higher 128 byte (80h to FFh)
The address 80h to FFh can be accessed by indirect addressing mode.
Address 80h to FFh is data area.
3.2.3.
Data memory - Expanded 2048 bytes ($0000 to $07FF)
From external address 0000h to 07FFh is the on-chip expanded SRAM area, total 2K Bytes. This area can be accessed
by external direct addressing mode (by instruction MOVX).
If the address of instruction MOVX @DPTR is larger then 07FFh, the SM59R16A5 will generate the external memory
control signal automatically.
The address space of instruction MOVX @Ri, i=0, 1 is determined by RCON [7:0] of special function register $86 RCON
(internal RAM control register). The default setting of RCON [7:0] is 00h (page0). One page of data RAM is 256 bytes.
When EMEN = 0, the internal 2K expanded RAM is enabled. If access memory space is more than 2K byte, the value of
RCON is sent to Port2 to access external RAM.
When EMEN = 1, the internal 2K expanded RAM is disabled. The value of RCON is invalid and high byte address is
decided by register context of Port2 register P2 [7:0].
MOVX @Ri, A
MOVX A,@Ri
EMEN = 0
EMEN = 1
0 ≦ RCON[7:0] ≦ 3
4 ≦ RCON [7:0] ≦ 255
Addr [15:8] <= RCON[7:0]
Port2 [7:0] <= P2 [7:0]
Port2 [7:0] <= RCON[7:0]
Port2 [7:0] <= P2 [7:0]
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
25
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
4. CPU Engine
The SM59R16A5 engine is composed of four components:
a. Control unit
b. Arithmetic – logic unit
c. Memory control unit
d. RAM and SFR control unit
The SM59R16A5 engine allows to fetch instruction from program memory and to execute using RAM or SFR.
following paragraphs describe the main engine registers.
Mnemonic
Description
Direct
Bit 7
ACC
B
Accumulator
B register
Program status
word
Stack Pointer
Data pointer low 0
Data pointer high
0
Data pointer low 1
Data pointer high
1
E0h
F0h
ACC.7
B.7
D0h
CY
PSW
SP
DPL
DPH
DPL1
DPH1
AUX
RCON
IFCON
4.1.
Auxiliary register
Internal RAM
control register
Interface control
register
Bit 6
Bit 5
8051 Core
ACC.6 ACC.5
B.6
B.5
AC
The
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
RESET
ACC.4
B.4
ACC.3
B.3
ACC.2
B.2
ACC.1
B.1
ACC.0
B.0
00H
00H
OV
PSW.1
P
00H
F0
RS[1:0]
81h
82h
SP[7:0]
DPL[7:0]
07H
00H
83h
DPH[7:0]
00H
84h
DPL1[7:0]
00H
85h
DPH1[7:0]
00H
91h
BRGS
-
P4SPI
P4UR
1
86h
P4IIC
P0KBI
P2PW
M
DPS
RCON[7:0]
8Fh
ITS
CDPR
-
-
00H
00H
ALEC[1:0]
EMEN
ISPE
00H
Accumulator
ACC is the Accumulator register. Most instructions use the accumulator to store the operand.
Mnemonic: ACC
7
6
ACC.7 ACC.6
5
ACC05
4
ACC.4
3
ACC.3
2
ACC.2
1
ACC.1
Address: E0h
0
Reset
ACC.0
00h
ACC[7:0]: The A (or ACC) register is the standard 8052 accumulator.
4.2.
B Register
The B register is used during multiply and divide instructions. It can also be used as a scratch pad register to store
temporary data.
Mnemonic: B
7
6
B.7
B.6
5
B.5
4
B.4
3
B.3
2
B.2
1
B.1
Address: F0h
0
Reset
B.0
00h
B[7:0]: The B register is the standard 8052 register that serves as a second accumulator.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
26
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
4.3.
Program Status Word
Mnemonic: PSW
7
6
CY
AC
5
F0
4
RS [1:0]
3
2
OV
1
F1
Address: D0h
0
Reset
P
00h
CY: Carry flag.
AC: Auxiliary Carry flag for BCD operations.
F0: General purpose Flag 0 available for user.
RS[1:0]: Register bank select, used to select working register bank.
RS[1:0]
Bank Selected
Location
00
Bank 0
00h – 07h
01
Bank 1
08h – 0Fh
10
Bank 2
10h – 17h
11
Bank 3
18h – 1Fh
OV: Overflow flag.
F1: General purpose Flag 1 available for user.
P: Parity flag, affected by hardware to indicate odd/even number of “one” bits in the
Accumulator, i.e. even parity.
4.4.
Stack Pointer
The stack pointer is a 1-byte register initialized to 07h after reset.
instructions, causing the stack to start from location 08h.
Mnemonic: SP
7
6
5
4
SP [7:0]
3
This register is incremented before PUSH and CALL
2
1
Address: 81h
0
Reset
07h
SP[7:0]: The Stack Pointer stores the scratchpad RAM address where the stack begins. In other
words, it always points to the top of the stack.
4.5.
Data Pointer
The data pointer (DPTR) is 2-bytes wide. The lower part is DPL, and the highest is DPH. It can be loaded as a 2-byte
register (e.g. MOV DPTR, #data16) or as two separate registers (e.g. MOV DPL,#data8). It is generally used to access
the external code or data space (e.g. MOVC A, @A+DPTR or MOVX A, @DPTR respectively).
Mnemonic: DPL
7
6
5
3
DPL [7:0]
2
1
Address: 82h
0
Reset
00h
4
3
DPH [7:0]
2
1
Address: 83h
0
Reset
00h
4
DPL[7:0]: Data pointer Low 0
Mnemonic: DPH
7
6
5
DPH [7:0]: Data pointer High 0
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
27
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
4.6.
Data Pointer 1
The Dual Data Pointer accelerates the moves of data block. The standard DPTR is a 16-bit register that is used to
address external memory or peripherals. In the SM59R16A5 core the standard data pointer is called DPTR, the second
data pointer is called DPTR1. The data pointer select bit chooses the active pointer. The data pointer select bit is located
in LSB of AUX register (DPS).
The user switches between pointers by toggling the LSB of AUX register. All DPTR-related instructions use the currently
selected DPTR for any activity.
Mnemonic: DPL1
7
6
5
4
3
DPL1 [7:0]
2
1
Address: 84h
0
Reset
00h
4
3
DPH1 [7:0]
2
1
Address: 85h
0
Reset
00h
DPL1[7:0]: Data pointer Low 1
Mnemonic: DPH1
7
6
5
DPH1[7:0]: Data pointer High 1
Mnemonic: AUX
7
6
5
BRGS
P4SPI
4
P4UR1
3
P4IIC
2
P0KBI
1
P2PWM
Address: 91h
0
Reset
DPS
00H
DPS: Data Pointer selects register.
DPS = 1 is selected DPTR1.
4.7.
Internal RAM control register
SM59R16A5 has 2K byte on-chip expanded RAM which can be accessed by external memory addressing method only
(By instruction MOVX). The address space of instruction MOVX @Ri, i= 0, 1 is determined by RCON [7:0] of RCON. The
default setting of RCON [7:0] is 00h (page0).
Mnemonic: RCON
7
6
4.8.
5
4
3
RCON[7:0]
5
-
4
-
2
1
Address: 86h
0
Reset
00H
Interface control register
Mnemonic: IFCON
7
6
ITS
CDPR
3
2
ALEC[1:0]
1
EMEN
Address: 8Fh
0
Reset
ISPE
00h
ITS: Instruction timing select. (default is 2T)
ITS = 0, 2T instruction mode.
ITS = 1, 1T instruction mode.
CDPR: code protect (Read Only)
ALEC[1:0]: ALE output control register.
ALEC[1:0]
ALE Output
00
Always output
01
No ALE output
10
Only Read or Write have ALE output
11
reserved
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
28
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
EMEN: Internal 2K SRAM disable.(default is enable)
EMEN = 0, Enable internal 2K RAM.
EMEN = 1, Disable internal 2K RAM.
ISPE: ISP function enable bit
ISPE = 1, enable ISP function
ISPE = 0, disable ISP function
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
29
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
5. GPIO
The SM59R16A5 has six I/O ports: Port 0, Port 1, Port 2, Port 3, Port 4, and Port 5. Ports 0, 1, 2, 3, 4 are 8-bit ports and
Port 5 is a 6-bit port. These are: quasi-bidirectional (standard 8051 port outputs), push-pull, open drain, and input-only.
Two configuration registers for each port select the output type for each port pin. All I/O port pins on the SM59R16A5 may
be configured by software to one of four types on a pin-by-pin basis, shown as below:
Mnemonic
P0M0
P0M1
P1M0
P1M1
P2M0
P2M1
P3M0
P3M1
P4M0
P4M1
P5M0
P5M1
Description
Direct
Port 0 output mode 0
Port 0 output mode 1
Port 1 output mode 0
Port 1 output mode 1
Port 2 output mode 0
Port 2 output mode 1
Port 3 output mode 0
Port 3 output mode 1
Port 4 output mode 0
Port 4 output mode 1
Port 5 output mode 0
Port 5 output mode 1
PxM1.y
0
0
1
1
PxM0.y
0
1
0
1
D2h
D3h
D4h
D5h
D6h
D7h
DAh
DBh
DCh
DDh
DEh
DFh
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2
I/O port function register
P0M0 [7:0]
P0M1[7:0]
P1M0[7:0]
P1M1[7:0]
P2M0[7:0]
P2M1[7:0]
P3M0[7:0]
P3M1[7:0]
P4M0[7:0]
P4M1[7:0]
P5M0[5:0]
P5M1[5:0]
Bit 1
Bit 0
RESET
00H
00H
00H
00H
00H
00H
00H
00H
00H
00H
00H
00H
Port output mode
Quasi-bidirectional (standard 8051 port outputs) (pull-up)
Push-pull
Input only (high-impedance)
Open drain
The OCI_SCL、ALE、OCI_SDA and RESET can be define as P4.4、P4.5、P4.6 and P4.7 by writer or ISP。
The XTAL2 and XTAL1 can define as P5.4 and P5.5 by writer or ISP,when user use internal OSC as system clock and
not use the RTC function.
For general-purpose applications, every pin can be assigned to either high or low independently as given below:
Mnemonic
Port 5
Port 4
Port 3
Port 2
Port 1
Port 0
Description
Port 5
Port 4
Port 3
Port 2
Port 1
Port 0
Direct
Bit 7
Bit 6
D8h
E8h
B0h
A0h
90h
80h
P4.7
P3.7
P2.7
P1.7
P0.7
P4.6
P3.6
P2.6
P1.6
P0.6
Mnemonic: P0
7
6
P0.7
P0.6
5
P0.5
4
P0.4
Bit 5
Ports
P5.5
P4.5
P3.5
P2.5
P1.5
P0.5
3
P0.3
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
RESET
P5.4
P4.4
P3.4
P2.4
P1.4
P0.4
P5.3
P4.3
P3.3
P2.3
P1.3
P0.3
P5.2
P4.2
P3.2
P2.2
P1.2
P0.2
P5.1
P4.1
P3.1
P2.1
P1.1
P0.1
P5.0
P4.0
P3.0
P2.0
P1.0
P0.0
0Fh
FFh
FFh
FFh
FFh
FFh
2
P0.2
1
P0.1
Address: 80h
0
Reset
P0.0
FFh
P0.7~ 0: Port0 [7] ~ Port0 [0]
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
30
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Mnemonic: P1
7
6
P1.7
P1.6
5
P1.5
4
P1.4
3
P1.3
2
P1.2
1
P1.1
Address: 90h
0
Reset
P1.0
FFh
4
P2.4
3
P2.3
2
P2.2
1
P2.1
Address: A0h
0
Reset
P2.0
FFh
4
P3.4
3
P3.3
2
P3.2
1
P3.1
Address: B0h
0
Reset
P3.0
FFh
4
P4.4
3
P4.3
2
P4.2
1
P4.1
Address: E8h
0
Reset
P4.0
FFh
4
P5.4
3
P5.3
2
P5.2
1
P5.1
Address: D8h
0
Reset
P5.0
3Fh
P1.7~ 0: Port1 [7] ~ Port1 [0]
Mnemonic: P2
7
6
P2.7
P2.6
5
P2.5
P2.7~ 0: Port2 [7] ~ Port2 [0]
Mnemonic: P3
7
6
P3.7
P3.6
5
P3.5
P3.7~ 0: Port3 [7] ~ Port3 [0]
Mnemonic: P4
7
6
P4.7
P4.6
5
P4.5
P4.7~ 0: Port4 [7] ~ Port4 [0]
Mnemonic: P5
7
6
-
5
P5.5
P5.5~ 0: Port5 [5] ~ Port5 [0]
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
31
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
6. Multiplication Division Unit (MDU)
This on-chip arithmetic unit provides 32-bit division, 16-bit multiplication, shift and normalize features, etc. All operations
are unsigned integer operations.
Mnemonic
Description
Direct
PCON
Power control
Arithmetic Control
register
Multiplication/Divi
sion Register 0
Multiplication/Divi
sion Register 1
Multiplication/Divi
sion Register 2
Multiplication/Divi
sion Register 3
Multiplication/Divi
sion Register 4
Multiplication/Divi
sion Register 5
87H
Bit 6
Bit 5
Bit 4
Multiplication Division Unit
SMOD MDUF
-
EFh
MDEF
ARCON
MD0
MD1
MD2
MD3
MD4
MD5
6.1.
Bit 7
MDOV
Bit 3
Bit 2
Bit 1
Bit 0
RESET
-
-
STOP
IDLE
40H
SLR
SC[4:0]
00H
00H
E9h
MD0[7:0]
EAh
MD1[7:0]
EBh
MD2[7:0]
ECh
MD3[7:0]
EDh
MD4[7:0]
00H
EEh
MD5[7:0]
00H
00H
00H
00H
Operating registers of the MDU
The MDU is handled by seven registers, which are memory mapped as special function registers. The arithmetic unit
allows operations concurrently to and independent of the CPU’s activity. Operands and results registers are MD0 to MD5.
Control register is ARCON. Any calculation of the MDU overwrites its operands.
Mnemonic: ARCON
7
6
5
MDEF MDOV
SLR
4
3
2
SC[4:0]
1
Address: EFh
0
Reset
00H
MDEF: Multiplication Division Error Flag.
The MDEF is an error flag. The error flag is read only. The error flag indicates an
improperly performed operation (when one of the arithmetic operations has been
restarted or interrupted by a new operation). The error flag mechanism is automatically
enabled with the first write to MD0 and disabled with the final read instruction from MD3
multiplication or shift/normalizing) or MD5 (division) in phase three.
The error flag is set when:
1. Phase two in process and write access to mdx registers (restart or interrupt
calculations)
The error flag is reset only if:
Phase two finished (arithmetic operation successful completed) and read access to MDx
registers.
MDOV: Multiplication Division Overflow flag. The overflow flag is read only.
The overflow flag is set when:
1. Division by Zero
2. Multiplication with a result greater then 0000FFFFh
3. Start of normalizing if the most significant bit of MD3 is set(MD3.7=1)
The overflow flag is reset when:
Write access to MD0 register(Start Phase one)
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
32
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
SLR: Shift direction bit.
SLR = 0 – shift left operation.
SLR = 1 – shift right operation.
SC[4:0]: Shift counter.
When preset with 00000b, normalizing is selected. After normalize sc.0 – sc.4 contains
the number of normalizing shifts performed. When sc.4 – sc.0 ≠ 0, shift operation is
started. The number of shifts performed is determined by the count written to sc.4 to sc.0.
sc.4 – MSB ... sc.0 – LSB
6.2.
Operation of the MDU
The operation of the MDU consists of three phases:
6.2.1.
First phase: loading the MDx registers, x = 0~5:
The type of calculation the MDU has to perform is selected following the order in which the mdx registers are written to.
Operation
First write
Last write
32bit/16bit
MD0 Dividend Low
MD1 Dividend
MD2 Dividend
MD3 Dividend High
MD4 Divisor Low
MD5 Divisor High
Table 6-1: MDU registers write sequence
16bit/16bit
16bit x 16bit
MD0 Dividend Low
MD0 Multiplicand Low
MD1 Dividend High
MD4 Multiplicator Low
MD1 Multiplicand High
MD4 Divisor Low
MD5 Divisor High
MD5 Multiplicator High
shift/normalizing
MD0 LSB
MD1
MD2
MD3 MSB
ARCON start conversion
A write to md0 is the first transfer to be done in any case. Next writes must be done as shown in table 6.1 to determine
MDU operation. Last write finally starts selected operation.
6.2.2.
Second phase: executing calculation.
During executing operation, the MDU works on its own parallel to the CPU. When MDU is finished, the MDUF register will
be set to one by hardware and the flag will clear at next calculation.
Mnemonic: PCON
7
6
SMOD MDUF
5
-
4
-
3
-
2
-
1
STOP
Address: 87h
0
Reset
IDLE
40h
MDUF: MDU finish flag.
When MDU is finished, the MDUF will be set by hardware and the bit will clear
by hardware at next calculation.
The following table gives the execution time in every mathematical operation.
Operation
Division 32bit/16bit
Division 16bit/16bit
Multiplication
Shift
Normalize
Table 6-2: MDU execution times
Number of Tclk
17 clock cycles
9 clock cycles
11 clock cycles
Min. 3 clock cycles, Max. 18 clock cycles
Min. 4 clock cycles, Max. 19 clock cycles
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
33
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
6.2.3.
Third phase: reading the result from the MDx registers.
Read out sequence of the first MDx registers is not critical but the last read (from MD5 - division and MD3 - multiplication,
shift and normalizing) determines the end of a whole calculation (end of phase three).
Operation
First read
Last read
Table 6-3: MDU registers read sequence
32Bit/16Bit
16Bit/16Bit
16Bit x 16Bit
MD0 Quotient Low
MD0 Quotient Low
MD0 Product Low
MD1 Quotient
MD1 Quotient High
MD1 Product
MD2 Quotient
MD2 Product
MD3 Quotient High
MD4 Remainder L
MD4 Remainder Low
MD5 Remainder H
MD5 Remainder High
MD3 Product High
shift/normalizing
MD0 LSB
MD1
MD2
MD3 MSB
Here the operation of normalization and shift will be explained more. In normalization, all reading zeroes in registers
MD0 to MD3 are removed by shift left. The whole operation is completed when the MSB (most significant bit) of MD3
register contains a ’1’. After normalizing, bits ARCON.4 (MSB) to ARCON.0 (LSB) contain the number of shift left
operations. As for shift, SLR bit (ARCON.5) has to contain the shift direction, and ARCON.4 to ARCON.0 represent the
shift count (which must not be 0). During shift, zeroes come into the left or right end of the registers MD0 or MD3,
respectively.
6.3.
Normalizing
All reading zeroes of integers variables in registers MD0 to MD3 are removed by shift left operations. The whole operation
is completed when the MSB (most significant bit) of MD3 register contains a ’1’. After normalizing, bits ARCON.4 (MSB)
to ARCON.0 (LSB) contain the number of shift left operations, which were done.
6.4.
Shifting
SLR bit (ARCON.5) has to contain the shift direction, and ARCON.4 to ARCON.0 the shift count (which must not be 0).
During shift, zeroes come into the left or right end of the registers MD0 or MD3, respectively.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
34
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
7. Timer 0 and Timer 1
The SM59R16A5 has three 16-bit timer/counter registers: Timer 0, Timer 1 and Timer 2. All can be configured for counter
or timer operations.
In timer mode, the Timer 0 register or Timer 1 register is incremented every 12 machine cycles, which means that it
counts up after every 12 periods of the clk signal.
In counter mode, the register is incremented when the falling edge is observed at the corresponding input pin T0or T1.
Since it takes 2 machine cycles to recognize a 1-to-0 event, the maximum input count rate is 1/2 of the oscillator
frequency. There are no restrictions on the duty cycle, however to ensure proper recognition of 0 or 1 state, an input
should be stable for at least 1 machine cycle.
Four operating modes can be selected for Timer 0 and Timer 1. Two Special Function registers (TMOD and TCON) are
used to select the appropriate mode.
Mnemonic
Description
Direct
TL0
Timer 0 , low byte
Timer 0 , high
byte
Timer 1 , low byte
Timer 1 , high
byte
Timer Mode
Control
Timer/Counter
Control
8Ah
TH0
TL1
TH1
TMOD
TCON
7.1.
Bit 7
Bit 6
Bit 5
Timer 0 and 1
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
RESET
TL0[7:0]
00h
8Ch
TH0[7:0]
00h
8Bh
TL1[7:0]
00h
8Dh
TH1[7:0]
00h
89h
GATE
C/T
M1
M0
GATE
C/T
M1
M0
00h
88h
TF1
TR1
TF0
TR0
IE1
IT1
IE0
IT0
00h
Timer/counter mode control register (TMOD)
Mnemonic: TMOD
7
6
5
GATE
C/T
M1
Timer 1
4
M0
3
GATE
2
1
C/T
M1
Timer 0
Address: 89h
0
Reset
M0
00h
GATE: If set, enables external gate control (pin INT0 or INT1 for Counter 0 or 1, respectively).
When INT0 or INT1 is high, and TRx bit is set (see TCON register), a counter is
incremented every falling edge on T0 or T1 input pin
C/T: Selects Timer or Counter operation. When set to 1, a counter operation is performed,
when cleared to 0, the corresponding register will function as a timer.
M[1:0]: Selects mode for Timer/Counter 0 or Timer/Counter 1.
M1
M0
Mode
Function
0
0
Mode0
13-bit counter/timer, with 5 lower bits in TL0 or TL1
register and 8 bits in TH0 or TH1 register (for Timer 0
and Timer 1, respectively). The 3 high order bits of TL0
and TL1 are hold at zero.
0
1
Mode1
16-bit counter/timer.
1
0
Mode2
8 -bit auto-reload counter/timer. The reload value is
kept in TH0 or TH1, while TL0 or TL1 is incremented
every machine cycle. When TLx overflows, a value
from THx is copied to TLx.
1
1
Mode3
If Timer 1 M1 and M0 bits are set to 1, Timer 1 stops. If
Timer 0 M1 and M0 bits are set to 1, Timer 0 acts as
two independent 8 bit timers / counters.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
35
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
7.2.
Timer/counter control register (TCON)
Mnemonic: TCON
7
6
5
TF1
TR1
TF0
4
TR0
3
IE1
2
IT1
1
IE0
Address: 88h
0
Reset
IT0
00h
TF1: Timer 1 overflow flag set by hardware when Timer 1 overflows. This flag can
be cleared by software and is automatically cleared when interrupt is
processed.
TR1: Timer 1 Run control bit. If cleared, Timer 1 stops.
TF0: Timer 0 overflow flag set by hardware when Timer 0 overflows. This flag can
be cleared by software and is automatically cleared when interrupt is
processed.
TR0: Timer 0 Run control bit. If cleared, Timer 0 stops.
IE1: Interrupt 1 edge flag. Set by hardware, when falling edge on external pin INT1
is observed. Cleared when interrupt is processed.
IT1: Interrupt 1 type control bit. Selects falling edge or low level on input pin to
cause interrupt.
IE0: Interrupt 0 edge flag. Set by hardware, when falling edge on external pin INT0
is observed. Cleared when interrupt is processed.
IT0: Interrupt 0 type control bit. Selects falling edge or low level on input pin to
cause interrupt.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
36
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
8. Timer 2 and Capture/Compare Unit
Timer 2 is not only a 16-bit timer, also a 4-channel unit with compare, capture and reload functions.
the programmable counter array (PCA) in some other MCUs except pulse width modulation (PWM).
Mnemonic
Description
Direct
AUX2
T2CON
Auxiliary register2
Timer 2 control
Compare/Capture
Control
Compare/Capture
Enable register
Compare/Capture
Enable 2 register
Timer 2, low byte
Timer 2, high byte
Compare/Reload/
Capture register,
low byte
Compare/Reload/
Capture register,
high byte
Compare/Capture
register 1, low
byte
Compare/Capture
register 1, high
byte
Compare/Capture
register 2, low
byte
Compare/Capture
register 2, high
byte
Compare/Capture
register 3, low
byte
Compare/Capture
register 3, high
byte
CCCON
CCEN
CCEN2
TL2
TH2
CRCL
CRCH
CCL1
CCH1
CCL2
CCH2
CCL3
CCH3
It is very similar to
Bit 2
92h
C8h
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Timer 2 and Capture Compare Unit
T2PS[2:0]
T2R[1:0]
C9h
CCI3
CCF2
C1h
-
COCAM1[2:0]
-
COCAM0[2:0]
00h
D1h
-
COCAM3[2:0]
-
COCAM2[2:0]
00h
CCI2
CCI1
CCI0
CCF3
CCh
CDh
TL2[7:0]
TH2[7:0]
CAh
CRCL[7:0]
CBh
CRCH[7:0]
C2h
CCL1[7:0]
C3h
CCH1[7:0]
C4h
CCL2[7:0]
C5h
CCH2[7:0]
C6h
CCL3[7:0]
C7h
CCH3[7:0]
Mnemonic: AUX2
7
6
5
4
3
2
-
Bit 1
Bit 0
P42CC[1:0]
T2I[1:0]
CCF1
CCF0
Address: 92h
1
0
Reset
P42CC[1: 0]
00H
P42CC[1: 0] 00: Capture/Compare function on Port1.
01: Capture/Compare function on Port2
10: Capture/Compare function on Port4
11: reserved
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
37
Ver.G SM59R16A5 01/2014
RESET
00h
00H
00h
00h
00h
00h
00h
00h
00h
00h
00h
00h
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Mnemonic: T2CON
7
6
5
T2PS[2:0]
4
3
T2R[1:0]
2
-
1
Address: C8h
0
Reset
T2I[1:0]
00H
T2PS[2:0]: Prescaler select bit:
T2PS = 000 – timer 2 is clocked with the oscillator frequency.
T2PS = 001 – timer 2 is clocked with 1/2 of the oscillator frequency.
T2PS = 010 – timer 2 is clocked with 1/4 of the oscillator frequency.
T2PS = 011 – timer 2 is clocked with 1/6 of the oscillator frequency.
T2PS = 100 – timer 2 is clocked with 1/8 of the oscillator frequency.
T2PS = 101 – timer 2 is clocked with 1/12 of the oscillator frequency.
T2PS = 110 – timer 2 is clocked with 1/24 of the oscillator frequency.
T2R[1:0]: Timer 2 reload mode selection
T2R[1:0] = 0X – Reload disabled
T2R[1:0] = 10 – Mode 0: Auto Reload
T2R[1:0] = 11 – Mode 1: T2EX Falling Edge Reload
T2I[1:0]: Timer 2 input selection
T2I[1:0] = 00 – Timer 2 stop
T2I[1:0] = 01 – Input frequency from prescaler(T2PS[2:0])
T2I[1:0] = 10 – Timer 2 is incremented by external signal at pin T2
T2I[1:0] = 11 – internal clock input is gated to the Timer 2
Mnemonic: CCCON
7
6
5
CCI3
CCI2
CCI1
4
CCI0
3
CCF3
2
CCF2
1
CCF1
Address: C9h
0
Reset
CCF0
00H
CCI3: Compare/Capture 3 interrupt control bit.
“1” is enable.
CCI2: Compare/Capture 2 interrupt control bit.
“1” is enable.
CCI1: Compare/Capture 1 interrupt control bit.
“1” is enable.
CCI0: Compare/Capture 0 interrupt control bit.
“1” is enable.
CCF3: Compare/Capture 3 flag set by hardware. This flag can be cleared by software.
CCF2: Compare/Capture 2 flag set by hardware. This flag can be cleared by software.
CCF1: Compare/Capture 1 flag set by hardware. This flag can be cleared by software.
CCF0: Compare/Capture 0 flag set by hardware. This flag can be cleared by software.
Compare/Capture interrupt share T2 interrupt vector.
Mnemonic: CCEN
7
6
5
4
-COCAM1[2:0]
3
--
2
Address: C1h
1
0
Reset
COCAM0[2:0]
00H
COCAM1[2:0] 000: Compare/Capture disable
001: Compare enable but no output on Pin
010: Compare mode 0
011: Compare mode 1
100: Capture on rising edge at pin CC1
101: Capture on falling edge at pin CC1
110: Capture on both rising and falling edge at pin CC1
111: Capture on write operation into register CC1
COCAM0[2:0] 000: Compare/Capture disable
001: Compare enable but no output on Pin
010: Compare mode 0
011: Compare mode 1
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
38
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
100: Capture on rising edge at pin CC0
101: Capture on falling edge at pin CC0
110: Capture on both rising and falling edge at pin CC0
111: Capture on write operation into register CC0
Mnemonic: CCEN2
7
6
5
4
-COCAM3[2:0]
3
--
2
Address: D1h
1
0
Reset
COCAM2[2:0]
00H
COCAM3[2:0] 000: Compare/Capture disable
001: Compare enable but no output on Pin
010: Compare mode 0
011: Compare mode 1
100: Capture on rising edge at pin CC3
101: Capture on falling edge at pin CC3
110: Capture on both rising and falling edge at pin CC3
111: Capture on write operation into register CC3
COCAM2[2:0] 000: Compare/Capture disable
001: Compare enable but no output on Pin
010: Compare mode 0
011: Compare mode 1
100: Capture on rising edge at pin CC2
101: Capture on falling edge at pin CC2
110: Capture on both rising and falling edge at pin CC2
111: Capture on write operation into register CC2
8.1.
Timer 2 function
Timer 2 can operate as timer, event counter, or gated timer as explained later.
8.1.1.
Timer mode
In this mode Timer 2 can by incremented in various frequency that depending on the prescaler. The prescaler is selected
by bit T2PS[2:0] in register T2CON.
8.1.2.
Event counter mode
In this mode, the timer is incremented when external signal T2 change value from 1 to 0. The T2 input is sampled in
every cycle. Timer 2 is incremented in the cycle following the one in which the transition was detected.
8.1.3.
Gated timer mode
In this mode, the internal clock which incremented timer 2 is gated by external signal T2.
8.1.4.
Reload of Timer 2
Reload (16-bit reload from the crc register) can be executed in the following two modes:
Mode 0: Reload signal is generate by a Timer 2 overflows - auto reload
Mode 1: Reload signal is generate by a negative transition at the corresponding input pin T2EX.
8.2.
Compare function
In the four independent comparators, the value stored in any compare/capture register is compared with the contents of
the timer register. The compare modes 0 and 1 are selected by bits C0CAMx. In both compare modes, the results of
comparison arrives at Port 1 within the same machine cycle in which the internal compare signal is activated.
When the channel 1、2 and 3 use at compare function,The compare mode setting of Channel 2 and Channel 3 should be
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
39
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
same as the compare mode setting of channel 1.
8.2.1.
Compare Mode 0
In mode 0, when the value in Timer 2 equals the value of the compare register, the output signal changes from low to high.
It goes back to a low level on timer overflow. In this mode, writing to the port will have no effect, because the input line
from the internal bus and the write-to-latch line are disconnected. The following figure illustrates the function of compare
mode 0.
Fig. 8-1: Compare mode 0 function
Contents of
Timer 2
CRC or CCx
Reload value
CCx Output
Timer 2 = CCx value
8.2.2.
Timer 2 overflow
Compare Mode 1
In compare mode 1, the transition of the output signal can be determined by software. A timer 2 overflow causes no
output change. In this mode, both transitions of a signal can be controlled. Fig. 8-2 shows a functional diagram of a
register/port configuration in compare Mode 1. In compare Mode 1, the value is written first to the “Shadow Register”,
when compare signal is active, this value is transferred to the output register.
Fig. 8-2: Compare mode 1 function
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
40
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Contents of
Timer 2
CRC or CCx
Reload value
CCx Output
Output register
Shadow register
CCx Output
Timer 2 = CCx value
8.3.
Capture function
Actual timer/counter contents can be saved into registers CCx or CRC upon an external event (mode 0) or a software
write operation (mode 1).
8.3.1.
Capture Mode 0
In mode 0, value capture of Timer 2 is executed when:
(a) Rising edge on input CC0-CC3
(b) Falling edge on input CC0-CC3
(c) Both rising and falling edge on input CC0-CC3
The contents of Timer 2 will be latched into the appropriate capture register.
8.3.2.
Capture Mode 1
In mode 1, value capture of timer 2 is caused by writing any value into the low-order byte of the dedicated capture register.
The value written to the capture register is irrelevant to this function. The contents of Timer 2 will be latched into the
appropriate capture register.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
41
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
9. Serial interface 0 and 1
There are two serial interfaces for data communication in SM59R16A5, they are the so called UART0 and UART1.
As the conventional UART, the communication speed can be selected by configuring the baud rate in SFRs.
These two serial buffers consists of two separate registers, a transmit buffer and a receive buffer. Writing data to the
SFR S0BUF or S1BUF sets this data in serial output buffer and starts the transmission. Reading from the S0BUF or
S1BUF reads data from the serial receive buffer. The serial port can simultaneously transmit and receive data. It can
also buffer 1 byte at receive, which prevents the receive data from being lost if the CPU reads the second byte before the
transmission of the first byte is completed.
Mnemonic
PCON
AUX
S0CON
S0RELL
S0RELH
S0BUF
S1CON
S1RELL
S1RELH
S1BUF
Description
Power control
Auxiliary
register
Serial Port 0
control register
Serial Port 0
reload register
low byte
Serial Port 0
reload register
high byte
Serial Port 0
data buffer
Serial Port 1
control register
Serial Port 1
reload register
low byte
Serial Port 1
reload register
high byte
Serial Port 1
data buffer
Direct
Bit 7
Bit 6
Bit 5
Bit 4
Serial interface 0 and 1
MDUF
P4UR
P4SPI
1
Bit 3
Bit 2
Bit 1
Bit 0
RESET
87h
SMOD
-
-
IDLE
40h
P4IIC
P0KBI
STOP
P2PW
M
91h
BRGS
DPS
00H
98h
SM0
SM1
SM20
REN0
TB80
RB80
TI0
RI0
00h
AAh
S0REL
.7
S0REL
.6
S0REL
.5
S0REL
.4
S0REL
.3
S0REL
.2
S0REL
.1
S0REL
.0
00h
BAh
-
-
-
-
-
-
S0REL
.9
S0REL
.8
00h
99h
S0BUF[7:0]
00h
9Bh
SM
-
SM21
REN1
TB81
RB81
TI1
RI1
00h
9Dh
S1REL
.7
S1REL
.6
S1REL
.5
S1REL
.4
S1REL
.3
S1REL
.2
S1REL
.1
S1REL
.0
00h
BBh
-
-
-
-
-
-
S1REL
.9
S1REL
.8
00h
9Ch
Mnemonic: AUX
7
6
5
BRGS
P4SPI
S1BUF[7:0]
4
P4UR1
3
P4IIC
2
P0KBI
1
P2PWM
00h
Address: 91h
0
Reset
DPS
00H
P4UR1: P4UR1 = 0 – Serial interface 1 function on P1.
P4UR1 = 1 – Serial interface 1 function on P4.
Mnemonic: S0CON
7
6
5
SM0
SM1
SM20
4
REN0
3
TB80
2
RB80
1
TI0
Address: 98h
0
Reset
RI0
00h
SM0,SM1: Serial Port 0 mode selection.
SM0 SM1
Mode
0
0
0
0
1
1
1
0
2
1
1
3
The 4 modes in UART0, Mode 0 ~ 3, are explained later.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
42
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
SM20: Enables multiprocessor communication feature
REN0: If set, enables serial reception. Cleared by software to disable reception.
th
TB80: The 9 transmitted data bit in modes 2 and 3. Set or cleared by the CPU
depending on the function it performs such as parity check, multiprocessor
communication etc.
th
RB80: In modes 2 and 3, it is the 9 data bit received. In mode 1, if SM20 is 0, RB80
is the stop bit. In mode 0, this bit is not used. Must be cleared by software.
TI0: Transmit interrupt flag, set by hardware after completion of a serial transfer.
Must be cleared by software.
RI0: Receive interrupt flag, set by hardware after completion of a serial reception.
Must be cleared by software.
Mnemonic: S1CON
7
6
5
SM
SM21
4
REN1
3
TB81
2
RB81
1
TI1
Address: 9Bh
0
Reset
RI1
00h
SM: Serial Port 1 mode select.
SM
Mode
0
A
1
B
The 2 modes in UART1, Mode A and Mode B, are explained later.
SM21: Enables multiprocessor communication feature.
REN1: If set, enables serial reception. Cleared by software to disable reception.
th
TB81: The 9 transmitted data bit in mode A. Set or cleared by the CPU depending on
the function it performs such as parity check, multiprocessor communication
etc.
th
RB81: In mode A, it is the 9 data bit received. In mode B, if SM21 is 0, RB81 is the
stop bit. Must be cleared by software.
TI1: Transmit interrupt flag, set by hardware after completion of a serial transfer.
Must be cleared by software.
RI1: Receive interrupt flag, set by hardware after completion of a serial reception.
Must be cleared by software.
9.1.
Serial interface 0
The Serial Interface 0 can operate in the following 4 modes:
SM0
0
0
1
1
SM1
0
1
0
1
Mode
0
1
2
3
Description
Shift register
8-bit UART
9-bit UART
9-bit UART
Board Rate
Fosc/12
Variable
Fosc/32 or Fosc/64
Variable
Here Fosc is the crystal or oscillator frequency.
9.1.1.
Mode 0
Pin RXD0 serves as input and output. TXD0 outputs the shift clock. 8 bits are transmitted with LSB first. The baud
rate is fixed at 1/12 of the crystal frequency. Reception is initialized in Mode 0 by setting the flags in S0CON as follows:
RI0 = 0 and REN0 = 1. In the other modes, a start bit when REN0 = 1 starts receiving serial data.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
43
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Fig. 9-1: Transmit mode 0 for Serial 0
Fig. 9-2: Receive mode 0 for Serial 0
9.1.2.
Mode 1
Here Pin RXD0 serves as input, and TXD0 serves as serial output. No external shift clock is used, 10 bits are
transmitted: a start bit (always 0), 8 data bits (LSB first), and a stop bit (always 1). On receive, a start bit synchronizes
the transmission, 8 data bits are available by reading S0BUF, and a stop bit sets the flag RB80 in the SFR S0CON. In
mode 1, either internal baud rate generator or timer 1 can be use to specify the desired baud rate.
Fig. 9-3: Transmit mode 1 for Serial 0
Fig. 9-4: Receive mode 1 for Serial 0
9.1.3.
Mode 2
This mode is similar to Mode 1, but with two differences. The baud rate is fixed at 1/32 (SMOD=1) or 1/64(SMOD=0) of
oscillator frequency, and 11 bits are transmitted or received: a start bit (0), 8 data bits (LSB first), a programmable Bit 9,
and a stop bit (1). Bit 9 can be used to control the parity of the serial interface: at transmission, bit TB80 in S0CON is
output as Bit 9, and at receive, Bit 9 affects RB80 in SFR S0CON.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
44
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
9.1.4.
Mode 3
The only difference between Mode 2 and Mode 3 is that: in Mode 3, either internal baud rate generator or timer 1 can be
use to specify baud rate.
Fig. 9-5: Transmit modes 2 and 3 for Serial 0
Fig. 9-6: Receive modes 2 and 3 for Serial 0
9.2.
Serial interface 1
The interrupt vector is 83h.
The Serial Interface 1 can operate in the following 2 modes:
SM
0
1
9.2.1.
Mode
A
B
Description
9-bit UART
8-bit UART
Variable
Variable
Baud Rate
Mode A
This mode is similar to Mode 2 and 3 of Serial interface 0, 11 bits are transmitted or received: a start bit (0), 8 data bits
(LSB first), a programmable Bit 9, and a stop bit (1). Bit 9 can be used to control the parity of the serial interface: at
transmission, bit TB81 in S1CON is outputted as Bit 9, and at receive, Bit 9 affects RB81 in SFR S1CON.
Fig. 9-7: Transmit mode A for Serial 1
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
45
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Fig. 9-8: Receive mode A for Serial 1
9.2.2.
Mode B
This mode is similar to Mode 1 of Serial interface 0. Pin RXD1 serves as input, and TXD1 serves as serial output. No
external shift clock is used. 10 bits are transmitted: a start bit (always 0), 8 data bits (LSB first), and a stop bit (always 1).
On receive, a start bit synchronizes the transmission, 8 data bits are available by reading S1BUF, and stop bit sets the
flag RB81 in the SFR S1CON. In mode B, internal baud rate generator is use to specify the baud rate.
Fig. 9-9: Transmit mode B for Serial 1
Fig. 9-10: Receive mode B for Serial 1
9.3.
Multiprocessor communication of Serial Interface 0 and 1
The feature of receiving 9 bits in Modes 2 and 3 of Serial Interface 0 or in Mode A of Serial Interface 1 can be used for
multiprocessor communication. In this case, the slave processors have bit SM20 in S0CON or SM21 in S1CON set to 1.
When the master processor outputs slave’s address, it sets the Bit 9 to 1, causing a serial port receive interrupt in all the
slaves. The slave processors compare the received byte with their network address. If matched, the addressed slave
will clear SM20 or SM21 and receive the rest of the message, while other slaves will leave SM20 or SM21 bit unaffected
and ignore this message. After addressing the slave, the host will output the rest of the message with the Bit 9 set to 0, so
no serial port receive interrupt will be generated in unselected slaves.
9.4.
Baud rate generator
9.4.1.
Serial interface 0 modes 1 and 3
(a) When BRGS = 0 (in SFR AUX):
Baud Rate =
2SMOD × FOSC
32 × 12 × (256 − TH1)
(b) When BRGS = 1 (in SFR AUX):
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
46
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
9.4.2.
9.5.
Baud Rate =
2SMOD × FOSC
64 × 210 − S0REL
)
Baud Rate =
FOSC
32 × 2 − S1REL
)
(
Serial interface 1 modes A and B
(
10
Clock source for baud rate
In case of application with higher clock precision requirement, external crystal is usually recommended clock source.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
47
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
10. Watchdog timer
The Watch Dog Timer (WDT) is an 8-bit free-running counter that generate reset signal if the counter overflows. The WDT
is useful for systems which are susceptible to noise, power glitches, or electronics discharge which causing software
dead loop or runaway. The WDT function can help user software recover from abnormal software condition. The WDT is
different from Timer0, Timer1 and Timer2 of general 8052. To prevent a WDT reset can be done by software periodically
clearing the WDT counter. User should check WDTF bit of WDTC register whenever un-predicted reset happened. After
an external reset the watchdog timer is disabled and all registers are set to zeros.
The watchdog timer has a free running on-chip RC oscillator (250KHz ±20%). The WDT will keep on running even after
the system clock has been turned off (for example, in sleep mode). During normal operation or sleep mode, a WDT
time-out (if enabled) will cause the MCU to reset. The WDT can be enabled or disabled any time during the normal mode.
Please refer the WDTE bit of WDTC register. The default WDT time-out period is approximately 16.38ms (WDTM [3:0] =
0100b).
The WDT has selectable divider input for the time base source clock. To select the divider input, the setting of bit3 ~ bit0
(WDTM [3:0]) of Watch Dog Timer Control Register (WDTC) should be set accordingly.
250KHz
2 WDTM
256
Watchdog reset time =
WDTCLK
WDTCLK =
WDTM [3:0]
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
Table 10.1 WDT time-out period
Divider
Time period @ 250KHz
(250 KHz RC oscillator in)
1
1.02ms
2
2.05ms
4
4.10ms
8
8.19ms
16
16.38ms (default)
32
32.77ms
64
65.54ms
128
131.07ms
256
262.14ms
512
524.29ms
1024
1.05s
2048
2.10s
4096
4.19s
8192
8.39s
16384
16.78s
32768
33.55s
When MCU is reset, the MCU will be read WDTEN control bit status. When WDTEN bit is set to 1, the watchdog function
will be disabled no matter what the WDTE bit status is. When WDTEN bit is clear to 0, the watchdog function will be
enabled if WDTE bit is set to 1 by program. User can to set WDTEN on the writer or ISP.
The program can enable the WDT function by programming 1 to the WDTE bit premise that WDTEN control bit is clear to
0. After WDTE set to 1, the 8 bit-counter starts to count with the selected time base source clock which set by WDTM [3:0].
It will generate a reset signal when overflows. The WDTE bit will be cleared to 0 automatically when MCU been reset,
either hardware reset or WDT reset.
Once the watchdog is started it cannot be stopped. User can refreshed the watchdog timer to zero by writing 0x55 to
Watch Dog Timer refresh Key (WDTK) register. This will clear the content of the 8-bit counter and let the counter re-start
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
48
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
to count from the beginning. The watchdog timer must be refreshed regularly to prevent reset request signal from
becoming active.
When Watchdog timer is overflow, the WDTF flag will set to one and automatically reset MCU. The WDTF flag can be
clear by software or external reset or power on reset.
Clear
Power on reset WDTF = 0
External reset
Software write “0”
250KHz RC
oscillator
1
TAKEY
(55, AA, 5A)
Set WDTF = 1
WDTCLK
WDT
Counter
2WDTM
Enable/Disable
WDT
WDTM[3:0]
WDT time-out reset
Refresh
WDT Counter
WDTC
Enable WDTC
write attribute
WDTF
WDTK
(0x55)
WDTEN
Fig. 10-1: Watchdog timer block diagram
Mnemonic
TAKEY
WDTC
WDTK
Description
Direct
Time Access Key
register
Watchdog timer
control register
Watchdog timer
refresh key
Bit 7
Bit 6
Bit 5
Bit 4
Watchdog Timer
F7h
B6h
Bit 3
Bit 2
Bit 1
Bit 0
RESET
TAKEY [7:0]
WDTF
-
WDTE
-
B7h
Mnemonic: TAKEY
7
6
5
00H
WDTM [3:0]
WDTK[7:0]
4
3
TAKEY [7:0]
2
1
04H
00H
Address: F7h
0
Reset
00H
Watchdog timer control register (WDTC) is read-only by default; software must write three specific
values 55h, AAh and 5Ah sequentially to the TAKEY register to enable the WDTC write attribute. That is:
MOV TAKEY, #55h
MOV TAKEY, #AAh
MOV TAKEY, #5Ah
Mnemonic: WDTC
7
6
5
WDTF
WDTE
4
-
3
2
1
WDTM [3:0]
Address: B6h
0
Reset
04H
WDTF: Watchdog timer reset flag.
When MCU is reset by watchdog, WDTF flag will be set to one by hardware. This flag
clear by software or external reset or power on reset.
WDTE: Control bit used to enable Watchdog timer.
The WDTE bit can be used only if WDTEN is "0". If the WDTEN bit is "0", then WDT
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
49
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
can be disabled / enabled by the WDTE bit.
0: Disable WDT.
1: Enable WDT.
The WDTE bit is not used if WDTEN is "1". That is, if the WDTEN bit is "1", WDT is
always disabled no matter what the WDTE bit status is. The WDTE bit can be read and
written.
WDTM [3:0]: WDT clock source divider bit. Please see table 10.1 to reference the WDT time-out
period.
Mnemonic: WDTK
7
6
5
4
3
WDTK[7:0]
2
1
Address: B7h
0
Reset
00h
WDTK: Watchdog timer refresh key.
A programmer must write 0x55 into WDTK register, and then the watchdog
timer will be cleared to zero.
For example, if enable WDT and select time-out reset period is 262.14ms.
First, programming the WDTEN to “0”.
Secondly,
MOV TAKEY, #55h
MOV TAKEY, #AAh
MOV TAKEY, #5Ah
; enable WDTC write attribute.
MOV WDTC, #28h
; Set WDTM [3:0] = 1000b. Set WDTE =1 to enable WDT
; function.
.
.
.
MOV WDTK, #55h
; Clear WDT timer to 0.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
50
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
11. Interrupt
The SM59R16A5 provides 15 interrupt sources with four priority levels. Each source has its own request flag(s) located in
a special function register. Each interrupt requested by the corresponding flag could individually be enabled or disabled
by the enable bits in SFR’s IEN0, IEN1, and IEN2.
When the interrupt occurs, the engine will vector to the predetermined address as shown in Table 11.1. Once interrupt
service has begun, it can be interrupted only by a higher priority interrupt. The interrupt service is terminated by a return
from instruction RETI. When an RETI is performed, the processor will return to the instruction that would have been next
when interrupt occurred.
When the interrupt condition occurs, the processor will also indicate this by setting a flag bit. This bit is set regardless of
whether the interrupt is enabled or disabled. Each interrupt flag is sampled once per machine cycle, and then samples are
polled by hardware. If the sample indicates a pending interrupt when the interrupt is enabled, then interrupt request flag is
set. On the next instruction cycle the interrupt will be acknowledged by hardware forcing an LCALL to appropriate vector
address.
Interrupt response will require a varying amount of time depending on the state of microcontroller when the interrupt
occurs. If microcontroller is performing an interrupt service with equal or greater priority, the new interrupt will not be
invoked. In other cases, the response time depends on current instruction. The fastest possible response to an interrupt is
7 machine cycles. This includes one machine cycle for detecting the interrupt and six cycles for perform the LCALL.
Table 11-1: Interrupt vectors
Interrupt Vector
Interrupt Request Flags
Address
IE0 – External interrupt 0
0003h
Interrupt Number
*(use Keil C Tool)
0
TF0 – Timer 0 interrupt
000Bh
1
IE1 – External interrupt 1
0013h
2
TF1 – Timer 1 interrupt
001Bh
3
RI0/TI0 – Serial channel 0 interrupt
0023h
4
TF2/EXF2 – Timer 2 interrupt
002Bh
5
PWMIF – PWM interrupt
0043h
8
SPIIF – SPI interrupt
004Bh
9
ADCIF – A/D converter interrupt
KBIIF – keyboard Interface interrupt
LVIIF – Low Voltage Interrupt
IICIF – IIC interrupt
RI1/TI1 – Serial channel 1 interrupt
0053h
005Bh
0063h
006Bh
0083h
10
11
12
13
16
RTC/ALARM interrupt
008Bh
17
Comparator interrupt
0093h
18
*See Keil C about C51 User’s Guide about Interrupt Function description
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
51
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Mnemonic
IEN0
IEN1
IEN2
IRCON
IRCON2
IP0
IP1
Description
Interrupt Enable
0 register
Interrupt Enable
1 register
Interrupt Enable
2 register
Interrupt request
register
Interrupt request
register 2
Interrupt priority
level 0
Interrupt priority
level 1
Direct
Bit 7
Bit 6
Bit 5
Interrupt
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
RESET
A8h
EA
-
ET2
ES0
ET1
EX1
ET0
EX0
00h
B8h
EXEN2
-
IEIIC
IELVI
IEKBI
IEADC
IESPI
IEPWM
00h
9Ah
-
-
-
-
-
ECmpI
ERTC
ES1
00h
C0H
EXF2
TF2
IICIF
LVIIF
KBIIF
ADCIF
SPIIF
PWMIF
00H
97H
-
-
-
-
-
CmpIF
RTCIF
-
00H
A9h
-
-
IP0.5
IP0.4
IP0.3
IP0.2
IP0.1
IP0.0
00h
B9h
-
-
IP1.5
IP1.4
IP1.3
IP1.2
IP1.1
IP1.0
00h
Interrupt Enable 0 register(IEN0)
Mnemonic: IEN0
7
6
EA
-
5
ET2
4
ES0
3
ET1
2
EX1
1
ET0
Address: A8h
0
Reset
EX0
00h
EA: EA=0 – Disable all interrupt.
EA=1 – Enable all interrupt.
ET2: ET2=0 – Disable Timer 2 overflow or external reload interrupt.
ET2=1 – Enable Timer 2 overflow or external reload interrupt.
ES0: ES0=0 – Disable Serial channel 0 interrupt.
ES0=1 – Enable Serial channel 0 interrupt.
ET1: ET1=0 – Disable Timer 1 overflow interrupt.
ET1=1 – Enable Timer 1 overflow interrupt.
EX1: EX1=0 – Disable external interrupt 1.
EX1=1 – Enable external interrupt 1.
ET0: ET0=0 – Disable Timer 0 overflow interrupt.
ET0=1 – Enable Timer 0 overflow interrupt.
EX0: EX0=0 – Disable external interrupt 0.
EX0=1 – Enable external interrupt 0.
Interrupt Enable 1 register(IEN1)
Mnemonic: IEN1
7
6
EXEN2
-
5
IEIIC
4
IELVI
3
IEKBI
2
IEADC
1
IESPI
Address: B8h
0
Reset
IEPWM
00h
EXEN2: Timer 2 reload interrupt enable.
EXEN2 = 0 – Disable Timer 2 external reload interrupt.
EXEN2 = 1 – Enable Timer 2 external reload interrupt.
IEIIC: IIC interrupt enable.
IEIICS = 0 – Disable IIC interrupt.
IEIICS = 1 – Enable IIC interrupt.
IELVI: LVI interrupt enable.
IELVI = 0 – Disable LVI interrupt.
IELVI = 1 – Enable LVI interrupt.
IEKBI: KBI interrupt enable.
IEKBI = 0 – Disable KBI interrupt.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
52
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
IEKBI = 1 – Enable KBI interrupt.
IEADC: A/D converter interrupt enable
IEADC = 0 – Disable ADC interrupt.
IEADC = 1 – Enable ADC interrupt.
IESPI: SPI interrupt enable.
IESPI = 0 – Disable SPI interrupt.
IESPI = 1 – Enable SPI interrupt.
IEPWM: PWM interrupt enable.
IEPWM = 0 – Disable PWM interrupt.
IEPWM = 1 – Enable PWM interrupt.
Interrupt Enable 2 register(IEN2)
Mnemonic: IEN2
7
6
-
5
-
4
-
3
-
2
ECmpI
1
ERTC
Address: 9Ah
0
Reset
ES1
00h
ECmpI: ECmpI =0 – Disable Comparator interrupt.
ECmpI =1 – Enable Comparator interrupt(include comparator_0 and comparator_1).
ERTC: ERTC =0 – Disable RTC interrupt.
ERTC =1 – Enable RTC interrupt(include Periodical and Alarm Int).
ES1: ES1=0 – Disable Serial channel 1 interrupt.
ES1=1 – Enable Serial channel 1 interrupt.
Interrupt request register(IRCON)
Mnemonic: IRCON
7
6
5
EXF2
TF2
IICIF
4
LVIIF
3
KBIIF
2
ADCIF
1
SPIIF
Address: C0h
0
Reset
PWMIF
00H
EXF2: Timer 2 external reloads flag. Must be cleared by software.
TF2: Timer 2 overflows flag. Must be cleared by software.
IICIF: IIC interrupt flag.
LVIIF: LVI interrupt flag.
KBIIF: KBI interrupt flag.
ADCIF: A/D converter end interrupt flag.
SPIIF: SPI interrupt flag.
PWMIF: PWM interrupt flag. Must be cleared by software.
Interrupt request register 2(IRCON2)
Mnemonic: IRCON2
7
6
5
-
4
-
3
-
2
CmpIF
1
RTCIF
Address: 97h
0
Reset
00H
RTCIF RTC interrupt flag(include Periodical and Alarm Int).
HW will clear this flag automatically when enter interrupt vector.
SW can clear this flag also.(in case RTC INT disable)
CmpIF Comparator interrupt flag.
HW will clear this flag automatically when enter interrupt vector.
SW can clear this flag also.(in case analog comparator INT disable)
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
53
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Priority level structure
All interrupt sources are combined in groups:
Table 11-2: Priority level groups
Groups
Serial channel 1 interrupt
RTC/ALARM interrupt
Comparator interrupt
-
External interrupt 0
Timer 0 interrupt
External interrupt 1
Timer 1 interrupt
Serial channel 0 interrupt
Timer 2 interrupt
PWM interrupt
SPI interrupt
ADC interrupt
KBI interrupt
LVI interrupt
IIC interrupt
Each group of interrupt sources can be programmed individually to one of four priority levels by setting or clearing one bit
in the special function register IP0 and one in IP1. If requests of the same priority level will be received simultaneously, an
internal polling sequence determines which request is serviced first.
Mnemonic: IP0
7
6
-
5
IP0.5
4
IP0.4
3
IP0.3
2
IP0.2
1
IP0.1
Address: A9h
0
Reset
IP0.0
00h
Mnemonic: IP1
7
6
-
5
IP1.5
4
IP1.4
3
IP1.3
2
IP1.2
1
IP1.1
Address: B9h
0
Reset
IP1.0
00h
IP1.x
0
0
1
1
Bit
IP1.0, IP0.0
IP1.1, IP0.1
IP1.2, IP0.2
IP1.3, IP0.3
IP1.4, IP0.4
IP1.5, IP0.5
Table 11-3: Priority levels
IP0.x
Priority Level
0
1
0
1
Level0 (lowest)
Level1
Level2
Level3 (highest)
Table 11-4: Groups of priority
Group
External interrupt 0
Serial channel 1 interrupt
Timer 0 interrupt
RTC/ALARM interrupt
External interrupt 1
Comparator interrupt
Timer 1 interrupt
Serial channel 0 interrupt
Timer 2 interrupt
-
PWM interrupt
SPI interrupt
ADC interrupt
KBI interrupt
LVI interrupt
IIC interrupt
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
54
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Table 11-5: Polling sequence
Interrupt source
Sequence
External interrupt 0
Serial channel 1 interrupt
PWM interrupt
RTC/ALARM interrupt
SPI interrupt
External interrupt 1
Comparator interrupt
ADC interrupt
Timer 1 interrupt
Polling sequence
Timer 0 interrupt
KBI interrupt
Serial channel 0 interrupt
LVI interrupt
Timer 2 interrupt
IIC interrupt
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
55
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
12. Power Management Unit
Power management unit serves two power management modes, IDLE and STOP, for the users to do power saving
function.
Mnemonic: PCON
7
6
SMOD MDUF
5
-
4
-
3
-
2
-
1
STOP
Address: 87h
0
Reset
IDLE
40h
STOP: Stop mode control bit. Setting this bit turning on the Stop Mode.
Stop bit is always read as 0
IDLE: Idle mode control bit. Setting this bit turning on the Idle Mode.
Idle bit is always read as 0
12.1. Idle mode
Setting the IDLE bit of PCON register invokes the IDLE mode. The IDLE mode leaves internal clocks and peripherals
running. Power consumption drops because the CPU is not active. The CPU can exit the IDLE state with any interrupts or
a reset.
12.2. Stop mode
Setting the STOP bit of PCON register invokes the STOP mode. All internal clocking in this mode is turn off. The CPU will
exit this state only if interrupts asserted from external INT0/1, KBI, LVI, and RTC, or a hardware reset by WDT and LVR.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
56
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
13. Pulse Width Modulation (PWM)
SM59R16A5 provides four-channel PWM outputs.
The interrupt vector is 43h.
Mnemonic
AUX
PWMC
PWMD0H
PWMD0L
PWMD1H
PWMD1L
PWMD2H
PWMD2L
PWMD3H
PWMD3L
PWMMDH
PWMMDL
Description
Auxiliary register
PWM Control
register
PWM 0 Data
register high byte
PWM 0 Data
register low byte
PWM 1 Data
register high byte
PWM 1 Data
register low byte
PWM 2 Data
register high byte
PWM 2 Data
register low byte
PWM 3 Data
register high byte
PWM 3 Data
register low byte
PWM Max Data
register high byte
PWM Max Data
register low byte
Direct
Bit 7
Bit 6
91h
BRGS
-
B5h
Bit 5
Bit 4
P4SPI
P4UR
1
-
PWMCS[2:0]
BCh
PWMP0
-
-
BDh
Bit 3
Bit 2
Bit 1
Bit 0
RESET
P2PW
DPS
M
PWM3E PWM2E PWM1E PWM0E
N
N
N
N
P4IIC
-
-
P0KBI
-
PWMD0[9:8]
PWMD0[7:0]
BEh
PWMP1
-
-
BFh
-
-
PWMP2
-
-
B2h
-
-
-
PWMD1[9:8]
PWMP3
-
-
B4h
-
-
-
PWMD2[9:8]
-
-
-
CFh
-
-
-
PWMD3[9:8]
4
P4UR1
3
P4IIC
2
P0KBI
1
P2PWM
-
PWMMD[9:8]
5
4
-
00H
00H
FFH
Address: 91h
0
Reset
DPS
00H
P2PWM : P2PWM = 0 – PWM function on P4.
P2PWM = 1 – PWM function on P2.
Mnemonic: PWMC
7
6
PWMCS[2:0]
00H
00H
PWMMD[7:0]
Mnemonic: AUX
7
6
5
BRGS
P4SPI
00H
00H
PWMD3[7:0]
CEh
00H
00H
PWMD2[7:0]
B3h
00H
00H
PWMD1[7:0]
B1h
00H
Address: B5h
3
2
1
0
Reset
PWM3EN PWM2EN PWM1EN PWM0EN 00H
PWMCS[2:0]: PWM clock select.
PWMCS [2:0]
Mode
000
Fosc
001
Fosc/2
010
Fosc/4
011
Fosc/6
100
Fosc/8
101
Fosc/12
110
Timer 0 overflow
111
Timer 0 external input (P3.4/T0)
PWM3EN: PWM channel 3 enable control bit.
PWM3EN = 1 – PWM channel 3 enable.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
57
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
PWM3EN = 0 – PWM channel 3 disable.
PWM2EN: PWM channel 2 enable control bit.
PWM2EN = 1 – PWM channel 2 enable.
PWM2EN = 0 – PWM channel 2 disable.
PWM1EN: PWM channel 1 enable control bit.
PWM1EN = 1 – PWM channel 1 enable.
PWM1EN = 0 – PWM channel 1 disable.
PWM0EN: PWM 0 enable control bit.
PWM0EN = 1 – PWM channel 0 enable.
PWM0EN = 0 – PWM channel 0 disable.
Mnemonic: PWMD0H
7
6
5
PWMP0
Mnemonic: PWMD0L
7
6
5
4
-
3
-
4
3
PWMD0[7:0]
2
2
Address: BCh
1
0
Reset
PWMD0[9:8]
00H
1
Address: BDh
0
Reset
00h
PWMP0: PWM channel 0 idle polarity select.
“0” – PWM channel 0 will idle low.
“1” – PWM channel 0 will idle high.
PWMD0[9:0]: PWM channel 0 data register.
Mnemonic: PWMD1H
7
6
5
PWMP1
Mnemonic: PWMD1L
7
6
5
4
-
3
-
4
3
PWMD1[7:0]
2
2
Address: BEh
1
0
Reset
PWMD1[9:8]
00H
1
Address: BFh
0
Reset
00H
PWMP1: PWM channel 1 idle polarity select.
“0” – PWM channel 1 will idle low.
“1” – PWM channel 1 will idle high.
PWMD1[9:0]: PWM channel 1 data register.
Mnemonic: PWMD2H
7
6
5
PWMP2
Mnemonic: PWMD2L
7
6
5
4
-
3
-
4
3
PWMD2[7:0]
2
2
Address: B1h
1
0
Reset
PWMD2[9:8]
00H
1
Address: B2h
0
Reset
00H
PWMP2: PWM channel 2 idle polarity select.
“0” – PWM channel 2 will idle low.
“1” – PWM channel 2 will idle high.
PWMD2[9:0]: PWM channel 2 data register.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
58
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Mnemonic: PWMD3H
7
6
5
PWMP3
Mnemonic: PWMD3L
7
6
5
4
-
3
-
4
3
PWMD3[7:0]
2
2
Address: B3h
1
0
Reset
PWMD3[9:8]
00H
1
Address: B4h
0
Reset
00H
PWMP3: PWM channel 3 idle polarity select.
“0” – PWM channel 3 will idle low.
“1” – PWM channel 3 will idle high.
PWMD3[9:0]: PWM channel 3 data register.
Mnemonic: PWMMDH
7
6
5
Mnemonic: PWMMDL
7
6
5
4
-
3
-
4
3
PWMMD[7:0]
2
2
Address: CEh
1
0
Reset
PWMMD[9:8]
00H
1
Address: CFh
0
Reset
FFH
PWMMD[9:0]: PWM Max Data register.
PWM count from 0000h to PWMMD[9:0]. When PWM count data equal PWMMD[9:0]
is overflow.
PWMPx = 0 & PWMDx = 00h
PWMx
Low
PWMPx = 0 & PWMDx ≠ 00h
PWMx
PWMPx = 1 & PWMDx = 00h
PWMx
High
PWMPx = 1 & PWMDx ≠ 00h
PWMx
PWMMD + 1
PWM clock
PWMDx
Leader pulse =
PWM clock
PWM period =
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
59
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
14. IIC function
The IIC module uses the SCL (clock) and the SDA (data) line to communicate with external IIC interface. Its speed can be
selected to 400Kbps (maximum) by software setting the IICBR [2:0] control bit. The IIC module provided 2 interrupts
(RXIF, TXIF). It will generate START, repeated START and STOP signals automatically in master mode and can detects
START, repeated START and STOP signals in slave mode. The maximum communication length and the number of
devices that can be connected are limited by a maximum bus capacitance of 400pF.
The interrupt vector is 6Bh.
Mnemonic
AUX
IICCTL
IICS
IICA1
IICA2
IICRWD
IICS2
Description
Auxiliary register
IIC control
register
IIC status register
IIC Address 1
register
IIC Address 2
register
IIC Read/Write
register
IIC status2
register
Direct
Bit 7
91h
BRGS
F9h
IICEN
F8h
MStart
Bit 6
Bit 5
IIC function
-
RXIF
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
RESET
P4SPI
P4UR
1
P4IIC
P0KBI
P2PW
M
DPS
00H
MSS
MAS
RStart
TXIF
RDR
TDR
FAh
IICA1[7:1]
FBh
IICA2[7:1]
FCh
FDh
Mnemonic: AUX
7
6
5
BRGS
P4SPI
RXAK
IICBR[2:0]
04H
TXAK
00H
RW
MATCH1
or RW1
MATCH2
or RW2
IICRWD[7:0]
-
-
4
P4UR1
-
-
AB_EN
3
P4IIC
2
P0KBI
1
P2PWM
3
RStart
2
A0H
60H
00H
BF_E
N
AB_F
BF
00H
Address: 91h
0
Reset
DPS
00H
P4IIC: P4IIC = 0 – IIC function on P1.
P4IIC = 1 – IIC function on P4.
Mnemonic: IICCTL
7
6
5
IICEN
MSS
4
MAS
1
IICBR[2:0]
Address: F9h
0
Reset
04h
IICEN: Enable IIC module
IICEN = 1 is Enable
IICEN = 0 is Disable.
MSS: Master or slave mode select.
MSS = 1 is master mode.
MSS = 0 is slave mode.
*The software must set this bit before setting others register.
MAS: Master address select (master mode only)
MAS = 0 is to use IICA1.
MAS = 1 is to use IICA2.
RStart: Re-start control bit (master mode only)
When this bit is set, the module will generate a start condition to the SDA and SCL lines (after
current ACK) and send out the calling address which is stored in the IICA1 or IICA2( selected by
MAS control bit).When module is finished to send out address, this bit will be cleared by
hardware.
IICBR[2:0]: Baud rate selection (master mode only), where Fosc is the external crystal or oscillator
frequency. The default is Fosc/512 for users’ convenience.
IICBR[2:0]
Baud rate
000
Fosc/32
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
60
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
001
010
011
100
101
110
111
Mnemonic: IICS
7
6
MStart
RxIF
Fosc/64
Fosc/128
Fosc/256
Fosc/512
Fosc/1024
Fosc/2048
Fosc/4096
5
TxIF
4
RDR
3
TDR
2
RxAK
1
TxAK
Address: F8h
0
Reset
RW
00h
MStart: Master Start control bit. (Master mode only)
If set the MStart bit, the module will generate a start condition to the SDA and SCL lines
and send out the calling address which is stored in the IICA1 or IICA2 (selected by MAS
control bit). When software cleared this bit, the module will generate a stop condition to
the SDA and SCL.
RxIF: The data Receive Interrupt Flag (RXIF) is set after the IICRWD (IIC Read Write Data
Buffer) is loaded with a newly receive data.
TxIF: The data Transmit Interrupt Flag (TXIF) is set when the data of the IICRWD (IIC Read
Write Data Buffer) is downloaded to the shift register.
RDR: The MCU must clear this bit after it gets the data from IICRWD. The IIC module is able to
write new data into IICRWD only when this bit is cleared.
TDR: When MCU finish writing data to IICRWD, the MCU needs to set this bit to ‘1’ to inform
the IIC module to send the data in the IICRWD. After IIC module finishes sending the
data from IICRWD, this bit will be cleared automatically.
RxAK: The Acknowledge Status indicate bit. When clear, it means an acknowledge signal has
been received after the complete 8 bits data transmit on the bus.
TxAK: The Acknowledge status transmit bit. When received complete 8 bits data, this bit will set
(NoAck) or clear (Ack) and transmit to master to indicate the receive status. Actually, it is
th
sent as the 9 bit in one byte transmission as show in Fig. 14-1.
RW: The slave mode read (received) or wrote (transmit) on the IIC bus. When this bit is clear,
the slave module received data on the IIC bus (SDA).(Slave mode only)
th
Fig. 14-1: Acknowledgement bit in the 9 bit of a byte transmission
Mnemonic: IICA1
7
6
5
4
IICA1[7:1]
R/W
3
2
1
Address: FAH
0
Reset
Match1 or
A0H
RW1
R or R/W
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
61
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Slave mode:
IICA1[7:1]: IIC Address registers
This is the first 7-bit address for this slave module. It will be checked when an address (from
master) is received
Match1: When IICA1 matches with the received address from the master side, this bit will set to 1 by
hardware. When IIC bus gets or send first data, this bit will clear automatically.
Master mode:
IICA1[7:1]: IIC Address registers
This 7-bit address indicate the slave with which it want to communicate.
RW1: This bit will be sent out as RW of the slave side if the module has set the MStart or RStart bit. It
th
appears at the 8 bit after the IIC address as shown in Fig. 14-2. It is used to tell the salve the
direction of the following communication. If it is 1, the module is in master receive mode. If 0, the
module is in master transmit mode.
th
Fig. 14-2: RW bit in the 8 bit after IIC address
Mnemonic: IICA2
7
6
5
Address: FBh
4
IICA2[7:1]
R/W
3
2
1
0
Match2 or RW2
R or R/W
Reset
60h
Slave mode:
IICA2[7:1]: IIC Address registers
This is the second 7-bit address for this slave module.
It will be checked when an address (from master) is received
Match2: When IICA2 matches with the received address from the master side, this bit will set to 1 by
hardware. When IIC bus gets or send first data, this bit will clear automatically.
Master mode:
IICA2[7:1]: IIC Address registers
This 7-bit address indicate the slave with which it want to communicate.
RW2: This bit will be sent out as RW of the slave side if the module has set the MStart or RStart bit. It is
used to tell the salve the direction of the following communication. If it is 1, the module is in
master receive mode. If 0, the module is in master transmit mode.
Mnemonic: IICRWD
7
6
5
4
3
IICRWD[7:0]
2
1
Address: FCh
0
Reset
00h
IICRWD[7:0]: IIC read write data buffer.
In receiving (read) mode, the received byte is stored here.
In transmitting mode, the byte to be shifted out through SDA stays here.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
62
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Mnemonic: IICS2
7
6
-
5
-
4
-
3
AB_EN
2
BF_EN
1
AB_F
Address: FDH
0
Reset
BF
00H
AB_EN: Arbitration lost enable bit. (Master mode only)
If set AB_EN bit, the hardware will check arbitration lost. Once arbitration lost occurred,
hardware will return to IDLE state. If this bit is cleared, hardware will not care arbitration
lost condition. Set this bit when multi-master and slave connection. Clear this bit when
single master to single slave.
BF_EN: Bus busy enable bit. (Master mode only)
If set BF_EN bit, hardware will not generate a start condition to bus until BF=0. Clear
this bit will always generate a start condition to bus when MStart is set. Set this bit when
multi-master and slave connection. Clear this bit when single master to single slave.
AB_F: Arbitration lost bit. (Master mode only)
In multi-master condition, when send out data bit “1” but return back “0”, bus arbitration
lost occurred and this bit will be set. Software need to clear this bit and check until BF=0
to resend data again.
BF: Bus busy bit. (Master mode only)
If detect scl=0 or sda=0 or bus start, this bit will be set. If detect stop and a period
passed(about 4.7us), this bit will be cleared. This bit can be cleared by software to
return ready state.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
63
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
15. SPI function
Serial Peripheral Interface (SPI) is a synchronous protocol that allows a master device to initiate communication with
slave devices.
The interrupt vector is 4Bh.
There are 4 signals used in SPI, they are
SPI_MOSI: data output in the master mode, data input in the slave mode,
SPI_MISO: data input in the master mode, data output in the slave mode,
SPI_SCK: clock output form the master, the above data are synchronous to this signal
SPI_SS: input in the slave mode.
This slave device detects this signal to judge if it is selected by the master.
In the master mode, it can select the desired slave device by any IO with value = 0.
relation of the 4 signals between master and slaves.
Master
Fig. 15-1 is an example showing the
Slave 2
Slave 1
MOSI
MISO
CLK
IO
IO
MOSI
MISO
CLK
MOSI
MISO
CLK
SS
SS
Fig. 15-1: SPI signals between master and slave devices
There is only one channel SPI interface. The SPI SFRs are shown as below:
Mnemonic
AUX
SPIC1
SPIC2
SPIS
SPITXD
SPIRXD
Description
Auxiliary register
SPI control register
1
SPI control register
2
SPI status register
SPI transmit data
buffer
SPI receive data
buffer
Direct
Bit 7
Bit 6
Bit 5
SPI function
91h
BRGS
F1h
SPIEN SPIMSS
F2h
SPIFD
F5h
-
-
P4SPI
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
RESET
P4UR
1
P4IIC
P0KBI
P2PW
M
DPS
00H
SPISS
SPICKP SPICKE
P
TBC[2:0]
-
SPIBR[2:0]
08H
RBC[2:0]
00H
SPIMLS SPIOV SPITXIF SPITDR SPIRXIF SPIRDR SPIRS
40H
F3h
SPITXD[7:0]
00H
F4h
SPIRXD[7:0]
00H
Mnemonic: AUX
7
6
5
BRGS
P4SPI
4
P4UR1
3
P4IIC
2
P0KBI
1
P2PWM
Address: 91h
0
Reset
DPS
00H
P4SPI: P4SPI = 0 – SPI function on P1.
P4SPI = 1 – SPI function on P4.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
64
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Mnemonic: SPIC1
7
6
SPIEN SPIMSS
5
SPISSP
4
SPICKP
3
SPICKE
2
Address: F1h
1
0
Reset
SPIBR[2:0]
08h
SPIEN: Enable SPI module. “1” is Enable. “0” is Disable.
SPIMSS: Master or Slave mode Select
“1” is Master mode.
“0” is Slave mode.
SPISSP: Slave Select (SS) active polarity (slave mode used only)
“1” - high active.
“0” - low active.
SPICKP: Clock idle polarity (master mode used only)
“1” – SCK high during idle. Ex :
“0” - SCK low during idle. Ex :
SPICKE: Clock sample edge select.
“1” – data latch in rising edge
“0” – data latch in falling edge.
* To ensure the data latch stability, SM59R16A5 generate the output data as given in the following
example, the other side can latch the stable data no matter in rising or falling edge.
sufficient set-up time
sufficient hold time
SPIBR[2:0]: SPI baud rate select (master mode used only), here Fosc is the external crystal or oscillator
frequency :
SPIBR[2:0] Baud rate
0:0:0
Fosc/4
0:0:1
Fosc/8
0:1:0
Fosc/16
0:1:1
Fosc/32
1:0:0
Fosc/64
1:0:1
Fosc/128
1:1:0
Fosc/256
1:1:1
Fosc/512
Mnemonic: SPIC2
7
6
5
SPIFD
TBC[2:0]
4
3
-
2
1
RBC[2:0]
Address: F2h
0
Reset
00h
SPIFD: Full-duplex mode enable.
“1” : enable full-duplex mode.
“0” : disable full-duplex mode.
When it is set, the TBC[2:0] and RBC[2:0] will be reset and keep to zero, i.e., only 8-bit
communication is allowed in the full-duplex mode. When the master device transmits data to the
slave device via the MOSI line, the slave device responds sends data back to the master device
via the MISO line. This implies that full-duplex transmission with both out-data and in-data are
synchronized with the same clock SCK as shown below.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
65
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Input Shift register
SPIRXD
Output Shift register
SPITXD
Clock Generator
MISO
MISO
MOSI
MOSI
SCK
SCK
Output Shift register
SPITXD
Input Shift register
SPIRXD
SyncMos Slave
SyncMos Master
TBC[2:0]: SPI transmitter bit counter, here 1-8 bits are allowed except for the full-duplex mode
TBC[2:0]
Bit counter
0:0:0
8 bits output
0:0:1
1 bit output
0:1:0
2 bits output
0:1:1
3 bits output
1:0:0
4 bits output
1:0:1
5 bits output
1:1:0
6 bits output
1:1:1
7 bits output
RBC[2:0]: SPI receiver bit counter, here 1-8 bits are allowed except for the full-duplex mode
RBC[2:0]
Bit counter
0:0:0
8 bits input
0:0:1
1 bit input
0:1:0
2 bits input
0:1:1
3 bits input
1:0:0
4 bits input
1:0:1
5 bits input
1:1:0
6 bits input
1:1:1
7 bits input
Mnemonic: SPIS
7
6
5
SPIMLS SPIOV
4
SPITXIF
3
SPITDR
2
SPIRXIF
1
SPIRDR
Address: F5h
0
Reset
SPIRS
40h
SPIMLS: MSB or LSB output /input first
“1” : MSB output/input first
“0” : LSB output/input first
SPIOV: Overflow flag.
When SPIRDR is set (one byte in SPIRXD but has not been taken away) and the next data also
enters (there is no blocking function), this flag will be set to inform that the received data in
SPIRXD is damaged by this overflow. It is clear by hardware when SPIRDR is cleared.
SPITXIF: Transmit Interrupt Flag.
This bit is set when the data of the SPITXD register is downloaded to the shift register.
SPITDR: Transmit Data Ready.
When MCU finish writing data to SPITXD register, the MCU needs to set this bit to ‘1’ to inform the
SPI module to send the data. After SPI module finishes sending the data from SPITXD or SPITXD
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
66
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
is downloaded to shift register, this bit will be cleared automatically.
SPIRXIF: Receive Interrupt Flag.
This bit is set after the SPIRXD is loaded with a newly receive data.
SPIRDR: Receive Data Ready.
When a byte is received, SPIRDR is set as a flag to inform MCU. The MCU must clear this bit
after it gets the data from SPIRXD register. If the SPI module on the transmit side writes new
data into the SPIRXD before this bit is cleared, then the data will be overwritten.
SPIRS: Receive Start.
This bit set to “1” to inform the SPI module to receive the data into SPIRXD register.
Mnemonic: SPITXD
7
6
5
4
3
SPITXD[7:0]
2
1
0
Address: F3h
Reset
00h
SPITXD[7:0]: Transmit data buffer.
Mnemonic: SPIRXD
7
6
5
4
3
SPIRXD[7:0]
2
1
Address: F4h
0
Reset
00h
SPIRXD[7:0]: Receive data buffer.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
67
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
16. KBI – Keyboard Interface
Keyboard interface (KBI) can be connected to an 8 x n matrix keyboard or any similar devices. It has 8 inputs with
programmable interrupt capability on either high or low level. These 8 inputs are through P2 or P0 and can be the external
interrupts to leave from the idle and stop modes. The 8 inputs are independent from each other but share the same
interrupt vector 5Bh.
Input
circuitry
Input
circuitry
Input
circuitry
Input
circuitry
Input
circuitry
Input
circuitry
Input
circuitry
Input
circuitry
KBI0
KBI1
KBI2
KBI3
KBI4
KBI5
KBI6
KBI7
OR
KBIIF: KBI interrupt flag
IEKBI: KBI interrupt enable
Figure 16.1 keyboard interface block diagram
250KHz
KBIx
0
De-bounce
KBF.x
1
KBD[1:0]
KBLS.x
KBE.x
Figure 16.2 keyboard input circuitry
Mnemonic
AUX
KBLS
KBE
KBF
KBD
Description
Auxiliary register
KBI level
selection
KBI input enable
KBI flag
KBI De-bounce
control register
Direct
Bit 7
Bit 6
Bit 5
KBI function
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
RESET
91h
BRGS
-
P4SPI
P4UR
1
P4IIC
P0KBI
P2PW
M
DPS
00H
93h
KBLS7
KBLS6
KBLS5
KBLS4
KBLS3
KBLS2
KBLS1
KBLS0
00H
94h
95h
KBE7
KBF7
KBE6
KBF6
KBE5
KBF5
KBE4
KBF4
KBE3
KBF3
KBE2
KBF2
KBE1
KBF1
KBE0
KBF0
00H
00H
96h
KBDEN
-
-
-
-
-
KBD1
KBD0
00H
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
68
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Mnemonic: AUX
7
6
5
BRGS
P4SPI
4
P4UR1
3
P4IIC
2
P0KBI
1
P2PWM
Address: 91h
0
Reset
DPS
00H
P0KBI: P0KBI = 0 – KBI function on P2.
P0KBI = 1 – KBI function on P0.
Mnemonic: KBLS
7
6
KBLS.7
KBLS.6
5
KBLS.5
4
KBLS.4
3
KBLS.3
2
KBLS.2
1
KBLS.1
Address: 93h
0
Reset
KBLS.0
00h
2
KBE.2
1
KBE.1
Address: 94h
0
Reset
KBE.0
00h
KBLS.7: Keyboard Line 7 level selection bit
0 : enable a low level detection on KBI7.
1 : enable a high level detection on KBI7.
KBLS.6: Keyboard Line 6 level selection bit
0 : enable a low level detection on KBI6.
1 : enable a high level detection on KBI6.
KBLS.5: Keyboard Line 5 level selection bit
0 : enable a low level detection on KBI5.
1 : enable a high level detection on KBI5.
KBLS.4: Keyboard Line 4 level selection bit
0 : enable a low level detection on KBI4.
1 : enable a high level detection on KBI4.
KBLS.3: Keyboard Line 3 level selection bit
0 : enable a low level detection on KBI3.
1 : enable a high level detection on KBI3.
KBLS.2: Keyboard Line 2 level selection bit
0 : enable a low level detection on KBI2.
1 : enable a high level detection on KBI2.
KBLS.1: Keyboard Line 1 level selection bit
0 : enable a low level detection on KBI1.
1 : enable a high level detection on KBI1.
KBLS.0: Keyboard Line 0 level selection bit
0 : enable a low level detection on KBI0.
1 : enable a high level detection on KBI0.
Mnemonic: KBE
7
6
KBE.7
KBE.6
5
KBE.5
4
KBE.4
3
KBE.3
KBE.7: Keyboard Line 7 enable bit
0 : enable standard I/O pin.
1 : enable KBF.7 bit in KBF register to generate an interrupt request.
KBE.6: Keyboard Line 6 enable bit
0 : enable standard I/O pin.
1 : enable KBF.6 bit in KBF register to generate an interrupt request.
KBE.5: Keyboard Line 5 enable bit
0 : enable standard I/O pin.
1 : enable KBF.5 bit in KBF register to generate an interrupt request.
KBE.4: Keyboard Line 4 enable bit
0 : enable standard I/O pin.
1 : enable KBF.4 bit in KBF register to generate an interrupt request.
KBE.3: Keyboard Line 3 enable bit
0 : enable standard I/O pin.
1 : enable KBF.3 bit in KBF register to generate an interrupt request.
KBE.2: Keyboard Line 2 enable bit
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
69
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
0 : enable standard I/O pin.
1 : enable KBF.2 bit in KBF register to generate an interrupt request.
KBE.1: Keyboard Line 1 enable bit
0 : enable standard I/O pin.
1 : enable KBF.1 bit in KBF register to generate an interrupt request.
KBE.0: Keyboard Line 0 enable bit
0 : enable standard I/O pin.
1 : enable KBF.0 bit in KBF register to generate an interrupt request.
Mnemonic: KBF
7
6
KBF.7
KBF.6
5
KBF.5
4
KBF.4
3
KBF.3
2
KBF.2
1
KBF.1
Address: 95h
0
Reset
KBF.0
00h
KBF.7: Keyboard Line 7 flag
This is set by hardware when KBI7 detects a programmed level.
It generates a Keyboard interrupt request if KBE.7 is also set. It must be cleared by software.
KBF.6: Keyboard Line 6 flag
This is set by hardware when KBI6 detects a programmed level.
It generates a Keyboard interrupt request if KBE.6 is also set. It must be cleared by software.
KBF.5: Keyboard Line 5 flag
This is set by hardware when KBI5 detects a programmed level.
It generates a Keyboard interrupt request if KBE.5 is also set. It must be cleared by software.
KBF.4: Keyboard Line 4 flag
This is set by hardware when KBI4 detects a programmed level.
It generates a Keyboard interrupt request if KBE.4 is also set. It must be cleared by software.
KBF.3: Keyboard Line 3 flag
This is set by hardware when KBI3 detects a programmed level.
It generates a Keyboard interrupt request if KBE.3 is also set. It must be cleared by software.
KBF.2: Keyboard Line 2 flag
This is set by hardware when KBI2 detects a programmed level.
It generates a Keyboard interrupt request if KBE.2 is also set. It must be cleared by software.
KBF.1: Keyboard Line 1 flag
This is set by hardware when KBI1 detects a programmed level.
It generates a Keyboard interrupt request if KBE.1 is also set. It must be cleared by software.
KBF.0: Keyboard Line 0 flag
This is set by hardware when KBI0 detects a programmed level.
It generates a Keyboard interrupt request if KBE.0 is also set. It must be cleared by software.
Mnemonic: KBD
7
6
KBDEN
-
5
-
4
-
3
-
2
-
1
KBD.1
Address: 96H
0
Reset
KBD.0
00H
KBDEN: Enable KBI de-bounce function. The default KBI function is enabled.
KBDEN = 0, enable KBI de-bounce function. The de-bounce time is selected by KBD [1:0].
KBDEN = 1, disable KBI de-bounce function. The KBI input pin without de-bounce mechanism.
KBD[1:0]: Select KBI de-bounce time. If KBDEN = “0”, the default de-bounce time is 320 ms.
KBD[1:0] = 00, the de-bounce time is 320 ms.
KBD[1:0] = 01, the de-bounce time is 160 ms.
KBD[1:0] = 10, the de-bounce time is 80 ms.
KBD[1:0] = 11, the de-bounce time is 40 ms.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
70
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
17. LVI – Low Voltage Interrupt
The interrupt vector 63h.
Mnemonic: LVC
7
6
5
LVI_EN
LVRXE
4
-
3
-
2
-
1
-
Address: E6h
0
Reset
20H
LVI_EN: Low voltage interrupt function enable bit.
LVI_EN = 0 : disable low voltage detect function.
LVI_EN = 1 : enable low voltage detect function.
LVRXE: External low voltage reset function enable bit.
LVRXE = 0 : disable external low voltage reset function.
LVRXE = 1 : enable external low voltage reset function.
Low Voltage Detect Level
SM59R16A5C
SM59R16A5L
LVI
3.5V
2.3V
LVRX
3.1V
2.1V
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
71
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
18. 10-bit Analog-to-Digital Converter (ADC)
The SM59R16A5 provides eight channels 10-bit ADC. The Digital output DATA [9:0] were put into ADCD [9:0]. The ADC
interrupt vector is 53H.
The ADC SFR show as below:
Mnemonic
ADCC1
ADCC2
ADCDH
ADCDL
ADCCS
Description
Direct
ADC Control
register 1
ADC Control
register 2
ADC data high
byte
ADC data low
byte
ADC clock select
ABh
Bit 7
Bit 6
Bit 5
ADC
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
RESET
ADC7EN ADC6EN ADC5EN ADC4EN ADC3EN ADC2EN ADC1EN ADC0EN
ACh
Start
ADJUST
-
-
-
ADCCH[2:0]
00H
00H
ADh
ADCDH [7:0]
00H
AEh
ADCDL [7:0]
00H
AFh
-
-
-
ADCCS[4:0]
Mnemonic: ADCC1
Address: ABh
7
6
5
4
3
2
1
0
Reset
ADC7EN ADC6EN ADC5EN ADC4EN ADC3EN ADC2EN ADC1EN ADC0EN
00H
ADC7EN: ADC channels 7 enable.
ADC7EN = 1 – Enable ADC channel 7
ADC6EN: ADC channels 6 enable.
ADC6EN = 1 – Enable ADC channel 6
ADC5EN: ADC channels 5 enable.
ADC5EN = 1 – Enable ADC channel 5
ADC4EN: ADC channels 4 enable.
ADC4EN = 1 – Enable ADC channel 4
ADC3EN: ADC channels 3 enable.
ADC3EN = 1 – Enable ADC channel 3
ADC2EN: ADC channels 2 enable.
ADC2EN = 1 – Enable ADC channel 2
ADC1EN: ADC channels 1 enable.
ADC1EN = 1 – Enable ADC channel 1
ADC0EN: ADC channels 0 enable.
ADC0EN = 1 – Enable ADC channel 0
Mnemonic: ADCC2
7
6
5
4
3
Start
ADJUST
-
-
-
2
Address: ACh
Rese
1
0
t
ADCCH[2:0]
00H
Start: When this bit is set, the ADC will be start conversion.
ADJUST: Adjust the format of ADC conversion DATA.
ADJUST = 0: (default value)
ADC data high byte ADCD [9:2] = ADCDH [7:0].
ADC data low byte ADCD [1:0] = ADCDL [1:0].
ADJUST = 1:
ADC data high byte ADCD [9:8] = ADCDH [1:0].
ADC data low byte ADCD [7:0] = ADCDL [7:0].
ADCCH[2:0]: ADC channel select.
ADCCH [2:0]
Channel
000
0
001
1
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
72
Ver.G SM59R16A5 01/2014
00H
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
010
011
100
101
110
111
2
3
4
5
6
7
ADJUST = 0:
Mnemonic: ADCDH
Address: ADh
7
6
5
4
3
2
1
0
Reset
ADCD[9] ADCD[8] ADCD[7] ADCD[6] ADCD[5] ADCD[4] ADCD[3] ADCD[2]
00H
Mnemonic: ADCDL
7
6
-
5
-
ADJUST = 1:
Mnemonic: ADCDH
7
6
-
4
-
5
-
4
-
3
-
2
-
3
-
1
ADCD[1]
2
-
Address: AEh
0
Reset
ADCD[0]
00H
Address: ADh
1
0
Reset
ADCD[9] ADCD[8]
00H
Mnemonic: ADCDL
Address: AEh
7
6
5
4
3
2
1
0
Reset
ADCD[7] ADCD[6] ADCD[5] ADCD[4] ADCD[3] ADCD[2] ADCD[1] ADCD[0]
00H
ADCD[9:0]: ADC data register.
Mnemonic: ADCCS
7
6
-
5
-
Address: AFh
4
3
2
1
0
Reset
ADCCS[4] ADCCS[3] ADCCS[2] ADCCS[1] ADCCS[0]
00H
ADCCS[4:0]: ADC clock select.
*The ADC clock maximum 12.5MHz.
*The ADC Conversion rate maximum 500KHz.
ADCCS[4:0]
ADC Clock(Hz)
Clocks for ADC Conversion
00000
Fclk/2
46
00001
Fclk/4
92
00010
Fclk/6
138
00011
Fclk/8
184
00100
Fclk/10
230
00101
Fclk/12
276
00110
Fclk/14
322
00111
Fclk/16
368
01000
Fclk/18
414
01001
Fclk/20
460
01010
Fclk/22
506
01011
Fclk/24
552
01100
Fclk/26
598
01101
Fclk/28
644
01110
Fclk/30
690
01111
Fclk/32
736
10000
Fclk/34
782
10001
Fclk/36
828
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
73
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
10010
10011
10100
10101
10110
10111
11000
11001
11010
11011
11100
11101
11110
11111
Fclk/38
Fclk/40
Fclk/42
Fclk/44
Fclk/46
Fclk/48
Fclk/50
Fclk/52
Fclk/54
Fclk/56
Fclk/58
Fclk/60
Fclk/62
Fclk/64
874
920
966
1012
1058
1104
1150
1196
1242
1288
1334
1380
1426
1472
Fclk
2 × ( ADCCS + 1)
ADC_Clock
ADC _ Conversion _ Rate =
23
ADC _ Clock =
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
74
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
19. In-System Programming (Internal ISP)
The SM59R16A5 can generate flash control signal by internal hardware circuit. Users utilize flash control register, flash
address register and flash data register to perform the ISP function without removing the SM59R16A5 from the system.
The SM59R16A5 provides internal flash control signals which can do flash program/chip erase/page erase/protect
functions. User need to design and use any kind of interface which SM59R16A5 can input data. User then utilize ISP
service program to perform the flash program/chip erase/page erase/protect functions.
19.1. ISP service program
The ISP service program is a user developed firmware program which resides in the ISP service program space.
After user developed the ISP service program, user then determine the size of the ISP service program. User need
to program the ISP service program in the SM59R16A5 for the ISP purpose.
The ISP service programs were developed by user so that it should includes any features which relates to the flash
memory programming function as well as communication protocol between SM59R16A5 and host device which
output data to the SM59R16A5. For example, if user utilize UART interface to receive/transmit data between
SM59R16A5 and host device, the ISP service program should include baud rate, checksum or parity check or any
error-checking mechanism to avoid data transmission error.
The ISP service program can be initiated under SM59R16A5 active or idle mode. It can not be initiated under power
down mode.
19.2. Lock Bit (N)
The Lock Bit N has two functions: one is for service program size configuration and the other is to lock the ISP
service program space from flash erase function.
The ISP service program space address range $F000 to $FFFF. It can be divided as blocks of N*256 byte. (N=0 to
16). When N=0 means no ISP function, all of 64K byte flash memory can be used as program memory. When N=1
means ISP service program occupies 256 byte while the rest of 63.75K byte flash memory can be used as program
memory. The maximum ISP service program allowed is 4K byte when N=16. Under such configuration, the usable
program memory space is 60K byte.
After N determined, SM59R16A5 will reserve the ISP service program space downward from the top of the program
address $FFFF. The start address of the ISP service program located at $Fx00 while x is an even number,
depending on the lock bit N. As shown in Table 19-1.
The lock bit N function is different from the flash protect function. The flash erase function can erase all of the flash
memory except for the locked ISP service program space. If the flash not has been protected, the content of ISP
service program still can be read. If the flash has been protected, the overall content of flash program memory space
including ISP service program space can not be read.
Table 19.1 ISP code area.
N
ISP service program address
0
No ISP service program
1
256 bytes ($FF00h ~ $FFFFh)
2
512 bytes ($FE00h ~ $FFFFh)
3
768 bytes ($FD00h ~ $FFFFh)
4
1.0 K bytes ($FC00h ~ $FFFFh)
5
1.25 K bytes ($FB00h ~ $FFFFh)
6
1.5 K bytes ($FA00h ~ $FFFFh)
7
1.75 K bytes ($F900h ~ $FFFFh)
8
2.0 K bytes ($F800h ~ $FFFFh)
9
2.25 K bytes ($F700h ~ $FFFFh)
10
2.5 K bytes ($F600h ~ $FFFFh)
11
2.75 K bytes ($F500h ~ $FFFFh)
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
75
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
12
13
14
15
16
3.0 K bytes ($F400h ~ $FFFFh)
3.25 K bytes ($F300h ~ $FFFFh)
3.5 K bytes ($F200h ~ $FFFFh)
3.75 K bytes ($F100h ~ $FFFFh)
4.0 K bytes ($F000h ~ $FFFFh)
ISP service program configurable in N*256 byte (N= 0 ~ 16)
19.3. Program the ISP Service Program
After Lock Bit N is set and ISP service program been programmed, the ISP service program memory will be
protected (locked) automatically. The lock bit N has its own program/erase timing. It is different from the flash
memory program/erase timing so the locked ISP service program can not be erased by flash erase function. If user
needs to erase the locked ISP service program, he can do it by writer only. User can not change ISP service program
when SM59R16A5 was in system.
19.4. Initiate ISP Service Program
To initiate the ISP service program is to load the program counter (PC) with start address of ISP service program and
execute it. There are four ways to do so:
(1) Blank reset. Hardware reset with first flash address blank ($0000=#FFH) will load the PC with start
address of ISP service program. The hardware reset includes Internal (power on reset) and external
pad reset.
(2) Execute jump instruction can load the start address of the ISP service program to PC.
(3) Enters ISP service program by hardware setting. User can force SM59R16A5 enter ISP service
program by setting P2.6, P2.7 “active low” or P4.3 “ active low” during hardware reset period. The
hardware reset includes Internal (power on reset) and external pad reset. In application system
design, user should take care of the setting of P2.6, P2.7 or P4.3 at reset period to prevent
SM59R16A5 from entering ISP service program.
(4) Enter’s ISP service program by hardware setting, the port3.0 will be detected the two clock signals
during hardware reset period. The hardware reset includes Internal (power on reset) and external
pad reset. And detect 2 clock signals after hardware reset.
During hardware reset period, the hardware will detect the status of P2.6/P2.7/P4.3/P3.0. If they meet one of above
conditions, chip will switch to ISP mode automatically. After ISP service program executed, user need to reset the
SM59R16A5, either by hardware reset or by WDT, or jump to the address $0000 to re-start the firmware program.
There are 8 kinds of entry mechanisms for user different applications. This entry method will select on the writer or
ISP.
(1)
(2)
(3)
(4)
(5)
(6)
(7)
(8)
First Address Blank. i.e. $0000 = 0xFF. And triggered by Internal reset signal.
First Address Blank. i.e. $0000 = 0xFF. And triggered by PAD reset signal.
P2.6 = 0 & P2.7 = 0. And triggered by Internal reset signal.
P2.6 = 0 & P2.7 = 0. And triggered by PAD reset signal.
P4.3 = 0. And triggered by Internal reset signal.
P4.3 = 0. And triggered by PAD reset signal.
P3.0 input 2 clocks. And triggered by Internal reset signal.
P3.0 input 2 clocks. And triggered by PAD reset signal.
19.5. ISP register – TAKEY, IFCON, ISPFAH, ISPFAL, ISPFD and ISPFC
Mnemonic
Description
Direct
TAKEY
Time Access Key
register
F7h
Bit 7
Bit 6
Bit 5
ISP function
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
RESET
TAKEY [7:0]
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
76
Ver.G SM59R16A5 01/2014
00H
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
IFCON
ISPFAH
ISPFAL
ISPFD
ISPFC
Interface Control
register
ISP Flash
Address - High
register
ISP Flash
Address - Low
register
ISP Flash Data
register
ISP Flash Control
register
8Fh
ITS
CDPR
-
-
ALEC[1:0]
EMEN
ISPE
00H
E1h
ISPFAH [7:0]
FFH
E2h
ISPFAL [7:0]
FFH
E3h
ISPFD [7:0]
FFH
E4h
EMF1
Mnemonic: TAKEY
7
6
5
EMF2
EMF3
EMF4
4
3
TAKEY [7:0]
2
-
ISPF.2
1
ISPF.1
ISPF.0
00H
Address: F7H
0
Reset
00H
ISP enable bit (ISPE) is read-only by default, software must write three specific values 55h, AAh and 5Ah
sequentially to the TAKEY register to enable the ISPE bit write attribute. That is:
MOV TAKEY, #55h
MOV TAKEY, #AAh
MOV TAKEY, #5Ah
Mnemonic: IFCON
7
6
ITS
CDPR
5
-
4
-
3
2
ALEC[1:0]
1
EMEN
Address: 8FH
0
Reset
ISPE
00H
The bit 0 (ISPE) of IFCON is ISP enable bit. User can enable overall SM59R16A5 ISP function by setting ISPE
bit to 1, to disable overall ISP function by set ISPE to 0. The function of ISPE behaves like a security key. User
can disable overall ISP function to prevent software program be erased accidentally. ISP registers ISPFAH,
ISPFAL, ISPFD and ISPFC are read-only by default. Software must be set ISPE bit to 1 to enable these 4
registers write attribute.
Mnemonic: ISPFAH
Address: E1H
7
6
5
4
3
2
1
0
Reset
ISPFAH7 ISPFAH6 ISPFAH5 ISPFAH4 ISPFAH3 ISPFAH2 ISPFAH1 ISPFAH0
FFH
ISPFAH [7:0]: Flash address-high for ISP function
Mnemonic: ISPFAL
7
6
ISPFAL7 ISPFAL6
5
ISPFAL5
4
ISPFAL4
3
ISPFAL3
2
ISPFAL2
1
ISPFAL1
Address: E2H
0
Reset
ISPFAL0
FFH
ISPFAL [7:0]: Flash address-Low for ISP function
The ISPFAH & ISPFAL provide the 16-bit flash memory address for ISP function. The flash memory address
should not include the ISP service program space address. If the flash memory address indicated by ISPFAH
& ISPFAL registers overlay with the ISP service program space address, the flash program/page erase of ISP
function executed thereafter will have no effect.
Mnemonic: ISPFD
7
6
ISPFD7
ISPFD6
5
ISPFD5
4
ISPFD4
3
ISPFD3
2
ISPFD2
1
ISPFD1
Address: E3H
0
Reset
ISPFD0
FFH
ISPFD [7:0]: Flash data for ISP function.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
77
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
The ISPFD provide the 8-bit data register for ISP function.
Mnemonic: ISPFC
7
6
5
EMF1
EMF2
EMF3
4
EMF4
3
-
2
ISPF[2]
1
ISPF[1]
Address: E4H
0
Reset
ISPF[0]
00H
EMF1: Entry mechanism (1) flag, clear by reset. (Read only)
EMF2: Entry mechanism (2) flag, clear by reset. (Read only)
EMF3: Entry mechanism (3) flag, clear by reset. (Read only)
EMF4: Entry mechanism (4) flag, clear by reset. (Read only)
ISPF [2:0]: ISP function select bit.
ISPF[2:0]
ISP function
000
Byte program
001
Chip protect
010
Page erase
011
Chip erase
100
Write option
101
Read option
110
Erase option
111
One page of flash memory is 256 byte
The Option function can access the Internal reset time select(description in section
1.4.1)、clock source select(description in section 1.5)、P4[4:7] pins function
select(description in section 5)、WDTEN control bit(description in section 10)、or ISP
entry mechanisms select(description in section 19)。
When chip protected or no ISP service, option can only read.
The choice ISP function will start to execute once the software write data to ISPFC register.
To perform byte program/page erases ISP function, user need to specify flash address at first. When
performing page erase function, SM59R16A5 will erase entire page which flash address indicated by ISPFAH
& ISPFAL registers located within the page.
e.g. flash address: $XYMN
page erase function will erase from $XY00 to $XYFF
To perform the chip erase ISP function, SM59R16A5 will erase all the flash program memory except the ISP
service program space. To perform chip protect ISP function, the SM59R16A5 flash memory content will be
read #00H.
e.g. ISP service program to do the byte program - to program #22H to the address $1005H
MOV TAKEY, #55h
MOV TAKEY, #AAh
MOV TAKEY, #5Ah
MOV IFCON, #01H
MOV ISPFAH, #10H
MOV ISPFAL, #05H
MOV ISPFD, #22H
MOV ISPFC, #00H
; enable ISPE write attribute
; enable SM59R16A5 ISP function
; set flash address-high, 10H
; set flash address-low, 05H
; set flash data to be programmed, data = 22H
; start to program #22H to the flash address $1005H
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
78
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
20. RTC(Real Time Clock) function
The RTC interrupt vector is 8BH.
The RTC SFR show as below:
Mnemonic
RTCADDR
RTCDATA
Mnemonic
RTCCTRL
SEC
MIN
HOUR
DAY
WEEK
MONTH
YEAR
ALMMIN
ALMHOUR
ALMDAY
ALMWEEK
ALMMONT
H
Description
RTC Address
RTC Data
Description
RTC Control
register
RTC SECOND
register
RTC MINUTE
register
RTC HOUR
register
RTC DAY
register
RTC WEEK
register
RTC MONTH
register
RTC YEAR
register
RTC minute
alarm
RTC hour alarm
RTC day alarm
RTC week
alarm
RTC month
alarm
Direct
Bit 7
Bit 6
9Eh
9Fh
-
-
Bit 5
RTC
-
Bit 4
Bit 3
Bit 2
RTCDATA[7:0]
Bit 1
Bit 0
RESET
RTCADDR[3:0]
Address
Bit 7
Bit 6
00h
RTCen
PeriodI
F
01h
-
SEC[6:4]
SEC[3:0]
00h
02h
-
MIN[6:4]
MIN[3:0]
00h
03h
-
-
HOUR[5:4]
HOUR[3:0]
00h
04h
-
-
DAY[5:4]
DAY[3:0]
01h
05h
-
-
-
-
06h
-
-
-
MONTH[4]
07h
Bit 5
Bit 4
Bit 3
ALARMInten
ALARMIF
PeriodIntE
n
RTC function
MINen
09h
10h
HOURen
DAYen
-
11h
WEEKen
-
-
-
12h
MONTHen
-
-
ALMMONTH[4]
Mnemonic: RTCCTRL
7
6
RTCen
PeriodIF
5
ALARMInten
ALMMIN[6:4]
4
ALARMIF
ALMHOUR[5:4]
ALMDAY[5:4]
3
PeriodIntEn
Bit 1
-
Bit 0
INT_SEL[2:0]
-
YEAR[7:4]
08h
Bit 2
00H
00H
WEEK[2:0]
00h
06h
MONTH[3:0]
01h
YEAR[3:0]
00h
ALMMIN[3:0]
00h
ALMHOUR[3:0]
ALMDAY[3:0]
00h
00h
ALMWEEK[2:0]
ALMMONTH[3:0]
2
RESET
1
INT_SEL[2:0]
Address: 00H
0
Reset
00h
RTCen: RTC Circuit enable
0: disable
1: enable
PeriodIF: Periodical interrupt flag
1: RTC Int caused by periodical Int. Must clear by software write “0”.
ALARMInten: ALARM Interrupt Enable
ALARM interrupt will be generated when ALARM data match RTC data.
0: ALARM Interrupt disable
1: ALARM Interrupt enable
ALARMIF: ALARM interrupt flag
1: RTC Int caused by Alarm Int.
Must clear by software write “0”.
PeriodIntEn: Periodical Interrupt enable
INT_SEL[2:0]: RTC interrupt will be generated periodically according INT_SEL[2:0]
000: interrupt is set as 0.5 second
001: interrupt is set as 1 second
010: interrupt is set as 0.5 minute
011: interrupt is set as 1 minute
100: interrupt is set as 0.5 hour
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
79
Ver.G SM59R16A5 01/2014
00h
00h
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
101: interrupt is set as 1 hour
Note: The counter of “Periodical INT” should start to count from RTC register been
programmed.
For example,if current time is 3:23,and we program INT_SEL[2:0] as 0.5 hour;Then
st
the 1 “Periodical INT” will raise at 3:53,not 3:30。
Mnemonic: SEC
7
6
5
SEC[6:4]
4
3
2
SEC[3:0]
1
Address: 01H
0
Reset
00H
1
Address: 02H
0
Reset
00H
SEC[6:0]: Show the current second counter in BCD format, range is 0~59.
SEC[6:4]: Represents 10 second.
SEC[3:0]: Represents second.
Mnemonic: MIN
7
6
5
MIN[6:4]
4
3
2
MIN[3:0]
MIN[6:0]: Show the current minute counter in BCD format, range is 0~59.
MIN[6:4]: Represents 10 minute.
MIN[3:0]: Represents minute.
Mnemonic: HOUR
7
6
5
4
HOUR[5:4]
3
2
1
HOUR[3:0]
Address: 03H
0
Reset
00H
HOUR[5:0]: Show the current hour counter in BCD format, range is 0~23.
HOUR[5:4]: Represents 10 hour.
HOUR[3:0]: Represents hour.
Mnemonic: DAY
7
6
5
DAY[5:4]
4
3
2
DAY[3:0]
1
Address: 04H
0
Reset
00H
DAY[5:0]: Show the current day counter in BCD format, range is 0~31.
DAY[5:4]: Represents 10 DAY.
DAY[3:0]: Represents DAY.
Mnemonic: WEEK
7
6
5
4
3
2
1
WEEK[2:0]
Address: 05H
0
Reset
00H
WEEK[2:0]: Show the week counter.
This register will be maintained by Firmware. There is no calculation in HW circuit.
000: Sunday
001: Monday
010: Tuesday
011: Wednesday
100: Thursday
101: Friday
110: Saturday
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
80
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Mnemonic: MONTH
7
6
5
4
MONTH[4]
3
Address: 06H
0
Reset
00H
2
1
MONTH[3:0]
MONTH[4:0]: Show the current month counter in BCD format, range is 1~12.
MONTH[4]: Represents 10 month.
MONTH[3:0]: Represents month.
Mnemonic: YEAR
7
6
5
YEAR[7:4]
4
3
Address: 07H
0
Reset
00H
2
1
YEAR[3:0]
YEAR[7:0]: Show the current year counter in BCD format, range is 0~99.
YEAR[7:4]: Represents 10 year.
YAER[3:0]: Represents year.
Mnemonic: ALMMIN
7
6
5
MINen
ALMMIN[6:4]
4
3
Address: 08H
0
Reset
00H
2
1
ALMMIN[3:0]
MINen: ALARM MINUTE enable
0: disable; needn’t compare ALMMIN[6:0] with RTC data to generate ALARM INT.
1: enable; need compare ALMMIN[6:0] with RTC data to generate ALARM INT.
ALMMIN[6:0]: ALARM MINUTE setting in BCD format, range is 0~59.
ALMMIN[6:4]: Setting 10 minute.
ALMMIN[3:0]: Setting minute.
Mnemonic: ALMHOUR
7
6
5
4
HOURen
ALMHOUR[5:4]
3
2
1
ALMHOUR[3:0]
0
Address: 09H
Reset
00H
HOURen: ALARM HOUR enable
0: disable; needn’t compare ALMHOUR[5:0] with RTC data to generate ALARM INT.
1: enable; need compare ALMHOUR[5:0] with RTC data to generate ALARM INT.
ALMHOUR[5:0]: ALARM HOUR setting in BCD format, range is 0~23.
ALMHOUR[5:4]: Setting 10 hour.
ALMHOUR[3:0]: Setting hour.
Mnemonic: ALMDAY
7
6
DAYen
-
5
4
ALMDAY[5:4]
3
2
1
ALMDAY[3:0]
0
Address: 10H
Reset
00H
DAYen: ALARM DAY enable
0: disable; needn’t compare ALMDAY[5:0] with RTC data to generate ALARM INT.
1: enable; need compare ALMDAY[5:0] with RTC data to generate ALARM INT.
ALMDAY[5:0] ALARM DAY setting in BCD format, range is 1~31.
ALMDAY[5:4]: Setting 10 DAY.
ALMDAY[3:0]: Setting DAY.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
81
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Mnemonic: ALMWEEK
7
6
5
WEEKen
4
3
2
1
ALMWEEK[2:0]
0
Address: 11H
Reset
00H
WEEKen: ALARM WEEK enable
0: disable; needn’t compare ALMWEEK [2:0] with RTC data to generate ALARM INT.
1: enable; need compare ALMWEEK[2:0] with RTC data to generate ALARM INT.
ALMWEEK[2:0] ALARM WEEK setting
This register will be maintained by Firmware.
There is no calculation in HW circuit.
000: Sunday
001: Monday
010: Tuesday
011: Wednesday
100: Thursday
101: Friday
110: Saturday
Mnemonic: ALMMONTH
7
6
5
MONTHen
-
4
ALMMONTH[4]
3
2
1
ALMMONTH[3:0]
0
Address: 12H
Reset
00H
MONTHen: ALARM MONTH enable
0: disable; needn’t compare ALMMONTH [4:0] with RTC data to generate ALARM INT.
1: enable; need compare ALMMONTH[4:0] with RTC data to generate ALARM INT.
ALMMONTH[4:0]: ALARM MONTH setting in BCD format, range is 1~12.
ALMMONTH[4]: Setting 10 MONTH.
ALMMONTH[3:0]: Setting MONTH.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
82
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
21. OPA/Comparator
SM59R16A5 had integrated an OPA/Comparator module on chip. This module supports OPA and Comparator
modes individually according to user’s configuration. When OPA Mode enabled, dual OP-Amps may be applied to
single or two-stage amplifier network, and may be applied as a front-end signal process and internally routed to
specific ADC channel. When Comparator Mode enabled, an internal reference voltage is available to be configured
on comparator terminals.
If OPA and Comparator Mode both are enabled at same module, the OPA Mode has higher priority.
The OPA/Comparator SFR show as below:
Mnemonic
OpPin
Cmp0CO
N
Cmp1CO
N
Description
OpCmp Pin
Select
Comparator
_0 control
Comparator
_1 control
Addr
Bit 7
Bit 6
Bit 5
Bit 4
Op/Comparator
Bit 3
Bit 2
Bit 1
Bit 0
RESET
F6h
Op0_En Cmp0_En C0PosVBG C0PosPad Op1_En Cmp1_En C1PosVBG C1PosPad
00h
FEh
Hys0En
Cmp0o
CMF0MS[1:0]
CMF0
--
--
ToADC
00h
FFh
Hys1En
Cmp1o
CMF1MS[1:0]
CMF1
--
--
--
00h
Mnemonic: OpPin
Address: F6h
7
6
5
4
3
2
1
0
Reset
Op0_En Cmp0_En C0PosVBG C0PosPad Op1_En Cmp1_En C1PosVBG C1PosPad
00h
Op0_En : Op0 enable.
1: Op0 circuit enables and switch to corresponding signal in multi-function
P2.5/P2.6/P2.7 by HW automatically.
Cmp0_En : Cmp0 enable.
1: Comparator_0 circuit enables and switch to corresponding signal
multi-function pin P2.5/P2.6/P2.7 by HW automatically.
C0PosVBG : Select Comparator_0 positive input source
1: set positive input source as internal reference voltage (1.23V±10%)
C0PosPad: Select Comparator_0 positive input source
1: set positive input source as external pin
Op1_En: Op1 enable.
1:Op1 circuit enables and switch to corresponding signal in multi-function
P2.2/P2.3/P2.4 by HW automatically.
Cmp1_En : Cmp1 enable.
1: Comparator_1 circuit enables and switch to corresponding signal
multi-function pin P2.2/P2.3/P2.4 by HW automatically.
C1PosVBG: Select Comparator_1 positive input source
1: set positive input source as internal reference voltage (1.23V±10%)
C1PosPad: Select Comparator_1 positive input source
1: set positive input source as external pin
pin
in
pin
in
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
83
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Opx_En、Cmpx_En、CxPosVBG 及 CxPosPad setting table:
Opx_En
Cmpx_En
CxPosVBG
CxPosPad
OP/Comparator
0
0
0
0
GPIO
0
0
0
1
GPIO
0
0
1
0
GPIO
0
0
1
1
GPIO
0
1
0
0
Not Allowed
0
1
0
1
Comparator
0
1
1
0
Comparator
0
1
1
1
Comparator
1
0
0
0
Not Allowed
1
0
0
1
OP
1
0
1
0
OP
1
0
1
1
Not Allowed
1
1
0
0
Not Allowed
1
1
0
1
OP
1
1
1
0
OP
1
1
1
1
Not Allowed
Mnemonic: Cmp0CON
7
6
5
4
Hys0En Cmp0o
CMF0MS[1:0]
3
CMF0
2
--
1
--
positive input source
N/A
N/A
N/A
N/A
N/A
Positive pin input voltage
Internal Reference Voltage
Internal Reference Voltage
N/A
Positive pin input voltage
Internal Reference Voltage
NA
N/A
Positive pin input voltage
Internal Reference Voltage
NA
Address:FEh
0
Reset
ToADC
00h
Hys0En: Hysteresis function enable
0: disable Hysteresis at comparator_0 input
1: enable
Cmp0o: Comparator_0 output (read only)
0: The positive input source was lower then negative input source
1: The positive input source was higher then negative input source
CMF0MS[1:0] : CMF0(Comparator_0 Flag) setting mode select
00: CMF0 will be set when comprator_0 output toggle
01: CMF0 will be set when comprator_0 output rising
10: CMF0 will be set when comprator_0 output falling
11: reserved
CMF0: Comparator_0 Flag
This bit is setting by hardware according to meet CMF0MS [1:0] select condition.
This bit must clear by software.
ToADC: Select ADC channel as input source of Op0 output
0:set ADC input source as decided by SFR ADCC2 register ADCCH [2:0]
1:set ADC input source ( another ADC channel, not ADC channel 0~7)
Mnemonic: Cmp1CON
7
6
5
4
Hys1En Cmp1o
CMF1MS[1:0]
3
CMF1
2
--
1
--
Address:FFh
0
Reset
-00h
Hys1En: Hysteresis function enable
0: disable Hysteresis at comparator_1 input
1: enable
Cmp1o: Comparator_1 output (read only)
0: The positive input source was lower then negative input source
1: The positive input source was higher then negative input source
CMF1MS[1:0] : CMF1(Comparator_1 Flag) setting mode select
00: CMF1 will be set when comprator_1 output toggle
01: CMF1 will be set when comprator_1 output rising
10: CMF1 will be set when comprator_1 output falling
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
84
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
11: reserved
CMF1: Comparator_1 Flag
This bit is setting by hardware according to meet CMF1MS [1:0] select condition.
This bit must clear by software.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
85
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
Operating Conditions
Symbol
Description
Min.
Typ.
Max.
Unit.
Remarks
TA
Operating temperature
-40
25
85
℃
Ambient temperature under bias
VDD33
Supply voltage
2.7
3.3
3.6
V
VDD5
Supply voltage
4.5
5.0
5.5
V
DC Characteristics
TA = -40℃ to 85℃, VCC = 5.0V
Symbol
Parameter
Valid
VIL1
Input Low-voltage
Port 0,1,2,3,4,5
VIL2
Input Low-voltage
RES, XTAL1
VIH1
Input High-voltage
Port 0,1,2,3,4,5
VIH2
Input High-voltage
RES, XTAL1
VOL
Output Low-voltage
Port 0,1,2,3,4,5
Output High-voltage
(1) Port 0,1,2,3,4,5
using Strong Pull-up
VOH1
VOH2
IIL
ITL
ILI
RRST
CIO
ICC
Notes:
Output High-voltage
(2)
using Weak Pull-up
Logic 0 Input Current
Logical Transition
Current
Input Leakage Current
Reset Pull-down
Resistor
Pin Capacitance
Port 0,1,2,3,4,5
Min
Max
Units
-0.5
0.8
V
0
0.8
V
2.0
VCC + 0.5
V
70%Vcc VCC + 0.5
V
0.4
Conditions
Vcc=5V
V
IOL=4.9mA
90% VCC
V
IOH= -4.6mA
2.4
V
IOH= -250uA
75% VCC
V
IOH= -162uA
90% VCC
V
IOH= -73uA
Vcc=5V
Port 0,1,2,3,4,5
-75
uA
Vin= 0.45V
Port 0,1,2,3,4,5
-650
uA
Vin= 2.0V
Port 0,1,2,3,4,5
±10
uA
0.45V<Vin<Vcc
300
kΩ
10
pF
Freq= 1MHz, Ta= 25℃
12
mA
Active mode, 12MHz VCC =5V
25 ℃
11
mA
Idle mode, 12MHz
25 ℃
5
uA
Power down mode
25 ℃
RES
Power Supply Current VDD
50
VCC =5V
VCC =5V
1. Port in Push-Pull Output Mode
2. Port in Quasi-Bidirectional Mode
FOSVOS TEL: 021-58998693
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
86
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
TA = -40℃ to 85℃, VCC = 3.3V
Symbol
Parameter
Valid
VIL1
Input Low-voltage
Port 0,1,2,3,4,5
VIL2
Input Low-voltage
RES, XTAL1
VIH1
Input High-voltage
Port 0,1,2,3,4,5
VIH2
Input High-voltage
RES, XTAL1
VOL
Output Low-voltage
Port 0,1,2,3,4,5
Output High-voltage
(1) Port 0,1,2,3,4,5
using Strong Pull-up
VOH1
VOH2
IIL
ITL
ILI
RRST
CIO
ICC
Notes:
Output High-voltage
(2)
using Weak Pull-up
Logic 0 Input Current
Logical Transition
Current
Input Leakage Current
Reset Pull-down
Resistor
Pin Capacitance
Port 0,1,2,3,4,5
Min
Max
Units
-0.5
0.8
V
0
0.8
V
2.0
VCC + 0.5
V
70%Vcc VCC + 0.5
V
0.4
Conditions
Vcc=3.3V
V
IOL=3.2mA
90% VCC
V
IOH= -2.3mA
2.4
V
IOH= -77uA
90% VCC
V
IOH= -33uA
Vcc=3.3V
Port 0,1,2,3,4,5
-75
uA
Vin= 0.45V
Port 0,1,2,3,4,5
-650
uA
Vin=1.5V
Port 0,1,2,3,4,5
±10
uA
0.45V<Vin<Vcc
300
kΩ
10
pF
Freq= 1MHz, Ta= 25℃
11
mA
Active mode ,12MHz
3.3 V 25 ℃
10
mA
Idle mode, 12MHz
25 ℃
4
uA
RES
Power Supply Current VDD
50
VCC =
VCC =3.3V
Power down mode VCC =3.3V
25 ℃
1. Port in Push-Pull Output Mode
2. Port in Quasi-Bidirectional Mode
FOSVOS TEL: 021-58998693
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
87
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
OPA / Comparator Characteristics
VCC = 5.0V
Conditions
Symbol
Parameter
Min
Typ
Max
Unit
3
5
mV
VDD - 0.4
V
VDD =5V
VOS
Input Offset Voltage
No load
VOUT
Output Voltage Swing
RL=15KΩ
CL=100pF
VIN+ - VIN- >200mV
0.1
BW
Gain Band Width
Product
RL=10KΩ
CL=100pF
0.4
0.5
0.55
MHz
CMRR
Common Mode
Rejection Ratio
No load
65
70
72
dB
PSRR
Power Supply
Rejection Ratio
No load
75
80
84
dB
SR
Slew Rate at Unity
Gain
No load
0.57
0.7
0.78
V/us
RL
MAX. load
RL=10KΩ
CL=100pF
H
Hysteresis
No load
>15
20
40
KΩ
60
mV
FOSVOS TEL: 021-58998693
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
88
Ver.G SM59R16A5 01/2014
SM59R16A5/SM59R09A5/SM59R05A5
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 2KB RAM embedded
VCC = 3.3V
Conditions
Symbol
Parameter
Min
Typ
Max
Unit
3
5
mV
VDD – 0.4
V
VDD =5V
VOS
Input Offset Voltage
No load
VOUT
Output Voltage Swing
RL=15KΩ
CL=100pF
VIN+ -VIN- >200mV
0.1
BW
Gain Band Width
Product
RL=10KΩ
CL=100pF
0.4
0.5
0.55
MHz
CMRR
Common Mode
Rejection Ratio
No load
60
65
68
dB
PSRR
Power Supply
Rejection Ratio
No load
60
65
68
dB
SR
Slew Rate at Unity
Gain
No load
0.57
0.7
0.78
V/us
RL
MAX. load
RL=10KΩ
CL=100pF
H
Hysteresis
No load
>15
20
40
KΩ
60
mV
FOSVOS TEL: 021-58998693
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M047
89
Ver.G SM59R16A5 01/2014