SM59R09A5 與W77E58 應用差異說明

SM59R09A5 Replace W77E58
APN
SM59R09A5 與 W77E58 應用差異說明
一、
二、
三、
適用產品:SM59R09A5
應用範圍:針對 SM59R09A5、SM59R09A3 與 W77E58 之應用差異,僅需對特殊功能暫
存器定義做小幅度修改即可.
功能說明:SM59R09A5、SM59R09A3 與 W77E58 各個 MCU 規格比較(表 1):
SM59R09A5
SM59R09A3
W77E58
2.7~5.5
2.7~5.5
4.5~5.5
3.5uA at VDD=5.0V
3.5uA at VDD=5.0V
50uA at VDD=5.5V
1T:up to 25
(1T,2T can
change on fly)
有(最大 24MHz)
36K
256+2048
1T:up to 25
(1T,2T can
change on fly)
有(最大 24MHz)
36K
256+2048
有(約 2~4MHz)
Interrupt
15
13
12
WDT
有
有
有
有
3
2
有
有
有(4 路),中斷向量
0x2BH
有(4 路,10 位),
中斷向量 0x43H
有
有
有
有
有
有
3
2
有
有
有(4 路),中斷向量
0x2BH
有(4 路,10 位),
中斷向量 0x43H
有
有
有
有
有
有
3
2
無
無
有
有
無
有(可調復位時間)
有
有
有
有(可調復位時間)
有
無
無
無
無
無
無
Feature
工作電壓 (V)
IDD(Power Down)
System clock(MHz)
內部 RC 震盪器
Program Flash ( byte)
RAM( byte)
16-bit Dual DPTR
Timer
UART
EEPROM
ICP/ISP/IAP
PCA
PWM
MDU
ADC
SPI interface
IIC interface
KBI interface
Port 4.4~4.7(40-pin PDIP)
&four I/O type
內置復位
低壓復位
即時時鐘(RTC)
OP & Compartor
4-T:up to 40
32K
256+1024
無
無
無
無
無
無
無
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
1
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
四、
特殊功能暫存器比較表:
SM59R09A5(表2):
Hex\Bin
F8
F0
E8
E0
D8
D0
C8
C0
B8
B0
A8
A0
98
90
88
80
X000
X001
IICS
B
P4
ACC
P5
PSW
T2CON
IRCON
IEN1
P3
IEN0
P2
S0CON
P1
TCON
P0
IICCTL
SPIC1
MD0
ISPFAH
X010
X011
X100
X101
X110
X111
Cmp0CON
Cmp1CON
IICA1
IICA2
IICRWD
IICS2
SPIC2
SPITXD
SPIRXD
SPIS
OpPin
TAKEY
MD1
MD2
MD3
MD4
MD5
ARCON
ISPFAL
ISPFD
ISPFC
LVC
SWRES
P3M0
P3M1
P4M0
P4M1
P5M0
P5M1
CCEN2
P0M0
P0M1
P1M0
P1M1
P2M0
P2M1
CCCON
CRCL
CRCH
TL2
TH2
PWMMDH PWMMDL
CCEN
CCL1
CCH1
CCL2
CCH2
CCL3
CCH3
IP1
S0RELH S1RELH PWMD0H PWMD0L PWMD1H PWMD1L
PWMD2H PWMD2L PWMD3H PWMD3L
PWMC
WDTC
WDTK
IP0
S0RELL
ADCC1
ADCC2
ADCDH
ADCDL
ADCCS
S0BUF
AUX
TMOD
SP
IEN2
AUX2
TL0
DPL
S1CON
KBLS
TL1
DPH
S1BUF
KBE
TH0
DPL1
S1RELL
KBF
TH1
DPH1
RTCADDR
RTCDATA
KBD
RCON
IRCON2
IFCON
PCON
X001
X010
X011
X100
X101
X110
X111
Bin/Hex
FF
F7
EF
E7
DF
D7
CF
C7
BF
B7
AF
A7
9F
97
8F
87
SM59R09A3(表 3):
Hex\Bin
F8
F0
E8
E0
D8
D0
C8
C0
B8
B0
A8
A0
98
90
88
80
X000
IICS
B
P4
ACC
P5
PSW
T2CON
IRCON
IEN1
P3
IEN0
P2
S0CON
P1
TCON
P0
Bin/Hex
IICCTL
IICA1
IICA2
IICRWD
IICS2
FF
SPIC1
SPIC2
SPITXD
SPIRXD
SPIS
TAKEY
F7
MD0
MD1
MD2
MD3
MD4
MD5
ARCON
EF
ISPFAH
ISPFAL
ISPFD
ISPFC
LVC
SWRES
E7
P3M0
P3M1
P4M0
P4M1
P5M0
P5M1
DF
CCEN2
P0M0
P0M1
P1M0
P1M1
P2M0
P2M1
D7
CCCON
CRCL
CRCH
TL2
TH2
PWMMDH PWMMDL
CF
CCEN
CCL1
CCH1
CCL2
CCH2
CCL3
CCH3
C7
IP1
S0RELH S1RELH PWMD0H PWMD0L PWMD1H PWMD1L
BF
PWMD2H PWMD2L PWMD3H PWMD3L
PWMC
WDTC
WDTK
B7
IP0
S0RELL
ADCC1
ADCC2
ADCDH
ADCDL
ADCCS
AF
A7
S0BUF
IEN2
S1CON
S1BUF
S1RELL
9F
AUX
AUX2
KBLS
KBE
KBF
KBD
97
TMOD
TL0
TL1
TH0
TH1
IFCON
8F
SP
DPL
DPH
DPL1
DPH1
RCON
PCON
87
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
2
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
W77E58(表3):
Hex\Bin
F8
F0
E8
E0
D8
D0
C8
C0
B8
B0
A8
A0
98
90
88
80
五、
X000
EIP
B
EIE
ACC
WDCON
PSW
T2CON
SCON1
IP
P3
IE
P2
S0CON
P1
TCON
P0
X001
X010
X011
X100
X101
T2MOD
SBUF1
SADEN
RCAP2L
RCAP2H
ROMMAP
TL2
PMR
TH2
STATUS
SADDR
SADDR1
X110
X111
TA
SADEN1
P4
S0BUF
EXIF
TMOD
SP
TL0
DPL
TL1
DPH
TH0
DPL1
TH1
DPH1
CKCON
DPS
PCON
Bin/Hex
FF
F7
EF
E7
DF
D7
CF
C7
BF
B7
AF
A7
9F
97
8F
87
特殊功能差異說明:
特殊功能
SM59R09A5/SM59R09A3
Addr.
W77E58
Addr.
雙數據指針
於AUX.DPS 設定
91H.0
P4
8 Bits可位元定址
E8H
4 Bits不可位元定址
TAKEY
F7H
IE1.EWDI(WDT interrupt enable,
WDTC
B6H
interrupt vector at 0x63H)
WDTK
B7H
CKCON
8EH
WDCON
D8H
看門狗1. 時脈源不同
2. 預分頻不同
3. 設定及清除
計時方式不
同
1. 時脈源由內部250KHz產生,溢出時
間固定。
2. 由WDTC[3:0]設定,預分頻由
1~32768分16階:
Period = 1.02 m sec ~ 33.55 sec
3. 須先設定KEY(TAKEY)後,才可對
WDTC設定;清除WDT於WDTK寫
於DPS.DPS設定
86H.0
A6H
E8H.4
1. 時脈源由外部晶振產生,溢出時
間不固定。
2. 由CKCON[7:6]設定,預分頻4
階,產生中斷信號後512時脈產
生重置信號。
WD1:WD0
Interrupt
Reset
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
3
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
入0x55。
参考附件一
00
2
17
2 +512
17
01
2
20
2 +512
10
2
23
2 +512
11
2
26
2 +512
20
23
26
3. 沒有KEY的設計,可直接改
WDCON及CKCON。
輔助記憶體
有2048 Bytes
Embedded
IFCON.EMEN
有1024 Bytes
8FH.1
PMR.DEM0
=1, 禁能
=1, 致能
=0, 致能 (default)
=0, 禁能(default)
中斷致能及優先
共提供15/13組中斷源及4階中斷優先
共提供12組中斷源及2階中斷優先權
權設定不同
權設定
設定
RAM
C4H.0
IEN0
A8H
IE
A8H
IEN1
B8H
EIE
E8H
IEN2
9AH
IP
B8H
IP
A9H
EIP
F8H
IP1
B9H
EIF
91H
参考附件二
雙串口
IEN0.ES0(UART0 interrupt enable,
A8H.4
interrupt vector at 0x23H)
IE.ES(UART0 interrupt enable,
A8H.4
interrupt vector at 0x23H)
(Dual UART)
IEN2.ES1(UART1 interrupt enable,
9AH.0
interrupt vector at 0x83H)
PCON.SMOD
AUX.P4UR1
IE.ES1(UART1 interrupt enable,
interrupt vector at 0x3BH)
87H.7
91H.4
PCON.SMOD
SCON
=0, UART1 at P1.
SBUF
=1, UART1 at P4
SCON1
TxD1 change from P1.3 to P4.3
SBUF1
RxD1 change from P1.2 to P4.2
SADDR1
S0CON
A8H.6
98H
SADEN1
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
4
Ver. A 2010/06
87H.7
98H
99H
C0H
C1H
AAH
BAH
SM59R09A5 Replace W77E58
APN
S0BUF
99H
STATUS
C5H
S0RELL
AAH
WDCON
D8H
S0RELH
BAH
S1CON
9BH
S1RELL
9DH
S1RELH
BBH
S1BUF
9CH
参考附件三
計時器 2
IEN0.ET2(Timer2 interrupt enable,
A8H.5
IE.ET2(Timer 2 interrupt enable,
A8H.5
interrupt vector at 0x2BH)
interrupt vector at 0x2BH)
(Timer 2)
T2CON
C8H
T2CON
C8H
CRCL
CAH
T2MOD
C9H
CRCH
CBH
RCAP2L
CAH
TL2
CCH
RCAP2H
CBH
TH2
CDH
TL2
CCH
TH2
CDH
参考附件四
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
5
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
附件一:看門狗設定不同說明
1. SM59R09A5/SM59R09A3 與 W77E58 看門狗功能比較:
SM59R09A5/SM59R09A3
內部獨立之 250KHz RC 震盪
器,復位時間固定
分 16 階,方便使用
1.02 m sec ~ 33.55 sec
時鐘源
復位階數
復位時間
W77E58
與外部晶振共用,復位時間不固定
分4階
需依公式計算復位時間
2. SM59R09A5/SM59R09A3 與 W77E58 看門狗特殊功能暫存器比較:
特殊功能暫存器名稱
看門狗功能設定
看門狗功能重置
功能致能暫存器保護
SM59R09A5/SM59R09A3
名稱及位址
WDTC (0xB6H)
WDTK (0xB7H)
TAKEY (0xF7H)
於此暫存器連續填入 0x55H,
0xAAH 及 0x5AH 以啟動功能
W77E58 名稱及位址
WDCON (0xD8H);CKCON(0X8EH)
WDCON (0xD8H)
無
3. SM59R09A5/SM59R09A3 與 W77E58 看門狗之特殊功能暫存器說明:
a. SM59R09A5/SM59R09A3 看門狗功能使用之暫存器說明:
Mnemonic: WDTC
7
6
5
WDTE
WDTF
4
-
3
2
1
WDTM [3:0]
Address: B6h
0
Reset
04H
WDTF: Watchdog timer reset flag.
When MCU is reset by watchdog, WDTF flag will be set to one by hardware. This flag
clear by software or external reset or power on reset.
WDTE: Control bit used to enable Watchdog timer.
The WDTE bit can be used only if WDTEN is “0”. If the WDTEN bit is “0”, then WDT
can be disabled / enabled by the WDTE bit.
0: Disable WDT.
1: Enable WDT.
The WDTE bit is not used if WDTEN is “1”. That is, if the WDTEN bit is “1”, WDT is
always disabled no matter what the WDTE bit status is. The WDTE bit can be read
and written.
WDTM [3:0]: WDT clock source divider bit. Please see below table to reference the WDT time-out
period.
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
6
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
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.
Mnemonic: TAKEY
7
6
5
4
3
TAKEY [7:0]
2
1
Address: F7h
0
Reset
00H
範例程式:於使用看門狗功能時需先使用 ISP 或 ICP 方式啟動看門狗功能,再於程式中再次啟動看門狗,
看門狗功能才能正常使用
MOV TAKEY, #55h
MOV TAKEY, #0AAh
MOV TAKEY, #5Ah
; 啟動 WDTC 寫入功能.
MOV WDTC, #28h
; 設定看門狗復位時間為 262.14 毫秒,並啟動看門狗功能
.
.
.
MOV WDTK, #55h
WDTM [3:0]
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
; 清除看門狗計數器.
Divider
(250 KHz RC oscillator in)
1
2
4
8
16
32
64
128
256
512
1024
2048
4096
8192
16384
32768
Time period @ 250KHz
1.02ms
2.05ms
4.10ms
8.19ms
16.38ms (default)
32.77ms
65.54ms
131.07ms
262.14ms
524.29ms
1.05s
2.10s
4.19s
8.39s
16.78s
33.55s
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
7
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
b. W77E58 看門狗功能使用之暫存器說明:
Mnemonic: WDCON
7
6
SMOD_1
POR
5
-
4
-
3
WDIF
2
WTRF
1
EWT
Address: D8h
0
Reset
RWT
0x0x0xx0B
SMOD_1: This bit Doubles the Serial Port 1 baud rate in mode 1,2 and 3 when set to 1
POR: Power-on reset flag. Hardware will set this flag on a power up condition. This flag can
be read or written by software. A write by software is the only way to clear this bit once
it is set.
WDIF: Watchdog Timer Interrupt Flag. If the watchdog interrupt is enabled, hardware will set
this bit to indicate that the watchdog interrupt has occurred. If the interrupt is not
enabled, then this bit indicates that the time-out period has elapsed. This bit must be
cleared by software.
WTRF: Watchdog Timer Reset Flag. Hardware will set this bit when the watchdog timer
causes a reset. Software can read it but must clear it manually. A power-fail reset will
also clear the bit. This bit helps software in determining the cause of a reset. If EWT =
0, the watchdog timer will have no affect on this bit.
EWT: Enable Watchdog timer Reset. Setting this bit will enable the Watchdog timer Reset
function.
RWT: Reset Watchdog Timer. This bit helps in putting the watchdog timer into a know state.
It also helps in resetting the watchdog timer before a time-out occurs. Failing to set the
RWT before time-out will cause an interrupt, if EWDI (EIE.4) is set and 512 clocks
after that a watchdog timer reset will be generated if EWT is set. This bit is
self-clearing by hardware.
The WDCON SFR is set to a 0x0x0xx0b on an external reset. WTRF is set to a 1 on a Watchdog
timer reset, but to a 0 on power on/down resets. WTRF is not altered by an external reset. POR is set to
1 by a power-on reset. EWT is set to 0 on a Power-on reset and unaffected by other resets. All the bits
in this SFR have unrestricted read access. POR, EWT, WDIF and RWT require Timed Access
procedure to write. The remaining bits have unrestricted write accesses.
Mnemonic: CKCON
7
6
5
WD1
WD0
T2M
4
T1M
3
T0M
2
MD2
1
MD1
Address: 8Eh
0
Reset
MD0
04H
WD1-0: Watchdog timer mode select bits: These bits determine the time-out period for the
watchdog timer. In all four time-out options the reset time-out is 512 clocks more than
the interrupt timeout period.
WD1
WD0
Interrupt time-out Reset time-out
0
0
217
217+512
0
1
220
220+512
1
0
223
223+512
1
1
226
226+512
T2M: Timer 2 clock select: When T2M is set to 1, timer 2 uses a divide by 4 clock, and when
set to 0 it uses a divide by 12 clock.
T1M: Timer 1 clock select: When T1M is set to 1, timer 1 uses a divide by 4 clock, and when
set to 0 it uses a divide by 12 clock.
T0M: Timer 0 clock select: When T0M is set to 1, timer 0 uses a divide by 4 clock, and when
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
8
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
set to 0 it uses a divide by 12 clock.
MD2-0: Stretch MOVX select bits: These three bits are used to select the stretch value for the
MOVX instruction. Using a variable MOVX length enables the user to access slower
external memory devices or peripherals without the need for external circuits. The RD
or WR strobe will be stretched by the selected interval. When accessing the on-chip
SRAM, the MOVX instruction is always in 2 machine cycles regardless of the stretch
setting. By default, the stretch has value of 1. If the user needs faster accessing, then
a stretch value of 0 should be selected.
MD2
0
MD1
0
MD0
0
Stretch value
0
0
0
1
1
0
0
1
1
1
1
1
1
0
0
1
1
0
1
0
1
0
1
2
3
4
5
6
7
MOVX duration
2 machine cycles
3 machine cycles
(Default)
4 machine cycles
5 machine cycles
6 machine cycles
7 machine cycles
8 machine cycles
9 machine cycles
Time-out values for the watchdog timer
WD1
WD0
Watchdog
Interval
Number of
Clocks
Time
@ 1.8432 MHz
Time
@10MHz
Time
@ 25MHz
0
0
217
131072
71.11 ms
13.11 ms
5.24 ms
0
1
220
1048576
568.89 ms
104.86 ms
41.94 ms
1
0
223
8388608
4551.11 ms
838.86 ms
335.54 ms
1
1
226
67108864
36408.88 ms
6710.89 ms
2684.35 ms
The Watchdog timer will de disabled by a power-on/fail reset. The Watchdog timer reset does not disable the
watchdog timer, but will restart it. In general, software should restart the timer to put it into a known state.
The default Watchdog time-out is 217 clocks, which is the shortest time-out period. The EWT, WDIF and RWT bits
are protected by the Timed Access procedure. This prevents software from accidentally enabling or disabling the
watchdog timer. More importantly, it makes it highly improbable that errant code can enable or disable the
watchdog timer.
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
9
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
附件二:中斷致能及優先權設定不同說明
1. SM59R09A5/SM59R09A3 與 W77E58 中斷功能比較:
新茂 SM59R09A5 提供 15 組中斷源、SM59R09A3 提供 13 組中斷源,W77E58 只有 12 組。
新茂提供 4 階中斷優先權設定,W77E58 只有 2 階。
中斷源旗標
IE0 – External interrupt 0
TF0 – Timer 0 interrupt
SM59R09A5
之中斷向量
0x03H
0x0BH
SM59R09A3
之中斷向量
0x03H
0x0BH
W77E58 之中斷向量
0x03H
0x0BH
IE1 – External interrupt 1
0x13H
0x13H
0x13H
TF1 – Timer 1 interrupt
RI0/TI0 – Serial channel 0 interrupt
TF2/EXF2 – Timer 2 interrupt
0x1BH
0x23H
0x2BH
0x1BH
0x23H
0x2BH
PWMIF – PWM interrupt
0x43H
0x43H
0x1BH
0x23H
0x2BH
無
SPIIF – SPI interrupt
0x4BH
0x4BH
無
0x53H
0x5BH
0x63H
0x6BH
0x83H
008Bh
0093h
Same as TF2
無
無
無
無
無
0x53H
0x5BH
0x63H
0x6BH
0x83H
無
無
Same as TF2
無
無
無
無
ADCIF – A/D converter interrupt
KBIIF – keyboard Interface interrupt
LVIIF – Low Voltage Interrupt
IICIF – IIC interrupt
RI1/TI1 – Serial channel 1 interrupt
RTC/ALARM interrupt
Comparator interrupt
PCA
IE2 – External interrupt 2
IE3 – External interrupt 3
IE4 – External interrupt 4
IE5 – External interrupt 5
Watchdog Timer
0x3BH
無
無
無
無
無
無
無
無
0x43H
0x4BH
0x53H
0x5BH
0x63H
2. SM59R09A5/SM59R09A3 與 W77E58 中斷特殊功能暫存器比較:
特殊功能暫存器名稱
中斷致能 0
中斷致能 1
中斷致能 2
中斷優先設定 0
中斷優先設定 1
SM59R09A5/SM59R09A3
名稱及位址
IEN0 (0xA8H)
IEN1 (0xB8H)
IEN2 (0x9AH)
IP0 (0xA9H)
IP1 (0xB9H)
W77E58 名稱及位址
IE (0xA8H)
EIE(0xE8H)
無
IP (0xB8H)
EIP(0xF8H)
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
10
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
3. SM59R09A5/SM59R09A3 與 W77E58 中斷之特殊功能暫存器說明:
a. SM59R09A5/SM59R09A3 中斷功能使用之暫存器說明:
Mnemonic: IEN0
7
6
EA
-
5
ET2
4
ES0
3
ET1
2
EX1
1
ET0
Address: A8h
0
Reset
EX0
00h
EA: EA=0 – Disable all interrupt.
EA=1 – Enable all interrupt.
ET2: ET2=0 – Disable Timer 2 overflow or external reload interrupt.
ET2=1 – Enable Timer 2 overflow or external reload interrupt.
ES0: ES0=0 – Disable Serial channel 0 interrupt.
ES0=1 – Enable Serial channel 0 interrupt.
ET1: ET1=0 – Disable Timer 1 overflow interrupt.
ET1=1 – Enable Timer 1 overflow interrupt.
EX1: EX1=0 – Disable external interrupt 1.
EX1=1 – Enable external interrupt 1.
ET0: ET0=0 – Disable Timer 0 overflow interrupt.
ET0=1 – Enable Timer 0 overflow interrupt.
EX0: EX0=0 – Disable external interrupt 0.
EX0=1 – Enable external interrupt 0.
Mnemonic: IEN1
7
6
EXEN2
5
IEIIC
4
IELVI
3
IEKBI
2
IEADC
1
IESPI
Address: B8h
0
Reset
IEPWM
00h
EXEN2: Timer 2 reload interrupt enable.
EXEN2 = 0 – Disable Timer 2 external reload interrupt.
EXEN2 = 1 – Enable Timer 2 external reload interrupt.
IEIIC: IIC interrupt enable.
IEIICS = 0 – Disable IIC interrupt.
IEIICS = 1 – Enable IIC interrupt.
IELVI: LVI interrupt enable.
IELVI = 0 – Disable LVI interrupt.
IELVI = 1 – Enable LVI interrupt.
IEKBI: KBI interrupt enable.
IEKBI = 0 – Disable KBI interrupt.
IEKBI = 1 – Enable KBI interrupt.
IEADC: A/D converter interrupt enable
IEADC = 0 – Disable ADC interrupt.
IEADC = 1 – Enable ADC interrupt.
IESPI: SPI interrupt enable.
IESPI = 0 – Disable SPI interrupt.
IESPI = 1 – Enable SPI interrupt.
IEPWM: PWM interrupt enable.
IEPWM = 0 – Disable PWM interrupt.
IEPWM = 1 – Enable PWM interrupt.
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
11
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
Mnemonic: IEN2
7
6
-
5
-
4
-
3
-
2
ECmpI
1
ERTC
Address: 9Ah
0
Reset
ES1
00h
ECmpI: (only SM59R09A5 have)
ECmpI =0 – Disable Comparator interrupt.
ECmpI =1 – Enable Comparator interrupt (include comparator_0 and comparator_1).
ERTC: (only SM59R09A5 have)
ERTC =0 – Disable RTC interrupt.
ERTC =1 – Enable RTC interrupt (include Periodical and Alarm Int).
ES1: ES1=0 – Disable Serial channel 1 interrupt.
ES1=1 – Enable Serial channel 1 interrupt.
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
SM59R09A5/SM59R09A3 Priority levels
IP1.x
IP0.x
Priority Level
0
0
1
1
0
1
0
1
Level0 (lowest)
Level1
Level2
Level3 (highest)
SM59R09A5/SM59R09A3 Groups of priority
Bit
IP1.0, IP0.0
External interrupt 0
IP1.1, IP0.1
Timer 0 interrupt
IP1.2, IP0.2
External interrupt 1
IP1.3, IP0.3
IP1.4, IP0.4
IP1.5, IP0.5
Timer 1 interrupt
Serial channel 0 interrupt
Timer 2 interrupt
Group
Serial channel 1 interrupt
RTC/ALARM interrupt
(only SM59R09A5 have)
Comparator interrupt
(only SM59R09A5 have)
-
PWM interrupt
SPI interrupt
ADC interrupt
KBI interrupt
LVI interrupt
IIC interrupt
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
12
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
SM59R09A5/SM59R09A3 Polling sequence
Interrupt source
Sequence
External interrupt 0
Serial channel 1 interrupt
PWM interrupt
Polling sequence
Timer 0 interrupt
RTC/ALARM interrupt
(only SM59R09A5 have)
SPI interrupt
External interrupt 1
Comparator interrupt
(only SM59R09A5 have)
ADC interrupt
Timer 1 interrupt
KBI interrupt
Serial channel 0 interrupt
LVI interrupt
Timer 2 interrupt
IIC interrupt
b. W77E58 中斷功能使用之暫存器說明:
Mnemonic: IE
7
6
EA
ES1
5
ET2
4
ES0
3
ET1
2
EX1
1
ET0
Address: A8h
0
Reset
EX0
00h
EA: EA=0 – Disable all interrupt.
EA=1 – Enable all interrupt.
ES1: ES1=0 – Disable Serial Port 1 interrupt.
ES1=1 – Enable Serial Port 1 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.
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
13
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
Mnemonic: EIE
7
6
-
5
-
4
EWDI
3
EX5
2
EX4
1
EX3
Address: E8h
0
Reset
EX2
00h
1
PT0
Address: B8h
0
Reset
PX0
00h
1
PX3
Address: F8h
0
Reset
PX2
00h
EWDI: Watchdog timer interrupt enable.
EWDI = 0 – Disable Watchdog timer interrupt.
EWDI = 1 – Enable Watchdog timer interrupt.
EX5: External Interrupt 5 enable.
EX5 = 0 – Disable External Interrupt 5.
EX5 = 1 – Enable External Interrupt 5.
EX4: External Interrupt4 enable
EX4 = 0 – Disable External Interrupt4.
EX4 = 1 – Enable External Interrupt4.
EX3: External Interrupt3 enable.
EX3 = 0 – Disable External Interrupt3.
EX3 = 1 – Enable External Interrupt3.
EX2: External Interrupt2 enable.
EX2 = 0 – Disable External Interrupt2.
EX2 = 1 – Enable External Interrupt2.
Mnemonic: IP
7
6
PS1
5
PT2
4
PS0
3
PT1
2
PX1
PS1: This bit defines the Serial port 1 interrupt priority.
PS = 1 sets it to higher priority level.
PT2: This bit defines the Timer 2 interrupt priority.
PT2 = 1 sets it to higher priority level.
PS0: This bit defines the Serial port 0 interrupt priority.
PS = 1 sets it to higher priority level.
PT1: This bit defines the Timer 1 interrupt priority.
PT1 = 1 sets it to higher priority level.
PX1: This bit defines the External interrupt 1 priority.
PX1 = 1 sets it to higher priority level.
PT0: This bit defines the Timer 0 interrupt priority.
PT0 = 1 sets it to higher priority level.
PX0: This bit defines the External interrupt 0 priority.
PX0 = 1 sets it to higher priority level.
Mnemonic: EIP
7
6
-
5
-
4
PWDI
3
PX5
2
PX4
PWDI: Watchdog timer interrupt priority.
PX5: External Interrupt 5 Priority.
= 0 - Low priority
= 1 - High priority
PX4: External Interrupt 4 Priority.
= 0 - Low priority
= 1 - High priority
PX3: External Interrupt 3 Priority.
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
14
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
= 0 - Low priority
= 1 - High priority
PX2: External Interrupt 2 Priority.
= 0 - Low priority
= 1 - High priority
W77E58 Priority structure of interrupts
Source
Flag
Priority Level
External Interrupt 0
Timer 0 Overflow
External Interrupt 1
Timer 1 Overflow
Serial Port
Timer 2 Overflow
Serial Port 1
External Interrupt 2
External Interrupt 3
External Interrupt 4
External Interrupt 5
Watchdog Timer
IE0
TF0
IE1
TF1
RI+TI
TF2+EXF2
RI_1+TI_1
IE2
IE3
IE4
IE5
WDIF
1(Highest)
2
3
4
5
6
7
8
9
10
11
12(Lowest)
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
15
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
附件三:雙串口設定不同說明
1. SM59R09A5/SM59R09A3 與 W77E58 雙串口功能比較:
新茂 SM59R09A5/ SM59R09A 之第二組串口接腳與 W77E58 同樣位於 P1.2 及 P1.3,但新茂還可將第
二組串口接腳切換至 P4.2 及 P4.3。
新茂第二組串口中斷向量位於 0x83H,W77E58 第二組串口中斷向量位於 0x3BH。
2. SM59R09A5/SM59R09A3 與 W77E58 雙串口特殊功能暫存器比較:
SM59R09A5/SM59R09A3
名稱及位址
S0CON (0x98H)
S0BUF (0x99H)
S0RELL(0xAAH)
S0RELH(0xBAH)
AUX(0x91H)
S1CON (0x9BH)
S1BUF (0x9CH)
S1RELL(0x9DH)
S1RELH(0xBBH)
無
無
無
無
特殊功能暫存器名稱
串口 0 控制
串口 0 資料暫存器
串口 0 重載低位元暫存器
串口 0 重載高位元暫存器
串口 1 腳位控制暫存器
串口 1 控制
串口 1 資料暫存器
串口 1 重載低位元暫存器
串口 1 重載高位元暫存器
串口 0 從機位址
串口 0 從機位址致能
串口 1 從機位址
串口 1 從機位址致能
W77E58 名稱及位址
SCON (0x98H)
SBUF(0x99H)
無
無
無
SCON1(0xC0H)
SBUF1 (0xC1H)
無
無
SADDR(0xA9H)
SADEN(0xB9H)
SADDR1(0xAAH)
SADEN1(0xBAH)
3. SM59R09A5/SM59R09A3 與 W77E58 雙串口之特殊功能暫存器說明:
a. SM59R09A5/SM59R09A3 雙串口功能使用之暫存器說明:
Mnemonic: PCON
7
6
SMOD MDUF
5
-
4
-
3
-
2
-
1
STOP
Address: 87h
0
Reset
IDLE
40h
SMOD: This bit doubles the serial port baud rate in mode 1, 2, and 3 when set to 1.
Mnemonic: AUX
7
6
5
P4SPI
BRS
4
P4UR1
3
P4IIC
2
P0KBI
1
P2PWM
Address: 91h
0
Reset
00H
DPS
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
16
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
BRS: Baud rate generator at Serial interface 0 modes 1 and 3
BRS = 0; Baud Rate =
2SMOD × FOSC
32 × 12 × (256 − TH1)
BRS = 1; Baud Rate =
2SMOD × FOSC
64 × 210 − S0REL
(
)
P4UR1: P4UR1 = 0 – Serial interface 1 function on P1.
P4UR1 = 1 – Serial interface 1 function on P4.
P4UR1
RXD1
TXD1
0
P1.2
P1.3
1
P4.2
P4.3
Mnemonic: S0CON
7
6
5
SM0
SM1
SM20
4
REN0
3
TB80
SM0,SM1: Serial Port 0 mode selection.
SM0 SM1
Mode
Description
0
0
0
Shift register
0
1
1
8-bit UART
1
0
2
9-bit UART
1
1
3
9-bit UART
2
RB80
Address: 98h
0
Reset
RI0
00h
1
TI0
Board Rate
Fosc/12
Variable
Fosc/32 or Fosc/64
Variable
SM20: Enables multiprocessor communication feature
REN0: If set, enables serial reception. Cleared by software to disable reception.
TB80: The 9th 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.
RB80: In modes 2 and 3, it is the 9th data bit received. In mode 1, if SM20 is 0,
RB80 is the stop bit. In mode 0, this bit is not used. Must be cleared by
software.
TI0: Transmit interrupt flag, set by hardware after completion of a serial transfer.
Must be cleared by software.
RI0: Receive interrupt flag, set by hardware after completion of a serial reception.
Must be cleared by software.
Mnemonic: S1CON
7
6
5
SM
SM21
4
REN1
SM: Serial Port 1 mode select.
SM
Mode Description
0
A
9-bit UART
1
B
8-bit UART
3
TB81
2
RB81
Address: 9Bh
0
Reset
RI1
00h
1
TI1
Baud Rate
Variable
Variable
Baud rate generator at Serial interface 1; Baud Rate =
FOSC
32 × 2 − S1REL
(
10
)
SM21: Enables multiprocessor communication feature.
REN1: If set, enables serial reception. Cleared by software to disable reception.
TB81: The 9th transmitted data bit in mode A. Set or cleared by the CPU depending
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
17
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
on the function it performs such as parity check, multiprocessor
communication etc.
RB81: In mode A, it is the 9th data bit received. In mode B, if SM21 is 0, RB81 is the
stop bit. Must be cleared by software.
TI1: Transmit interrupt flag, set by hardware after completion of a serial transfer.
Must be cleared by software.
RI1: Receive interrupt flag, set by hardware after completion of a serial reception.
Must be cleared by software.
b. W77E58 雙串口功能使用之暫存器說明:
Mnemonic: PCON
7
6
SMOD
SMOD0
5
-
4
-
3
-
2
-
1
STOP
Address: 87h
0
Reset
IDLE
00h
SMOD: This bit doubles the serial port baud rate in mode 1, 2, and 3 when set to 1.
SMOD0: Framing Error Detection Enable: When SMOD0 is set to 1, then SCON.7
(SCON1.7) indicates a Frame Error and acts as the FE(FE_1) flag. When SMOD0
is 0, then SCON.7(SCON1.7) acts as per the standard 8052 function.
Mnemonic: SCON
7
6
SM0/FE
SM1
5
SM2
4
REN
3
TB8
2
RB8
1
TI
Address: 98h
0
Reset
RI
00h
SM0/FE: Serial port 0, Mode 0 bit or Framing Error Flag: The SMOD0 bit in PCON SFR
determines whether this bit acts as SM0 or as FE. The operation of SM0 is
described below. When used as FE, this bit will be set to indicate an invalid stop bit.
This bit must be manually cleared in software to clear the FE condition.
SM0,SM1: Serial Port 0 mode selection.
SM0 SM1 Mode
Description
Length
Board Rate
4/12 Tclk
0
0
0
Synchronous
8
0
1
1
Asynchronous
10
Variable
1
0
2
Asynchronous
11
Fosc/32 or Fosc/64
1
1
3
Asynchronous
11
Variable
SM2: Multiple processors communication. Setting this bit to 1 enables the multiprocessor
communication feature in mode 2 and 3. In mode 2 or 3, if SM2 is set to 1, then RI
will not be activated if the received 9th data bit (RB8) is 0. In mode 1, if SM2 = 1,
then RI will not be activated if a valid stop bit was not received. In mode 0, the SM2
bit controls the serial port clock. If set to 0, then the serial port runs at a divide by
12 clock of the oscillator. This gives compatibility with the standard 8052. When set
to 1, the serial clock become divide by 4 of the oscillator clock. This results in faster
synchronous serial communication.
REN: Receive enable: When set to 1 serial reception is enabled, otherwise reception is
disabled.
TB8: This is the 9th bit to be transmitted in modes 2 and 3. This bit is set and cleared by
software as desired.
RB8: In modes 2 and 3 this is the received 9th data bit. In mode 1, if SM2 = 0, RB8 is the
stop bit that was received. In mode 0 it has no function.
TI: Transmit interrupt flag: This flag is set by hardware at the end of the 8th bit time in
mode 0, or at the beginning of the stop bit in all other modes during serial
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
18
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
transmission. This bit must be cleared by software.
RI: Receive interrupt flag: This flag is set by hardware at the end of the 8th bit time in
mode 0, or halfway through the stop bits time in the other modes during serial
reception. However the restrictions of SM2 apply to this bit. This bit can be cleared
only by software.
Mnemonic: SADDR
7
6
5
4
3
2
1
Address: A9h
0
Reset
00h
SADDR: The SADDR should be programmed to the given or broadcast address for
serial port 0 to which the slave processor is designated.
Mnemonic: SADDR1
7
6
5
4
3
2
1
Address: AAh
0
Reset
00h
SADDR1: The SADDR1 should be programmed to the given or broadcast address for
serial port 1 to which the slave processor is designated.
Mnemonic: SADEN
7
6
5
4
3
2
1
Address: B9h
0
Reset
00h
SADEN: This register enables the Automatic Address Recognition feature of the Serial
port 0. When a bit in the SADEN is set to 1, the same bit location in SADDR
will be compared with the incoming serial data. When SADEN.n is 0, then the
bit becomes a "don't care" in the comparison. This register enables the
Automatic Address Recognition feature of the Serial port 0. When all the bits
of SADEN are 0, interrupt will occur for any incoming address.
Mnemonic: SADEN1
7
6
5
4
3
2
1
Address: BAh
0
Reset
00h
SADEN1: This register enables the Automatic Address Recognition feature of the Serial
port 1. When a bit in the SADEN1 is set to 1, the same bit location in SADDR1
will be compared with the incoming serial data. When SADEN1.n is 0, then the
bit becomes a "don't care" in the comparison. This register enables the
Automatic Address Recognition feature of the Serial port 1. When all the bits
of SADEN1 are 0, interrupt will occur for any incoming address.
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
19
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
Mnemonic: SCON1
7
6
SM0_1/FE_1
SM1_1
5
SM2_1
4
REN_1
3
TB8_1
2
RB8_1
1
TI_1
Address: C0h
0
Reset
RI_1
00h
SM0_1/FE_1: Serial port 1, Mode 0 bit or Framing Error Flag 1: The SMOD0 bit in PCON SFR
determines whether this bit acts as SM0_1 or as FE_1. the operation of SM0_1 is
described below. When used as FE_1, this bit will be set to indicate an invalid stop bit.
This bit must be manually cleared in software to clear the FE_1 condition.
SM0_1,SM1_1: Serial Port 1 mode selection.
SM0_1 SM1_1 Mode
0
0
0
0
1
1
1
0
2
1
1
3
Description
Synchronous
Asynchronous
Asynchronous
Asynchronous
Length
8
10
11
11
Board Rate
4/12 Tclk
Variable
Fosc/32 or Fosc/64
Variable
SM2_1: Multiple processors communication. Setting this bit to 1 enables the multiprocessor
communication feature in mode 2 and 3. In mode 2 or 3, if SM2_1 is set to 1, then
RI_1 will not be activated if the received 9th data bit (RB8_1) is 0. In mode 1, if
SM2_1 = 1, then RI_1 will not be activated if a valid stop bit was not received. In
mode 0, the SM2_1 bit controls the serial port 1 clock. If set to 0, then the serial port 1
runs at a divide by 12 clock of the oscillator. This gives compatibility with the standard
8052. When set to 1, the serial clock become divide by 4 of the oscillator clock. This
results in faster synchronous serial communication.
REN_1: Receive enable: When set to 1 serial reception is enabled, otherwise reception is
disabled.
TB8_1: This is the 9th bit to be transmitted in modes 2 and 3. This bit is set and cleared by
software as desired.
RB8_1: In modes 2 and 3 this is the received 9th data bit. In mode 1, if SM2_1 = 0, RB8_1 is
the stop bit that was received. In mode 0 it has no function.
TI_1: Transmit interrupt flag: This flag is set by hardware at the end of the 8th bit time in
mode 0, or at the beginning of the stop bit in all other modes during serial
transmission. This bit must be cleared by software.
RI_1: Receive interrupt flag: This flag is set by hardware at the end of the 8th bit time in
mode 0, or halfway through the stop bits time in the other modes during serial
reception. However the restrictions of SM2_1 apply to this bit. This bit can be cleared
only by software.
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
20
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
附件四:計時器 2 設定不同說明
1. SM59R09A5/SM59R09A3 與 W77E58 計時器 2 功能比較:
新茂 SM59R09A5/ SM59R09A3 之計時器 2 除了可當 16 位元之計時器,還有 4 個通道之比較、捕獲及
重載之功能,類似於可編程計數器陣列(PCA)。
W77E58 之計時器 2 只可當 16 位元之計時器用。
2. SM59R09A5/SM59R09A3 與 W77E58 計時器 2 之特殊功能暫存器比較:
特殊功能暫存器名稱
計時器 2 控制暫存器
計時器 2 模式控制暫存器
計時器 2 捕獲重載低位元
計時器 2 捕獲重載高位元
計時器 2 低位元
計時器 2 高位元
比較及補獲通道選擇暫存器
比較及補獲控制暫存器
比較及補獲致能暫存器 1
比較及補獲致能暫存器 2
比較、捕獲及重載通道 1 低位元
比較、捕獲及重載通道 1 高位元
比較、捕獲及重載通道 2 低位元
比較、捕獲及重載通道 2 高位元
比較、捕獲及重載通道 3 低位元
比較、捕獲及重載通道 3 高位元
SM59R09A5/SM59R09A3
名稱及位址
T2CON (0xA8H)
W77E58 名稱及位址
T2CON (0xA8H)
T2MOD(0xA9H)
RCAP2L(0xCAH)
RCAP2H(0xCBH)
TL2(0xCCH)
TH2(0xCDH)
CKCON(0xA8H)
CRCL(0xCAH)
CRCH(0xCBH)
TL2(0xCCH)
TH2(0xCDH)
AUX2(0x92H)
CCCON(0xC9H)
CCEN(0xC1H)
CCEN2(0xD1H)
CCL1(0xC2H)
CCH1(0xC3H)
CCL2(0xC4H)
CCH2(0xC5H)
CCL3(0xC6H)
CCH3(0xC7H)
3. SM59R09A5/SM59R09A3 與 W77E58 計時器 2 之特殊功能暫存器說明:
a. SM59R09A5/SM59R09A3 計時器 2 功能使用之暫存器說明:
Mnemonic: T2CON
7
6
5
T2PS[2:0]
4
3
T2R[1:0]
2
-
1
Address: C8h
0
Reset
T2I[1:0]
00H
T2PS[2:0]: Prescaler select bit:
T2PS = 000 – timer 2 is clocked with the oscillator frequency.
T2PS = 001 – timer 2 is clocked with 1/2 of the oscillator frequency.
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
21
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
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
T2R[1:0] = 11 – Mode 1
T2I[1:0]: Timer 2 input selection
T2I[1:0] = 00 – Timer 2 stop
T2I[1:0] = 01 – Input frequency f/12 or f/24
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: AUX2
7
6
5
4
3
P42CC[1: 0] 00: Capture/Compare function on Port1.
01: Capture/Compare function on Port2
10: Capture/Compare function on Port4
11: reserved
P42CC[1: 0]
CC0
00
P1.0
01
P2.0
10
P4.0
Mnemonic: CCCON
7
6
5
CCI3
CCI2
CCI1
4
CCI0
3
CCF3
2
Address: 92h
1
0
Reset
P42CC[1: 0]
00H
CC1
P1.1
P2.1
P4.1
2
CCF2
CC2
P1.3
P2.2
P4.2
1
CCF1
CC3
P1.4
P2.3
P4.3
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.
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
22
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
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
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
b. W77E58 計時器 2 功能使用之暫存器說明:
Mnemonic: T2CON
7
6
5
TF2
EXF2
RCLK
4
TCLK
3
EXEN2
2
TR2
1
C / T2
Address: C8h
0
Reset
CP / RL2
00H
TF2: Timer 2 overflow flag: This bit is set when Timer 2 overflows. It is also set when the
count is equal to the capture register in down count mode. It can be set only if RCLK and
TCLK are both 0. It is cleared only by software. Software can also set or clear this bit.
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
23
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
EXF2: Timer 2 External Flag: A negative transition on the T2EX pin (P1.1) or timer 2 overflow
will cause this flag to set based on the CP / RL2 , EXEN2 and DCEN bits. If set by a
negative transition, this flag must be cleared by software. Setting this bit in software or
detection of a negative transition on T2EX pin will force a timer interrupt if enabled.
RCLK: Receive Clock Flag: This bit determines the serial port 0 time-base when receiving data
in serial modes 1 or 3. If it is 0, then timer 1 overflow is used for baud rate generation,
otherwise timer 2 overflow is used. Setting this bit forces timer 2 in baud rate generator
mode.
TCLK: Transmit Clock Flag: This bit determines the serial port 0 time-base when transmitting
data in modes 1 and 3. If it is set to 0, the timer 1 overflow is used to generate the baud
rate clock otherwise timer 2 overflow is used. Setting this bit forces timer 2 in baud rate
generator mode.
EXEN2: Timer 2 External Enable. This bit enables the capture/reload function on the T2EX pin if
Timer 2 is not generating baud clocks for the serial port. If this bit is 0, then the T2EX pin
will be ignored, otherwise a negative transition detected on the T2EX pin will result in
capture or reload.
TR2: Timer 2 Run Control. This bit enables/disables the operation of timer 2. Clearing this bit
will halt the timer 2 and preserve the current count in TH2, TL2.
C/T2: Counter/Timer Select. This bit determines whether timer 2 will function as a timer or a
counter. Independent of this bit, the timer will run at 2 clocks per tick when used in baud
rate generator mode. If it is set to 0, then timer 2 operates as a timer at a speed
depending on T2M bit (CKCON.5), otherwise it will count negative edges on T2 pin.
CP/RL2: Capture/Reload Select. This bit determines whether the capture or reload function will be
used for timer 2. If either RCLK or TCLK is set, this bit will be ignored and the timer will
function in an auto-reload mode following each overflow. If the bit is 0 then auto-reload
will occur when timer 2 overflows or a falling edge is detected on T2EX pin if EXEN2 = 1.
If this bit is 1, then timer 2 captures will occur when a falling edge is detected on T2EX
pin if EXEN2 =1.
Mnemonic: T2MOD
7
6
5
HC5
HC4
HC3
4
HC2
3
T2CR
2
1
T2OE
Address: C9h
0
Reset
DCEN
00H
HC5: Hardware Clear INT5 flag. Setting this bit allows the flag of external interrupt 5 to be
automatically cleared by hardware while entering the interrupt service routine.
HC4: Hardware Clear INT4 flag. Setting this bit allows the flag of external interrupt 4 to be
automatically cleared by hardware while entering the interrupt service routine.
HC3: Hardware Clear INT3 flag. Setting this bit allows the flag of external interrupt 3 to be
automatically cleared by hardware while entering the interrupt service routine.
HC2: Hardware Clear INT2 flag. Setting this bit allows the flag of external interrupt 3 to be
automatically cleared by hardware while entering the interrupt service routine.
T2CR: Timer 2 Capture Reset. In the Timer 2 Capture Mode this bit enables/disables hardware
automatically reset Timer 2 while the value in TL2 and TH2 have been transferred into
the capture register.
T2OE: Timer 2 Output Enable. This bit enables/disables the Timer 2 clock out function.
DCEN: Down Count Enable: This bit, in conjunction with the T2EX pin, controls the direction that
timer 2 counts in 16-bit auto-reload mode.
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
24
Ver. A 2010/06
SM59R09A5 Replace W77E58
APN
Mnemonic: CKCON
7
6
5
WD1
WD0
T2M
4
T1M
3
T0M
2
MD2
1
MD1
Address: 8Eh
0
Reset
MD0
04H
WD1-0: Watchdog timer mode select bits: These bits determine the time-out period for the
watchdog timer. In all four time-out options the reset time-out is 512 clocks more than
the interrupt timeout period.
WD1
WD0
Interrupt time-out Reset time-out
0
0
217
217+512
0
1
220
220+512
1
0
223
223+512
1
1
226
226+512
T2M: Timer 2 clock select: When T2M is set to 1, timer 2 uses a divide by 4 clock, and when
set to 0 it uses a divide by 12 clock.
T1M: Timer 1 clock select: When T1M is set to 1, timer 1 uses a divide by 4 clock, and when
set to 0 it uses a divide by 12 clock.
T0M: Timer 0 clock select: When T0M is set to 1, timer 0 uses a divide by 4 clock, and when
set to 0 it uses a divide by 12 clock.
MD2-0: Stretch MOVX select bits: These three bits are used to select the stretch value for the
MOVX instruction. Using a variable MOVX length enables the user to access slower
external memory devices or peripherals without the need for external circuits. The RD
or WR strobe will be stretched by the selected interval. When accessing the on-chip
SRAM, the MOVX instruction is always in 2 machine cycles regardless of the stretch
setting. By default, the stretch has value of 1. If the user needs faster accessing, then
a stretch value of 0 should be selected.
MD2
0
MD1
0
MD0
0
Stretch value
0
0
0
1
1
0
0
1
1
1
1
1
1
0
0
1
1
0
1
0
1
0
1
2
3
4
5
6
7
MOVX duration
2 machine cycles
3 machine cycles
(Default)
4 machine cycles
5 machine cycles
6 machine cycles
7 machine cycles
8 machine cycles
9 machine cycles
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0173
25
Ver. A 2010/06