Sonix-Sn8f5701sg C2981266
Sonix-Sn8f5701sg C2981266
SN8F5701 Series
Datasheet
8051-based Microcontroller
SN8F5701
SN8F57011
www.sonix.com.tw SN8F5701 Series
1 Device Overview
1.1 Features
- Enhanced 8051 microcontroller with reduced with individual duty, inverters and frequency
instruction cycle time (up to 12 times 80C51) control
- Up to 8 MHz flexible CPU frequency - 12-bit SAR ADC with 6 external and 1 internal
- Internal 32 MHz Clock Generator (IHRC) channels, and 4 internal reference voltages
- 4 KB non-volatile flash memory (IROM) with - UART interface
in-system program support - On-Chip Debug Support:
- 256 bytes internal RAM (IRAM) Single-wire debug interface
- 8 interrupt sources with priority levels control 2 hardware breakpoints
and unique interrupt vectors Unlimited software breakpoints
- 5 internal interrupts ROM data security/protection
- 3 external interrupts: INT0/INT1/INT2 - Watchdog and programmable external reset
- 1 set of DPTR - 1.8-V low voltage detector
- 2 set 8/16-bit timers with 4 operation modes - Wide supply voltage (1.8 V – 5.5 V) and
- 1 set 16-bit timers with PWM generator temperature (-40 °C to 85 °C) range
- each PWM generator has 6 output channels
1.2 Applications
- Brushless DC motor - Household
- Home automation - Other
Channels
ADC ext.
Package
Ext. INT
Types
PWM
UART
CMP
OPA
I2C
I/O
SPI
SN8F57011 4 4 - - V 4 - - 2 SOT23-6L
On-chip Debug
Support 8051-based CPU ALU
Accumulator
PC, SP, DPTR
32 MHz IHRC
4KB On-chip
On-chip High Clock Timers ADC
Non-volatile Memory
Generator
2 Table of Contents
1 Device Overview........................................................................................................................... 2
2 Table of Contents ......................................................................................................................... 4
3 Revision History ............................................................................................................................ 5
4 Pin Assignments ........................................................................................................................... 6
5 CPU ............................................................................................................................................. 10
6 Special Function Registers .......................................................................................................... 15
7 Reset and Power-on Controller .................................................................................................. 23
8 System Clock and Power Management...................................................................................... 30
9 System Operating Mode ............................................................................................................ 38
10 Interrupt ..................................................................................................................................... 43
11 GPIO ........................................................................................................................................... 51
12 External Interrupt ....................................................................................................................... 54
13 Timer 0 and Timer 1 ................................................................................................................... 58
14 Timer3 ........................................................................................................................................ 67
15 ADC ............................................................................................................................................. 75
16 UART ........................................................................................................................................... 84
17 In-System Program ..................................................................................................................... 93
18 Clock Fine-Tuning ....................................................................................................................... 97
19 Electrical Characteristics .......................................................................................................... 100
20 Instruction Set .......................................................................................................................... 103
21 Development Environment ...................................................................................................... 108
22 SN8F5701 Starter-Kit................................................................................................................ 110
23 ROM Programming Pin ............................................................................................................. 113
24 Ordering Information ............................................................................................................... 117
25 Package Information ................................................................................................................ 119
26 Appendix: Reference Document .............................................................................................. 124
3 Revision History
Revision Date Description
1.0 May 2017 First issue
1.1 Jul. 2017 Modify ADC VREFH description and Electrical Characteristic chapter.
1.2 Oct. 2017 1. Modify ordering information.
2. Add package information.
1.3 Jul. 2018 1. Remove 2.4/3.3V low voltage detectors description in features
2. Update Electrical Characteristics chapter
1.4 Mar. 2019 1. Repair an error, omission, etc.
2. MP5 Writer Programming Pin Mapping adds normal mode and
high speed mode sections.
3. Modify Pin Circuit Diagrams section.
4. Modify ADC input offset range.
5. Modify power on sequence and system clock timing.
6. Modify Package Information section.
7. Modify Timer0/ Timer1 section.
1.5 Nov. 2019 1. Modify ADC register description.
2. Add DFN8L package type.
SONIX reserves the right to make change without further notice to any products herein to improve reliability, function or design. SONIX does not
assume any liability arising out of the application or use of any product or circuit described herein; neither does it convey any license under its
patent rights nor the rights of others. SONIX products are not designed, intended, or authorized for us as components in systems intended, for
surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the SONIX
product could create a situation where personal injury or death may occur. Should Buyer purchase or use SONIX products for any such unintended
or unauthorized application. Buyer shall indemnify and hold SONIX and its officers, employees, subsidiaries, affiliates and distributors harmless
against all claims, cost, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or
death associated with such unintended or unauthorized use even if such claim alleges that SONIX was negligent regarding the design or manufacture
of the part.
4 Pin Assignments
Port 0
Pin Name Type Description
P0.0 Digital I/O GPIO: Bi-direction pin. Schmitt trigger structure as input mode.
Built-in pull-up resisters. Level change wake-up.
AIN0 Analog Input ADC: input channel 0.
PWM0 Digital Output PWM: programmable PWM output.
INT0 Digital Input INT0: external interrupt 0.
P0.1 Digital I/O GPIO: Bi-direction pin. Schmitt trigger structure as input mode.
Built-in pull-up resisters. Level change wake-up.
AIN1 Analog Input ADC: input channel 1.
PWM1 Digital Output PWM: programmable PWM output.
INT1 Digital Input INT1: external interrupt 1.
P0.2 Digital I/O GPIO: Bi-direction pin. Schmitt trigger structure as input mode.
Built-in pull-up resisters. Level change wake-up.
AIN2 Analog Input ADC: input channel 2.
Reset Digital Input System reset (active low).
PWM2 Digital Output PWM: programmable PWM output.
INT2 Digital Input INT2: external interrupt 2.
URX Digital Input UART: reception pin
P0.3 Digital I/O GPIO: Bi-direction pin. Schmitt trigger structure as input mode.
Built-in pull-up resisters. Level change wake-up.
AIN3 Analog Input ADC: input channel 3.
PWM3 Digital Output PWM: programmable PWM output.
UTX Digital Output UART: transmission pin.
P0.4 Digital I/O GPIO: Bi-direction pin. Schmitt trigger structure as input mode.
Built-in pull-up resisters. Level change wake-up.
AIN4 Analog Input ADC: input channel 4.
SWAT Digital I/O Debug interface.
PWM4 Digital Output PWM: programmable PWM output.
P0.5 Digital I/O GPIO: Bi-direction pin. Schmitt trigger structure as input mode.
Built-in pull-up resisters. Level change wake-up.
AIN5 Analog Input ADC: input channel 5.
PWM5 Digital Output PWM: programmable PWM output.
Pull-Up
VDD
Resistor
PnM PnUR
Output
I/O Output Bus
Latch
Bi-direction I/O Pin Shared with Specific Digital Input Function, e.g. INT0, UART.
Pull-Up
VDD
Resistor Specific Input
Function Control Bit
PnM PnUR
Specific Input Bus
Output
Output Bus
Latch
*. Specific Output
Function Control Bit
*. Some specific functions switch I/O direction directly, not through PnM register.
Bi-direction I/O Pin Shared with Specific Digital Output Function, e.g. T3, UART.
Pull-Up
VDD
Resistor
PnM PnUR
Output
Output Bus
Latch
Specific Output Bus
*. Specific Output
Function Control Bit
Specific Output
Function Control Bit
*. Some specific functions switch I/O direction directly, not through PnM register.
Bi-direction I/O Pin Shared with Specific Analog Input Function, e.g. ADC.
Pull-Up
VDD Resistor
*. Specific Analog
PnM PnUR
Function Control Bit
Output
I/O Output Bus
Latch
Analog IP Input
Terminal
*. Some specific functions switch I/O direction directly, not through PnM register.
5 CPU
SN8F5000 family is an enhanced 8051 microcontroller (MCU). It is fully compatible with MCS-51
instructions, hence the ability to cooperate with modern development environment (e.g. Keil C51).
Generally speaking, SN8F5000 CPU has 9.4 to 12.1 times faster than the original 8051 at the same
frequency.
0x0FFF
4 KB Flash
Memory
0xFF
256 bytes
RAM
0x0000 0x00
IROM IRAM
The 256-byte data RAM in internal data memory is a standard 8051 RAM access configuration. The
upper 128-byte RAM is general purpose RAM and can configure by direct addressing access and
indirect addressing access. The lower 128-byte can be indirect access RAM in general purpose or
direct access RAM in special function register (SFR).
0x0000-0x007F: General purpose RAM contains work register area and bit addressable area.
In this area, direct or indirect addressing can be used.
0x0000-0x001F: Work register area includes 4-bank. Each bank has 8 work registers (R0 - R7)
which is selected by RS0/RS1 in PSW register.
In the bit addressable area, user can read or write any single bit in this range by using the unique
address for that bit. Supports 16bytes bit addressable RAM area giving 128 addressable bits. Each
bit has individual address in the range from 00H to 7FH. Thus, the bit can be addressed directly.
Bit0 of the byte 20H has bit address 00H and Bit 7 of the byte 20H has bit address 07H. Bit0 of the
byte 2FH has bit address 78H and Bit 7 of the byte 2FH has bit address 7FH. When set “SETB 42H”,
it means the bit2 of the byte 28H is set.
Byte Address Bite 0 Bite 1 Bite 2 Bite 3 Bite 4 Bite 5 Bite 6 Bite 7
0x20 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07
0x21 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F
0x22 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17
0x23 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F
0x24 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27
Bit Addressable Area
5.3 Stack
Stack can be assigned to any area of internal RAM (IRAM). However, it requires manual assignment
to ensure its area does not overlap other RAM’s variables. An overflow or underflow stack could
also mistakenly overwrite other RAM’s variables; thus, these factors should be considered while
arrange the size of stack.
By default, stack pointer (SP register) points to 0x07 which means the stack area begin at IRAM
address 0x08. In other word, if a planned stack area is assigned from IRAM address 0xC0, the
appropriate SP register is anticipated to set at 0xBF after system reset.
An assembly PUSH instruction costs one byte of stack. LCALL, ACALL instructions and interrupt
respectively costs two bytes stack. POP-instruction decreases one count, and a RET/RETI subtract
two counts of stack pointer.
Note: Stack and IRAM share the same area, Keil C51 compiler will not display
“error” or “warning” when overlap condition is occurred so user must pay
attention.
The ROM includes reset vector, Interrupt vector, general purpose area and reserved area. The reset
vector is program beginning address. The interrupt vector is the head of interrupt service routine
when any interrupt occurring. The general purpose area is main program area including main loop,
sub-routines and data table.
0x0000 Reset vector: Program counter points to 0x0000 after any reset events (power on
reset, reset pin reset, watchdog reset, LVD reset…).
0x0001~0x0002: General purpose area to process system reset operation.
0x0003~0x00EB: Multi interrupt vector area. Each of interrupt events has a unique interrupt
vector.
0x00EC~0x0FDF: General purpose area for user program and ISP (EEPROM function).
0x0FE0~0x0FF6: General purpose area for user program. Do not execute ISP.
0x0FF6~0x0FFF: Reserved area. Do not execute ISP.
SP Register (0x81)
Bit Field Type Initial Description
7..0 SP R/W 0x07 Stack pointer
E8 - - - - - - - -
D8 S0CON2 - - - - - - -
C8 - - - - - - - -
C0 - - - - - - - -
Note: All SFRs in the left-most column are bit-addressable. (Every 0x0/0x8-ending
SFR addresses are bit-addressable).
B Register (0xF0)
Bit Field Type Initial Description
7..0 B[7:0] R/W 0x00 The B register is used during multiplying and division
instructions. It can also be used as a scratch-pad register
to hold temporary data.
When using the assembly code programs, please add the following sentence.
1 $NOMOD51 ;Do not recognize the 8051-specific predefined special register.
2 #include <SN8F5701.H>
When using the C code programs, please add the following sentence.
1 #include <SN8F5701.H>
After adding the header file, user can use name of registers to program. During compilation, the
compiler will register name translate into register position through the header file.
Different devices need to use a different header file to declare, but the option file is to use the
same.
Copyright © 2019, SONiX Technology Co., Ltd. Reset and Power-on Controller
Datasheet Rev. 1.5 23
www.sonix.com.tw SN8F5701 Series
The code option is the system hardware configurations including noise filter option, watchdog
timer operation, reset pin option and flash ROM security control. The code option items are as
following table:
Code Option Content Function Description
Program Memory Security Disable Disable ROM code Security function
Security Security Enable Enable ROM code Security function
Noise Filter Disable Disable Noise Filter
Enable Enable Noise Filter
CK_Fine_Tuning Disable Disable CK_Fine_Tuning
Enable Enable CK_Fine_Tuning
External Reset Reset with De-bounce Enable External reset pin with De-bounce
Reset without De-bounce Enable External reset pin without De-bounce
GPIO with P02 Enable P02
Watchdog Reset Always Watchdog timer is always on enable even in
STOP mode and IDLE mode
Enable Enable watchdog timer. Watchdog timer
stops in STOP mode and IDLE mode
Disable Disable Watchdog function
Watchdog Overflow 64ms Watchdog timer clock source FILRC /4
Period 128ms Watchdog timer clock source FILRC /8
256ms Watchdog timer clock source FILRC /16
512ms Watchdog timer clock source FILRC /32
Copyright © 2019, SONiX Technology Co., Ltd. Reset and Power-on Controller
Datasheet Rev. 1.5 24
www.sonix.com.tw SN8F5701 Series
VDD
External Reset VSS External Reset
External Reset High Detect
Low Detect Watchdog
Watchdog Normal Run Overflow
Watchdog
Reset Watchdog Stop
The power stabilization period spends 4.6 ms in typical condition. Afterward the microcontroller
fetches CPU Clock Source selection automatically. The selected clock source would be driven, and
the system counts 2048 times of the clock period and 5 times of the internal low-speed oscillator
clocks to ensure its reliability.
Note: In high power noise environment, user can put 10ohm resistor in the front of
0.1uF capacitor & VDD PAD to suppress power noise and avoid IC damage.
Copyright © 2019, SONiX Technology Co., Ltd. Reset and Power-on Controller
Datasheet Rev. 1.5 25
www.sonix.com.tw SN8F5701 Series
Power VSS
Power is below LVD Detect
Voltage and System Reset.
Power On
Delay Time
Condition LVD_L
VDD ≤ 1.8 V Reset
Copyright © 2019, SONiX Technology Co., Ltd. Reset and Power-on Controller
Datasheet Rev. 1.5 26
www.sonix.com.tw SN8F5701 Series
Watchdog timer interval time = 256 * 1/ (Internal Low-Speed oscillator frequency/WDT Pre-scalar)
= 256 / (FILRC/WDT Pre-scaler) …sec
When watchdog is operating in always mode, the system will consume additional power.
Copyright © 2019, SONiX Technology Co., Ltd. Reset and Power-on Controller
Datasheet Rev. 1.5 27
www.sonix.com.tw SN8F5701 Series
An optional de-bounce period can improve reset signal’s stability. Instead of immediate reset, the
system reset requires an 8-ms-long logic low to avoid bouncing from a button key. Any signal lower
than de-bounce period would not affect the CPU’s execution.
VDD VDD
R1 DIODE R1
47K ohm 47K ohm
R2
100 ohm
RST
MCU R2
100 ohm
RST
MCU
C1 C1
0.1uF 0.1uF
VSS VSS
VCC VCC
GND GND
Note:
1. The reset circuit is no any protection against unusual power or brown out reset on the
left side of the figure.
2. The R2 100 ohm resistor of “Simply reset circuit” and “Diode & RC reset circuit” is
necessary to limit any current flowing into reset pin from external capacitor C in
the event of reset pin breakdown due to Electrostatic Discharge (ESD) or Electrical
Over-stress (EOS) on the right side of the figure.
Copyright © 2019, SONiX Technology Co., Ltd. Reset and Power-on Controller
Datasheet Rev. 1.5 28
www.sonix.com.tw SN8F5701 Series
PFLAG Register
Bit Field Type Initial Description
7 POR R - This bit is automatically set if the microcontroller has
been reset by LVD.
6 WDT R - This bit is automatically set if the microcontroller has
been reset by watchdog.
5 RST R - This bit is automatically set if the microcontroller has
been reset by external reset pin.
4..0 Reserved R 0
SRST Register
Bit Field Type Initial Description
7..1 Reserved R 0
0 SRSTREQ R/W 0 Consecutively set this bit for two times to trigger
software reset.
Copyright © 2019, SONiX Technology Co., Ltd. Reset and Power-on Controller
Datasheet Rev. 1.5 29
www.sonix.com.tw SN8F5701 Series
The normal mode means that CPU and peripheral functions are under normally execution. The
system clock is based on the combination of source selection, clock divider, and program memory
wait state. IDLE mode is the situation that temporarily suspends CPU clock and its execution, yet it
remains peripherals’ functionality (e.g. timers, PWM, and UART). STOP mode disables all functions
and clock generator until a wakeup signal to return normal mode.
Subsequently, the selected clock source (fosc) is divided by 4 to 128 times which is controlled by
CLKSEL register. The CPU input the divided clock as its operation base (named fcpu). Applying
CLKSEL’s setting when CLKCMD register be written 0x69.
1 CKCON = 0x70; // For change safely the system clock
2 CLKSEL = 0x05; // Set fcpu = fosc / 4
3 CLKCMD = 0x69; // Apply CLKSEL’s setting
4 CKCON = 0x00; // IROM fetch = fcpu / 1
CPU
IROM
fosc Divider fcpu
IHRC 32MHz
÷4 to ÷128 ROM
interface
CLKSEL CKCON
ROM interface is built in between CPU and IROM (program memory). It optionally extends the data
fetching cycle in order to support lower speed program memory.
Copyright © 2019, SONiX Technology Co., Ltd. System Clock and Power Management
Datasheet Rev. 1.5 30
www.sonix.com.tw SN8F5701 Series
Note: For user develop program in C language or assembly, the first line of the
program “must be set” CLKSEL= 0x05~0x00, CLKMD= 0x69 and then set CKCON=
0x00~0x70, this priority cannot be modified.
System clock rate and program memory extended cycle limitation as follows.
Code Option
Fcpu = CLKSEL[2:0] IROM Fetch = CKCON[6:4]
CPU Clock Source
IHRC 32M Only Support Only Support
000 = fosc / 128 000 = fcpu / 1 => Recommend!
001 = fosc / 64 001 = fcpu / 2
010 = fosc / 32 010 = fcpu / 3
011 = fosc / 16 011 = fcpu / 4
100 = fosc / 8 100 = fcpu / 5
101 = fosc / 4 101 = fcpu / 6
110 = fcpu / 7
111 = fcpu / 8
IHRC 32M: The system high-speed clock source is internal high-speed 32MHz RC type
oscillator.
The least two bits of PCON register (IDLE at bit 0 and STOP at bit 1) control the microcontroller’s
power management unit.
If IDLE bit is set by program, only CPU clock source would be gated. Consequently, peripheral
functions (such as timers, PWM, and UART) and clock generator (IHRC 32 MHz) remain execution
in this status. Any change from P0 input and interrupt events can make the microcontroller turns
back to normal mode, and the IDLE bit would be cleared automatically.
Copyright © 2019, SONiX Technology Co., Ltd. System Clock and Power Management
Datasheet Rev. 1.5 31
www.sonix.com.tw SN8F5701 Series
The IDLE mode wake-up sources are P0/P1 level change trigger and any interrupt event.
If STOP bit is set, by contrast, CPU, peripheral functions, and clock generator are suspended. Data
storage in registers and RAM would be kept in this mode. Any change from P0 can wake up the
microcontroller and resume system’s execution. STOP bit would be cleared automatically.
For user who is develop program in C language, IDLE and STOP macros is strongly recommended to
control the microcontroller’s system mode, instead of set IDLE and STOP bits directly.
1 IDLE();
2 STOP();
Copyright © 2019, SONiX Technology Co., Ltd. System Clock and Power Management
Datasheet Rev. 1.5 32
www.sonix.com.tw SN8F5701 Series
Copyright © 2019, SONiX Technology Co., Ltd. System Clock and Power Management
Datasheet Rev. 1.5 33
www.sonix.com.tw SN8F5701 Series
Vdd Vp
Power On Reset
Flag
Oscillator
Tcfg Tost Tosp
Fcpu
(Instruction Cycle)
External Reset
Flag
Oscillator
Tcfg Tost Tosp
Fcpu
(Instruction Cycle)
System is under reset
status.
Oscillator
Tcfg Tost Tosp
Fcpu
(Instruction Cycle)
Wake-up Pin
Rising Edge
Oscillator
Tost
Tosp
Fcpu
(Instruction Cycle)
Copyright © 2019, SONiX Technology Co., Ltd. System Clock and Power Management
Datasheet Rev. 1.5 34
www.sonix.com.tw SN8F5701 Series
Wake-up Pin
Rising Edge
Timer overflow.
Timer ... 0xFD 0xFE 0xFF 0x00 0x01 0x02 ... ... ... ... ...
Oscillator
Fcpu
(Instruction Cycle)
RC Oscillator
Tost
Ceramic/Resonator
Tost
Crystal
Tost
Copyright © 2019, SONiX Technology Co., Ltd. System Clock and Power Management
Datasheet Rev. 1.5 35
www.sonix.com.tw SN8F5701 Series
Copyright © 2019, SONiX Technology Co., Ltd. System Clock and Power Management
Datasheet Rev. 1.5 36
www.sonix.com.tw SN8F5701 Series
Copyright © 2019, SONiX Technology Co., Ltd. System Clock and Power Management
Datasheet Rev. 1.5 37
www.sonix.com.tw SN8F5701 Series
STOP mode
Wake-up condition:
PCON.0 is “1” P0 input status is level changing.
All interrupt in EAL = 1 & function
interrupt enable.
IDLE mode
9.4 Wake up
Under STOP mode (sleep mode) or idle mode, program doesn’t execute. The wakeup trigger can
wake the system up to normal mode. The wakeup trigger sources are external trigger (P0 level
change) and internal trigger (any interrupt in EAL = 1 & function interrupt enable). The wakeup
function builds in interrupt operation issued request flag and trigger system executing interrupt
service routine as system wakeup occurrence.
When the system is in STOP mode the high clock oscillator stops. When waked up from STOP mode,
MCU waits for 2048 external high-speed oscillator clocks + 5 internal low-speed oscillator clocks
and 64 internal high-speed oscillator clocks + 5 internal low-speed oscillator clocks as the wakeup
time to stable the oscillator circuit. After the wakeup time, the system goes into the normal mode.
The value of the external high clock oscillator wakeup time is as the following.
The Wakeup time = 1/Fosc * 2048 (sec) + 1/Flosc * 5 + high clock start-up time
Example: In STOP mode (sleep mode), the system is waked up. After the wakeup time, the system
goes into normal mode. The wakeup time is as the following.
The value of the internal high clock oscillator RC type wakeup time is as the following.
The Wakeup time = 1/Fosc * 64 (sec) + 1/Flosc * 5 + high clock start-up time
Example: In STOP mode (sleep mode), the system is waked up. After the wakeup time, the system
goes into normal mode. The wakeup time is as the following.
Note: The high clock start-up time is depended on the VDD and oscillator type of
high clock.
Under STOP mode and green mode, the I/O ports with wakeup function are able to wake the
system up to normal mode. The wake-up trigger edge is level changing in rising edge or falling edge.
The Port 0 has wakeup function. Port 0 wakeup functions always enable.
10 Interrupt
The MCU provides 8 interrupt sources (3 external and 5 interrupt) with 4 priority levels. Each
interrupt source includes one or more interrupt request flag(s). When interrupt event occurs, the
associated interrupt flag is set to logic 1. If both interrupt enable bit and global interrupt (EAL=1)
are enabled, the interrupt request is generated and interrupt service routine (ISR) will be started.
Some interrupt request flags must be cleared by software. However, most interrupt request flags
can be cleared by hardware automatically. In the end, ISR is finished after complete the RETI
instruction. The summary of interrupt source, interrupt vector, priority order and control bit are
shown as the table below.
For special priority needs, 4-level priority levels (Level 0 – Level 3) are used. All interrupt sources
are classified into 6 priority groups (Group0 – Group5). Each group can be set one specific priority
level. Priority level is selected by IP0/IP1 registers. Level 3 is the highest priority and Level 0 is the
lowest. The interrupt sources inside the same group will share the same priority level. With the
The ISR with the higher priority level can be serviced first; even can break the on-going ISR with
the lower priority level. The ISR with the lower priority level will be pending until the ISR with the
higher priority level completes.
When more than one interrupt request occur, the highest priority request must be executed first.
Choose the highest priority request according natural priority and priority level. The steps are as
the following:
1. Choose the groups which have the highest priority level between all groups.
2. Choose the group which is the highest nature priority between the groups with the highest
priority level.
3. Choose the ISR which has the highest nature priority inside the group with the highest
priority.
Level 2 Group 1
Level 1 Group 2
Level 0 Group 3
Low
Group 4
Low Group 5
Higher priority level has higher priority All groups within the same priority level
IP0.0 = IP0.1 = IP0.2 = IP0.3 = IP0.4 = IP0.5
IP1.0 = IP1.1 = IP1.2 = IP1.3 = IP1.4 = IP1.5
As the example, group5 has the highest priority level and group0~group2 have the lowest priority
level. It means the interrupt vector in group5 has the highest interrupt priority, the 2nd interrupt
priority in group4 and the 3rd interrupt priority in group3. Group0~ group2 have the same priority
level thus the nature priority rule will be followed. Therefore, interrupt priority will be group5>
group4> group3> group0> group1> group2.
10 Group 4
Priority Level: GP5>GP4>GP3>GP2=GP1=GP0
01 Group 3
Interrupt Priority: GP5>GP4>GP3>GP0>GP1>GP2
00 Group 0
00 Group 1
Low 00 Group 2
If you want to avoid the above, it is recommended to use the interrupt bit characteristics. Most of
the interrupt request flag can't be written 1 by which you can avoid clearing asynchronous
adjacent flags.
For user who is develop program in C language, the flag clear macros is strongly recommended to
clear request flag, instead of clear request flag bits directly.
1 TCONCLR(bit); // The marco can clear the flag of TCON. bit is 0~7.
2 IRCON2CLR(bit); // The marco can clear the flag of IRCON2. bit is 0~7.
ORG 0 ; 0000H
JMP START ; Jump to user program address.
…
ORG 0X0003 ; Jump to interrupt service routine address.
JMP ISR_INT0
ORG 0X000B
JMP ISR_T0
…
ORG 0X0083
JMP ISR_INT2
…
ORG 0X00ECH
START: ; 00ECH, The head of user program.
… ; User program.
…
…
JMP START ; End of user program.
…
ISR_ INT0: ; The head of interrupt service routine.
PUSH ACC ; Save ACC to stack buffer.
PUSH PSW ; Save PSW to stack buffer.
…
POP PSW ; Load PSW from stack buffer.
POP ACC ; Load ACC from stack buffer.
RETI ; End of interrupt service routine.
ISR_T0: ;
PUSH ACC ; Save ACC to stack buffer.
PUSH PSW ; Save PSW to stack buffer.
…
POP PSW ; Load PSW from stack buffer.
POP ACC ; Load ACC from stack buffer.
RETI ; End of interrupt service routine.
…
ISR_INT2 ;
PUSH ACC ; Save ACC to stack buffer.
PUSH PSW ; Save PSW to stack buffer.
…
POP PSW ; Load PSW from stack buffer.
POP ACC ; Load ACC from stack buffer.
RETI ; End of interrupt service routine.
11 GPIO
The microcontroller has up to 6 bidirectional general purpose I/O pin (GPIO). Unlike the original
8051 only has open-drain output, SN8F5701 builds in push-pull output structure to improve its
driving performance.
P0M: 0xF9
Bit Field Type Initial Description
5 P05M R/W 0 Mode selection of P0.5
0: Input mode
1: Output mode
4 P04M R/W 0 Mode selection of P0.4
0: Input mode
1: Output mode
3 P03M R/W 0 Mode selection of P0.3
0: Input mode
1: Output mode
2..0 et cetera
A write P0 register value would be latched immediately, yet the value would be outputted until the
mapped P0M is set to output mode. If the pin is currently in output mode, any value set to P0
register would be presented on the pin immediately.
P0: 0x80
Bit Field Type Initial Description
5 P05 R/W 1 Read: P0.5 pin’s logic level
Write 1/0: Output logic high or low (applied if P05M = 1)
4 P04 R/W 1 Read: P0.4 pin’s logic level
Write 1/0: Output logic high or low (applied if P04M = 1)
3 P03 R/W 1 Read: P0.3 pin’s logic level
Write 1/0: Output logic high or low (applied if P03M = 1)
2..0 et cetera
P0UR: 0xF1
Bit Field Type Initial Description
5 P05UR R/W 0 On-chip pull-up resister control of P0.5
0: Disable*
1: Enable
4 P04UR R/W 0 On-chip pull-up resister control of P0.4
0: Disable*
1: Enable
3 P03UR R/W 0 On-chip pull-up resister control of P0.3
0: Disable*
1: Enable
2..0 et cetera
* Recommended disable pull-up resister if the pin is output mode or analog function
12 External Interrupt
INT0, INT1 and INT2 are external interrupt trigger sources. Build in edge trigger configuration
function and edge direction is selected by PEDGE register. When both external interrupt
(EX0/EX1/EX2) and global interrupt (EAL) are enabled, the external interrupt request flag
(IE0/IE1/IE2) will be set to “1” as edge trigger event occurs. The program counter will jump to the
interrupt vector (ORG 0x0003/ 0x0013/ 0x0083) and execute interrupt service routine. Interrupt
request flag will be cleared by hardware before ISR is executed.
fcpu ÷12
M
U
M
X
U Timer 0 clock
X
fEXT0 Divider INT0
fosc
÷1 to ÷128
T0CT T0GATE
T0RATE
fcpu ÷12
M
U
M
X
U Timer 1 clock
X
fEXT1 Divider INT1
fosc
÷1 to ÷128
T1CT T1GATE
T1RATE
TR0 T0CT
T0GATE
Fcpu ÷12
TR0
T0 Time Out
TL0[4:0] TH0[7:0] TF0 interrupt flag
÷1
÷2
÷4
÷8
Fosc ÷16
÷32
÷64
÷128
T0 Rate
INT0
TR1 T1CT
T1GATE
Fcpu ÷12
TR1
T1 Time Out
TL1[4:0] TH1[7:0] TF1 interrupt flag
÷1
÷2
÷4
Fosc ÷8
÷16
÷32
÷64
÷128
T1 Rate
INT1
TR0 T0CT
T0GATE
Fcpu ÷12
TR0
T0 Time Out
TL0[7:0] TH0[7:0] TF0 interrupt flag
÷1
÷2
÷4
÷8
Fosc ÷16
÷32
÷64
÷128
T0 Rate
INT0
TR1 T1CT
T1GATE
Fcpu ÷12
TR1
T1 Time Out
TL1[7:0] TH1[7:0] TF1 interrupt flag
÷1
÷2
÷4
Fosc ÷8
÷16
÷32
÷64
÷128
T1 Rate
INT1
13.4 Mode 2: 8-bit Up Counting Timer with Specified Reload Value Support
Timer 0 and Timer 1 in mode 2 is an 8-bit up counting timer (TL0/TL1) with a specifiable reload
value. An overflow event (TL0/TL1 counts from 0xFF to 0x00) issues its TF0/TF1 flag for firmware or
interrupt controller; meanwhile, the timer duplicates TH0/TH1 value to TL0/TL1 register in the
same time. As a result, the timer is actually counts from 0xFF to the value of TH0/TH1.
TH0[7:0]
TR0 T0CT
T0GATE
Fcpu ÷12
Load
TR0
T0 Time Out
TL0[7:0] TF0 interrupt flag
÷1
÷2
÷4
Fosc ÷8
÷16
÷32
÷64
÷128
T0 Rate
INT0
TH1[7:0]
TR1 T1CT
T1GATE
Fcpu ÷12
Load
TR1
T1 Time Out
TL1[7:0] TF1 interrupt flag
÷1
÷2
÷4
Fosc ÷8
÷16
÷32
÷64
÷128
T1 Rate
INT1
In this mode TL0 counter is enabled by TR0, and its overflow signal is reflected in TF0 flag. TH0
counter is controlled by TR1, and TF1 flag is also occupied by TH0 overflow signal.
Timer 1 cannot issue any overflow event in this situation, and it can be seen as a self-counting
timer without flag support.
TR1
TR0 T0CT
T0GATE
Fcpu ÷12
TR0
T0 Time Out
TL0[7:0] TF0 interrupt flag
÷1
÷2
÷4
Fosc ÷8
÷16
÷32
÷64
÷128
T0 Rate
INT0
14 Timer3
Timer 3 is a 16-bit up counting timer and supports 6-channel general PWM function. By the
counter reaches the up-boundary value (T3Y), it clears its counter and triggers an interrupt signal.
PWM’s duty cycle is controlled by PW0D~PW5D register. Each PWM channel has its own duty
control.
The PWM function has six programmable channels shared with GPIO pins and controlled by
PWCH[5:0] bit. The output operation must be through enabled each bit/channel of PWCH[5:0] bits.
The enabled PWM channel exchanges from GPIO to PWM output. When the PWCH[5:0] bits
disables, the PWM channel returns to last status of GPIO mode. The Timer 3 build in IDLE Mode
wake-up function if interrupt enable. When timer overflow occurs (counts from T3Y-1 to T3Y), T3F
would be issued immediately which can read/write by firmware. T3 interrupt function is controlled
by ET3.
TF3
T3Y
T3YH/T3YL
Data Buffer
Reload
16-Bit
Comparator
Reload
PWnD
PWnDH/PWnDL
Data Buffer
T3F
resolution. T3C keeps counting, and the system compares T3C and PWnD. When T3C=PWnD, the
PWM output status exchanges to low and T3C keeps counting. When T3 timer overflow occurs
(T3Y-1 to 0x0000), and one cycle of PWM signal finishes. T3C is reloaded from 0x0000
automatically, and PWM output status exchanges to high for next cycle. PWnD decides the high
duty duration, and T3Y decides the resolution and cycle of PWM. PWnD can’t be larger than T3Y, or
the PWM signal is error. PWM clock source is fosc, T3RATE[2:0] bits: 000 = fosc/128, 001 = fosc/64,
010 = fosc/32, 011 = fosc/16, 100 = fosc/8, 101 = fosc/4, 110 = fosc/2, 111 = fosc/1.
Enable T3 . T3C overflows from T3Y-1 to T3Y.
T3C is 0x0000. T3C = PWnD. T3C is loaded from 0x0000.
PWM outputs high status. PWMn exchanges to low status. PWM exchanges to high status.
PWM Output
PWM Output
T3EN=0 T3EN=1 outputs PWM signal T3EN=0. The pin exchanges T3EN=1
to last GPIO mode (output low).
PWM Output
T3EN=0 T3EN=1 outputs PWM signal T3EN=0. The pin exchanges T3EN=1
to last GPIO mode (output high).
T3EN=0 T3EN=1 outputs PWM signal T3EN=0. The pin exchanges T3EN=1
to last GPIO mode (input).
PWM Cycle=T3Y
PWM Duty=PWnD
PWM
PWMn
(PWNVn=1)
PWMn
(PWNVn=0)
The PWM has frequency mode to change PWM output frequency. The frequency mode is
controlled by PWO[5:0]. When PWOn=1, PWMn pin outputs 1/2*frequency PWM signal. When
PWOn=0, PWMn pin outputs 1*frequency PWM signal.
PWMn
(PWOn=1)
PWMn
(PWOn=0)
PWnDH/PWnDL Registers (PW0DH: 0xA7, PW0DL: 0xA6 / PW1DH: 0xAC, PW1DL: 0xAB / PW2DH:
0xAE, PW2DL: 0xAD / PW3DH: 0xB2, PW3DL: 0xB1 / PW4DH: 0xB4, PW4DL: 0xB3 / PW5DH: 0xB6,
PW5DL: 0xB5)
Bit Field Type Initial Description
7..0 PWnDH/L R/W 0x00 16-bit PWMn duty control
15 ADC
The analog to digital converter (ADC) is SAR structure with 6-input sources and up to 4096-step
resolution to transfer analog signal into 12-bits digital buffers. The ADC builds in 6-channel input
source to measure 6 different analog signal sources. The ADC resolution is 12-bit. The ADC has four
clock rates to decide ADC converting rate. The ADC reference high voltage includes 4 sources. Four
internal power source including VDD, 4V, 3V and 2V. The ADC builds in P0CON register to set pure
analog input pin. After setup ADENB and ADS bits, the ADC starts to convert analog signal to digital
data. ADC can work in idle mode. After ADC operating, the system would be waked up from green
mode to normal mode if interrupt enable.
VHS[2:0]
Internal Reference
Voltage Source
(2V, 3V, 4V, VDD)
Internal reference
VHS[1:0] (2V, 3V, 4V)
CHS[3:0]
ADCKS[1:0]
ADENB ADS
When ADC IP is enabled by ADENB bit, it is necessary to make an ADC start-up by program. Writing
a 1 to the ADS bit of register ADM. After setup ADENB and ADS bits, the ADC starts to convert
analog signal to digital data. The ADS bit is reset to logic 0 when the conversion is complete. When
the conversion is complete, the ADC circuit will set EOC and ADCF bits to “1” and the digital data
outputs in ADB and ADR registers. If ADC interrupt function is enabled (EADC = 1), the ADC
interrupt request occurs and executes interrupt service routine when ADCF is “1” after ADC
converting. Clear ADCF by hardware automatically in interrupt procedure.
ADC input pins are shared with digital I/O pins. Connect an analog signal to COMS digital input pin,
especially, the analog signal level is about 1/2 VDD will cause extra current leakage. In the power
down mode, the above leakage current will be a big problem. Unfortunately, if users connect more
than one analog input signal to Port0 will encounter above current leakage situation. Write “1”
into PnCON register will configure related pin as pure analog input pin to avoid current leakage.
Note that When ADC pin is general I/O mode, the bit of P0CON must be set to “0”, or the digital
I/O signal would be isolated.
ADC Low Reference Voltage ≤ ADC Sampled Input Voltage ≤ ADC High Reference Voltage
The ADC converting time affects ADC performance. If input high rate analog signal, it is necessary
to select a high ADC converting rate. If the ADC converting time is slower than analog signal
variation rate, the ADC result would be error. So to select a correct ADC clock rate to decide a right
ADC converting rate is very important.
16
12 bits ADC conversion time =
ADC clock rate/4
Table 15-1 The AIN input voltage vs. ADB output data
AIN n ADB11 ADB10 ADB9 ADB8 ADB7 ADB6 ADB5 ADB4 ADB3 ADB2 ADB1 ADB0
0/4096*VREFH 0 0 0 0 0 0 0 0 0 0 0 0
1/4096*VREFH 0 0 0 0 0 0 0 0 0 0 0 1
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
4094/4096*VREFH 1 1 1 1 1 1 1 1 1 1 1 0
4095/4096*VREFH 1 1 1 1 1 1 1 1 1 1 1 1
16 UART
The UART provides a flexible full-duplex synchronous/asynchronous receiver/transmitter. The serial
interface provides an up to 0.25MHz flexible full-duplex transmission. It can operate in four modes
(one synchronous and three asynchronous). Mode0 is a shift register mode and operates as
synchronous transmitter/receiver. In Mode1-Mode3 the UART operates as asynchronous
transmitter/receiver with 8-bit or 9-bit data. The transfer format has start bit, 8-bit/ 9-bit data and
stop bit. Transmission is started by writing to the S0BUF register. After reception, input data are
available after completion of the reception in the S0BUF register. TB80/RB80 bit can be used as the
9th bit for transmission and reception in 9-bit UART mode. Programmable baud rate supports
different speed peripheral devices.
The UTX/URX pins also support open-drain structure. The open-drain option is controlled by PnOC
bit. When PnOC=0, disable UTX/URX open-drain structure. When PnOC=1, enable UTX/URX
open-drain structure. If enable open-drain structure, UTX/URX pin must set high level (IO mode
control will be ignored) and need external pull-up resistor.
The UART supports interrupt function. ES0 is UART0 transfer interrupt function control bit. UART
transmitter and receiver interrupt function is controlled by ES0. When ES0 = 0, disable
transmitter/receiver interrupt function. When ES0 = 1, enable UART transmitter/ receiver interrupt
function. UART transmitter and receiver interrupt function are share interrupt vector 0x0023.
When UART interrupt function enable, the program counter points to interrupt vector to do UART
interrupt service routine after UART operating. TI0/RI0 is UART0 interrupt request flag, and also to
be the UART operating status indicator when interrupt is disabled. TI0 and RI0 must clear by
software.
UART provides four operating mode (one synchronous and three asynchronous) controlled by
S0CON register. These modes can be support in different baud rate and communication protocols.
UTX pin:
P03M=1 and P03=1
URX pin:
0 0 0 Synchronous Fcpu/12 X 8 X Transmitter:
P02M=1 and P02=1
Receiver:
P02M=0 and P02=1
Baud rate generator UTX pin:
0 1 1 Asynchronous 1 8 1
or T1 overflow rate P03M=1 and P03=1
URX pin:
1 0 2 Asynchronous Fcpu/64 or Fcpu/32 1 9 1
P02M=0
Baud rate generator
1 1 3 Asynchronous 1 9 1
or T1 overflow rate
Data transmission is controlled by REN0 bit. After transmission configuration, load transmitted
data into S0BUF, and then UART starts to transmit the pocket. The TI0 flag is set at the beginning of
Data reception is controlled by REN0 bit. When REN0=1, data reception function is enabled. Data
reception starts by receiving the start bit for master terminal, URX detects the falling edge of start
bit, and then the RI0 flag is set in the middle of a stop bit. Until reception completion, input data is
stored in S0BUF register and the stop bit is stored in RB80.
Stop
bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7
Start
Data transmission is controlled by REN0 bit. After transmission configuration, load transmitted
data into S0BUF, and then UART starts to transmit the pocket. The 9th data bit is taken from TB80.
The TI0 flag is set at the beginning of the stop bit.
Data reception is controlled by REN0 bit. When REN0=1, data reception function is enabled. Data
reception starts by receiving the start bit for master terminal, URX detects the falling edge of start
bit, and then the RI0 flag is set in the middle of a stop bit. Until reception completion, lower 8-bit
input data is stored in S0BUF register and the 9th bit is stored in RB80.
Stop
bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit8
Start
Data transmission is controlled by REN0 bit. After transmission configuration, load transmitted
data into S0BUF, and then UART starts to transmit the pocket. The 9th data bit is taken from TB80.
The TI0 flag is set at the beginning of the stop bit.
Data reception is controlled by REN0 bit. When REN0=1, data reception function is enabled. Data
reception starts by receiving the start bit for master terminal, URX detects the falling edge of start
bit, and then the RI0 flag is set in the middle of a stop bit. Until reception completion, lower 8-bit
input data is stored in S0BUF register and the 9th bit is stored in RB80.
Stop
bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit8
Start
The baud rate of UART mode 1 and mode 3 is generated by either S0RELH/S0RELL registers (BD = 1)
or Timer 1 overflow period (BD = 0). The SMOD bit doubles the frequency from the generator.
If the S0RELH/S0RELL is selected (BD = 1) in mode 1 and 3, the baud rate is generated as following
equation.
fcpu
Baud Rate = 2SMOD × 𝑏𝑝𝑠
64 × (1024 − S0REL)
If the Timer 1 overflow period is selected (BD = 0) in mode 1 and 3, the baud rate is generated as
following equation. The Timer 1 must be in 8-bit auto-reload mode which can generate periodically
overflow signals.
1
Baud Rate = 2SMOD × 𝑏𝑝𝑠
32 × Timer 1 period
Table 16-2 Recommended Setting T1 overflow period (T1 clock=32M) for Common UART Baud Rates (fcpu = 8 MHz)
Baud Rate SMOD Timer Period TH1/TL1 Accuracy
4800 0 6.510 us 0x30 0.16 %
9600 1 6.510 us 0x30 0.16 %
19200 1 3.255 us 0x98 0.16 %
38400 1 1.628 us 0xCC 0.16 %
56000 1 1.116 us 0xDC -0.80 %
57600 1 1.085 us 0xDD -0.80 %
115200 1 0.543 us 0xEF 2.08 %
128000 1 0.488 us 0xF0 -2.40 %
Note:
1. When baud rate generator source is T1 overflow rate, the max counter value is
0xFB. (Only supports 0x00~0xFB).
2. When baud rate generator source is T1 overflow rate, the system clock fcpu must
be greater four times to T1 overflow rate.
Conversely, when REN0 bit is 1, UART internal clocks are run, and registers can access. The REN0
bit must be set to 1, before the initial setting UART.
Note: TI0 and RI0 are clear by software when interrupt is enabled.
P0 Register (0x80)
Bit Field Type Initial Description
3 P03 R/W 0 0: Set P0.3 (UTX) always low*
1: Make P0.3 (UTX) can output UART data (required)
2 P02 R/W 0 This bit is available to read at any time for monitoring
the bus statue.
Else Refer to other chapter(s)
* Setting P03 initially high because UART block drive the shared pin low signal only.
17 In-System Program
SN8F5701 builds in an on-chip 4 KB program memory, aka IROM, which is equally divided to 128
pages (32 bytes per page). The in-system program is a procedure that enables a firmware to freely
modify every page’s data; in other word, it is the channel to store value(s) into the non-volatile
memory and/or live update firmware.
0x0FFF
Page 127
0x0FE0
0x0FDF
Page 126
0x0FC0
0x003F
Page 1
0x0020
0x001F
Page 0
0x0000
Program memory (IROM)
00C0
00E0
0100 One ISP Program Page
0120 One ISP Program Page
… One ISP Program Page
0300 One ISP Program Page
0320 One ISP Program Page
… One ISP Program Page
0700 One ISP Program Page
0720 One ISP Program Page
… One ISP Program Page
0FE0 This page includes ROM reserved area. We strongly recommend to reserve the
area not to do ISP erase.
These configurations must be setup completely before starting Page Program. ISP is configured
using the following steps:
1. Save program data into IRAM. The data continues for 32 bytes.
2. Set the start address of the content location to PERAM.
3. Set the start address of the anticipated update area to PEROM [15:5]. (By PEROMH/PRROML
registers)
4. Write ‘0x5A’ into PECMD [7:0] to trigger ISP function.
As an example, assume the 126th page of program memory (IROM, 0x0FC0 – 0x0FDF) is the
anticipated update area; the content is already stored in IRAM address 0x60 – 0x7F. To perform the
in-system program, simply write starting IROM address 0x0FC0 to EPROMH/EPROML registers, and
then specify buffer starting address 0x60 to EPRAM register. Subsequently, write ‘0x5A’ into
PECMD [7:0] registers to duplicate the buffer’s data to 126th page of IROM.
In general, every page has the capability to be modified by in-system program procedure. However,
since the first and least pages (page 0 and 127) respectively stores reset vector and information for
power-on controller, incorrectly perform page program (such as turn off power while programming)
may cause faulty power-on sequence / reset.
These configurations must be setup completely before starting Byte Program. ISP is configured
using the following steps:
1. Save program data into IRAM. The data only for 1 byte.
2. Set the start address of the content location to PERAM.
3. Set the start address of the anticipated update area to PEROM [15:0]. (By PEROMH/PRROML
registers)
4. Write ‘0x1E’ into PECMD [7:0] to trigger ISP function.
As an example, assume the address 0x0FC5 of IRPM is the anticipated update area; the content is
already stored in IRAM address 0x60. To perform the in-system byte program, simply write starting
IROM address 0x0FC5 to EPROMH/EPROML registers, and then specify buffer starting address 0x60
to EPRAM register. Subsequently, write ‘0x1E’ into PECMD [7:0] registers to duplicate the buffer’s
data to the address 0x0FC5 of IROM.
Note:
1. Watch dog timer should be clear before the Flash write (program) operation, or
watchdog timer would overflow and reset system during ISP operating.
2. Don’t execute ISP flash ROM program operation for the first page and the last
page, or affect program operation.
18 Clock Fine-Tuning
SN8F5701 builds in clock fine-tuning function that is a procedure to fine-tune system clock
frequency by firmware. The function is enabled by code option (CK_Fine_Tuning). When
CK_Fine_Tuning = 0, the clock fine-tuning function is disabled. When CK_Fine_Tuning = 1, the clock
fine-tuning function is enabled. After system power-on, the 10-bit initial clock trim value will be
loaded to FRQ[9:0] buffer by hardware. The trim value corresponds to IHRC 32MHz. Change the
trim value of FRQ[9:0] to modify internal clock frequency.
Note: Please check IROM fetching cycle < 8MHz to avoid system error.
19 Electrical Characteristics
20 Instruction Set
This chapter categorizes the SN8F5701 microcontroller’s comprehensive assembly instructions. It
includes five categories—arithmetic operation, logic operation, data transfer operation, Boolean
manipulation, and program branch—which are fully compatible with standard 8051.
Symbol description
Symbol Description
Rn Working register R0 - R7
direct One of 128 internal RAM locations or any Special Function Register
@Ri Indirect internal or external RAM location addressed by register R0 or R1
#data 8-bit constant (immediate operand)
#data16 16-bit constant (immediate operand)
bit One of 128 software flags located in internal RAM, or any flag of
bit-addressable Special Function Registers
addr16 Destination address for LCALL or LJMP, can be anywhere within the 64-Kbyte
page of program memory address space
addr11 Destination address for ACALL or AJMP, within the same 2-Kbyte page of
program memory as the first byte of the following instruction
rel SJMP and all conditional jumps include an 8-bit offset byte. Its range is
+127/-128 bytes relative to the first byte of the following instruction
A Accumulator
Arithmetic operations
Mnemonic Description
ADD A, Rn Add register to accumulator
ADD A, direct Add directly addressed data to accumulator
ADD A, @Ri Add indirectly addressed data to accumulator
ADD A, #data Add immediate data to accumulator
ADDC A, Rn Add register to accumulator with carry
ADDC A, direct Add directly addressed data to accumulator with carry
ADDC A, @Ri Add indirectly addressed data to accumulator with carry
ADDC A, #data Add immediate data to accumulator with carry
SUBB A, Rn Subtract register from accumulator with borrow
SUBB A, direct Subtract directly addressed data from accumulator with borrow
SUBB A, @Ri Subtract indirectly addressed data from accumulator with borrow
SUBB A, #data Subtract immediate data from accumulator with borrow
INC A Increment accumulator
INC Rn Increment register
INC direct Increment directly addressed location
INC @Ri Increment indirectly addressed location
INC DPTR Increment data pointer
DEC A Decrement accumulator
DEC Rn Decrement register
DEC direct Decrement directly addressed location
DEC @Ri Decrement indirectly addressed location
MUL AB Multiply A and B
DIV Divide A by B
DA A Decimally adjust accumulator
Logic operations
Mnemonic Description
ANL A, Rn AND register to accumulator
ANL A, direct AND directly addressed data to accumulator
ANL A, @Ri AND indirectly addressed data to accumulator
ANL A, #data AND immediate data to accumulator
ANL direct, A AND accumulator to directly addressed location
ANL direct, #data AND immediate data to directly addressed location
ORL A, Rn OR register to accumulator
Boolean manipulation
Mnemonic Description
CLR C Clear carry flag
CLR bit Clear directly addressed bit
SETB C Set carry flag
SETB bit Set directly addressed bit
CPL C Complement carry flag
CPL bit Complement directly addressed bit
ANL C, bit AND directly addressed bit to carry flag
ANL C, /bit AND complement of directly addressed bit to carry
ORL C, bit OR directly addressed bit to carry flag
ORL C, /bit OR complement of directly addressed bit to carry
MOV C, bit Move directly addressed bit to carry flag
MOV bit, C Move carry flag to directly addressed bit
Program branches
Mnemonic Description
ACALL addr11 Absolute subroutine call
LCALL addr16 Long subroutine call
RET Return from subroutine
RETI Return from interrupt
AJMP addr11 Absolute jump
LJMP addr16 Long jump
SJMP rel Short jump (relative address)
JMP @A+DPTR Jump indirect relative to the DPTR
JZ rel Jump if accumulator is zero
JNZ rel Jump if accumulator is not zero
JC rel Jump if carry flag is set
JNC rel Jump if carry flag is not set
JB bit, rel Jump if directly addressed bit is set
JNB bit, rel Jump if directly addressed bit is not set
JBC bit, rel Jump if directly addressed bit is set and clear bit
CJNE A, direct, rel Compare directly addressed data to accumulator and jump if not equal
CJNE A, #data, rel Compare immediate data to accumulator and jump if not equal
CJNE Rn, #data, rel Compare immediate data to register and jump if not equal
CJNE @Ri, #data, rel Compare immediate to indirect and jump if not equal
DJNZ Rn, rel Decrement register and jump if not zero
DJNZ direct, rel Decrement directly addressed location and jump if not zero
NOP No operation for one cycle
21 Development Environment
SONIX provides an Embedded ICE emulator system to offer SN8F5701 firmware development. The
platform is an in-circuit debugger and controlled by Keil C51 IDE software on Microsoft Windows
platform. The platform includes SN-Link3, SN8F5701 Starter-kit and Keil C51 IDE software to build a
high-speed, low cost, powerful and multi-task development environment including emulator,
debugger and programmer. To execute emulation is like run real chip because the emulator circuit
integrated in SN8F5701 to offer a real development environment.
Before starting debug, microcontroller’s power (VDD) must be switched off. Connect the SWAT to
both 6th and 8th pins of SN-Link, and respectively link VDD and VSS to 7th pin and 2nd pin. A
handshake procedure would be automatically started by turn on the microcontroller, and SN-Link’s
green LED (Run) indicates the success of connection (refer SN8F5000 Debug Tool Manual for
further detail).
0.1uF
VDD 1 8 VSS
P0.0 2 7 P0.5
P0.1 3 6 P0.4/SWAT
RST/P0.2 4 5 P0.3
SN8F5701 VDD 7 8
5 6
3 4 1 3 5 7
1 2 RST VDD
2 4 6 8
Debug Interface VSS SWAT SWAT
MP5 Writer
22 SN8F5701 Starter-Kit
SN8F5000 Starter-Kit provides easy-development platform. It includes SN8F5000 family real chip
and I/O connectors to input signal or drive device of user’s application. It is a simple platform to
develop application as target board not ready. The Starter-Kit can be replaced by target board,
because SN8F5000 family integrates embedded ICE in-circuit debugger circuitry.
22.2 Schematic
Power Source
J11
DC 7.5V D11 U11 U12
3 1 1 3 VDD5 3 2 VDD33 1
VIN VOUT VIN VOUT
2
GND
1N4001 C11 C12 C13 C14 3
2
J13 J14
USB
VDD
Microcontroller
R21
47 kOhm
U1 150mil J21 SW21 RESET PULL-UP
VDD 1 8 GND VDD 7 8 P04 VDD
VDD VSS
P00 2 7 P05 5 6 1 P02
P00 P05
P01 3 6 P04 3 4 C20 2
P01 P04
P02 4 5 P03 1 2 0.1 uF 3
P02 P03
4 C21
SOP SN8F5701S Debug Port P02 N/A
J30
P00 1 2 P00 P00/PWM0 AIN0 P00 AIN1 P01 AIN2 P02 AIN3 P03 AIN4 P04 AIN5 P05
P01 3 4 P01 P01/PWM1
P02 5 6 P02 P02/PWM2/URX C30 C31 C32 C33 C34 C35
P03 7 8 P03 P03/PWM3/UTX
P04 9 10 P04 P04/PWM4/SWAT
P05 11 12 P05 P05/PWM5
13 14 GND
Port 0
Normal mode can meet most programming needs. However, if you want to shorten the
programming time, you can use the high speed mode. High speed mode requires a more stable
connection environment. Please confirm whether the environment can meet the requirements
before use.
1 VDD VDD 1 21 6 27
2 GND VSS 8 28 2 23
7 SWAT P0.4 6 26 1 22
9 SWAT P0.4 6 26 1 22
20 PDB P0.3 5 25 3 24
1 VDD VDD 1 21
2 GND VSS 8 28
3 DFTCLK P0.0 2 22
5 SEL P0.1 3 23
7 SWAT P0.4 6 26
9 SWAT P0.4 6 26
11 DAH P0.2 4 24
13 DAL P0.5 7 27
20 PDB P0.3 5 25
24 Ordering Information
A typical surface of SONiX microcontroller is printed with three columns: logo, device’s full name,
and date code.
SONiX Logo
Full Name
SN8F 5701 PG
8-bit MCU Device Series Package
Note: TR package (Tape & Reel Packing) will add “R” character after the package name.
25 Package Information
25.1 P-DIP8
D
8 5
θ
E1 E eA
1 4
A2
A
SEATING PLANE
A1
L
e1
B1
B
25.2 SOP8
8 5
H
“A”
E
PIN 1
CORNER 1 4
TOP VIEW
D
L
A
A1
GAGE PLANE
e
B SEATING PLANE
θ
SIDE VIEW DETAIL “A”
25.3 TSSOP8
8 5
E1
E
PIN 1
CORNER
1 4
TOP VIEW “A”
D L
A2
A
GAGE PLANE
A1
b e SEATING PLANE
θ
SIDE VIEW DETAIL “A”
25.4 SOT23-6L
6 4
E1
E
1 3
“A”
TOP VIEW
D L
e1
A2
A
b GAGE PLANE
A1
e SEATING PLANE θ
SIDE VIEW DETAIL “A”
25.5 DFN8L
D
8 5 D2 8
E E2
PIN 1 CORNER
8X L
1 4 1
PIN 1 CORNER TOP VIEW e 8X b
BOTTOM VIEW
VIEW M-M
M M
A3
A1
SIDE VIEW
SN8F5701 Series
Datasheet
8051-based Microcontroller