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.
N
X 88--
X
Biitt
B
Miiccrroo--
M
Coonnttrroolllleerr
C
SONiX TECHNOLOGY CO., LTD Page 1 V1.4
AMENDMENT HISTORY
Version Date Description
VER 0.1 Aug. 2004 Preliminary Version first issue
VER 0.2 Jan. 2005 1. Add SN8P27142/ SN8P27143 relative data.
2. Fix ADC clock and Timer clock description.
3. Add LVD36 relative information.
4. Correct the LVD24 bit location from bit 3 to bit 4 in PFLAG register description.
5. Modify LVD code option related description
6. Modify TC0RATE and TC1RATE table.
7. Add TC0X8 and TC1X8 notice.
8. Release the ROM address 0x04 ~ 0x07 as general-purpose area.
9. Remove the instruction limitation at interrupt vector address (0x08)
10. Change IDE support version to M2IDE V1.04
11. Modify pin circuit diagram.
12. There is no Schmitt trigger input in port 4.
13. Add description of P0.3 without wakeup function
VER 0.3 Mar. 2005 1. Modify Zero flag description.
2. In instruction set table, change “S = 0”, otherwise “S = 1” to “S = 1”, otherwise “S =
0”
3. Fix ADC conversion time formula.
4. Remove “Note:For 12-bit resolution the conversion time is 16 steps”.
5. Remove “Note: Please use "@RST_WDT" macro to clear the watchdog timer
successfully both in S8KD-2 ICE emulation and real chip.”
6. Modify watchdog reset section
7. Fixed the slow mode current of electrical characteristic table.
VER 1.0
VER 1.1 Nov.2005
VER 1.2 Dec.2005
VER 1.3 Sep.2006
VER 1.4 Feb 2007
Sept 2005 1. Modify Programming Pin Mapping.
2. Modify PROGRAM CHECK LIST.
3. Modify P13 AVREF pin description
4. Modify 27142/143 pin assignment.
5. Modify P57,P66 TC0RATE、TC1RATE.
6. Modify P57,P66:TC0X8=1 Fosc/2~Fosc/256 to Fosc/1~Fosc/128
7. Modify P107 SLOW Mode Current.
8. ADD P97 “Note”.
Nov.2005 1. ADD Brown-Out reset circuit.
2. Working Voltage vs. Frequency graphs.
1. ADD ADC current.
2. Modify Topr value.
1. Remove 32k mode.
2. Modify P108 SN8P271XAXD to SN8P271XXD.
3. Modify P52 wakeup trigger signal.
4. Remove CHARACTERISTIC GRAPHS.
5. Modify reset section.
6. Limit Fcpu=Fosc/4~./8 when Noise Filter enable
7. Remove Pc
1. Modify 15.2 STANDARD ELECTRICAL CHARACTERISTIC.
♦Input only pin: P0
Bi-directional: P2, P4, P5
Wakeup: P0.0, P0.1, P0.2 External interrupt: P0.0, P0.1
Pull-up resisters: P0, P2, P4, P5External high clock: RC type up to 10 MHz
P4 pins shared with ADC inputs.External high clock: Crystal type up to 16 MHz
Max 8-channel 12-bit ADC.
♦
One channel 7-bit DAC.
♦
Powerful instructions
♦
One clocks per instruction cycle (1T)
Most of instructions are one cycle only
All ROM area lookup table function (MOVC) SN8P27142: P-DIP 18 pins, SOP 18pins
SN8P27143:P-DIP 20 pins, SOP 20 pins, SSOP 20 pins
SN8P2714: SK-DIP 28 pins, SOP 28pins
SN8P2715: P-DIP 32 pins, SOP 32 pins
Internal low clock: RC type 16KHz(3V), 32KHz(5V)
Normal mode: Both high and low clock active
Slow mode: Low clock only
Sleep mode: Both high and low clock stop
Package (Chip form support)
♦
FEATURES SELECTION TABLE
CHIP ROM RAM Stack
SN8P27142 2K*16 128 8 - V V 15 5ch- 2 - 2 DIP18/SOP18
SN8P27143 2K*16 128 8 - V V 16 6ch- 2 - 2 DIP20/SOP20/SSOP20
SN8P2714 2K*16 128 8 - V V 23 8ch 1ch2 - 3 SKDIP28/SOP28
SN8P2715 2K*16 128 8 - V V 27 8ch 1ch2 - 3 DIP32/SOP32
SN8P2704A 4K*16 256 8 V V V 18 5ch 1ch2 18 SKDIP28/SOP28
SN8P2705A 4K*16 256 8 V V V 23 8ch 1ch2 19 DIP32/SOP32
Note: For SN8P27143 and SN8P27142 must configure P02R (bit 2 of P0UR) as “1” to avoid sleep mode fail.
Instruction cycle is oscillator clock.
Notice: In Fosc/1, Noise Filter must be disabled.
Instruction cycle is 2 oscillator clocks.
Notice: In Fosc/2, Noise Filter must be disabled.
LVD will reset chip if VDD is below 2.0V
Enable LVD24 bit of PFLAG register for 2.4V low voltage indicator.
LVD will reset chip if VDD is below 2.4V
Enable LVD36 bit of PFLAG register for 3.6V low voltage indicator.
High_Clk
Noise_Filter
Watch_Dog
Fcpu
Security
RST_P0.3
LVD
Ext_RC
12M_X’tal High speed crystal /resonator (e.g. 12MHz ~ 16MHz) for high clock oscillator.
4M_X’tal Middle speed crystal /resonator (e.g. 4MHz ~ 10Mhz) for high clock oscillator.
Enable
Disable
Always_On Watchdog timer always on even in sleep (power down) mode.
Enable
Disable Disable Watchdog function.
Fosc/1
Fosc/2
Fosc/4 Instruction cycle is 4 oscillator clocks.
Fosc/8 Instruction cycle is 8 oscillator clocks.
Enable Enable ROM code Security function.
Disable Disable ROM code Security function.
Reset Enable external reset pin
P0.3 Enable P0.3 input only pin without pull-up register
LVD_L LVD will reset chip if VDD is below 2.0V
LVD_M
LVD_H
SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
Table 2-1. Code Option Table of SN8P2714x/2715
Notice:
¾ In high noisy environment, enable “Noise Filter” and set Watch_Dog as “Always_On” is
strongly recommended.
¾ Enable “Noise Filter” will limit the Fcpu = Fosc/4 or Fosc/8
¾ Fcpu code option is only available for High Clock
¾ Fosc = Fhosc (External high clock) in normal mode.
¾ Fosc = Flosc (Internal low RC clock) in slow mode.
¾ In slow mode, Fcpu = Fosc / 4.
SONiX TECHNOLOGY CO., LTD Page 15 V1.4
SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
3 ADDRESS SPACES
3.1 PROGRAM MEMORY (ROM)
3.1.1 OVERVIEW
ROM Maps for SN8P2710 devices provide 2K X 16-bit OTP programmable memory. The SN8P2710 program memory
is able to fetch instructions through 12-bit wide PC (Program Counter) and can look up ROM data by using ROM code
registers (R, X, Y, Z). In standard configuration, the device’s 2,048 x 16-bit program memory has four areas:
¾ 1-word reset vector addresses
¾ 1-word Interrupt vector addresses
¾ 4-words reserved area
¾ 2K words
All of the program memory is partitioned into three coding areas. The 1
vector area), the 2
nd
area is for the interrupt vector (0008H) and the 3ed area is user code area from 0009H to 07FBH.
st
area is located from 00H to 07H(The Reset
0000H
0001H Jump to user start address
0002H Jump to user start address
0003H Jump to user start address
0004H Jump to user start address
0005H Jump to user start address
0006H Jump to user start address
0007H
0008H
0009H User program
000FH
0010H
0011H
07FBH
07FCH
07FFH
Figure 3-1 ROM Address Structure
General purpose area
.
.
General purpose area
.
.
.
ROM
Reset vector
Interrupt vector
Code Option
User reset vector
Jump to user start address
User interrupt vector
End of user program
SONiX TECHNOLOGY CO., LTD Page 16 V1.4
SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
3.1.2 USER RESET VECTOR ADDRESS (0000H)
A 1-word vector address area is used to execute system reset. After power on reset or watchdog timer overflow reset,
then the chip will restart the program from address 0000h and all system registers will be set as default values. The
following example shows the way to define the reset vector in the program memory.
 Example: After power on reset, external reset active or reset by watchdog timer overflow.
ORG 0 ; 0000H
JMP START ; Jump to user program address.
. ;
ORG 10H
START: ; 0010H, The head of user program.
. ; User program
.
.
.
ENDP
; End of program
3.1.3 INTERRUPT VECTOR ADDRESS (0008H)
A 1-word vector address area is used to execute interrupt request. If any interrupt service is executed, the program
counter (PC) value is stored in stack buffer and points to 0008h of program memory to execute the vectored interrupt.
Users have to define the interrupt vector and the following example shows the way to define the interrupt vector in the
program memory.
 Example 1: This demo program includes interrupt service routine and the user program is behind the
interrupt service routine.
ORG 0 ; 0000H
JMP START ; Jump to user program address.
.
START: ; The head of user program.
ORG 8
B0XCH A, ACCBUF
B0MOV A, PFLAG
B0MOV PFLAGBUF, A
.
.
B0MOV A, PFLAGBUF
B0MOV PFLAG, A
B0XCH A, ACCBUF
RETI
.
.
.
JMP START
ENDP
; Interrupt service routine
; B0XCH doesn’t change C, Z flag
; Save PFLAG register in a buffer
; User code
; User code
; Restore PFLAG register from buffer
; End of interrupt service routine
; User program
; End of user program
; End of program
SONiX TECHNOLOGY CO., LTD Page 17 V1.4
SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
 Example 2: The demo program includes interrupt service routine and the address of interrupt service
routine is in a special address of general-purpose area.
ORG 0 ; 0000H
JMP START ; Jump to user program address.
. ; 0001H ~ 0007H are reserved
ORG 08
JMP MY_IRQ ; 0008H, Jump to interrupt service routine address
ORG 10H
START: ; 0010H, The head of user program.
. ; User program
.
.
.
MY_IRQ: ;The head of interrupt service routine
¾Note: It is easy to get the rules of SONIX program from demo programs given above. These points are as
following.
1.The address 0000H is a “JMP” instruction to make the program go to general-purpose ROM area.
2. The interrupt service starts from 0008H. Users can put the whole interrupt service routine from 0008H
(Example1) or to put a “JMP” instruction in 0008H then place the interrupt service routine in other
general-purpose ROM area (Example2) to get more modularized coding style.
JMP START
B0XCH A, ACCBUF
B0MOV A, PFLAG
B0MOV PFLAGBUF, A
.
.
B0MOV A, PFLAGBUF
B0MOV PFLAG, A
RETI
ENDP
; End of user program
; B0XCH doesn’t change C, Z flag
; Save PFLAG register in a buffer
; User code
; User code
; Restore PFLAG register from buffer
; End of interrupt service routine
; End of program
SONiX TECHNOLOGY CO., LTD Page 18 V1.4
SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
3.1.4 GENERAL PURPOSE PROGRAM MEMORY AREA
The ROM locations 0001H~0007H and 0009H~07FBH are used as general-purpose memory. The area is stored
instruction’s op-code and look-up table data. The SN8P2710 includes jump table function by using program counter
(PC) and look-up table function by using ROM code registers (R, Y, Z).
The boundary of program memory is separated by the high-byte program counter (PCH) every 100H. In jump table
function and look-up table function, the program counter can’t leap over the boundary by program counter
automatically. Users need to modify the PCH value to “PCH+1” as the PCL overflow (from 0FFH to 000H).
3.1.5 LOOKUP TABLE DESCRIPTION
In the ROM’s data lookup function, Y register to the highest 8-bit and Z register to the lowest 8-bit data of ROM
address. After MOVC instruction is executed, the low-byte data of ROM then will be stored in ACC and high-byte data
stored in R register.
ÂExample: To look up the ROM data located “TABLE1”.
B0MOV Y, #TABLE1$M ; To set lookup table1’s middle address
B0MOV Z, #TABLE1$L ; To set lookup table1’s low address.
MOVC ; To lookup data, R = 00H, ACC = 35H
;
;
@@:. . ;
TABLE1: DW 0035H ; To define a word (16 bits) data.
DW 5105H ; “
DW 2012H ; “
¾CAUSION: The Y register can’t increase automatically if Z register cross boundary from 0xFF to 0x00.
Therefore, user must take care such situation to avoid loop-up table errors. If Z register overflow, Y
register must be added one. The following INC_YZ macro shows a simple method to process Y and Z
registers automatically.
¾Note: Because the program counter (PC) is only 12-bit, the X register is useless in the application. Users
can omit “B0MOV X, #TABLE1$H”. SONiX ICE support more larger program memory addressing
capability. So make sure X register is “0” to avoid unpredicted error in loop-up table operation.
INCMS Z ; Z+1
JMP @F ; Not overflow
INCMS Y ; Z overflow (FFH Æ 00), Æ Y=Y+1
NOP ; Not overflow
MOVC ; To lookup data, R = 51H, ACC = 05H.
; Increment the index address for next address
ÂExample: INC_YZ Macro
INC_YZ MACRO INCMS Z ; Z+1
JMP @F ; Not overflow
INCMS Y ; Y+1
NOP ; Not overflow
@@: ENDM
SONiX TECHNOLOGY CO., LTD Page 19 V1.4
SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
The other coding style of loop-up table is to add Y or Z index register by accumulator. Be careful if carry happen. Refer
following example for detailed information:
ÂExample: Increase Y and Z register by B0ADD/ADD instruction
B0MOV Y, #TABLE1$M ; To set lookup table’s middle address.
B0MOV Z, #TABLE1$L ; To set lookup table’s low address.
GETDATA: ;
MOVC ; To lookup data. If BUF = 0, data is 0x0035
; If BUF = 1, data is 0x5105
; If BUF = 2, data is 0x2012
.
.
. . ;
TABLE1: DW 0035H ; To define a word (16 bits) data.
DW 5105H ; “
DW 2012H ; “
B0MOV A, BUF ; Z = Z + BUF.
B0ADD Z, A
B0BTS1 FC ; Check the carry flag.
JMP GETDATA ; FC = 0
INCMS Y ; FC = 1. Y+1.
NOP
SONiX TECHNOLOGY CO., LTD Page 20 V1.4
SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
3.1.6 JUMP TABLE DESCRIPTION
The jump table operation is one of multi-address jumping function. Add low-byte program counter (PCL) and ACC
value to get one new PCL. The new program counter (PC) points to a series jump instructions as a listing table. The
way is easy to make a multi-stage program.
When carry flag occurs after executing of “ADD PCL, A”, it will not affect PCH register. Users have to check if the jump
table leaps over the ROM page boundary or the listing file generated by SONIX assembly software. If the jump table
leaps over the ROM page boundary (e.g. from xxFFH to xx00H), move the jump table to the top of next program
memory page (xx00H). Here one page mean 256 words.
ÂExample : If PC = 0323H (PCH = 03H、PCL = 23H)
ORG 0X0100 ; The jump table is from the head of the ROM boundary
B0ADD PCL, A ; PCL = PCL + ACC, the PCH can’t be changed.
JMP A0POINT ; ACC = 0, jump to A0POINT
JMP A1POINT ; ACC = 1, jump to A1POINT
JMP A2POINT ; ACC = 2, jump to A2POINT
JMP A3POINT ; ACC = 3, jump to A3POINT
In following example, the jump table starts at 0x00FD. When execute B0ADD PCL, A. If ACC = 0 or 1, the jump
table points to the right address. If the ACC is larger then 1 will cause error because PCH doesn’t increase one
automatically. We can see the PCL = 0 when ACC = 2 but the PCH still keep in 0. The program counter (PC) will
point to a wrong address 0x0000 and crash system operation. It is important to check whether the jump table
crosses over the boundary (xxFFH to xx00H). A good coding style is to put the jump table at the start of ROM
boundary (e.g. 0100H).
 Example: If “jump table” crosses over ROM boundary will cause errors.
ROM Address
. .
. .
. .
0X00FD
0X00FE
0X00FF
0X0100
0X0101
. .
. .
SONIX provides a macro for safe jump table function. This macro will check the ROM boundary and move the jump
table to the right position automatically. The side effect of this macro is maybe wasting some ROM size. Notice the
maximum jmp table number for this macro is limited under 254.
@JMP_A MACRO VAL IF (($+1) !& 0XFF00) !!= (($+(VAL)) !& 0XFF00)
JMP ($ | 0XFF) ORG ($ | 0XFF)
ENDIF
ADD PCL, A
ENDM
¾Note: “VAL” is the number of the jump table listing number.
ÂExample: “@JMP_A” application in SONIX macro file called “MACRO3.H”.
B0MOV A, BUF0 ; “BUF0” is from 0 to 4.
@JMP_A 5 ; The number of the jump table listing is five.
JMP A0POINT ; If ACC = 0, jump to A0POINT
JMP A1POINT ; ACC = 1, jump to A1POINT
JMP A2POINT ; ACC = 2, jump to A2POINT
JMP A3POINT ; ACC = 3, jump to A3POINT
JMP A4POINT ; ACC = 4, jump to A4POINT
If the jump table position is from 00FDH to 0101H, the “@JMP_A” macro will make the jump table to start from 0100h.
SONiX TECHNOLOGY CO., LTD Page 22 V1.4
SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
3.2 DATA MEMORY (RAM)
3.2.1 OVERVIEW
The SN8P2710 has internally built-in the data memory up to 128 bytes for storing the general-purpose data.
For SN8P2710
¾ 128 * 8-bit general purpose area in bank 0
¾ 128 * 8-bit system special register area
The memory is located in bank 0. The bank 0, using the first 128-byte location assigned as general-purpose area, and
the remaining 128-byte in bank 0 as system register.
BANK 0
000h 000h~07Fh of Bank 0 = To store general-
“ purpose data (128 bytes).
“
“
“
“
07Fh
080h 080h~0FFh of Bank 0 = To store system
“ registers (128 bytes).
“
“
“
“
0FFh
RAM location
General purpose area
System register
End of bank 0 area
Figure 3-2 RAM Location of SN8P2710
¾Note: The undefined locations of system register area are logic “high” after executing read instruction
“MOV A, M”.
SONiX TECHNOLOGY CO., LTD Page 23 V1.4
SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
3.3 WORKING REGISTERS
The locations 82H to 84H of RAM bank 0 in data memory stores the specially defined registers such as register R, Y, Z,
respectively shown in the following table. These registers can use as the general purpose of working buffer and be
used to access ROM’s and RAM’s data. For instance, all of the ROM’s table can be looked-up with R, Y and Z
registers. The data of RAM memory can be indirectly accessed with Y and Z registers.
80H 81H 82H 83H 84H 85H
RAM
- - R/W R/W R/W -
3.3.1 Y, Z REGISTERS
The Y and Z registers are the 8-bit buffers. There are three major functions of these registers. First, Y and Z registers
can be used as working registers. Second, these two registers can be used as data pointers for @YZ register. Third,
the registers can be address ROM location in order to look-up ROM data.
Y initial value = XXXX XXXX
084H Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Y
R/W R/W R/W R/W R/W R/W R/W R/W
Z initial value = XXXX XXXX
083H Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Z
R/W R/W R/W R/W R/W R/W R/W R/W
The @YZ that is data point_1 index buffer located at address E7H in RAM bank 0. It employs Y and Z registers to
addressing RAM location in order to read/write data through ACC. The Lower 4-bit of Y register is pointed to RAM
bank number and Z register is pointed to RAM address number, respectively. The higher 4-bit data of Y register is
truncated in RAM indirectly access mode.
ÂExample: If want to read a data from RAM address 25H of bank 0, it can use indirectly addressing mode to
B0MOV Y, #00H ; To set RAM bank 0 for Y register
B0MOV Z, #25H ; To set location 25H for Z register
B0MOV A, @YZ ; To read a data into ACC
ÂExample: Clear general-purpose data memory area of bank 0 using @YZ register.
MOV A, #0
B0MOV Y, A ; Y = 0, bank 0
MOV A, #07FH
B0MOV Z, A ; Z = 7FH, the last address of the data memory area
CLR_YZ_BUF: CLR @YZ ; Clear @YZ to be zero
DECMS Z ; Z – 1, if Z= 0, finish the routine
JMP CLR_YZ_BUF ; Not zero
CLR @YZ
END_CLR: ; End of clear general purpose data memory area of bank 0
.
Note: Please consult the “LOOK-UP TABLE DESCRIPTION” about Y, Z register look-up table application.
YBIT7 YBIT6 YBIT5 YBIT4 YBIT3 YBIT2 YBIT1 YBIT0
ZBIT7 ZBIT6 ZBIT5 ZBIT4 ZBIT3 ZBIT2 ZBIT1 ZBIT0
access data as following.
- - R Z Y -
SONiX TECHNOLOGY CO., LTD Page 24 V1.4
SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
3.3.2 R REGISTERS
There are two major functions of the R register. First, R register can be used as working registers. Second, the R
registers can be store high-byte data of look-up ROM data. After MOVC instruction executed, the high-byte data of a
ROM address will be stored in R register and the low-byte data stored in ACC.
R initial value = XXXX XXXX
082H Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
R
R/W R/W R/W R/W R/W R/W R/W R/W
¾Note: Please consult the “LOOK-UP TABLE DESCRIPTION” about R register look-up table application.
RBIT7 RBIT6 RBIT5 RBIT4 RBIT3 RBIT2 RBIT1 RBIT0
3.4 PROGRAM FLAG
The PFLAG includes reset flag, low voltage detect flag, carry flag, decimal carry flag (DC) and zero flag (Z). If the result
of operating is zero or there is carry, borrow occurrence, then these flags will be set to PFLAG register.
PFLAG initial value = 00xx,x000
086H Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
PFLAG
R/W R/W R/W R/W - R/W R/W R/W
NT0 NPD LVD36 LVD24 - C DC Z
3.4.1 RESET FLAG
NT0 NPD Reset Status
0 0 Watch-dog time out
0 1 Reserved
1 0 Reset by LVD
1 1 Reset by external Reset Pin
3.4.2 LVD 2.4V FLAG
LVD24 VDD Status
1 VDD <= 2.4V
0 VDD > 2.4V
Note: This bit is only valid when code option LVD=LVD_M
3.4.3 LVD 3.6V FLAG
LVD36 VDD Status
1 VDD <= 3.6V
0 VDD > 3.6V
Note: This bit is only valid when code option LVD=LVD_H
SONiX TECHNOLOGY CO., LTD Page 25 V1.4
SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
3.4.4 CARRY FLAG
C = 1: If executed arithmetic addition with occurring carry signal or executed arithmetic subtraction without borrowing
signal or executed rotation instruction with shifting out logic “1”.
C = 0: If executed arithmetic addition without occurring carry signal or executed arithmetic subtraction with borrowing
signal or executed rotation instruction with shifting out logic “0”.
3.4.5 DECIMAL CARRY FLAG
DC = 1: If executed arithmetic addition with occurring carry signal from low nibble or executed arithmetic subtraction
without borrow signal from high nibble.
DC = 0: If executed arithmetic addition without occurring carry signal from low nibble or executed arithmetic subtraction
with borrow signal from high nibble.
3.4.6 ZERO FLAG
Z = 1: ACC or arithmetic operation result is zero after executing a instruction. Refer instruction set table for
detailed information.
Z = 0: ACC or arithmetic operation result is not zero after executing a instruction. Refer instruction set table
for detailed information.
SONiX TECHNOLOGY CO., LTD Page 26 V1.4
SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
3.5 ACCUMULATOR
The ACC is an 8-bits data register responsible for transferring or manipulating data between ALU and data memory. If
the result of operating is zero (Z) or there is carry (C or DC) occurrence, then these flags will be set to PFLAG register.
ACC is not in data memory (RAM), so ACC can’t be access by “B0MOV” instruction during the instant addressing
mode.
ÂExample: Read and write ACC value.
; Read ACC data and store in BUF data memory
MOV BUF, A
. .
; Write a immediate data into ACC
MOV A, #0FH
. .
; Write ACC data from BUF data memory
MOV A, BUF
. .
The ACC value don’t store in any interrupt service executed. ACC must be exchanged to another data memory defined
by users. Thus, once interrupt occurs, these data must be stored in the data memory based on the user’s program as
follows.
ÂExample: ACC and working registers protection.
ACCBUF EQU 00H ; ACCBUF is ACC data buffer in bank 0.
INT_SERVICE:
B0XCH A, ACCBUF
B0XCH A, ACCBUF ; Re-load ACC
RETI ; Exit interrupt service vector
¾Notice: To save and re-load ACC data must be used “B0XCH” instruction, or the PLAGE value maybe
modified by ACC.
B0MOV A, PFLAG
B0MOV PFLAGBUF, A
.
.
B0MOV A, PFLAGBUF
B0MOV PFLAG, A
; B0XCH doesn’t change C, Z flag
; Save PFLAG register in a buffer
; Restore PFLAG register from buffer
SONiX TECHNOLOGY CO., LTD Page 27 V1.4
SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
3.6 STACK OPERATIONS
3.6.1 OVERVIEW
The stack buffer of SN8P2710 has 8-level high area and each level is 11-bits length. This buffer is designed to save
and restore program counter’s (PC) data when interrupt service is executed. The STKP register is a pointer designed
to point active level in order to save or restore data from stack buffer for kernel circuit. The STKnH and STKnL are the
12-bit stack buffers to store program counter (PC) data.
STACK BUFFER
STACK BUFFER
PCL
PCL
PCLPCL
STK0L
STK0L
STK0L
RET /
RET /
RETI
RETI
CALL /
CALL /
interrupt
interrupt
STKP = 7
STKP = 7
STKP = 7
PCH
PCH
PCHPCH
STK0H
STK0H
STK0H
STKP + 1
STKP + 1
STKP + 1
STKP - 1
STKP - 1
STKP - 1STKP - 1
STKP = 6
STKP = 6
STKP = 6
STKP = 5
STKP = 5
STKP = 5
STKP = 4
STKP = 4
STKP = 4
STKP = 3
STKP = 3
STKP = 3
STKP = 2
STKP = 2
STKP = 2
STKP = 1
STKP = 1
STKP = 1
STKP = 0
STKP = 0
STKP = 0
STKP
STKPSTKP
Figure 3-3 Stack Operation
STK1H
STK1H
STK1H
STK2H
STK2H
STK2H
STK3H
STK3H
STK3H
STK4H
STK4H
STK4H
STK5H
STK5H
STK5H
STK6H
STK6H
STK6H
STK7H
STK7H
STK7H
STKP
STKPSTKP
STK1L
STK1L
STK1L
STK2L
STK2L
STK2L
STK3L
STK3L
STK3L
STK4L
STK4L
STK4L
STK5L
STK5L
STK5L
STK6L
STK6L
STK6L
STK7L
STK7L
STK7L
SONiX TECHNOLOGY CO., LTD Page 28 V1.4
SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
3.6.2 STACK REGISTERS
The stack pointer (STKP) is a 4-bit register to store the address used to access the stack buffer, 11-bits data memory
(STKnH and STKnL) set aside for temporary storage of stack addresses.
The two stack operations are writing to the top of the stack (Stack-Save) and reading (Stack-Restore) from the top of
stack. Stack-Save operation decrements the STKP and the Stack-Resotre operation increments one time. That makes
the STKP always points to the top address of stack buffer and writes the last program counter value (PC) into the stack
buffer.
The program counter (PC) value is stored in the stack buffer before a CALL instruction executed or during interrupt
service routine. Stack operation is a LIFO type (Last in and first out). The stack pointer (STKP) and stack buffer
(STKnH and STKnL) are located in the system register area bank 0.
STKP (stack pointer) initial value = 0xxx x111
0DFH Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
STKP
R/W - - - - R/W R/W R/W
STKPBn: Stack pointer. (n = 0 ~ 3)
GIE: Global interrupt control bit. 0 = disable, 1 = enable. More detail information is in interrupt chapter.
0F0H~0FFH Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
STKnH
- - - - - R/W R/W R/W
0F0H~0FFH Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
STKnL
R/W R/W R/W R/W R/W R/W R/W R/W
STKnH: Store PCH data as interrupt or call executing. The n expressed 0 ~7.
STKnL: Store PCL data as interrupt or call executing. The n expressed 0 ~7.
GIE - - - - STKPB2 STKPB1 STKPB0
- - - - - SnPC10 SnPC9 SnPC8
SnPC7 SnPC6 SnPC5 SnPC4 SnPC3 SnPC2 SnPC1 SnPC0
SONiX TECHNOLOGY CO., LTD Page 29 V1.4
SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
3.6.3 STACK OPERATION EXAMPLE
The two kinds of Stack-Save operations to reference the stack pointer (STKP) and write the program counter contents
(PC) into the stack buffer are CALL instruction and interrupt service. Under each condition, the STKP is decremented
and points to the next available stack location. The stack buffer stores the program counter about the op-code address.
The Stack-Save operation is as following table.
The RETI instruction is for interrupt service routine. The RET instruction is for CALL instruction. When a Stack-Restore
operation occurs, the STKP is incremented and points to the next free stack location. The stack buffer restores the last
program counter (PC) to the program counter registers. The Stack-Restore operation is as following table.