Reset 功能使用方法

Reset 功能使用方法
Reset 功能使用方法
1
适用产品:
1.1 SM59R16A5/SM59R09A5/SM59R05A5/SM59R16A3/SM59R09A3/SM59R05A3
1.2 SM59R04A2/ SM59R04A1/ SM59R03A1/ SM59R02A1
2
Reset 使用概述:
2.1 本系列 MCU 除了标准 Reset Pin 重置功能,另外提供软件重置功能、内建重置电路 (可选择重置
时间长短)及低电压重置功能提供客户使用。
2.2 当低电压重置功能产生时,其中断向量为 0x63H。
3
Reset 功能相关的特殊缓存器 [Reset Special Function Register] (SFR)
Mnemonic
Description
Direct
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
RESET
Reset
TAKEY
Time Access Key
register
F7h
TAKEY [7:0]
00H
SWRES
Software Reset
register
E7h
SWRES [7:0]
00H
IEN0
Interrupt Enable
0 register
A8h
EA
-
ET2
ES0
ET1
EX1
ET0
EX0
00h
IEN1
Interrupt Enable
1 register
B8h
EXEN2
-
IEIIC
IELVI
IEKBI
IEADC
IESPI
IEPWM
00h
IRCON
Interrupt request
register
C0H
EXF2
TF2
IICIF
LVIIF
KBIIF
ADCIF
SPIIF
PWMIF
00H
E6H
LVI_EN
-
LVRXE
-
-
-
-
LVC
4
软件重置功能选择方式:
Address: F7H
Mnemonic: TAKEY
7
6
5
4
3
TAKEY [7:0]
2
1
0
Reset
00H
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0180
1
Ver A 2010/06
20H
Reset 功能使用方法
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, #055h
MOV TAKEY, #0AAh
MOV TAKEY, #05Ah
Mnemonic: SWRES
7
6
Address: E7H
5
4
3
SWRES [7:0]
2
1
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.
Software reset example:
MOV TAKEY, #055h
MOV TAKEY, #0AAh
MOV TAKEY, #05Ah
MOV SWRES, #0FFh
5
内建重置电路功能,重置时间可由烧录时设定:
(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
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0180
2
Ver A 2010/06
Reset 功能使用方法
6
低电压重置功能:
The interrupt vector 63h.
Mnemonic: LVC
7
LVI_EN
Address: E6h
6
-
5
LVRXE
4
-
3
-
2
-
1
-
0
Reset
20H
LVI_EN: Low voltage interrupt function enable bit.
LVI_EN = 0 : disable low voltage detect function.
LVI_EN = 1 : enable low voltage detect function. LVIIF will be set when low voltage detect.
LVRXE: External low voltage reset function enable bit.
LVRXE = 0 : disable external low voltage reset function.
LVRXE = 1 : enable external low voltage reset function.
以下适用组件:SM59R16A5/SM59R09A5/SM59R05A5
Low Voltage Detect Level
LVI
LVRX
C = 4.5V ~ 5.5V
3.5V
3.1V
L =2.7V ~ 3.6V
2.3V
2.1V
以下适用组件:SM59R04A2
Low Voltage Detect Level
LVI
C = 4.5V ~ 5.5V
3.5V
L =2.7V ~ 3.6V
2.3V
LVRX
3.1V
2.1V
Mnemonic: IEN1
7
EXEN2
6
-
Address: B8h
5
IEIIC
4
IELVI
3
IEKBI
2
IEADC
1
IESPI
0
IEPWM
Reset
00h
IELVI: LVI interrupt enable.
IELVI = 0 – Disable LVI interrupt.
IELVI = 1 – Enable LVI interrupt.
Mnemonic: IRCON
7
EXF2
6
TF2
Address: C0h
5
IICIF
4
LVIIF
3
KBIIF
2
ADCIF
1
SPIIF
0
PWMIF
Reset
00H
LVIIF: LVI interrupt flag.
LVIIF will be set when LVI_EN=1 & occur low voltage detect. Must be cleared by software.
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0180
3
Ver A 2010/06
Reset 功能使用方法
7
中断功能:
IE0 – External interrupt 0
TF0 – Timer 0 interrupt
Interrupt Vector
Address
0003h
000Bh
Interrupt Number
*(use Keil C Tool)
0
1
IE1 – External interrupt 1
0013h
2
TF1 – Timer 1 interrupt
RI0/TI0 – Serial channel 0 interrupt
TF2/EXF2 – Timer 2 interrupt
001Bh
0023h
002Bh
3
4
5
PWMIF – PWM interrupt
0043h
8
SPIIF – SPI interrupt
004Bh
9
ADCIF – A/D converter interrupt
KBIIF – keyboard Interface interrupt
LVIIF – Low Voltage Interrupt
IICIF – IIC interrupt
RI1/TI1 – Serial channel 1 interrupt
RTC/ALARM interrupt
Comparator interrupt
0053h
005Bh
0063h
006Bh
0083h
008Bh
0093h
10
11
12
13
16
17
18
Interrupt Request Flags
*See Keil C about C51 User’s Guide about Interrupt Function description
8
重置功能范例程序(1) 软件重置:
Description
Main program
Software reset sample code
//===================================================================
//
//
S Y N C M O S
T E C H N O L O G Y
//
//===================================================================
#include "..\h\SM59R04A2.h"
void Function_Enable(void)
{
TAKEY = 0x55;
TAKEY = 0xAA;
TAKEY = 0x5A;
}
void Software_Reset(void)
{
Function_Enable();
SWRES = 0xFF;
}
// must write specific value sequentially
// before execute S/W Reset
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0180
4
Ver A 2010/06
Reset 功能使用方法
void main(void)
{
P0 = 0x55;
while(1)
{
P0 = 0xAA;
Software_Reset();
}
}
9
// user code
// user code
// execute S/W Reset
重置功能范例程序(2) 低电压侦测置功能:
Description
LVI & LVR sample code
//===================================================================
//
//
S Y N C M O S
T E C H N O L O G Y
//
//===================================================================
#include "..\h\SM59R04A2.h"
bit LVI_test =0;
void LVI_interrupt(void) interrupt d_LVI_Vector // vector=63h
{
P0 =0x04;
// test code
LVI_test = 1;
LVIIF =0;
// clear LVI flag
}
Main program
void LVI_init(void)
{
EA
= 1;
IEN1 |= 0x10;
LVC |= 0xA0;
}
void main(void)
{
P0 =0x01;
LVI_init();
while(1)
{
if(LVI_test)
P0 =0x08;
else
P0 = 0x02;
}
}
// Enable all interrupt
// Enable LVI interrupt
// Enable LVR & LVD
// test code
// test code
// test code
Specifications subject to change without notice, contact your sales representatives for the most recent information.
ISSFA-0180
5
Ver A 2010/06