issfd-m059_i_sm59r16..

SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
Description .......................................................................................................................................................................... 3
Features .............................................................................................................................................................................. 3
Pin Configuration ................................................................................................................................................................ 4
Block Diagram..................................................................................................................................................................... 8
Pin Description .................................................................................................................................................................... 9
Special Function Register (SFR) ...................................................................................................................................... 11
Function Description ......................................................................................................................................................... 14
1.
General Features ..................................................................................................................................................... 14
1.1.
Embedded Flash ......................................................................................................................................... 14
1.2.
IO Pads ....................................................................................................................................................... 14
1.3.
2T/1T Selection ........................................................................................................................................... 14
1.4.
RESET ........................................................................................................................................................ 15
1.4.1.
Hardware RESET function ............................................................................................................. 15
1.4.2.
Software RESET function .............................................................................................................. 15
1.4.3.
Time Access Key register (TAKEY)................................................................................................ 15
1.4.4.
Software Reset register (SWRES) ................................................................................................. 15
1.4.5.
Reset Status Flag (RSTS) .............................................................................................................. 16
1.4.6.
Example of software reset ............................................................................................................. 16
1.5.
Clocks ......................................................................................................................................................... 16
2.
Instruction Set .......................................................................................................................................................... 17
3.
Memory Structure ..................................................................................................................................................... 21
3.1.
Program Memory ........................................................................................................................................ 21
3.2.
Data Memory............................................................................................................................................... 23
3.2.1.
Data memory - lower 128 byte (00H to 7FH) ................................................................................. 23
3.2.2.
Data memory - higher 128 byte (80H to FFH) ............................................................................... 24
3.2.3.
Data memory - Expanded 1024 bytes ($0000 to $03FF) .............................................................. 24
4.
CPU Engine ............................................................................................................................................................. 25
4.1.
Accumulator ................................................................................................................................................ 25
4.2.
B Register ................................................................................................................................................... 25
4.3.
Program Status Word .................................................................................................................................. 26
4.4.
Stack Pointer ............................................................................................................................................... 26
4.5.
Data Pointer ................................................................................................................................................ 26
4.6.
Data Pointer 1 ............................................................................................................................................. 27
4.7.
Internal RAM control register ...................................................................................................................... 27
4.8.
Interface control register ............................................................................................................................. 27
5.
GPIO ........................................................................................................................................................................ 29
6.
Timer 0 and Timer 1 ................................................................................................................................................. 31
6.1.
Timer/counter mode control register (TMOD) ............................................................................................. 31
6.2.
Timer/counter control register (TCON) ....................................................................................................... 32
6.3.
Peripheral Frequency control register (PFCON) ......................................................................................... 32
6.4.
Mode 0 (13-bit Counter/Timer) .................................................................................................................... 33
6.5.
Mode 1 (16-bit Counter/Timer) .................................................................................................................... 33
6.6.
Mode 2 (8-bit auto-reload Counter/Timer) .................................................................................................. 34
6.7.
Mode 3 (Timer 0 acts as two independent 8 bit Timers / Counters) ........................................................... 34
7.
Timer 2 and Capture/Compare Unit ......................................................................................................................... 35
7.1.
Timer 2 function........................................................................................................................................... 37
7.1.1.
Timer mode .................................................................................................................................... 37
7.1.2.
Event counter mode ....................................................................................................................... 37
7.1.3.
Gated timer mode .......................................................................................................................... 37
7.1.4.
Reload of Timer 2 ........................................................................................................................... 37
7.2.
Compare function ........................................................................................................................................ 37
7.2.1.
Compare Mode 0 ........................................................................................................................... 37
7.2.2.
Compare Mode 1 ........................................................................................................................... 38
7.3.
Capture function .......................................................................................................................................... 39
7.3.1.
Capture Mode 0 ............................................................................................................................. 39
7.3.2.
Capture Mode 1 ............................................................................................................................. 39
8.
Serial interface 0 ...................................................................................................................................................... 40
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
1
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
8.1.
Serial interface 0 ......................................................................................................................................... 41
8.1.1.
Mode 0 ........................................................................................................................................... 41
8.1.2.
Mode 1 ........................................................................................................................................... 42
8.1.3.
Mode 2 ........................................................................................................................................... 42
8.1.4.
Mode 3 ........................................................................................................................................... 42
8.2.
Multiprocessor communication of Serial Interface 0 ................................................................................... 43
8.3.
Baud rate generator .................................................................................................................................... 43
8.3.1.
Serial interface 0 modes 1 and 3 ................................................................................................... 43
9.
Watchdog timer ........................................................................................................................................................ 44
10.
Interrupt ........................................................................................................................................................... 47
10.1.
Priority level structure ............................................................................................................................. 49
11.
Power Management Unit ................................................................................................................................. 51
11.1. Idle mode .................................................................................................................................................... 51
11.2. Stop mode ................................................................................................................................................... 51
12.
Pulse Width Modulation (PWM) ...................................................................................................................... 52
13.
IIC function ...................................................................................................................................................... 55
14.
SPI function ..................................................................................................................................................... 59
15.
LVI – Low Voltage Interrupt ............................................................................................................................. 63
16.
In-System Programming (Internal ISP) ........................................................................................................... 64
16.1.
ISP service program ............................................................................................................................... 64
16.2.
Lock Bit (N) ............................................................................................................................................. 64
16.3.
Program the ISP Service Program ......................................................................................................... 65
16.4.
Initiate ISP Service Program................................................................................................................... 65
16.5.
ISP register – TAKEY, IFCON, ISPFAH, ISPFAL, ISPFD and ISPFC .................................................... 65
Operating Conditions ........................................................................................................................................................ 68
DC Characteristics ............................................................................................................................................................ 68
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
2
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
Product List
Features
SM59R16G6W40PP, SM59R09G6W40PP, SM59R05G6W40PP,


SM59R16G6W44JP, SM59R09G6W44JP, SM59R05G6W44JP
SM59R16G6W44QP, SM59R09G6W44QP, SM59R05G6W44QP,
SM59R16G6W44UP, SM59R09G6W44UP, SM59R05G6W44UP,
SM59R16G6W48VP, SM59R09G6W48VP, SM59R05G6W48VP
Description
The SM59R16G6 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.
SM59R16G6 contains 1KB on-chip RAM, more than 46
GPIOs (LQFP 48), 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 SM59R16G6 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
SM59R16G6ihhkL YWW
i: process identifier {W = 2.7V ~ 5.5V}
hh: Pin count
k: package type postfix {as table below }
L:PB Free identifier
{No text is Non-PB free,”P” is PB free}
Y: year
WW: week
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

























Operating Voltage: 2.7V ~ 5.5V
High speed architecture of 1 clock/machine cycle
(1T), runs up to 25MHz
1T/2T can be switched on the fly by SFR
Instruction-set compatible with MCS-51
64K/36K/20KBytes on-chip program memory.
External RAM addresses up to 64K bytes.
Standard 12T interface for external RAM access.
256 bytes RAM as standard 8052, plus 1K bytes
on-chip expandable RAM
Dual 16-bit Data Pointers (DPTR0 & DPTR1)
One serial peripheral interfaces in full duplex mode
(UART0),
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
22.1184MHz Internal RC oscillator, with programmable
clock divider
Configurable Oscillator pin
ISP/IAP/ICP functions.
ISP service program space configurable in N*256 byte
(N=0 to 16) size.
EEPROM function
On-chip in-circuit emulator (ICE) function with
On-Chip Debugger(OCD)
ALE output select.
LVI/LVR ±5% (LVR deglitch 500ns)
Enhanced user code protection
Power management unit for idle and power down
modes
Contact SyncMOS : www.syncmos.com.tw
6F, No.10-2 Li- Hsin 1st Road , SBIP, Hsinchu, Taiwan
TEL: 886-3-567-1820
FAX: 886-3-567-1891
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
3
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
Pin Configuration
40
VDD
CC1/T2EX/P1.1
2
39
P0.0/AD0
RXD0/P1.2
3
38
P0.1/AD1
TXD0/CC2/P1.3
4
37
P0.2/AD2
CC3/SS/P1.4
5
36
P0.3/AD3
MOSI/P1.5
6
35
P0.4/AD4
IIC_SCL/MISO/P1.6
7
34
P0.5/AD5
IIC_SDA/SPI_CLK/P1.7
8
33
P0.6/AD6
P4.7/RESET(default)
9
32
P0.7/AD7
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/PWM3
T0/P3.4
14
27
P2.6/A14/PWM2
T1/P3.5
15
26
P2.5/A13/PWM1
WR/P3.6
16
25
P2.4/A12/PWM0
RD/P3.7
17
24
P2.3/A11/CC3
P5.4/XTAL2
18
23
P2.2/A10/CC2
OSC_IN/P5.5/XTAL1
19
22
P2.1/A9/CC1
VSS
20
21
P2.0/A8/CC0
YWW
(40L PDIP Top View)
SyncMOS
1
SM59R16G6ihhPP
CC0/T2/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-M059
4
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
18
19
20
21
22
23
24
25
26
27
28
CC1/A9/P2.1
CC2/A10/P2.2
CC3/A11/P2.3
PWM0/A12/P2.4
16
T1/P3.5
CC0/A8/P2.0
15
T0/P3.4
SS/IIC_SCL/CC0/PWM0/P4.0
14
INT1/P3.3
VSS
13
INT0/P3.2
OSC_IN/P5.5/XTAL1
12
TXD0/P3.1
P5.4/XTAL2
11
SPI_CLK/CC3/PWM3/P4.3
SM59R16G6
ihhJP
YWW
(44L PLCC Top View)
RD/P3.7
10
RXD0/P3.0
WR/P3.6
9
P4.7/RESET(default)
39
SyncMOS
P0.4/AD4
38
P0.3/AD3
40
P0.5/AD5
37
P0.2/AD2
41
P0.6/AD6
36
P0.1/AD1
42
P0.7/AD7
35
P0.0/AD0
43
OCI_SDA/P4.6
34
VDD
44
P4.1/PWM1/CC1/IIC_SDA/MOSI
33
P4.2/PWM2/CC2/MISO
1
ALE/P4.5
32
P1.0/T2/CC0
2
OCI_SCL/P4.4
31
P1.1/T2EX/CC1
3
P2.7/A15/PWM3
30
P1.2/RXD0
4
P2.6/A14/PWM2
29
P1.3/CC2/TXD0
5
7
IIC_SDA/SPI_CLK/P1.7
17
IIC_SCL/MISO/P1.6
6
8
MOSI/P1.5
P1.4/SS/CC3
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
P2.5/A13/PWM1
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
5
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
P0.4/AD4
P0.5/AD5
P0.6/AD6
P0.7/AD7
OCI_SDA/P4.6
P4.1/PWM1/CC1/IIC_SDA/MOSI
ALE/P4.5
OCI_SCL/P4.4
P2.7/A15/PWM3
P2.6/A14/PWM2
P2.5/A13/PWM1
32
31
30
29
28
27
26
25
24
23
11
44
T1/P3.5
CC3/SS/P1.4
(44L PQFP/LQFP Top
View)
10
43
T0/P3.4
TXD0/CC2/P1.3
9
42
INT1/P3.3
RXD0/P1.2
8
41
INT0/P3.2
CC1/T2EX/P1.1
7
40
TXD0/P3.1
CC0/T2/P1.0
6
39
SPI_CLK/CC3/PWM3/P4.3
MISO/CC2/PWM2/P4.2
SM59R16G6
ihhQ(U)P
YWW
5
38
RXD0/P3.0
VDD
4
37
P4.7/RESET(default)
AD0/P0.0
SyncMOS
3
36
IIC_SDA/SPI_CLK/P1.7
AD1/P0.1
2
35
IIC_SCL/MISO/P1.6
AD2/P0.2
1
34
MOSI/P1.5
AD3/P0.3
33
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
22
P2.4/A12/PWM0
21
P2.3/A11/CC3
20
P2.2/A10/CC2
19
P2.1/A9/CC1
18
P2.0/A8/CC0
17
P4.0/PWM0/CC0/IIC_SCL/SS
16
VSS
15
XTAL1/P5.5/OSC_IN
14
XTAL2/P5.4
13
P3.7/RD
12
P3.6/WR
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
6
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
P0.4/AD4
P0.5/AD5
P0.6/AD6
P0.7/AD7
OCI_SDA/P4.6
P4.1/PWM1/CC1/IIC_SDA/MOSI
ALE/P4.5
OCI_SCL/P4.4
P2.7/A15/PWM3
P2.6/A14/PWM2
P2.5/A13/PWM1
P5.1
35
34
33
32
31
30
29
28
27
26
25
10
11
12
T0/P3.4
T1/P3.5
48
INT1/P3.3
P5.2
9
CC3/SS/P1.4
47
INT0/P3.2
TXD0/CC2/P1.3
46
TXD0/P3.1
45
8
RXD0/P1.2
7
44
SPI_CLK/CC3/PWM3/P4.3
CC1/T2EX/P1.1
6
43
RXD0/P3.0
CC0/T2/P1.0
5
42
P4.7/RESET(default)
MISO/CC2/PWM2/P4.2
SM59R16G6
IhhVP
YWW
(48L LQFP Top View)
4
41
IIC_SDA/SPI_CLK/P1.7
VDD
SyncMOS
3
AD0/P0.0
40
IIC_SCL/MISO/P1.6
AD1/P0.1
39
2
38
MOSI/P1.5
AD2/P0.2
1
37
P5.3
AD3/P0.3
36
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
24
P5.0
23
P2.4/A12/PWM0
22
P2.3/A11/CC3
21
P2.2/A10/CC2
20
P2.1/A9/CC1
19
P2.0/A8/CC0
18
P4.0/PWM0/CC0/IIC_SCL/SS
17
VSS
16
XTAL1/P5.5/OSC_IN
15
XTAL2/P5.4
14
P3.7/RD
13
P3.6/WR
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
7
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
PWM0
PWM1
PWM2
PWM3
IIC_SCL
IIC_SDA
SPI_MIS
SPI_MOS
O
I
SPI_CLK
SPI_SS
UART
0
PWM
IIC
SPI
RXD0
TXD0
Block Diagram
RESE
T
MAX810
XTAL2
XTAL1
SRAM
1KBytes
SRAM
256Bytes
Flash 64KBytes
CPU
Watchdo
g
Port
0
Port
1
Port
2
Port
3
Port
4
Port
5
Port 0
Port 1
Port 2
Port 3
Port 4
Port 5
Interrupt
ALE
WR
RD
ICE
ICP
Timer2
& CCU
T0
T1
CC0~CC
3
T2
T2EX
OCI_SC
L
OCI_SD
A
Interface control
Timer
0/1
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
8
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
Pin Description
40L
PDIP
44L
PLCC
44L
PQFP
48L
LQFP
Symbol
I/O
1
39
42
P4.2/PWM2/CC2/
MISO
I/O
1
2
40
43
P1.0/T2/CC0
I/O
2
3
41
44
P1.1/T2EX/CC1
I/O
3
4
42
45
P1.2/RXD0
I/O
4
5
43
46
P1.3/TXD0/CC2
I/O
5
6
44
47
P1.4/SS/CC3
I/O
48
1
P5.2
P5.3
I/O
I/O
P1.5/MOSI
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/
SPI_CLK
I/O
11
13
7
8
P3.1/TXD0
I/O
12
13
14
15
16
17
18
14
15
16
17
18
19
20
8
9
10
11
12
13
14
9
10
11
12
13
14
15
I/O
I/O
I/O
I/O
I/O
I/O
O
19
21
15
16
20
22
16
17
P3.2/#INT0
P3.3/#INT1
P3.4/T0
P3.5/T1
P3.6/#WR
P3.7/#RD
XTAL2/P5.4
XTAL1/P5.5/
OSC_IN
VSS
P4.0/PWM0/CC0/
IIC_SCL/SS
P1.6/MISO/
IIC_SCL
P1.7/SPI_CLK/
IIC_SDA
RESET(default)/P
4.7
I/O
Description
Bit 2 of port 4 & PWM Channel 2 & Timer 2 compare/capture
Channel 2 & SPI interface Serial Data Master Input or Slave
Output pin
Bit 0 of port 1 & Timer 2 external input clock & Timer 2
compare/capture Channel 0
Bit 1 of port 1 & Timer 2 capture trigger & Timer 2
compare/capture Channel 1
Bit 2 of port 1 & Serial interface channel 0 receive data
Bit 3 of port 1 & Serial interface channel 0 transmit data or
receive clock in mode 0 & Timer 2 compare/capture Channel 2
Bit 4 of port 1 & 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 & SPI interface Serial Data Master Output or
Slave Input pin
Bit 6 of port 1 & SPI interface Serial Data Master Input or Slave
Output pin & IIC SCL pin
I/O
Bit 7 of port 1 & SPI interface Clock pin & IIC SDA pin
I/O
Reset pin(default) & Bit 7 of port 4
I
I
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 & 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
Bit 7 of port 3 & external memory read signal
Crystal output & bit4 of port 5
Crystal input & bit5 of port 5 & Oscillator input
Power supply
Bit 0 of port 4 & PWM Channel 0 & Timer 2 compare/capture
23
17
18
I/O
Channel 0 & IIC SCL pin & SPI interface Slave Select pin
Bit 0 of port 2 & Bit 8 of external memory address & Timer 2
21
24
18
19
P2.0 /A8/CC0
I/O
compare/capture Channel 0
Bit 1 of port 2 & Bit 9 of external memory address & Timer 2
22
25
19
20
P2.1 /A9/CC1
I/O
compare/capture Channel 1
Bit 2 of port 2 & Bit 10 of external memory address & Timer 2
23
26
20
21
P2.2/A10/CC2
I/O
compare/capture Channel 2
Bit 3 of port 2 & Bit 11 of external memory address & Timer 2
24
27
21
22
P2.3/A11/CC3
I/O
compare/capture Channel 3
40L
44L
44L
48L
Symbol
I/O
Description
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
9
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
PDIP
PLCC
PQFP
LQFP
25
28
22
23
P2.4/A12/PWM0
I/O
24
25
P5.0
P5.1
I/O
I/O
26
29
23
26
P2.5/A13/PWM1
I/O
27
30
24
27
P2.6/A14/PWM2
I/O
28
31
25
28
P2.7/A15/PWM3
I/O
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
33
34
35
36
37
38
39
40
36
37
38
39
40
41
42
43
44
30
31
32
33
34
35
36
37
38
33
34
35
36
37
38
39
40
41
P0.7/AD7
P0.6/AD6
P0.5/AD5
P0.4/AD4
P0.3/AD3
P0.2/AD2
P0.1/AD1
P0.0/AD0
VDD
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I
Bit 4 of port 2 & Bit 12 of external memory address & PWM
Channel 0
Bit 0 of port 5
Bit 1 of port 5
Bit 5 of port 2 & Bit 13 of external memory address & PWM
Channel 1
Bit 6 of port 2 & Bit 14 of external memory address & PWM
Channel 2
Bit 7 of port 2 & Bit 15 of external memory address & 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
Bit 6 of port 0 & Bit 6 of external memory address/ data
Bit 5 of port 0 & Bit 5 of external memory address/ data
Bit 4 of port 0 & Bit 4 of external memory address/ data
Bit 3 of port 0 & Bit 3 of external memory address/ data
Bit 2 of port 0 & Bit 2 of external memory address/ data
Bit 1 of port 0 & Bit 1 of external memory address/ data
Bit 0 of port 0 & Bit 0 of external memory address/ data
Power supply
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
10
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB 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
F8
IICS
IICCTL
IICA1
IICA2
IICRWD
IICS2
SPIC1
SPIC2
SPITXD
SPIRXD
SPIS
F0
B
E8
E0
P4
ACC
ISPFAH
ISPFAL
ISPFD
ISPFC
ISPST
D8
P5
PFCON
P3M0
P3M1
P4M0
P4M1
D0
PSW
CCEN2
P0M0
P0M1
P1M0
P1M1
C8
C0
T2CON
IRCON
CCCON
CCEN
CRCL
CCL1
CRCH
CCH1
TL2
CCL2
TH2
CCH2
B8
IEN1
IP1
S0RELH
B0
P3
PWMD2H
PWMD2L
A8
A0
IEN0
P2
IP0
RSTS
S0RELL
98
S0CON
S0BUF
PWMD0H
PWMD3H
X110
Bin/Hex
FF
TAKEY
F7
LVC
SWRES
EF
E7
P5M0
P5M1
DF
P2M0
P2M1
PWMMDH PWMMDL
CCL3
CCH3
PWMD0L PWMD1H
PWMD3L
X111
PWMC
WDTC
PWMD1L
WDTK
D7
CF
C7
BF
B7
AF
A7
9F
90
P1
AUX
AUX2
88
80
Hex\Bin
TCON
P0
X000
TMOD
SP
X001
TL0
DPL
X010
97
TL1
DPH
X011
TH0
DPL1
X100
TH1
DPH1
X101
RCON
X110
IFCON
PCON
X111
8F
87
Bin/Hex
Note: Special Function Registers reset values and description for SM59R16G6
Register
Location
Reset value
Description
P0
SP
80H
81H
FFH
07H
Port 0
Stack Pointer
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
P1
90H
FFH
Port 1
AUX
91H
00H
Auxiliary register
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
11
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
Register
Location
Reset value
Description
AUX2
92H
00H
Auxiliary register 2
S0CON
98H
00H
Serial Port 0, Control Register
S0BUF
99H
00H
Serial Port 0, Data Buffer
P2
A0H
FFH
Port 2
RSTS
A1H
00H
Reset Status Flag Register
IEN0
A8H
00H
Interrupt Enable Register 0
IP0
A9H
00H
Interrupt Priority Register 0
S0RELL
AAH
00H
Serial Port 0, Reload Register, low byte
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
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
CCEN
C1H
00H
Compare/Capture Enable Register
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
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
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
12
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
Register
Location
Reset value
Description
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
D8H
3FH
Port 5
PFCON
P3M0
P3M1
D9H
DAH
DBH
00H
00H
00H
Peripheral Frequency control register
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
ISPST
E5H
00H
ISP Flash status
LVC
E6H
20H
Low voltage control register
SWRES
E7H
00H
Software Reset register
P4
E8H
FFH
Port 4
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
SPIS
F5H
40H
SPI status 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
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
13
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
Function Description
1. General Features
SM59R16G6 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 its writer or In-System Programming
(ISP).
1.2. IO Pads
The SM59R16G6 has six I/O ports: Port 0, Port 1, Port 2, Port 3, Port 4, and Port 5. Ports 0, 1, 2, 3 are 8-bit ports,Port 4
is a 7-bit port 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 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; when
user use external OSC as system clock and input into XTAL1, Only XTAL2 can be defined as P5.4.
All the pads for P0 ~ P5 are with slew rate 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
SM59R16G6’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. SM59R16G6 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-M059
14
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
1.4.
1.4.1.
RESET
Hardware RESET function
SM59R16G6 provides Internal reset circuit inside, the Internal reset time can set by writer or ISP.
Internal Reset time
25ms (default)
200ms
100ms
50ms
16ms
8ms
4ms
1.4.2.
Software RESET function
SM59R16G6 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
RSTS
1.4.3.
Description
Time Access Key
register
Software Reset
register
Reset Status Flag
register
Direct
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
A1h
-
-
-
PDRF
WDTF
SWRF
LVRF
2
1
Address: F7H
0
Reset
00H
PORF
00H
Time Access Key register (TAKEY)
Mnemonic: TAKEY
7
6
1.4.4.
Bit 7
5
4
3
TAKEY [7:0]
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
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-M059
15
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
1.4.5.
Reset Status Flag (RSTS)
Mnemonic: RSTS
7
6
-
5
-
4
PDRF
3
WDTF
2
SWRF
1
LVRF
Address: A1H
0
Reset
PORF
00H
PDRF: Pad reset flag.
When MCU is reset by reset pad, PDRF flag will be set to one by hardware. This flag clear by
software.
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.
SWRF: Software reset flag.
When MCU is reset by software, SWRF flag will be set to one by hardware. This flag clear by
software.
LVRF: Low voltage reset flag.
When MCU is reset by LVR, LVRF flag will be set to one by hardware. This flag clear by software.
PORF: Power on reset flag.
When MCU is reset by POR, PORF flag will be set to one by hardware. This flag clear by
software.
1.4.6.
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 22.1184MHz Internal OSC. 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 internal OSC with difference frequency division as given in
source can set by writer or ICP.
table 1-1, the clock
Table 1-1: Selection of clock source
Clock source
external crystal
External OSC into Xtal1
22.1184 MHz from internal OSC(default)
11.0592MHz from internal OSC
5.5296MHz from internal OSC
2.7648MHz from internal OSC
1.3824MHz from internal OSC
The internal OSC have ±2% variance at room temperature.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
16
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
2. Instruction Set
All SM59R16G6 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 SM59R16G6 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
ADD A,#data
ADDC A,Rn
Bytes
1
Cycles
1
25
2
2
Add indirect RAM to accumulator
26-27
1
2
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-M059
17
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB 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-M059
18
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB 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-M059
19
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB 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-M059
20
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
3. Memory Structure
The SM59R16G6 memory structure follows general 8052 structure. It is integrate the expanded 1KB data memory and
64KB program memory.
3.1.
Program Memory
The SM59R16G6 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 SM59R16G6 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 16 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: SM59R16G6 programmable Flash
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
21
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB 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 : SM59R09G6 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 : SM59R05G6 programmable Flash
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
22
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
3.2. Data Memory
The SM59R16G6 has 1K + 256Bytes on-chip SRAM, 256 Bytes of it are the same as general 8052 internal memory
structure while the expanded 1KBytes 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
03FF
FF
FF
Higher 128 Bytes (Accessed by
indirect addressing mode only)
SFR (Accessed by direct
addressing mode only)
80
7F
00
Expanded 1K Bytes
(Accessed by direct
external addressing
mode by instruction
MOVX)
80
Lower 128 Bytes (Accessed by
direct & indirect addressing
mode )
0000
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-M059
23
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB 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 1024 bytes ($0000 to $03FF)
From external address 0000H to 03FFH is the on-chip expanded SRAM area, total 1K Bytes. This area can be accessed
by external direct addressing mode (by instruction MOVX).
If the address of instruction MOVX @DPTR is larger then 03FFH, the SM59R16G6 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 1K expanded RAM is enabled. If access memory space is more than 1K byte, the value of
RCON is sent to Port2 to access external RAM.
When EMEN = 1, the internal 1K 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-M059
24
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
4. CPU Engine
The SM59R16G6 engine is composed of four components:
a. Control unit
b. Arithmetic – logic unit
c. Memory control unit
d. RAM and SFR control unit
The SM59R16G6 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
P1UR
86H
P4IIC
-
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-M059
25
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
4.3.
Program Status Word
Mnemonic: PSW
7
6
CY
AC
5
F0
4
3
RS [1:0]
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
3
This register is incremented before PUSH and CALL
2
1
SP [7:0]
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-M059
26
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB 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 SM59R16G6 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
P1UR
3
P4IIC
2
-
1
P2PWM
Address: 91H
0
Reset
DPS
00H
DPS: Data Pointer selects register.
DPS = 1 is selected DPTR1.
4.7.
Internal RAM control register
SM59R16G6 has 1K 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-M059
27
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
EMEN: Internal 1K SRAM disable.(default is enable)
EMEN = 0, Enable internal 1K RAM.
EMEN = 1, Disable internal 1K 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-M059
28
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
5. GPIO
The SM59R16G6 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, 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 SM59R16G6 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; when
user use external OSC as system clock and input into XTAL1, Only XTAL2 can be defined as P5.4.
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-M059
29
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB 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-M059
30
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
6. Timer 0 and Timer 1
The SM59R16G6 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 1/12/96 machine cycles, which means that it
counts up after every 1/12/96 periods of the clock signal. It’s dependent on SFR(PFCON).
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
TL0
TH0
TL1
TH1
TMOD
TCON
PFCON
6.1.
Description
Direct
Bit 7
Bit 6
Bit 5
Timer 0 and 1
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
RESET
Timer 0 , low byte
Timer 0 , high
byte
Timer 1 , low byte
Timer 1 , high
byte
Timer Mode
Control
Timer/Counter
Control
Peripheral
Frequency control
register
8AH
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
D9H
S0RELPS[1:0]
T1PS[1:0]
T0PS[1:0]
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.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
31
Ver.I SM59R16G6 04/2015
00H
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
1
6.2.
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.
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.
6.3.
Peripheral Frequency control register (PFCON)
Mnemonic: PFCON
7
6
5
4
S0RELPS[1:0]
3
2
T1PS[1:0]
Address: D9H
1
0
Reset
T0PS[1:0]
00H
T0PS[1:0]: Timer0 Prescaler select
T0PS[1:0]
Prescaler
00
Fosc/12
01
Fosc
10
Fosc/96
11
reserved
T1PS[1:0]: Timer1 Prescaler select
T1PS[1:0]
Prescaler
00
Fosc/12
01
Fosc
10
Fosc/96
11
reserved
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
32
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
6.4.
Mode 0 (13-bit Counter/Timer)
÷12
OSC
00
01
÷96
10
C/T = 1
T1PS[1:0]
T1 pin
TR1
GATE1
ET1
C/T = 0
TL1
TH1
(5 Bits) (8 Bits)
EA
0
1
1
Control
If not higher priority
Interrupt Processing
AND
NOT
TF1
0
Jump
001BH
OR
INT1 pin
D0D1D2D3D4
D5D6D7
D0D1D2D3D4D5D6D7
TL1
6.5.
TF1
TH1
Mode 1 (16-bit Counter/Timer)
÷12
OSC
00
01
÷96
10
C/T = 1
T1PS[1:0]
T1 pin
TR1
GATE1
ET1
C/T = 0
TH1
TL1
(8 Bits) (8 Bits)
EA
0
1
1
Control
If not higher priority
Interrupt Processing
AND
NOT
TF1
0
Jump
001BH
OR
INT1 pin
D0D1D2D3D4D5D6D7
D0D1D2D3D4D5D6D7
TL1
TH1
TF1
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
33
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
6.6.
Mode 2 (8-bit auto-reload Counter/Timer)
÷12
OSC
00
01
÷96
10
C/T = 1
T1PS[1:0]
T1 pin
TR1
GATE1
TL1
(8 Bits)
Auto
Reload
OR
1
1
If not higher priority
Interrupt Processing
TH1
(8 Bits)
INT1 pin
6.7.
TF1
0
0
Control
AND
NOT
EA
ET1
C/T = 0
Jump
001BH
Mode 3 (Timer 0 acts as two independent 8 bit Timers / Counters)
÷12
00
TH0
(8 Bits)
TF1
Interrupt
Request
(001BH)
TL0
(8 Bits)
TF0
Interrupt
Request
(000BH)
TR1
OSC
01
÷96
C/T = 0
10
C/T = 1
T0PS[1:0]
T1 pin
TR1
GATE1
Control
AND
NOT
OR
INT1 pin
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
34
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
7. 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
-
Bit 1
Bit 0
P42CC[1:0]
T2I[1:0]
CCF1
CCF0
RESET
00H
00H
CCH
CDH
TL2[7:0]
TH2[7:0]
00H
00H
CAH
CRCL[7:0]
00H
CBH
CRCH[7:0]
00H
C2H
CCL1[7:0]
00H
C3H
CCH1[7:0]
00H
C4H
CCL2[7:0]
00H
C5H
CCH2[7:0]
00H
C6H
CCL3[7:0]
00H
C7H
CCH3[7:0]
00H
Mnemonic: AUX2
7
6
-
5
-
4
-
3
-
Address: 92H
1
0
Reset
P42CC[1: 0]
00H
2
-
P42CC[1: 0] 00: Capture/Compare function on Port1.
01: Capture/Compare function on Port2
10: Capture/Compare function on Port4
11: reserved
Mnemonic: T2CON
7
6
T2PS[2:0]
5
4
3
T2R[1:0]
2
-
1
Address: C8H
0
Reset
T2I[1:0]
00H
T2PS[2:0]: Prescaler select bit:
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
35
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
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
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
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
36
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
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
7.1.
Timer 2 function
Timer 2 can operate as timer, event counter, or gated timer as explained later.
7.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.
7.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.
7.1.3.
Gated timer mode
In this mode, the internal clock which incremented timer 2 is gated by external signal T2.
7.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.
7.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 bit 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.
7.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.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
37
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
Fig. 7-1: Compare mode 0 function
Contents of
Timer 2
CRC or CCx
Reload value
CCx Output
Timer 2 = CCx value
7.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. 7-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. 7-2: Compare mode 1 function
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
38
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
Contents of
Timer 2
CRC or CCx
Reload value
CCx Output
Output register
Shadow register
CCx Output
Timer 2 = CCx value
7.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).
7.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.
7.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-M059
39
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
8. Serial interface 0
There are one serial interfaces for data communication in SM59R16G6, they are the so called UART0.
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 sets this data in serial output buffer and starts the transmission. Reading from the S0BUF 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
PFCON
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
Peripheral
Frequency
control
register
Direct
Bit 7
Bit 6
Bit 5
Bit 4
Serial interface 0
-
Bit 3
Bit 2
Bit 1
Bit 0
RESET
87H
SMOD
-
-
IDLE
40H
P1UR
P4IIC
-
STOP
P2PW
M
91H
BRGS
-
P4SPI
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
D9H
S0BUF[7:0]
-
Mnemonic: AUX
7
6
5
BRGS
P4SPI
-
4
P1UR
S0RELPS[1:0]
3
P4IIC
2
-
00H
T1PS[1:0]
1
P2PWM
T0PS[1:0]
Address: 91H
0
Reset
DPS
00H
P1UR: P1UR = 0 – Serial interface 0 function on P3.
P1UR = 1 – Serial interface 0 function on P1.
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.
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.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
40
Ver.I SM59R16G6 04/2015
00H
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
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: PFCON
7
6
5
4
S0RELPS[1:0]
3
2
T1PS[1:0]
Address: D9H
1
0
Reset
T0PS[1:0]
00H
S0RELPS[1:0]: S0REL Prescaler select
S0RELPS[1:0] Prescaler
00
Fosc/64
01
Fosc/32
T1PS[1:0]: Timer1 Prescaler select
T1PS[1:0]
Prescaler
00
Fosc/12
01
Fosc
10
Fosc/96
11
reserved
8.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.
8.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.
Fig. 8-1: Transmit mode 0 for Serial 0
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
41
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
Fig. 8-2: Receive mode 0 for Serial 0
8.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. 8-3: Transmit mode 1 for Serial 0
Fig. 8-4: Receive mode 1 for Serial 0
8.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.
8.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. 8-5: Transmit modes 2 and 3 for Serial 0
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
42
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
8.2.
Fig. 8-6: Receive modes 2 and 3 for Serial 0
Multiprocessor communication of Serial Interface 0
The feature of receiving 9 bits in Modes 2 and 3 of Serial Interface 0 can be used for multiprocessor communication. In
this case, the slave processors have bit SM20 in S0CON. 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 and receive the rest of the message, while
other slaves will leave SM20 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.
8.3.
Baud rate generator
8.3.1.
Serial interface 0 modes 1 and 3
(a) When BRGS = 0 (in SFR AUX):
T1PS[1:0] = 00
2SMOD × FOSC
Baud Rate =
32 × 12 × ( 256 − TH1)
T1PS[1:0] = 01
Baud Rate =
2SMOD × FOSC
32 × ( 256 − TH1)
Baud Rate =
2SMOD × FOSC
32 × 96 × ( 256 − TH1)
T1PS[1:0] = 10
(b) When BRGS = 1 (in SFR AUX):
S0RELPS[1:0] = 00
Baud Rate =
2SMOD × FOSC
64 × ( 210 − S0REL )
Baud Rate =
2SMOD × FOSC
32 × ( 210 − S0REL )
S0RELPS[1:0] = 01
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
43
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
9. 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). 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 9.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
to count from the beginning. The watchdog timer must be refreshed regularly to prevent reset request signal from
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
44
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
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. 9-1: Watchdog timer block diagram
Mnemonic
TAKEY
WDTC
WDTK
RSTS
Description
Direct
Time Access Key
register
Watchdog timer
control register
Watchdog timer
refresh key
Reset Status Flag
register
Bit 7
Bit 6
Bit 5
Bit 4
Watchdog Timer
F7H
Bit 2
Bit 1
Bit 0
RESET
TAKEY [7:0]
B6H
-
WDTE
-
B7H
00H
WDTM [3:0]
04H
WDTK[7:0]
A1H
Mnemonic: TAKEY
7
6
5
Bit 3
4
3
TAKEY [7:0]
PDRF
WDTF
2
1
00H
SWRF
LVRF
PORF
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
WDTE
4
-
3
2
1
WDTM [3:0]
Address: B6H
0
Reset
04H
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
can be disabled / enabled by the WDTE bit.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
45
Ver.I SM59R16G6 04/2015
00H
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
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 9.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 327.68ms.
First, programming the information block OP3 bit7 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.
Mnemonic: RSTS
7
6
-
5
-
4
PDRF
3
WDTF
2
SWRF
1
LVRF
Address: A1H
0
Reset
PORF
00H
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.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
46
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
10. Interrupt
The SM59R16G6 provides 10 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.
When the interrupt occurs, the engine will vector to the predetermined address as shown in Table 10.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 10-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
LVIIF – Low Voltage Interrupt
IICIF – IIC interrupt
004BH
0063H
006BH
9
12
13
*See Keil C about C51 User’s Guide about Interrupt Function description
Mnemonic
IEN0
IEN1
IRCON
IP0
IP1
Description
Interrupt Enable
0 register
Interrupt Enable
1 register
Interrupt request
register
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
-
-
IESPI
IEPWM
00H
C0H
EXF2
TF2
IICIF
LVIIF
-
-
SPIIF
PWMIF
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
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
47
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
Interrupt Enable 0 register(IEN0)
Mnemonic: IEN0
Address: A8H
7
6
5
4
3
2
1
0
Reset
EA
ET2
ES0
ET1
EX1
ET0
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
Address: B8H
7
6
5
4
3
2
1
0
Reset
EXEN2
IEIIC
IELVI
IESPI 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.
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 request register(IRCON)
Mnemonic: IRCON
7
6
5
EXF2
TF2
IICIF
4
LVIIF
3
-
2
-
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.
SPIIF: SPI interrupt flag.
PWMIF: PWM interrupt flag. Must be cleared by software.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
48
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
10.1.
Priority level structure
All interrupt sources are combined in groups:
Table 10-2: Priority level groups
Groups
External interrupt 0
PWM interrupt
Timer 0 interrupt
SPI interrupt
External interrupt 1
Timer 1 interrupt
Serial channel 0 interrupt
LVI interrupt
Timer 2 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 10-3: Priority levels
IP0.x
Priority Level
0
1
0
1
Level0 (lowest)
Level1
Level2
Level3 (highest)
Table 10-4: Groups of priority
Group
External interrupt 0
Timer 0 interrupt
External interrupt 1
Timer 1 interrupt
Serial channel 0 interrupt
Timer 2 interrupt
PWM interrupt
SPI interrupt
LVI interrupt
IIC interrupt
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
49
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
Table 10-5: Polling sequence
Interrupt source
Sequence
External interrupt 0
PWM interrupt
SPI interrupt
External interrupt 1
Timer 1 interrupt
Serial channel 0 interrupt
LVI interrupt
Polling sequence
Timer 0 interrupt
Timer 2 interrupt
IIC interrupt
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
50
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
11. 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
-
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
11.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.
11.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 from a no-clocked interrupt (external INT0/1, LVI ) or a reset (WDT and LVR) condition. Internally generated
interrupts (timer, serial port ...) have no effect on stop mode since they require clocking activity.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
51
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
12. Pulse Width Modulation (PWM)
SM59R16G6 provides four-channel PWM outputs.
The interrupt vector is 43H.
Mnemonic
Description
Direct
Bit 7
Bit 6
Bit 5
Bit 4
P4SPI
P1UR
Bit 3
Bit 2
Bit 1
Bit 0
RESET
AUX
PWMC
PWMD0H
PWMD0L
PWMD1H
PWMD1L
PWMD2H
PWMD2L
PWMD3H
PWMD3L
PWMMDH
PWMMDL
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
91H
BRGS
B5H
-
PWMCS[2:0]
BCH
PWMP0
-
-
-
BDH
-
-
-
PWMD0[9:8]
PWMD0[7:0]
BEH
PWMP1
-
-
-
BFH
-
PWMP2
-
-
-
B2H
-
-
PWMD1[9:8]
PWMP3
-
-
-
B4H
-
-
PWMD2[9:8]
-
-
-
-
CFH
-
-
PWMD3[9:8]
4
P1UR
3
P4IIC
2
-
1
P2PWM
-
PWMMD[9:8]
5
4
-
00H
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]
5
P4SPI
00H
00H
PWMD3[7:0]
CEH
00H
00H
PWMD2[7:0]
B3H
00H
00H
PWMD1[7:0]
B1H
Mnemonic: AUX
7
6
BRGS
-
P2PW
DPS
M
PWM3E PWM2E PWM1E PWM0E
N
N
N
N
P4IIC
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-M059
52
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB 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-M059
53
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB 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-M059
54
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
13. 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
P1UR
P4IIC
-
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
P1UR
-
-
3
P4IIC
2
-
3
RStart
2
AB_EN
1
P2PWM
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
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
55
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
000
001
010
011
100
101
110
111
Mnemonic: IICS
7
6
MStart
RxIF
Fosc/32
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. 13-1: Acknowledgement bit in the 9 bit of a byte transmission
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
56
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
Mnemonic: IICA1
7
6
5
4
IICA1[7:1]
R/W
3
2
1
Address: FAH
0
Reset
Match1 or RW1
A0H
R or R/W
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 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. 13-2: RW bit in the 8 bit after IIC address
Mnemonic: IICA2
7
6
5
4
IICA2[7:1]
R/W
3
2
1
Address: FBH
0
Reset
Match2 or RW2
60H
R or R/W
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 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.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
57
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
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.
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-M059
58
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
14. 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 master 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. 14-1 is an example showing the
Slave 2
Slave 1
MOSI
MISO
CLK
IO
IO
MOSI
MISO
CLK
MOSI
MISO
CLK
SS
SS
Fig. 14-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
SPIRF SPIMLS SPIOV SPITXIF SPITDR SPIRXIF SPIRDR
-
P4SPI
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
RESET
P1UR
P4IIC
-
P2PW
M
DPS
00H
SPISS
SPICKP SPICKE
P
TBC[2:0]
SPIRST
SPIBR[2:0]
08H
RBC[2:0]
00H
SPIR
S
40H
F3H
SPITXD[7:0]
00H
F4H
SPIRXD[7:0]
00H
Mnemonic: AUX
7
6
5
BRGS
P4SPI
4
P1UR
3
P4IIC
2
-
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-M059
59
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
Mnemonic: SPIC1
7
6
5
SPIEN SPIMSS 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
“1” – SPI_SCK high during idle. Ex :
“0” – SPI_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, SM59R16G6 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
SPIRST
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-M059
60
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB 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
SPIRST: SPI Restart.(Slave mode used only)
SPIRST = 0 is disable.
SPI transmit/receive data when SS active.
SPIRST = 1 is enable.
SPI transmit/receive new data when SS restart.
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
SPIRF
SPIMLS
5
SPIOV
4
SPITXIF
3
SPITDR
2
SPIRXIF
1
SPIRDR
Address: F5H
0
Reset
SPIRS
40H
SPIRF: SPI SS/CS Release Flag.
This bit is set when SS/CS release & SPIRST as ‘1’.
SPIMLS: MSB or LSB first output /input Select.
“1” is MSB first output/input.
“0” is LSB first output/input.
SPIOV: Overflow flag.
When SPIRDR is set and next data already into shift register, this flag will be set.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
61
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
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, 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.
The MCU must clear this bit after it gets the data from SPIRXD register. The SPI module is able to
write new data into SPIRXD only when this bit is cleared.
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.
P.S. MISO pin must be floating when SS or CS no-active in slave mode.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
62
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
15. LVI – Low Voltage Interrupt
The interrupt vector 63H.
Mnemonic: LVC
7
6
5
4
LVI_EN
LVR_EN LVSIF
3
-
2
-
1
-
Address: E6H
0
Reset
LVIS
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.
LVR_EN External low voltage reset function enable bit.
LVR_EN = 0 - disable external low voltage reset function.
LVR_EN = 1 - enable external low voltage reset function.
LVSIF Low Voltage Status Flag
1:the VDD voltage under LVI voltage
0:the VDD voltage above LVI voltage
LVIS: Low Voltage Interrupt level Selection:
0 :The level of voltage is Low-level
1 :The level of voltage is Hi-level
Hi-level:
Symbol
VLVI
VLVR
Parameter
Low Voltage Interrupt Voltage Level
Low Voltage Reset Voltage Level
Min
3.4
3.2
Typ
3.7
3.5
Max
4.0
3.8
Units
V
V
Typ
2.3
2.1
Max
2.5
2.3
Units
V
V
Notes: The VLVI always above VLVR about 0.2V.
Low-level:
Symbol
VLVI
VLVR
Parameter
Low Voltage Interrupt Voltage Level
Low Voltage Reset Voltage Level
Min
2.1
1.9
Notes: The VLVI always above VLVR about 0.2V.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
63
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
16. In-System Programming (Internal ISP)
The SM59R16G6 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 SM59R16G6 from the system.
The SM59R16G6 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 SM59R16G6 can input data. User then utilize ISP
service program to perform the flash program/chip erase/page erase/protect functions.
16.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 SM59R16G6 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 SM59R16G6 and host device which
output data to the SM59R16G6. For example, if user utilize UART interface to receive/transmit data between
SM59R16G6 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 SM59R16G6 active or idle mode. It can not be initiated under power
down mode.
16.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, SM59R16G6 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 16-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 16.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-M059
64
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB 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)
16.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 SM59R16G6 was in system.
16.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 SM59R16G6 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
SM59R16G6 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
SM59R16G6, 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.
16.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-M059
65
Ver.I SM59R16G6 04/2015
00H
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB 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 SM59R16G6 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.
The ISPFD provide the 8-bit data register for ISP function.
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
66
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
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
reserved
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:6] pins function
select(description in section 5)、WDTEN control bit(description in section 9)、or ISP
entry mechanisms select(description in section 16)。
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, SM59R16G6 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, SM59R16G6 will erase all the flash program memory except the ISP
service program space. To perform chip protect ISP function, the SM59R16G6 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 SM59R16G6 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-M059
67
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
Operating Conditions
Symbol
Description
Min.
Typ.
Max.
Unit.
Remarks
TA
Operating temperature
-40
25
85
℃
Ambient temperature under bias
VDD
Supply voltage
2.7
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 ℃
VCC =5V
5
uA
Power down mode
25 ℃
VCC =5V
RES
Power Supply Current VDD
50
1. Port in Push-Pull Output Mode
2. Port in Quasi-Bidirectional Mode
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
68
Ver.I SM59R16G6 04/2015
SM59R16G6/SM59R09G6/SM59R05G6
8-Bit Micro-controller
64KB/36KB/20KB with ISP Flash
& 1KB RAM embedded
TA = -40℃ to 85℃, VCC = 3.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
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.0V
V
IOL=3.2mA
90% VCC
V
IOH= -2.3mA
2.4
V
IOH= -77uA
90% VCC
V
IOH= -33uA
Vcc=3.0V
Port 0,1,2,3,4,5
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.0 V 25 ℃
10
mA
Idle mode, 12MHz
25 ℃
4
uA
Power down mode VCC =3.0V
25 ℃
RES
Power Supply Current VDD
50
VCC =
VCC =3.0V
1. Port in Push-Pull Output Mode
2. Port in Quasi-Bidirectional Mode
Specifications subject to change without notice contact your sales representatives for the most recent information.
ISSFD-M059
69
Ver.I SM59R16G6 04/2015