
SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 1 V1.7
SN8P2977
USER’S MANUAL
Specification V1.7
SSO
O
N
NiiXX 88--
B
Biitt
M
Miiccrroo--
C
Coonnttrroolllleerr
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.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 2 V1.7
AMENDENT HISTORY
Modify BZRM & ROMDAH & ROMDAL register only write.
1. Modify 1.2 MIGRATION TABLEUART Total Capacitors descriptions.
2. Modify 1.1 SELECTION TABLE descriptions.
3. Modify 1.6 PIN DESCRIPTIONS descriptions.
4. Modify 2.1.3 CODE OPTION TABLE Low_power descriptions.
5. Modify 2.1.5.3 BIT DEFINITION of SYSTEM REGISTER descriptions.
6. Modify 5.1 Operating mode description.
7. Modify 11.5 C-TYPE LCD DRIVER MODE description.
8. Modify 12.1 ROMADRH/ROMADRL REGISTER description.
9. Modify 13 Regulator, PGIA and ADC description.
10. Add AMPCKS[2:0]: PGIA chopper selection.(Always set “7.8k Hz”) description.
11. Add 13.4.2 AMPM- Amplifier Mode Control Register Note_2: When PGIA Gain set 1x
(GS[2:0]=111) application, the AI+/AI- signal input buffer of PGIA mustbe enabled
(AMPENB=1) for input high impedance characteristic of ADC.
12. Modify 13.5 Temperature Sensor (TS) description.
13. Modify 13.6 24-Bit Analog to Digital Converter (ADC) description.
14. Modify 13.6.5 ADCM1- ADC Mode1 Register Bit 0 ADCENB description.
15. Modify 13.6.7 ADC Data Register Note description.
16. Modify 14 APPLICATION CIRCUIT.
17. Modify 17 ELECTRICAL CHARACTERISTIC.
1. Modify 13.4.1 CHS- Analog input signal channel selection Register note 4.
(GS[2:0]=000)
2. Modify 13.4.2 AMPM- Amplifier Mode Control Register note1 & note2. (GS[2:0]=000)
3. Modify 12.2 ROMADRH/ROMADRL REGISTER
1. Add ROMADR[15] : ISP ROM Programming selection control bit. (Always set “0”)
2. Modify ROMADR[11:0] : ISP ROM Programming Address.
3. Modify ELECTRICAL CHARACTERISTIC P0 IoH Min value 7mA.
4. Modify ELECTRICAL CHARACTERISTIC P1 IoH Min value 15mA,Typ value 20mA
5. Modify ELECTRICAL CHARACTERISTIC P3 IoH Min value 12mA.
6. Modify ELECTRICAL CHARACTERISTIC P2 IoL Min value 45mA,Typ value 60mA
7. ADD ELECTRICAL CHARACTERISTIC P1,P3 IoL Min value 45mA
8. ADD ELECTRICAL CHARACTERISTIC LBT 3.0V Min = 2.8V,Typ=3.0V,Max=3.2V
9. ADD ELECTRICAL CHARACTERISTIC LBT 3.6V Min = 3.4V,Typ=3.6V,Max=3.8V
Add package information(QFN32、TSSOP28、SSOP20、SOP16)
1.Modify the ceramic capacitor configuration of the application circuit.(page125,126)
2.Modify QFN32 symbols table.(A Typical→0.8mm, A Max→0.9mm)(page 139)
3.Add Package information(Ver1.5) to FEATURES(Chapter 1.3)
4.Modify QFN32 package type of name to 2975 from 2977.(page 14)
1.Modify the name of package type in SSOP20 from SN8P2972 to SN8P2973.(page14)

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 3 V1.7
Table of Content
AMENDENT HISTORY ........................................................................................................................................ 2
PRODUCT OVERVIEW............................................................................................................................... 8
1.1 SELECTION TABLE ................................................................................................................................ 8
1.2 MIGRATION TABLEUART ..................................................................................................................... 8
1.3 FEATURES ............................................................................................................................................... 9
1.4 SYSTEM BLOCK DIAGRAM ................................................................................................................ 10
1.5 PIN ASSIGNMENT ................................................................................................................................. 11
1.6 PIN DESCRIPTIONS .............................................................................................................................. 15
1.7 PIN CIRCUIT DIAGRAMS..................................................................................................................... 16
CENTRAL PROCESSOR UNIT (CPU) ...................................................................................................... 17
2.1 MEMORY MAP ...................................................................................................................................... 17
2.1.1 PROGRAM MEMORY (ROM) .......................................................................................................... 17
2.1.2 RESET VECTOR (0000H) .................................................................................................................. 18
2.1.3 CODE OPTION TABLE .......................................................................................................................... 26
2.1.4 DATA MEMORY (RAM) ....................................................................................................................... 27
2.1.5 SYSTEM REGISTER .......................................................................................................................... 28
2.1.6 ACCUMULATOR ............................................................................................................................... 31
2.1.7 PROGRAM FLAG .............................................................................................................................. 32
2.1.8 PROGRAM COUNTER ...................................................................................................................... 33
2.1.9 MULTI-ADDRESS JUMPING ........................................................................................................... 35
2.1.10 Y, Z REGISTERS ........................................................................................................................... 36
2.1.11 H, L REGISTERS ........................................................................................................................... 37
2.1.12 R REGISTERS ................................................................................................................................ 38
2.2 ADDRESSING MODE ............................................................................................................................ 39
2.2.1 IMMEDIATE ADDRESSING MODE ................................................................................................ 39
2.2.2 DIRECTLY ADDRESSING MODE ................................................................................................... 39
2.2.3 INDIRECTLY ADDRESSING MODE ............................................................................................... 39
2.3 STACK OPERATION ............................................................................................................................. 40
2.3.1 OVERVIEW ........................................................................................................................................ 40
2.3.2 STACK REGISTERS .......................................................................................................................... 41
2.3.3 STACK OPERATION EXAMPLE ..................................................................................................... 42
RESET ........................................................................................................................................................ 43
3.1 OVERVIEW ............................................................................................................................................ 43
3.2 POWER ON RESET ................................................................................................................................ 43
3.3 WATCHDOG RESET ............................................................................................................................. 44
3.4 BROWN OUT RESET ............................................................................................................................. 44
3.4.1 BROWN OUT DESCRIPTION ........................................................................................................... 44
3.4.2 THE SYSTEM OPERATING VOLTAGE DECSRIPTION ............................................................... 45
3.4.3 BROWN OUT RESET IMPROVEMENT .......................................................................................... 45
SYSTEM CLOCK ....................................................................................................................................... 47

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 4 V1.7
4.1 OVERVIEW ............................................................................................................................................ 47
4.2 CLOCK BLOCK DIAGRAM .................................................................................................................. 47
4.3 OSCM REGISTER .................................................................................................................................. 48
4.4 SYSTEM HIGH CLOCK ......................................................................................................................... 49
4.5 SYSTEM LOW CLOCK .......................................................................................................................... 49
4.5.1 SYSTEM CLOCK MEASUREMENT ................................................................................................ 50
SYSTEM OPERATION MODE .................................................................................................................. 51
5.1 OVERVIEW ............................................................................................................................................ 51
5.2 SYSTEM MODE SWITCHING .............................................................................................................. 52
5.3 WAKEUP ................................................................................................................................................ 54
5.3.1 OVERVIEW ........................................................................................................................................ 54
5.3.2 WAKEUP TIME.................................................................................................................................. 54
INTERRUPT .............................................................................................................................................. 55
6.1 OVERVIEW ............................................................................................................................................ 55
6.2 INTEN INTERRUPT ENABLE REGISTER ........................................................................................... 56
6.3 INTRQ INTERRUPT REQUEST REGISTER ......................................................................................... 56
6.4 GIE GLOBAL INTERRUPT OPERATION ............................................................................................ 57
6.5 PUSH, POP ROUTINE ............................................................................................................................ 58
6.6 EXTERNAL INTERRUPT OPERATION ............................................................................................... 59
6.7 MULTI-INTERRUPT OPERATION ....................................................................................................... 60
I/O PORT.................................................................................................................................................... 62
7.1 I/O PORT MODE ..................................................................................................................................... 62
7.2 I/O PIN SHARE WITH LCD FUNCTION ............................................................................................... 62
7.3 I/O PULL UP REGISTER ........................................................................................................................ 64
7.4 I/O PORT DATA REGISTER .................................................................................................................. 65
7.5 HIGH-SINK CURRENT I/O PORT ................................................................................................................ 66
TIMERS ..................................................................................................................................................... 67
8.1 WATCHDOG TIMER ............................................................................................................................. 67
8.2 TIMER 0 (T0) .......................................................................................................................................... 69
8.2.1 OVERVIEW ........................................................................................................................................ 69
8.2.2 T0M MODE REGISTER ..................................................................................................................... 69
8.2.3 T0C COUNTING REGISTER ............................................................................................................. 71
8.2.4 T0 TIMER OPERATION SEQUENCE (High_Clk = IHRC) .............................................................. 72
8.2.5 RTC OPERATION SEQUENCE (High_Clk =“IHRC_RTC” and “T0TB = 1”) ....................... 73
8.3 TIMER/COUNTER 0 (TC0) .................................................................................................................... 75
8.3.1 OVERVIEW ........................................................................................................................................ 75
8.3.2 TC0M MODE REGISTER .................................................................................................................. 76
8.3.3 TC0X8, TC0GN FLAGS ..................................................................................................................... 77
8.3.4 TC0C COUNTING REGISTER .......................................................................................................... 78
8.3.5 TC0R AUTO-LOAD REGISTER ....................................................................................................... 80
8.3.6 TC0 CLOCK FREQUENCY OUTPUT (BUZZER) ............................................................................ 81
8.3.7 TC0 TIMER OPERATION SEQUENCE ............................................................................................ 82

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 5 V1.7
8.4 PWM0 MODE ......................................................................................................................................... 83
8.4.1 OVERVIEW ........................................................................................................................................ 83
8.4.2 TC0IRQ AND PWM DUTY ............................................................................................................... 84
8.4.3 PWM PROGRAM EXAMPLE ............................................................................................................ 84
8.4.4 PWM0 DUTY CHANGING NOTICE ................................................................................................ 85
UART ......................................................................................................................................................... 86
9.1 OVERVIEW ............................................................................................................................................ 86
9.2 UART OPERATION ............................................................................................................................... 86
9.3 UART TRANSFER FORMAT ................................................................................................................ 87
9.4 ABNORMAL POCKET ........................................................................................................................... 88
9.5 UART BAUD RATE ............................................................................................................................... 88
9.6 UART RECEIVER CONTROL REGISTER............................................................................................ 90
9.7 UART TRANSMITTER CONTROL REGISTER ................................................................................... 90
9.8 UART TRANSMITTER CONTROL REGISTER ................................................................................... 91
9.9 UART OPERATION EXAMLPE ............................................................................................................ 92
BUZZER FUNCTION ................................................................................................................................ 93
10.1 OVERVIEW ............................................................................................................................................ 93
10.2 BUZZER CONTROL REGISTER ........................................................................................................... 93
LCD DRIVER ............................................................................................................................................. 94
11.1 OVERVIEW ............................................................................................................................................ 94
11.2 LCD TIMING .......................................................................................................................................... 94
11.3 LCDM1 REGISTER ................................................................................................................................ 96
11.4 LCDM2 REGISTER ................................................................................................................................ 96
11.5 C-TYPE LCD DRIVER MODE ............................................................................................................... 98
11.6 R-TYPE LCD DRIVER MODE ............................................................................................................... 99
11.7 LCD RAM LOCATION ......................................................................................................................... 101
IN SYSTEM PROGRAM ROM ................................................................................................................ 102
12.1 OVERVIEW .......................................................................................................................................... 102
12.2 ROMADRH/ROMADRL REGISTER ................................................................................................... 102
12.3 ROMDAH/ROMADL REGISTERS ...................................................................................................... 102
12.4 ISP ROM ROUTINE EXAMPLE .......................................................................................................... 103
REGULATOR, PGIA AND ADC ............................................................................................................. 104
13.1 OVERVIEW .......................................................................................................................................... 104
13.2 ANALOG INPUT .................................................................................................................................. 104
13.3 VOLTAGE REGULATOR ............................................................................................................................ 105
13.3.1 Voltage Regulator Control Register ............................................................................................... 105
13.4 PGIA -PROGRAMMABLE GAIN INSTRUMENTATION AMPLIFIER ............................................................... 106
13.4.1 CHS- Analog input signal channel selection Register ................................................................... 106
13.4.2 AMPM- Amplifier Mode Control Register .................................................................................... 108
13.5 TEMPERATURE SENSOR (TS) ................................................................................................................... 109
13.6 24-BIT ANALOG TO DIGITAL CONVERTER (ADC) ................................................................................... 111
13.6.1 Analog Inputs and Voltage Operation Range ................................................................................ 111

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 6 V1.7
13.6.2 Reference Voltage ......................................................................................................................... 111
13.6.3 ADC Gain and Offset .................................................................................................................... 112
13.6.4 Output Word Rate .......................................................................................................................... 113
13.6.5 ADCM1- ADC Mode1 Register .................................................................................................... 113
13.6.6 ADCM2- ADC Mode2 Register .................................................................................................... 114
13.6.7 ADC Data Register ........................................................................................................................ 115
13.7 LBTM: LOW BATTERY DETECT .............................................................................................................. 121
13.7.1 LBTM: Low Battery Detect Register ............................................................................................ 121
13.8 ANALOG SETTING AND APPLICATION ...................................................................................................... 123
APPLICATION CIRCUIT ........................................................................................................................ 125
14.1 SCALE (LOAD CELL) APPLICATION CIRCUIT............................................................................................ 125
14.2 THERMOMETER APPLICATION CIRCUIT..................................................................................................... 126
INSTRUCTION SET TABLE ................................................................................................................... 127
DEVELOPMENT TOOLS ........................................................................................................................ 128
16.1 DEVELOPMENT TOOL VERSION ............................................................................................................... 128
16.1.1 ICE (IN CIRCUIT EMULATION) ............................................................................................................. 128
16.1.2 OTP WRITER ...................................................................................................................................... 128
16.1.3 IDE (INTEGRATED DEVELOPMENT ENVIRONMENT) ............................................................................. 128
16.2 OTP PROGRAMMING PIN TO TRANSITION BOARD MAPPING .................................................................... 129
16.3 APPENDIX A: EV-KIT BOARD CIRCUIT .......................................................................................... 130
16.4 SN8P2977 EMULATION .......................................................................................................................... 131
16.4.1 INTRODUCTION ......................................................................................................................... 131
16.4.2 SN8ICE2K_Plus_II Hardware Setting Notice for SN2977 EV-Kit ............................................... 131
16.4.3 SN8P2977 EV Board DESCRIPTION .......................................................................................... 132
16.4.4 EV BOARD SETTING ................................................................................................................. 133
16.4.5 Notice for EV Emulation ............................................................................................................... 133
ELECTRICAL CHARACTERISTIC ......................................................................................................... 134
17.1 ABSOLUTE MAXIMUM RATING ...................................................................................................... 134
17.2 ELECTRICAL CHARACTERISTIC ..................................................................................................... 134
PACKAGE INFORMATION .................................................................................................................... 136
18.1 DIP 48 PIN ............................................................................................................................................. 136
18.2 SSOP 48 PIN .......................................................................................................................................... 137
18.3 LQFP 48 PIN .......................................................................................................................................... 138
18.4 QFN 32 PIN ........................................................................................................................................... 139
18.5 TSSOP28 PIN ........................................................................................................................................ 140
18.6 SSOP20 PIN ........................................................................................................................................... 141
18.7 SOP 18 PIN ............................................................................................................................................ 142
18.8 SOP 16 PIN ............................................................................................................................................ 143
MARKING DEFINITION ......................................................................................................................... 144
19.1 INTRODUCTION ................................................................................................................................. 144
19.2 MARKING INDETIFICATION SYSTEM ............................................................................................ 144

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 7 V1.7
19.3 MARKING EXAMPLE ......................................................................................................................... 145
19.4 DATECODE SYSTEM .......................................................................................................................... 145

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 8 V1.7
PRODUCT OVERVIEW
1.1 SELECTION TABLE
Table 1-1 Selection table of SN8Px9x7 serial
1.2 MIGRATION TABLEUART
Table 1-2 SN8P29x7 Migration Table
1x, 16x, 32x, 64x, 128x
(ADC Gain option ~ 2x)
1x, 16x, 32x, 64x, 128x, 200x
(ADC Gain option ~ 2x)
2.0V or 1.5V
/1V or 0.75V
1 fully differential Input
2 fully differential Input
4 single-ended Input
ADC Reference External Voltage V(R+, R-)
ADC Reference Internal Voltage
ADC Run in Green Mode
(with wake-up function)
AVDDR/AVE+ working in slow mode
Operating/Slow mode Current Consumption
T0: base timer / RTC
TC0: timer/counter/buzzer/PWM
T0: base timer / RTC
TC0: timer/counter/buzzer/PWM

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 9 V1.7
1.3 FEATURES
OTP ROM size: 4K * 16 bits
Three internal interrupts: T0, TC0, ADC
Three external interrupts: INT0 / INT1, UART(RX/TX)
Single power supply: 2.4V ~ 3.6V (Analog Part)
2.0V ~ 3.6V (Digital Part)
Bi-directional: P0, P1, P2, P3
On-chip Regulator (AVDDR) with 2.4V voltage
output and maximum 10mA driven current
Pull-up resistors: P0, P1
High-Sink Current I/O: P2, P3
On-chip Regulator AVE with selectable 2V/1.5V/0.75/1V
◆ On-chip 1.2V Band gap reference for battery monitor
Internal LBT 2.2V~3.6V; or external P10 input LBT
One clocks per instruction cycle
Build in ADC reference voltage = 0.23V~1.6V
All instructions are one word length
In-system Programmer ROM with Int. 6.5V generation
Most of instructions are 1 cycle only.
Maximum instruction cycle is “2”.
JMP instruction jumps to all ROM area.
All ROM area look-up table function (MOVC)
Fcpu : IHRC/4, /8, /16, /32
Both R type and C type LCD
1C-type LCD Voltage: 2.6 ~3.3V
◆ Seven-segment display driver:
P2/P3 are High Current Sink I/O and applied for LED display
T0: Basic Timer. Build in 0.5 sec RTC mode
◆ TC0:Auto-reload Timer/Counter/PWM0/Buzzer
Dual clock system offers four operating modes
Internal high clock: RC type up to 8 MHz
Buzzer Output P03: 0.98K / 1.96K / 3.9K/ 7.8K
Internal Low clock: RC type up to 32kHz
Programmable Gain Instrumentation Amplifier
Normal mode: Both high and low clock active
PGIA Gain option: 1x/4x/8x/16x/32x/64x/128x
Slow mode: Low clock active and 32768 X’tal
Green mode: Low clock active and optional high clock
ADC Gain selection: 1x, 2x
Sleep mode: Both high and low clock stop
ADC Offset selection: (-1/4, -2/4, -3/4) * Vref )
ADC Interrupt and Green Mode wakeup function
4-ADC channels configuration:
Dice/LQFP48/DIP48/SSOP48/QFN32
TSSOP28/SSOP20/SOP18/SOP16
- Two fully differential channels

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 10 V1.7
1.4 SYSTEM BLOCK DIAGRAM
INTERRUPT
CONTROL
ACC
TIMING GENERATOR
RAM
SYSTEM REGISTERS
LVD
WATCHDOG TIMER
TIMER & COUNTER
ALU
PC
FLAGS
IR
OTP
ROM
AVDDR/AVE
Internal
High RC
oscillator
P0
P1
Internal
Low RC
oscillator
Regulator
PGIA
Low Battery
Comparator
Internal
Reference
20-BIT ADC
VLCD/VDD Detect
AI1~ AI4
LCD Driver
R/C-Type
COM0
COM3
SIG00
SIG15
……
20-BIT ADC
UART
UTX,URX
P2
P3
Figure 1-1 Simplified system block diagram

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 11 V1.7
1.5 PIN ASSIGNMENT
SN8P2977 DIP48/SSOP48

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 12 V1.7
SN8P2977 LQFP48

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 13 V1.7
SN8P2975 QFN32
SN8P2974 TSSOP28
VLCD/VPP
AVDDR
AI1
AI2
VSS
VDD
INT1/P0.1
P0.2
1
2
3
4
5
6
7
8
P
0
.
3
/
B
Z
P
0
.
4
/
T
X
P
0
.
6
/
L
X
I
N
P
0
.
7
/
L
X
O
U
T
S
E
G
1
5
/
P
2
0
S
E
G
1
4
/
P
2
1
S
E
G
1
3
/
P
2
2
S
E
G
1
2
/
P
2
3
9
1011121
3141516
24
23
22
21
20
19
18
17
32313
0292827
262
5
SEG4/P33
SEG5/P32
SEG6/P31
SEG7/P30
SEG8/P27
SEG9/P26
SEG10/P25
SEG11/P24
C
O
M
0
C
O
M
1
C
O
M
2
C
O
M
3
S
E
G
0
/
P
3
7
S
E
G
1
/
P
3
6
S
E
G
2
/
P
3
5
S
E
G
3
/
P
3
4

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 14 V1.7
SN8P2973 SSOP20

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 15 V1.7
1.6 PIN DESCRIPTIONS
Power supply input pins for digital / Analog circuit
Regulator power output pin, Voltage = 2.4V, 2.8V, 3.2V
Regulator power output pin, Voltage = 0.75V/1V(sink only), 1.5V/2.0V
Analog input channel of PGIA. (AI3/AI4 share with R+/R- function)
VPP: OTP ROM programming pin only. (No reset function.)
VLCD: LCD driver power pin. (When R-Type LCD mode, VLCD = VDD auto
connection)
COM0~COM3 LCD driver common port
P37 IO function share with LCD SEG0.
P36 IO function share with LCD SEG1.
P35 IO function share with LCD SEG2.
P34 IO function share with LCD SEG3.
P33 IO function share with LCD SEG4.
P32 IO function share with LCD SEG5.
P31 IO function share with LCD SEG6.
P30 IO function share with LCD SEG7.
P27 IO function share with LCD SEG8.
P26 IO function share with LCD SEG9.
P25 IO function share with LCD SEG10.
P24 IO function share with LCD SEG11.
P23 IO function share with LCD SEG12.
P22 IO function share with LCD SEG13.
P21 IO function share with LCD SEG14.
P20 IO function share with LCD SEG15.
P00~P07 bi-direction pins / wakeup pins/ Built-in pull-up resisters
IO share with Buzzer function
IO share with LXIN 32768 Oscillator.
IO share with LXOUT 32768 Oscillator.
P10~P11 bi-direction pins / Built-in pull-up resisters (optional)
I/O shire with LBT function (Low battery detect, comparator input)
I/O shire with PWM0/TC0OUT.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 16 V1.7
1.7 PIN CIRCUIT DIAGRAMS
Port 0, Port 1 structure:
Port 2, Port 3 structure:
Pull-Up
Pin
Output
Latch
PnM, PnUR
Input Bus
PnM
Output Bus
PnSEG
LCD-SEG Function
Pull-Up
Pin
Output
Latch
PnM, PnUR
Input Bus
PnM
Output Bus

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 17 V1.7
CENTRAL PROCESSOR UNIT (CPU)
2.1 MEMORY MAP
2.1.1 PROGRAM MEMORY (ROM)
4K words ROM
Jump to user start address
Jump to user start address
Jump to user start address

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 18 V1.7
2.1.2 RESET VECTOR (0000H)
A one-word vector address area is used to execute system reset.
Power On Reset
Watchdog 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: Defining Reset Vector
; Jump to user program address.
; 0010H, The head of user program.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 19 V1.7
2.1.2.1 INTERRUPT VECTOR (0008H)
A 1-word vector address area is used to execute interrupt request. If any interrupt service executes, the program
counter (PC) value is stored in stack buffer and jump to 0008h of program memory to execute the vectored interrupt.
Users have to define the interrupt vector. The following example shows the way to define the interrupt vector in the
program memory.
Note: Users have to save and load ACC and PFLAG register by program as interrupt occurrence.
Example: Defining Interrupt Vector. The interrupt service routine is following ORG 8.
; Define ACCBUF for store ACC data.
; Define PFLAGBUF for store PFLAG data.
; Jump to user program address.
; Save PFLAG register in a buffer.
; Restore PFLAG register from buffer.
; Restore ACC from buffer.
; End of interrupt service routine
; The head of user program.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 20 V1.7
Example: Defining Interrupt Vector. The interrupt service routine is following user program.
; Define ACCBUF for store ACC data.
; Define PFLAGBUF for store PFLAG data.
; Jump to user program address.
; 0008H, Jump to interrupt service routine address.
; 0010H, The head of user program.
;The head of interrupt service routine.
; Save PFLAG register in a buffer.
; Restore PFLAG register from buffer.
; Restore ACC from buffer.
; End of interrupt service routine.
Note: It is easy to understand the rules of SONIX program from demo programs given above. These points
are as following:
The address 0000H is a “JMP” instruction to make the program starts from the beginning.
The address 0008H is interrupt vector.
User’s program is a loop routine for main purpose application.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 21 V1.7
2.1.2.1 LOOK-UP TABLE DESCRIPTION
In the ROM’s data lookup function, Y register is pointed to middle byte address (bit 8~bit 15) and Z register is pointed
to low byte address (bit 0~bit 7) of ROM. After MOVC instruction executed, the low-byte data will be stored in ACC and
high-byte data stored in R register.
Example: To look up the ROM data located “TABLE1”.
; To set lookup table1’s middle address
; To set lookup table1’s low address.
; To lookup data, R = 00H, ACC = 35H
; Increment the index address for next address.
; Z overflow (FFH 00), Y=Y+1
; To lookup data, R = 51H, ACC = 05H.
; To define a word (16 bits) data.
Note: The Y register will not increase automatically when Z register crosses boundary from 0xFF to
0x00. Therefore, user must take care such situation to avoid look-up table errors. If Z register is
overflow, Y register must be added one. The following INC_YZ macro shows a simple method to process
Y and Z registers automatically.
Example: Modify above example by “INC_YZ” macro.
; To set lookup table1’s middle address
; To set lookup table1’s low address.
; To lookup data, R = 00H, ACC = 35H
; Increment the index address for next address.
; To lookup data, R = 51H, ACC = 05H.
; To define a word (16 bits) data.
The other example of look-up table is to add Y or Z index register by accumulator. Please be careful if “carry” happen.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 22 V1.7
Example: Increase Y and Z register by B0ADD/ADD instruction.
; To set lookup table’s middle address.
; To set lookup table’s low address.
; To lookup data. If BUF = 0, data is 0x0035
; If BUF = 1, data is 0x5105
; If BUF = 2, data is 0x2012
; To define a word (16 bits) data.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 23 V1.7
2.1.2.2 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. It is
easy to make a multi-jump program depends on the value of the accumulator (A).
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.
Note: Program counter can’t carry from PCL to PCH when PCL is overflow after executing addition
instruction.
; The jump table is from the head of the ROM boundary
; PCL = PCL + ACC, the PCH can’t be changed.
; ACC = 0, jump to A0POINT
; ACC = 1, jump to A1POINT
; ACC = 2, jump to A2POINT
; 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.
; PCL = PCL + ACC, the PCH can’t be changed.
; ACC = 2 jump table cross boundary here

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 24 V1.7
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 maybe wastes some ROM size.
Example: If “jump table” crosses over ROM boundary will cause errors.
(($+1) !& 0XFF00) !!= (($+(VAL)) !& 0XFF00)
Note: “VAL” is the number of the jump table listing number.
Example: “@JMP_A” application in SONIX macro file called “MACRO3.H”.
; The number of the jump table listing is five.
; ACC = 0, jump to A0POINT
; ACC = 1, jump to A1POINT
; ACC = 2, jump to A2POINT
; ACC = 3, jump to A3POINT
; ACC = 4, jump to A4POINT
If the jump table position is across a ROM boundary (0x00FF~0x0100), the “@JMP_A” macro will adjust the jump table
routine begin from next RAM boundary (0x0100).
Example: “@JMP_A” operation.
; Before compiling program.
; The number of the jump table listing is five.
; ACC = 0, jump to A0POINT
; ACC = 1, jump to A1POINT
; ACC = 2, jump to A2POINT
; ACC = 3, jump to A3POINT
; ACC = 4, jump to A4POINT
; After compiling program.
; The number of the jump table listing is five.
; ACC = 0, jump to A0POINT
; ACC = 1, jump to A1POINT
; ACC = 2, jump to A2POINT
; ACC = 3, jump to A3POINT
; ACC = 4, jump to A4POINT

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 25 V1.7
2.1.2.3 CHECKSUM CALCULATION
The last ROM address is reserved area. User should avoid these addresses (last address) when calculate the
Checksum value.
Example: The demo program shows how to calculated Checksum from 00H to the end of user’s code.
; Save low end address to end_addr1
; Save middle end address to end_addr2
; Check if the YZ address = the end of code
; If Z != 00H calculate to next address
; Check if Z = low end address
; If Not jump to checksum calculate
; If Yes, check if Y = middle end address
; If Not jump to checksum calculate
; If Yes checksum calculated is done.
; Jump to checksum calculate

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 26 V1.7
2.1.3 CODE OPTION TABLE
Enable Watchdog function (WDT work in Normal/slow Mode).
Disable Watchdog function.
Enable Watchdog function (WDT work in Normal/slow/Green/Sleep
Mode).
Enable ROM code Security function.
Disable ROM code Security function.
High clock Fcpu = IHRC/4 = 2MHz.
High clock Fcpu = IHRC/8 = 1MHz.
High clock Fcpu = IHRC/16 = 0.5MHz.
High clock Fcpu = IHRC/32 = 0.25MHz.
Note1: In high noisy environment, set Watch_Dog as “Always_On” is strongly recommended.
Note2: Fcpu code option is only available for High Clock. Fcpu of slow mode is Flosc/4.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 27 V1.7
2.1.4 DATA MEMORY (RAM)
256 X 8-bit RAM
General purpose area
(Bank 0)
General purpose area
(Bank 1)

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 28 V1.7
2.1.5 SYSTEM REGISTER
2.1.5.1 SYSTEM REGISTER TABLE
0 1 2 3 4 5 6 7 8 9 A B C D E F
B - - - - - - - - P0M - - - - - -
2.1.5.2 SYSTEM REGISTER DESCRIPTION
Working register, @LH and ROM
addressing register
Working register, @YZ and ROM
addressing register
LCD mode register
R=
PFLAG =
RBANK =
LCDM2 =
Working register and ROM look-up data
buffer
ROM page and special flag register
Bank selection register
LCD mode register
Port 2 function control register
Port 3 function control register
Buzzer function control register
Voltage Regulators control register
PGIA input channel control register
PGIA mode selection register
Low Battery Detect Register
ADC high-byte data buffer
ADC medium-byte data buffer
Port N input/output mode register
INT0/INT1 edge selection register
Interrupt request register
Interrupt enable register
Timer 0 counting register
Timer/Counter 0 mode register
Timer/Counter 0 Counting register
Timer/Counter 0 auto-reload data buffer
STKP =
URRX =
UTXD =
@YZ =
STK0~STK7=
Stack pointer buffer
UART received control register
UART transmitted data buffer.
RAM YZ indirect addressing index pointer
Stack 0 ~ stack 7 Buffer
URTX =
URCR =
URXD =
@HL =
UART transmitter control register
UART baud rate control register
UART received data buffer.
RAM HL indirect addressing index pointer

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 29 V1.7
2.1.5.3 BIT DEFINITION of SYSTEM REGISTER

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 30 V1.7
Note:
1. To avoid system error, make sure to put all the “0” and “1” as it indicates in the above table.
2. All of register names had been declared in SN8ASM assembler.
3. One-bit name had been declared in SN8ASM assembler with “F” prefix code.
4. “b0bset”, “b0bclr”, ”bset”, ”bclr” instructions are only available to the “R/W” registers.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 31 V1.7
2.1.6 ACCUMULATOR
The ACC is an 8-bit 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
; Write a immediate data into ACC
; Write ACC data from BUF data memory
The system doesn’t store ACC and PFLAG value when interrupt executed. ACC and PFLAG data must be saved to
other data memories by program.
Example: Protect ACC and working registers.
; Define ACCBUF for store ACC data.
; Define PFLAGBUF for store PFLAG data.
; Save PFLAG register in a buffer.
; Restore PFLAG register from buffer.
; Restore ACC from buffer.
; Exit interrupt service vector
Note: To save and re-load ACC data, users must use “B0XCH” instruction, or else the PFLAG Register
might be modified by ACC operation.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 32 V1.7
2.1.7 PROGRAM FLAG
The PFLAG register contains the arithmetic status of ALU operation, C, DC, Z bits indicate the result status of ALU
operation.
Bit 2 C: Carry flag
1 = Addition with carry, subtraction without borrowing, rotation with shifting out logic “1”, comparison result
≥ 0.
0 = Addition without carry, subtraction with borrowing signal, rotation with shifting out logic “0”, comparison
result < 0.
Bit 1 DC: Decimal carry flag
1 = Addition with carry from low nibble, subtraction without borrow from high nibble.
0 = Addition without carry from low nibble, subtraction with borrow from high nibble.
Bit 0 Z: Zero flag
1 = The result of an arithmetic/logic/branch operation is zero.
0 = The result of an arithmetic/logic/branch operation is not zero.
Note: Refer to instruction set table for detailed information of C, DC and Z flags.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 33 V1.7
2.1.8 PROGRAM COUNTER
The program counter (PC) is a 11-bit binary counter separated into the high-byte 3 and the low-byte 8 bits. This
counter is responsible for pointing a location in order to fetch an instruction for kernel circuit. Normally, the program
counter is automatically incremented with each instruction during program execution.
Besides, it can be replaced with specific address by executing CALL or JMP instruction. When JMP or CALL instruction
is executed, the destination address will be inserted to bit 0 ~ bit 10.
- - - - - 0 0 0 0 0 0 0 0 0 0
ONE ADDRESS SKIPPING
There are nine instructions (CMPRS, INCS, INCMS, DECS, DECMS, BTS0, BTS1, B0BTS0, B0BTS1) with one
address skipping function. If the result of these instructions is true, the PC will add 2 steps to skip next instruction.
If the condition of bit test instruction is true, the PC will add 2 steps to skip next instruction.
; To skip, if Carry_flag = 1
; Move BUF0 value to ACC.
; To skip, if Zero flag = 0.
If the ACC is equal to the immediate data or memory, the PC will add 2 steps to skip next instruction.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 34 V1.7
If the destination increased by 1, which results overflow of 0xFF to 0x00, the PC will add 2 steps to skip next
instruction.
INCS instruction:
; Jump to C0STEP if ACC is not zero.
; Jump to C0STEP if BUF0 is not zero.
If the destination decreased by 1, which results underflow of 0x01 to 0x00, the PC will add 2 steps to skip next
instruction.
DECS instruction:
; Jump to C0STEP if ACC is not zero.
; Jump to C0STEP if BUF0 is not zero.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 35 V1.7
2.1.9 MULTI-ADDRESS JUMPING
Users can jump around the multi-address by either JMP instruction or ADD M, A instruction (M = PCL) to activate
multi-address jumping function. Program counter can’t carry to PCH when PCL overflow automatically after executing
addition instructions. Users have to take care program counter result and adjust PCH value by program. For jump table
or others applications, users have to calculate PC value to avoid PCL overflow making PC error and program executing
error.
Note: Program counter can’t carry to PCH when PCL overflow automatically after executing addition
instructions. Users have to take care program counter result and adjust PCH value by program.
Example: If PC = 0323H (PCH = 03H, PCL = 23H)
Example: If PC = 0323H (PCH = 03H, PCL = 23H)
; PCL = PCL + ACC, the PCH cannot be changed.
; If ACC = 0, jump to A0POINT
; ACC = 1, jump to A1POINT
; ACC = 2, jump to A2POINT
; ACC = 3, jump to A3POINT

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 36 V1.7
2.1.10 Y, Z REGISTERS
The Y and Z registers are the 8-bit buffers. There are three major functions of these registers.
can be used as general working registers
can be used as RAM data pointers with @YZ register
can be used as ROM data pointer with the MOVC instruction for look-up table
Example: Uses Y, Z register as the data pointer to access data in the RAM address 025H of bank0.
; To set RAM bank 0 for Y register
; To set location 25H for Z register
; To read a data into ACC
Example: Uses the Y, Z register as data pointer to clear the RAM data.
; Z = 7FH, the last address of the data memory area
; Z – 1, if Z= 0, finish the routine
; End of clear general purpose data memory area of bank 0

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 37 V1.7
2.1.11 H, L REGISTERS
The H and L registers are the 8-bit buffers. There are two major functions of these registers.
can be used as general working registers
can be used as RAM data pointers with @HL register
Example: Uses H, L register as the data pointer to access data in the RAM address 020H of bank0.
; To set RAM bank 0 for H register
; To set location 20H for L register
; To read a data into ACC
Example: Uses the H, L register as data pointer to clear the RAM data.
; L = 7FH, the last address of the data memory area
; L – 1, if Z= 0, finish the routine
; End of clear general purpose data memory area of bank 0

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 38 V1.7
2.1.12 R REGISTERS
R register is an 8-bit buffer. There are two major functions of the register.
Can be used as working register
For store high-byte data of look-up table
(MOVC instruction executed, the high-byte data of specified ROM address will be stored in R register and the
low-byte data will be stored in ACC).
Note: Please refer to the “LOOK-UP TABLE DESCRIPTION” about R register look-up table application.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD Page 39 V1.7
2.2 ADDRESSING MODE
2.2.1 IMMEDIATE ADDRESSING MODE
The immediate addressing mode uses an immediate data to set up the location in ACC or specific RAM.
Example: Move the immediate data 12H to ACC.
; To set an immediate data 12H into ACC.
Example: Move the immediate data 12H to R register.
; To set an immediate data 12H into R register.
Note: In immediate addressing mode application, the specific RAM must be 0x80~0x87 working register.
2.2.2 DIRECTLY ADDRESSING MODE
The directly addressing mode moves the content of RAM location in or out of ACC.
Example: Move 0x12 RAM location data into ACC.
; To get a content of RAM location 0x12 of bank 0 and save in
ACC.
Example: Move ACC data into 0x12 RAM location.
; To get a content of ACC and save in RAM location 12H of
bank 0.
2.2.3 INDIRECTLY ADDRESSING MODE
The indirectly addressing mode is to access the memory by the data pointer registers (Y/Z).
Example: Indirectly addressing mode with @HL register.
; To clear H register to access RAM bank 0.
; To set an immediate data 12H into L register.
; Use data pointer @HL reads a data from RAM location
Example: Indirectly addressing mode with @YZ register.
; To clear Y register to access RAM bank 0.
; To set an immediate data 12H into Z register.
; Use data pointer @YZ reads a data from RAM location

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 40
Version 1.7
2.3 STACK OPERATION
2.3.1 OVERVIEW
The stack buffer has 8-level. These buffers are designed to push and pop up program counter’s (PC) data when
interrupt service routine and “CALL” instruction are executed. The STKP register is a pointer designed to point active
level in order to push or pop up data from stack buffer. The STKnH and STKnL are the stack buffers to store program
counter (PC) data.
RET /
RETI
CALL /
INTERRUPT
STKP = 7
STKP = 6
STKP = 5
STKP = 4
STACK Level
STK7H
STK6H
STK5H
STK4H
STACK Buffer
High Byte
PCH
STKP
STK7L
STK6L
STK5L
STK4L
STACK Buffer
Low Byte
PCL
STKP
STKP - 1STKP + 1
STKP = 3
STKP = 2
STKP = 1
STKP = 0
STK3L
STK2L
STK1L
STK0L
STK3H
STK2H
STK1H
STK0H

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 41
Version 1.7
2.3.2 STACK REGISTERS
The stack pointer (STKP) is a 3-bit register to store the address used to access the stack buffer, 13-bit 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 (push) and reading from the top of stack (pop). Push
operation decrements the STKP and the pop operation increments each time. That makes the STKP always point to
the top address of stack buffer and write 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.
Bit[2:0] STKPBn: Stack pointer (n = 0 ~ 2)
Bit 7 GIE: Global interrupt control bit.
0 = Disable.
1 = Enable. Please refer to the interrupt chapter.
Example: Stack pointer (STKP) reset, we strongly recommended to clear the stack pointer in the
beginning of the program.
STKn = STKnH , STKnL (n = 7 ~ 0)

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 42
Version 1.7
2.3.3 STACK OPERATION EXAMPLE
The two kinds of Stack-Save operations refer to the stack pointer (STKP) and write the content of program counter (PC)
to the stack buffer are CALL instruction and interrupt service. Under each condition, the STKP decreases 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 the following table.
There are Stack-Restore operations correspond to each push operation to restore the program counter (PC). The RETI
instruction uses for interrupt service routine. The RET instruction is for CALL instruction. When a pop 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 the following table.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 43
Version 1.7
RESET
3.1 OVERVIEW
The system would be reset in three conditions as following.
Power on reset
Watchdog reset
Brown out reset
When any reset condition occurs, all system registers keep initial status, program stops and program counter is cleared.
After reset status released, the system boots up and program starts to execute from ORG 0.
Finishing any reset sequence needs some time. The system provides complete procedures to make the power on reset
successful. For different oscillator types, the reset time is different. That causes the VDD rise rate and start-up time of
different oscillator is not fixed. RC type oscillator’s start-up time is very short, but the crystal type is longer. Under client
terminal application, users have to take care the power on reset time for the master terminal requirement. The reset
timing diagram is as following.
VDD
VSS
Watchdog Normal Run
Watchdog Stop
System Normal Run
System Stop
LVD Detect Level
Watchdog
Overflow
Watchdog
Reset Delay
Time
Power On
Delay Time
Power
Watchdog Reset
System Status
3.2 POWER ON RESET
The power on reset depend no LVD operation for most power-up situations. The power supplying to system is a rising
curve and needs some time to achieve the normal voltage. Power on reset sequence is as following.
Power-up: System detects the power voltage up and waits for power stable.
System initialization: All system registers is set as initial conditions and system is ready.
Oscillator warm up: Oscillator operation is successfully and supply to system clock.
Program executing: Power on sequence is finished and program executes from ORG 0.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 44
Version 1.7
3.3 WATCHDOG RESET
Watchdog reset is a system protection. In normal condition, system works well and clears watchdog timer by program.
Under error condition, system is in unknown situation and watchdog can’t be clear by program before watchdog timer
overflow. Watchdog timer overflow occurs and the system is reset. After watchdog reset, the system restarts and
returns normal mode. Watchdog reset sequence is as following.
Watchdog timer status: System checks watchdog timer overflow status. If watchdog timer overflow occurs, the
system is reset.
System initialization: All system registers is set as initial conditions and system is ready.
Oscillator warm up: Oscillator operation is successfully and supply to system clock.
Program executing: Power on sequence is finished and program executes from ORG 0.
Watchdog timer application note is as following.
Before clearing watchdog timer, check I/O status and check RAM contents can improve system error.
Don’t clear watchdog timer in interrupt vector and interrupt service routine. That can improve main routine fail.
Clearing watchdog timer program is only at one part of the program. This way is the best structure to enhance the
watchdog timer function.
Note: Please refer to the “WATCHDOG TIMER” about watchdog timer detail information.
3.4 BROWN OUT RESET
3.4.1 BROWN OUT DESCRIPTION
The brown out reset is a power dropping condition. The power drops from normal voltage to low voltage by external
factors (e.g. EFT interference or external loading changed). The brown out reset would make the system not work well
or executing program error.
VDD
VSS
V1
V2
V3
System Work
Well Area
System Work
Error Area
Brown Out Reset Diagram
The power dropping might through the voltage range that’s the system dead-band. The dead-band means the power
range can’t offer the system minimum operation power requirement. The above diagram is a typical brown out reset
diagram. There is a serious noise under the VDD, and VDD voltage drops very deep. There is a dotted line to separate
the system working area. The above area is the system work well area. The below area is the system work error area
called dead-band. V1 doesn’t touch the below area and not effect the system operation. But the V2 and V3 is under the
below area and may induce the system error occurrence. Let system under dead-band includes some conditions.
DC application:
The power source of DC application is usually using battery. When low battery condition and MCU drive any loading,
the power drops and keeps in dead-band. Under the situation, the power won’t drop deeper and not touch the system
reset voltage. That makes the system under dead-band.
AC application:
In AC power application, the DC power is regulated from AC power source. This kind of power usually couples with AC
noise that makes the DC power dirty. Or the external loading is very heavy, e.g. driving motor. The loading operating

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 45
Version 1.7
induces noise and overlaps with the DC power. VDD drops by the noise, and the system works under unstable power
situation.
The power on duration and power down duration are longer in AC application. The system power on sequence protects
the power on successful, but the power down situation is like DC low battery condition. When turn off the AC power,
the VDD drops slowly and through the dead-band for a while.
3.4.2 THE SYSTEM OPERATING VOLTAGE DECSRIPTION
To improve the brown out reset needs to know the system minimum operating voltage which is depend on the system
executing rate and power level. Different system executing rates have different system minimum operating voltage.
The electrical characteristic section shows the system voltage to executing rate relationship.
Vdd (V)
System Rate (Fcpu)
System Mini.
Operating Voltage.
System Reset
Voltage.
Dead-Band Area
Normal Operating
Area
Reset Area
Normally the system operation voltage area is higher than the system reset voltage to VDD, and the reset voltage is
decided by LVD detect level. The system minimum operating voltage rises when the system executing rate upper even
higher than system reset voltage. The dead-band definition is the system minimum operating voltage above the system
reset voltage.
3.4.3 BROWN OUT RESET IMPROVEMENT
How to improve the brown reset condition? There are some methods to improve brown out reset as following.
LVD reset
Watchdog reset
Reduce the system executing rate
LVD reset:
VDD
VSS
System Normal Run
System Stop
LVD Detect Voltage
Power On
Delay Time
Power
System Status
Power is below LVD Detect
Voltage and System Reset.
The LVD (low voltage detector) is built-in Sonix 8-bit MCU to be brown out reset protection. When the VDD drops and
is below LVD detect voltage, the LVD would be triggered, and the system is reset. The LVD detect level is different by
each MCU. The LVD voltage level is a point of voltage and not easy to cover all dead-band range. Using LVD to
improve brown out reset is depend on application requirement and environment. If the power variation is very deep,
violent and trigger the LVD, the LVD can be the protection. If the power variation can touch the LVD detect level and
make system work error, the LVD can’t be the protection and need to other reset methods. More detail LVD information
is in the electrical characteristic section.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 46
Version 1.7
Watchdog reset:
The watchdog timer is a protection to make sure the system executes well. Normally the watchdog timer would be clear
at one point of program. Don’t clear the watchdog timer in several addresses. The system executes normally and the
watchdog won’t reset system. When the system is under dead-band and the execution error, the watchdog timer can’t
be clear by program. The watchdog is continuously counting until overflow occurrence. The overflow signal of
watchdog timer triggers the system to reset, and the system return to normal mode after reset sequence. This method
also can improve brown out reset condition and make sure the system to return normal mode.
If the system reset by watchdog and the power is still in dead-band, the system reset sequence won’t be successful
and the system stays in reset status until the power return to normal range.
Reduce the system executing rate:
If the system rate is fast and the dead-band exists, to reduce the system executing rate can improve the dead-band.
The lower system rate is with lower minimum operating voltage. Select the power voltage that’s no dead-band issue
and find out the mapping system rate. Adjust the system rate to the value and the system exits the dead-band issue.
This way needs to modify whole program timing to fit the application requirement.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 47
Version 1.7
SYSTEM CLOCK
4.1 OVERVIEW
The micro-controller is a dual clock system. There are high-speed clock and low-speed clock. The high-speed clock is
only generated from internal 8MHz high-speed RC oscillator circuit (IHRC 8MHz). The low-speed clock is generated
from internal RC oscillator circuit or external 32768Hz Crystal.
Both the high-speed clock and the low-speed clock can be system clock (Fosc). The system clock in slow mode is
divided by 4 to be the instruction cycle (Fcpu).
Normal Mode (High Clock): Fcpu = Fhosc / 4 = 2MHz. (Fhosc= 8MHz IHRC)
Fcpu = Fhosc / 8 = 1MHz. (Fhosc= 8MHz IHRC)
Fcpu = Fhosc / 16 = 500 kHz. (Fhosc= 8MHz IHRC)
Fcpu = Fhosc / 32 = 250 kHz. (Fhosc= 8MHz IHRC)
Slow Mode (Low Clock): Fcpu = Flosc/4. (Flosc= ILRC or 32768Hz)
4.2 CLOCK BLOCK DIAGRAM
Fhosc.
Flosc. Fcpu = Flosc/4
CPUM[1:0]
STPHX
Fosc
Fosc
CLKMD
Fcpu
÷32
÷16
÷8
÷4
Code Option
(High_Clk_Div)
Fhosc: System high clock source is from internal high RC (IHRC).
Flosc: System low clock source is from internal low RC (ILRC) or external 32k.
Fosc: System clock source.
Fcpu: Instruction cycle.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 48
Version 1.7
4.3 OSCM REGISTER
The OSCM register is an oscillator control register. It controls oscillator status, system mode.
Bit 1 STPHX: External high-speed oscillator control bit.
0 = IHRC free run.
1 = IHRC free run stop. Internal low-speed RC oscillator is still running.
Bit 2 CLKMD: System high/Low clock mode control bit.
0 = Normal (dual) mode. System clock is high clock.
1 = Slow mode. System clock is internal low clock if code option is IHRC.
Bit[4:3] CPUM[1:0]: CPU operating mode control bits.
00 = normal.
01 = sleep (power down) mode.
10 = green mode.
11 = reserved.
Example: Stop high-speed oscillator
Example: When entering the power down mode (sleep mode), both high-speed oscillator and internal
low-speed oscillator will be stopped.
; To stop IHRC and internal low-speed
; oscillator called power down mode (sleep mode).

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 49
Version 1.7
4.4 SYSTEM HIGH CLOCK
The system high clock is only from internal 8MHz oscillator RC type (IHRC). The system clock in normal mode is
divided by 4 ,8,16 or 32 controlled by “High_Clk_Div of code option”, to be the instruction cycle (Fcpu).
4.5 SYSTEM LOW CLOCK
The system low clock source is only from internal RC oscillator (ILRC).The system clock in slow mode is divided by 4
to be the instruction cycle (Fcpu).
The system low clock source is the internal low-speed oscillator built in the micro-controller. The low-speed oscillator
uses RC type oscillator circuit. The frequency is affected by the voltage and temperature of the system. In common
condition, the frequency of the RC oscillator is about 32 KHz at 3.2V. The relation between the RC frequency and
voltage is as the following figure.
The internal low RC supports watchdog clock source and system slow mode controlled by CLKMD.
Flosc = Internal low RC oscillator (about 32KHz@3.2V).
Slow mode Fcpu = Flosc / 4
The only one condition to stop ILRC is the system into power down mode with watchdog disable or enable. If watchdog
set “Always_On” and system into power down mode, the ILRC actives well and system will be reset until watchdog
overflow occuring.
Example: Stop internal low-speed oscillator by power down mode.
; To stop IHRC and ILRC or 32k crystal called power down
mode
Note: The internal low-speed clock can’t be turned off individually. It is controlled by CPUM0, CPUM) bits
of OSCM register.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 50
Version 1.7
4.5.1 SYSTEM CLOCK MEASUREMENT
Under design period, the users can measure system clock speed by software instruction cycle (Fcpu). This way is
useful in RC mode.
Example: Fcpu instruction cycle of external oscillator.
; Set P1.0 to be output mode for outputting Fcpu toggle signal.
; Output Fcpu toggle signal in low-speed clock mode.
; Measure the Fcpu frequency by oscilloscope.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 51
Version 1.7
SYSTEM OPERATION MODE
5.1 OVERVIEW
The chip is featured with low power consumption by switching around four different modes as following.
Normal mode (High-speed mode)
Slow mode (Low-speed mode)
Power-down mode (Sleep mode)
Green mode
Power Down Mode
(Sleep Mode)
Slow Mode
Green Mode
Normal Mode
CLKMD = 1
CLKMD = 0
P0 Wake-up Function Active.
CPUM1, CPUM0 = 01.
CPUM1, CPUM0 = 10.
P0 Wake-up Function Active.
T0/TC0 Timer Time Out.
ADC C onversion Complete.
P0 Wake-up Function Active.
T0/TC0 Timer Time Out.
ADC C onversion Complete.
System Mode Switching Diagram
Operating mode description
*Active if high clock still
running. (STPHX=0)
Refer to code option
description
* Active if high clock
still running. (STPHX=0)
**Active if TC0GN=1
*Active if high clock still
running. (STPHX=0)
**Active if TC0GN=1
Note_1: When system into green mode with conditions of UART function enable and TX or RX still
running, the system will be wakeup. @ICE MODE
Note_2: P04 and P05 can not wakeup IC when UART function enable. @Real chip
Note_3: When system into green mode with conditions of Code option IHRC_RTC function enable and
P06/P07 still running, the system will be wakeup. @ICE MODE

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 52
Version 1.7
5.2 SYSTEM MODE SWITCHING
Example: Switch normal/slow mode to power down (sleep) mode.
Note: During the sleep, only the wakeup pin and reset can wakeup the system back to the normal mode.
Example: Switch normal mode to slow mode.
;To set CLKMD = 1, Change the system into slow mode
;To stop external high-speed oscillator for power saving.
Example: Switch slow mode to normal mode (The IHRC oscillator is still running)
Example: Switch slow mode to normal mode (The IHRC oscillator stops)
If internal high clock stop and program want to switch back normal mode. It is necessary to delay at least 20ms for
external clock stable.
; Turn on the IHRC oscillator.
; If VDD = 3.2V, ILRC =32KHz (typical) will delay
; 0.125ms X 162 = 20.25ms for external clock stable
; Change the system back to the normal mode
Example: Switch normal/slow mode to green mode.
Note: If T0 timer wakeup function is disabled in the green mode, the wakeup pin P0 can wakeup the
system backs to the previous operation mode.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 53
Version 1.7
Example: Switch normal/slow mode to Green mode and enable T0 wakeup function.
; Set T0 timer wakeup function.
; To disable T0 interrupt service
; To set T0 clock = Fcpu / 64
; To set T0C initial value = 74H (To set T0 interval = 10 ms)
; To disable T0 interrupt service
; To clear T0 interrupt request
Note: During the green mode with T0 wake-up function, the wakeup pins and T0 can wakeup the system
back to the last mode. T0 wake-up period is controlled by program and T0EN must be set.
Example: Switch normal/slow mode to Green mode and enable ADC wakeup function.
; Set ADC timer wakeup function.
; To Turn On all analog voltage regulators.
; Go into green mode with high clock running
Note_1: when system into green mode with conditions of ADC function enable and high clock still
running, the system will be wakeup when ADC conversion complete.
Note_2: The ADC green mode wakeup function is disable when ADCEN=0 or stop high clock (STPHX=1)
is set before into green mode.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 54
Version 1.7
5.3 WAKEUP
5.3.1 OVERVIEW
Under power down mode (sleep mode) or green mode, program doesn’t execute. The wakeup trigger can wake the
system up to normal mode or slow mode. The wakeup trigger sources are external trigger (P0 level change) and
internal trigger (T0 timer overflow and ADC conversion complete).
Power down mode is waked up to normal mode. The wakeup trigger is only external trigger (P0 level change)
Green mode is waked up to last mode (normal mode or slow mode). The wakeup triggers are external trigger (P0
level change) and internal trigger (T0 timer overflow and ADC conversion complete).
5.3.2 WAKEUP TIME
When the system is in power down mode (sleep mode), the high clock oscillator stops. When waked up from power
down mode, MCU waits for 64 internal high-speed RC oscillator (IHRC) clocks as the wakeup time to stable the
oscillator circuit. After the wakeup time, the system goes into the normal mode.
Note: Wakeup from green mode is no wakeup time because the clock doesn’t stop in green mode.
The value of the power down wakeup time is as the following.
The Wakeup time = 1/Fhosc * 64 (sec) + high clock start-up time
Note: The high clock start-up time is depended on the VDD. In general, high clock start-up time will be
several micro-second (us) at VDD=3V.
Example: The system is waked up from power down (sleep mode) by P0 level chande. After the
wakeup time, the system goes into normal mode. The wakeup time is as the following.
The wakeup time = 1/Fhosc * 64 = 8us (Fhosc = 8MHz)
The total wakeup time = 8us + oscillator start-up time (5us)

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 55
Version 1.7
INTERRUPT
6.1 OVERVIEW
This MCU provides five interrupt sources, including three internal interrupt (T0/TC0/ADC) and two external interrupt
(INT0/UART). The external interrupt can wakeup the chip while the system is switched from power down mode to
high-speed normal mode, and interrupt request is latched until return to normal mode. Once interrupt service is
executed, the GIE bit in STKP register will clear to “0” for stopping other interrupt request. On the contrast, when
interrupt service exits, the GIE bit will set to “1” to accept the next interrupts’ request. All of the interrupt request signal s
are stored in INTRQ register.
INTEN Interrupt Enable Register
Interrupt
Enable
Gating
INTRQ
6-Bit
Latchs
Interrupt Vector Address (0008H)
Global Interrupt Request Signal
ADC Out
ADCIRQ
UTXIRQ
INT1 Trigger
T0 Time Out
TC0 Time Out
UART Receive END
UART Transmit END
P01IRQ
T0IRQ
TC0IRQ
URXIRQ
INT0 Trigger
P00IRQ
Note: The GIE bit must enable during all interrupt operation.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 56
Version 1.7
6.2 INTEN INTERRUPT ENABLE REGISTER
INTEN is the interrupt request control register including four internal interrupts, two external interrupts enable control
bits. One of the register to be set “1” is to enable the interrupt request function. Once of the int errupt occur, the stack is
incremented and program jump to ORG 8 to execute interrupt service routines. The program exits the interrupt service
routine when the returning interrupt service routine instruction (RETI) is executed.
Bit 0 P00IEN: External P0.0 interrupt control bit.
0 = Disable INT0 interrupt function.
1 = Enable INT0 interrupt function.
Bit 1 P01IEN: External P0.1 interrupt control bit.
0 = Disable INT1 interrupt function.
1 = Enable INT1 interrupt function.
Bit 2 UTXIEN: UART transmit interrupt control bit.
0 = Disable UART transmit interrupt function.
1 = Enable UART transmit interrupt function.
Bit 3 URXIEN: UART receive interrupt control bit.
0 = Disable UART receive interrupt function.
1 = Enable UART receive interrupt function.
Bit 4 T0IEN: T0 timer interrupt control bit.
0 = Disable T0 interrupt function.
1 = Enable T0 interrupt function.
Bit 5 TC0IEN: TC0 timer interrupt control bit.
0 = Disable TC0 interrupt function.
1 = Enable TC0 interrupt function.
Bit 7 ADCIEN: ADC interrupt control bit.
0 = Disable ADC interrupt function.
1 = Enable ADC interrupt function.
6.3 INTRQ INTERRUPT REQUEST REGISTER
INTRQ is the interrupt request flag register. The register includes all interrupt request indication flags. Each one of the
interrupt requests occurs, the bit of the INTRQ register would be set “1”. The INTRQ value needs to be clear by
programming after detecting the flag. In the interrupt vector of program, users know the any interrupt requests
occurring by the register and do the routine corresponding of the interrupt request.
Bit 0 P00IRQ: External P0.0 interrupt request bit.
0 = Non INT0 interrupt request.
1 = INT0 interrupt request.
Bit 1 P01IRQ: External P0.1 interrupt request bit.
0 = Non INT1 interrupt request.
1 = INT1 interrupt request.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 57
Version 1.7
Bit 2 UTXIRQ: UART transmit interrupt request flag..
0 = None UART transmit interrupt request..
1 = UART transmit interrupt request.
Bit 3 URXIRQ: UART receive interrupt request flag.
0 = None UART receive interrupt request..
1 = UART receive interrupt request.
Bit 4 T0IRQ: T0 timer interrupt request control bit.
0 = Non T0 interrupt request.
1 = T0 interrupt request.
Bit 5 TC0IRQ: TC0 timer interrupt request control bit.
0 = Non TC0 interrupt request.
1 = TC0 interrupt request.
Bit 7 ADCIRQ: ADC interrupt request controls bit.
0 = Non ADC interrupt request.
1 = ADC interrupt request.
6.4 GIE GLOBAL INTERRUPT OPERATION
GIE is the global interrupt control bit. All interrupts start work after the GIE = 1 It is necessary for interrupt service
request. One of the interrupt requests occurs, and the program counter (PC) points to the interrupt vector (ORG 8) and
the stack add 1 level.
Bit 7 GIE: Global interrupt control bit.
0 = Disable global interrupt.
1 = Enable global interrupt
Bit [3:0] STKPBn: Stack pointer, n = 0~3.
Example: Set global interrupt control bit (GIE).
Note: The GIE bit must enable during all interrupt operation.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 58
Version 1.7
6.5 PUSH, POP ROUTINE
When any interrupt occurs, system will jump to ORG 8 and execute interrupt service routine. It is necessary to save
ACC, PFLAG data. The chip doesn’t have any special instructions to process ACC, PFLAG registers when into
interrupt service routine. Users have to save ACC, PFLAG by program, Using “B0XCH” to save/load ACC buffer,
“B0MOV” to save/load PFLAG and avoid main routine error after interrupt service routine finishing.
Note: To save/load ACC data, users must be “B0XCH” instruction, or else the PFLAG register might be
modified by ACC operation.
Example: Store ACC and PAFLG data by program when interrupt service routine executed.
; ACCBUF is ACC data buffer.
; PFLAGBUF is PFLAG data buffer.
; Save ACC to ACCBUF buffer.
; Save PFLAG to PFLAGBUF buffer.
; Load PFLAG from PFLAGBUF buffer.
; Load ACC from ACCBUF buffer.
; Exit interrupt service vector

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 59
Version 1.7
6.6 EXTERNAL INTERRUPT OPERATION
When the INT0/INT1 trigger occurs, the P00IRQ/P01IRQ will be set to “1” no matter the P00IEN/P01IEN is enable or
disable. If the P00IEN/P01IEN = 1 and the trigger event P00IRQ/P01IRQ is also set to be “1”. As the result, the
system will execute the interrupt vector (ORG 8). If the P00IEN/P01IEN = 0 and the trigger event P00IRQ/P01IRQ is
still set to be “1”. Moreover, the system won’t execute interrupt vector even when the P00IRQ/P01IRQ is set to be “1”.
Users need to be cautious with the operation under multi-interrupt situation.
Note: The interrupt trigger direction of P0.0/P0.1 is control by PEDGE register.
Bit[4:3] P00G[1:0]: P0.0 interrupt trigger edge control bits.
00 = reserved.
01 = rising edge.
10 = falling edge.
11 = rising/falling bi-direction (Level change trigger).
Bit[6:5] P01G[1:0]: P0.1 interrupt trigger edge control bits.
00 = reserved.
01 = rising edge.
10 = falling edge.
11 = rising/falling bi-direction (Level change trigger).
Example: Setup INT0 interrupt request and bi-direction edge trigger.
; Set INT0 interrupt trigger as bi-direction edge.
; Enable INT0 interrupt service
; Clear INT0 interrupt request flag
Example: INT0 interrupt service routine.
… ; Push routine to save ACC and PFLAG to buffers.
; P00IRQ = 0, exit interrupt vector
… ; INT0 interrupt service routine
… ; Pop routine to load ACC and PFLAG from buffers.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 60
Version 1.7
6.7 MULTI-INTERRUPT OPERATION
Under certain condition, the software designer uses more than one interrupt requests. Processing multi-interrupt
request requires setting the priority of the interrupt requests. The IRQ flags of interrupts are controlled by the interrupt
event. Nevertheless, the IRQ flag “1” doesn’t mean the system will execute the interrupt vector. In addition, which
means the IRQ flags can be set “1” by the events without enable the interrupt. Once the event occurs, the IRQ will be
logic “1”. The IRQ and its trigger event relationship is as the below table.
Trigger Event Description
P0.0 trigger controlled by PEDGE
P0.1 trigger controlled by PEDGE
For multi-interrupt conditions, two things need to be taking care of. One is to set the priority for these interrupt requests.
Two is using IEN and IRQ flags to decide which interrupt to be executed. Users have to check interrupt control bit and
interrupt request flag in interrupt routine.
Example: Check the interrupt request under multi-interrupt operation
; Push routine to save ACC and PFLAG to buffers.
; Check INT0 interrupt request
; Jump check to next interrupt
; Jump check to next interrupt
; Check T0 interrupt request
; Jump check to next interrupt
; Jump to T0 interrupt service routine
; Check TC0 interrupt request
; Jump check to next interrupt
; Jump to TC0 interrupt service routine
; Check ADC interrupt request
; Jump check to next interrupt
; Jump to ADC interrupt service routine

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 61
Version 1.7
; Check UTX interrupt request
; Jump check to next interrupt
; Jump to UART TX interrupt service routine
; Check URX interrupt request
; Jump to UART RX interrupt service routine
; Pop routine to load ACC and PFLAG from buffers.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 62
Version 1.7
I/O PORT
7.1 I/O PORT MODE
The port direction is programmed by PnM register. All I/O ports can select input or output direction.
Bit[7:0] PnM[7:0]: Pn mode control bits. (n = 0~1).
0 = Pn is input mode.
1 = Pn is output mode.
Note:
1. Users can program them by bit control instructions (B0BSET, B0BCLR).
2. Port 0 ~ Port 3 are bi-direction I/O port.
3. Port P2 ~ P3 is high-sink I/O Pin, It can drive seven-segment display.
7.2 I/O PIN SHARE WITH LCD FUNCTION
The microcontroller builds in LCD functions. The LCD driver output pins share with GPIO function, which can be
configured by setting PxSEG registers.
Bit[7:0] P2nSEG: Port 2 function control bit
0 = Set as LCD function Pin. (SEG8~SEG15)
1 = Set as IO function Pin. (P27~P20)

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 63
Version 1.7
Bit[7:0] P3nSEG: Port 3 function control bit
0 = Set as LCD function Pin. (SEG0~SEG7)
1 = Set as IO function Pin. (P37~P30)
Example: I/O or LCD function selecting
; Set P2 ports to be LCD mode.
; Set P3 ports to be LCD mode.
; Set P2 ports to be I/O mode.
; Set P34~P37 ports to be LCD mode.
; Set P30~P33 ports to be I/O mode.
Example: I/O mode selecting
; Set all ports to be input mode.
; Set all ports to be output mode.
; Set P1.0 to be input mode.
; Set P1.0 to be output mode.
; Set P2.0 to be input mode.
; Set P3.0 to be output mode.
Note:
1. P2/P3 I/O is share pin with LCD function
2. Port P2 ~ P3 is high-sink I/O Pin, It can drive seven-segment display.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 64
Version 1.7
7.3 I/O PULL UP REGISTER
Bit [7:0] Pn0R~Pn7R: I/O port pull-up resistor control bit. (n = 0~1).
0 = Disable pull-up resistor.
1 = Enable pull-up resistor.
Note: PnUR is Write Only Register.
Example: I/O Pull up Register
; Enable Port1 Pull-up register,

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 65
Version 1.7
7.4 I/O PORT DATA REGISTER
Bit [7:0] Pn0~Pn7: I/O port data buffer. (n = 0~1).
0 = Input low or output low.
1 = Input high or output high.
Example: Read data from input port.
Example: Write data to output port.
; Write data FFH to all Port.
Example: Write one bit data to output port.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 66
Version 1.7
7.5 High-sink current I/O PORT
The SN8P2977 has a built-in High sink I/O to support drive seven-segment display from port P2/P3 and it with typical
60mA current sinking capacity. when the pin is LOW, it can only accept that much current flowing to ground.
When P2/P3 is high-current sink I/O mode, Advisable AI3/R+ pin to AVDDR, AI4/R- pin to ground and ADC reference
voltage set as External reference, avoid high current sink grounding influence ADC operation.
32768Hz
20p
ON/OFF
Key 1
Key 2
20p
Optional for RTC Clock
Weight Scale Application Circuit
LQFP48-Pin, LED 4*8
10uf
1uf
LED
BLE
Module
VBAT
SN8P 2977
SEG1/P36
SEG0/P37
COM3
COM2
COM1
COM0
VLCD/VPP
AVDDR
AVE
AVSS
AVDD
NC
A
I
1
A
I
2
A
I
3
/
R
+
A
I
4
/
R
-
NCNCNCN
C
P
1
0
/
L
B
T
0
P
1
1
/
P
W
M
0
P
0
0
/
I
N
T
0
P
0
1
/
I
N
T
1
P21/SEG14
P20/SEG15
NC
NC
DVDD
DVSS
LXOUT / P 07
LXIN / P06
RX / P05
TX / P04
P03
P02
P
3
5
/
S
E
G
2
P
3
4
/
S
E
G
3
P
3
3
/
S
E
G
4
P
3
2
/
S
E
G
5
P
3
1
/
S
E
G
6
P
3
0
/
S
E
G
7
P
2
7
/
S
E
G
8
P
2
6
/
S
E
G
9
P
2
5
/
S
E
G
1
0
P
2
4
/
S
E
G
1
1
P
2
3
/
S
E
G
1
2
P
2
2
/
S
E
G
1
3
1uf
VBAT
0.1uf
Load Cell
AVDDR
VBAT
VBAT
0.1uf
AVDDR
Note: In High-current sink I/O mode, Recommend ADC reference voltage set external reference
IRVS[3:0]=11xx and AI3/R+ pin to AVDDR, AI4/R- pin to AVSS.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 67
Version 1.7
TIMERS
8.1 WATCHDOG TIMER
The watchdog timer (WDT) is a binary up counter designed for monitoring program execution. If the program goes into
the unknown status by noise interference, WDT overflow signal raises and resets MCU. Watchdog clock controlled by
code option and the clock source is internal low-speed oscillator (32 KHz @3V).
Watchdog overflow time = 16384/ Internal Low-Speed oscillator (sec).
1. Note:
1. If watchdog is “Always_On” mode, it keeps running event under power down mode or green
mode.
2. For S8KD ICE simulation, clear watchdog timer using “@RST_WDT” macro is necessary. Or
the S8KD watchdog would be error.
Watchdog clear is controlled by WDTR register. Moving 0x5A data into WDTR is to reset watchdog timer.
Example: An operation of watchdog timer is as following. To clear the watchdog timer counter in the top
of the main routine of the program.
; Clear the watchdog timer.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 68
Version 1.7
Example: Clear watchdog timer by @RST_WDT macro.
; Clear the watchdog timer.
Watchdog timer application note is as following.
Before clearing watchdog timer, check I/O status and check RAM contents can improve system error.
Don’t clear watchdog timer in interrupt vector and interrupt service routine. That can improve main routine fail.
Clearing watchdog timer program is only at one part of the program. This way is the best structure to enhance the
watchdog timer function.
Example: An operation of watchdog timer is as following. To clear the watchdog timer counter in the top of the
main routine of the program.
; I/O or RAM error. Program jump here and don’t
; clear watchdog. Wait watchdog timer overflow to reset IC.
; I/O and RAM are correct. Clear watchdog timer and
; Only one clearing watchdog timer of whole program.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 69
Version 1.7
8.2 TIMER 0 (T0)
8.2.1 OVERVIEW
The T0 is an 8-bit binary up timer and event counter. If T0 timer occurs an overflow (from FFH to 00H), it will continue
counting and issue a time-out signal to trigger T0 interrupt to request interrupt service.
The main purposes of the T0 timer are as following.
8-bit programmable up counting timer: Generates interrupts at specific time intervals based on the selected
clock frequency.
RTC timer: Generates interrupts at real time intervals based on the selected clock source. RTC function is only
available in code option = "IHRC_RTC".
Green mode wakeup function: T0 can be green mode wake-up time as T0ENB = 1. System will be wake-up by
T0 time out.
Fcpu
T0 Rate
(Fcpu/2~Fcpu/256)
T0ENB
CPUM0,1
T0C 8-Bit Binary Up Counting Counter
T0 Time Out
Load
Internal Data Bus
T0ENB
RTC
T0TB
Note: In RTC mode, the T0 interval time is fixed at 0.5 sec and isn’t controlled by T0C.
Bit 0 T0TB: RTC clock source control bit.
0 = Disable RTC (T0 clock source from Fcpu).
1 = Enable RTC, T0 will be 0.5 sec RTC (Low clock must be 32768 crystal).
Bit 1 TC0GN: Enable TC0 Green mode wake up function
0 = Disable.
1 = Enable.
Bit 2 TC0X8: TC0 internal clock source control bit.
0 = TC0 internal clock source is Fcpu. TC0RATE is from Fcpu/2~Fcpu/256.
1 = TC0 internal clock source is Fosc. TC0RATE is from Fosc/1~Fosc/128.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 70
Version 1.7
Bit [6:4] T0RATE[2:0]: T0 internal clock select bits.
000 = fcpu/256.
001 = fcpu/128.
…
110 = fcpu/4.
111 = fcpu/2.
Bit 7 T0ENB: T0 counter control bit.
0 = Disable T0 timer.
1 = Enable T0 timer.
Note: In RTC mode, the T0 interval time is fixed at 0.5 sec and T0C is 256 counts.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 71
Version 1.7
8.2.3 T0C COUNTING REGISTER
T0C is an 8-bit counter register for T0 interval time control.
The equation of T0C initial value is as following.
T0C initial value = 256 - (T0 interrupt interval time * input clock)
Example: To set 10ms interval time for T0 interrupt. High clock is 8MHz IHRC. Fcpu=Fosc/8. Select
T0RATE=010 (Fcpu/64).
T0C initial value = 256 - (T0 interrupt interval time * input clock)
= 256 - (10ms * 8MHz / 8 / 64)
= 256 - (10-2 * 8* 106 / 8 / 64)
= 100
= 64H
The basic timer table interval time of T0.
High speed mode (Fcpu = 8MHz / 8)
Low speed mode (Fcpu = 32768Hz / 4)
Note: In RTC mode, T0C is 256 counts and generatesT0 0.5 sec interval time. Don’t change T0C
value in RTC mode.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 72
Version 1.7
8.2.4 T0 TIMER OPERATION SEQUENCE (High_Clk = IHRC)
T0 timer operation sequence of setup T0 timer is as following.
Stop T0 timer counting, disable T0 interrupt function and clear T0 interrupt request flag.
; T0 interrupt function is disabled.
; T0 interrupt request flag is cleared.
;The T0 rate control bits exist in bit4~bit6 of T0M. The
; value is from x000xxxxb~x111xxxxb.
Set T0 clock source from Fcpu or RTC.
; Select T0 Fcpu clock source.
; Select T0 RTC clock source.
Set T0 interrupt interval time.
Set T0 timer function mode.
; Enable T0 interrupt function.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 73
Version 1.7
8.2.5 RTC OPERATION SEQUENCE (High_Clk =“IHRC_RTC” and “T0TB = 1”)
T0 timer with RTC operation sequence (High_Clk code option = “IHRC_RTC” and “T0TB = 1”) of setup T0 timer is
as following.
Declare buffer.
Stop T0 timer counting, disable T0 interrupt function and clear T0 interrupt request flag.
; T0 interrupt function is disabled.
; T0 interrupt request flag is cleared.
Set T0 clock source from RTC.
; Select T0 RTC clock source.
Set T0 interrupt interval time.
; Clear T0FLAG before execute Main routing.
Disable T0 timer function mode.
; Disable T0 interrupt function.
Enable T0 timer with RTC function.
Execute MAIN routing polling T0 timer.(Execute MAIN routing interval time is not more than 200ms).
; Check T0C value overflow
; Check T0C overflow Flag and update time.
CKT_T0CVAL sub-routing (Check T0C value status).

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 74
Version 1.7
; If FC = 1, jmp EXIT_CKTT0CVAL
; Set T0IRQFLAG (T0C counts overflow.).
CKT_T0FLAG sub-routing (Check T0 timer overflow flag).
; Call delay time = over 1/32.768ms (for RTC limit).
Into green mode before.
; Check T0C value overflow
; Check T0C overflow Flag and update time.
Process green mode after wakeup.
; Check other trigger wakeup source.
; Call delay time = over 1/32.768ms (for RTC limit).

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 75
Version 1.7
8.3 TIMER/COUNTER 0 (TC0)
8.3.1 OVERVIEW
The TC0 is an 8-bit binary up counting timer. TC0 has two clock sources including internal clock and external clock for
counting a precision time. The internal clock source is from Fcpu or Fosc controlled by TC0X8 flag to get faster clock
source (Fosc). The external clock is INT0 from P0.0 pin (Falling edge trigger). Using TC0M register selects TC0C’s
clock source from internal or external. If TC0 timer occurs an overflow, it will continue counting and issue a time-out
signal to trigger TC0 interrupt to request interrupt service. TC0 overflow time is 0xFF to 0X00 normally. Under PWM
mode, TC0 overflow is decided by PWM cycle controlled by ALOAD0 and TC0OUT bits.
The main purposes of the TC0 timer is as following.
8-bit programmable up counting timer: Generates interrupts at specific time intervals based on the selected
clock frequency.
External event counter: Counts system “events” based on falling edge detection of external clock signals at the
INT0 input pin.
Green mode wake-up function: TC0 can be green mode wake-up timer. System will be wake-up by TC0 time
out.
Buzzer output
PWM output
Fcpu
TC0 Rate
(Fcpu/2~Fcpu/256)
Fosc
TC0 Rate
(Fosc/1~Fosc/128)
TC0X8
INT0
(Schmitter Trigger)
TC0CKS TC0ENB
CPUM0,1
TC0C
8-Bit Binary Up
Counting Counter
TC0R Reload
Data Buffer
Compare
ALOAD0
R
S
TC0 Time Out
Auto. Reload
TC0 / 2
Buzzer
Internal P1.1 I/O Circuit
P1.1
PWM
PWM0OUT
TC0OUT
ALOAD0, TC0OUT
Load

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 76
Version 1.7
8.3.2 TC0M MODE REGISTER
Bit 0 PWM0OUT: PWM output control bit.
0 = Disable PWM output.
1 = Enable PWM output. PWM duty controlled by TC0OUT, ALOAD0 bits.
Bit 1 TC0OUT: TC0 time out toggle signal output control bit. Only valid when PWM0OUT = 0.
0 = Disable, P1.1 is I/O function.
1 = Enable, P1.1 is output TC0OUT signal.
Bit 2 ALOAD0: Auto-reload control bit. Only valid when PWM0OUT = 0.
0 = Disable TC0 auto-reload function.
1 = Enable TC0 auto-reload function.
Bit 3 TC0CKS: TC0 clock source select bit.
0 = Internal clock (Fcpu or Fosc).
1 = External clock from P0.0/INT0 pin.
Bit [6:4] TC0RATE[2:0]: TC0 internal clock select bits.
Bit 7 TC0ENB: TC0 counter control bit.
0 = Disable TC0 timer.
1 = Enable TC0 timer.
1.
Note: When TC0CKS=1, TC0 became an external event counter and TC0RATE is useless. No more P0.0
interrupt request will be raised. (P0.0IRQ will be always 0).

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 77
Version 1.7
8.3.3 TC0X8, TC0GN FLAGS
Bit 0 T0TB: RTC clock source control bit.
0 = Disable RTC (T0 clock source from Fcpu).
1 = Enable RTC.
Bit 1 TC0GN: Enable TC0 Green mode wake up function
0 = Disable.
1 = Enable.
Bit 2 TC0X8: TC0 internal clock source control bit.
0 = TC0 internal clock source is Fcpu. TC0RATE is from Fcpu/2~Fcpu/256.
1 = TC0 internal clock source is Fosc. TC0RATE is from Fosc/1~Fosc/128.
Bit [6:4] T0RATE[2:0]: T0 internal clock select bits.
000 = fcpu/256.
001 = fcpu/128.
…
110 = fcpu/4.
111 = fcpu/2.
Bit 7 T0ENB: T0 counter control bit.
0 = Disable T0 timer.
1 = Enable T0 timer.
2.
Note: Under TC0 event counter mode (TC0CKS=1), TC0X8 bit and TC0RATE are useless.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 78
Version 1.7
8.3.4 TC0C COUNTING REGISTER
TC0C is an 8-bit counter register for TC0 interval time control.
The equation of TC0C initial value is as following.
TC0C initial value = 256 - (TC0 interrupt interval time * input clock)
Example: To set 10ms interval time for TC0 interrupt. TC0 clock source is Fcpu (TC0KS=0, TC0X8=0) and
no PWM output (PWM0=0). High clock is external 8MHz. Fcpu=Fosc/8. Select TC0RATE=010 (Fcpu/64).
TC0C initial value = N - (TC0 interrupt interval time * input clock)
= 256 - (10ms * 8MHz / 8 / 64)
= 256 - (10-2 * 8 * 106 / 8 / 64)
= 100
= 64H
The basic timer table interval time of TC0, TC0X8 = 0.
High speed mode (Fcpu = 8MHz / 8)
Low speed mode (Fcpu = 32768Hz / 4)
The basic timer table interval time of TC0, TC0X8 = 1.
High speed mode (Fcpu = 8MHz / 8)
Low speed mode (Fcpu = 32768Hz / 4)

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 79
Version 1.7

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 80
Version 1.7
8.3.5 TC0R AUTO-LOAD REGISTER
TC0 timer is with auto-load function controlled by ALOAD0 bit of TC0M. When TC0C overflow occurring, TC0R value
will load to TC0C by system. It is easy to generate an accurate time, and users don’t reset TC0C during interrupt
service routine.
3.
Note: Under PWM mode, auto-load is enabled automatically. The ALOAD0 bit is selecting overflow
boundary.
The equation of TC0R initial value is as following.
TC0R initial value = N - (TC0 interrupt interval time * input clock)
N is TC0 overflow boundary number. TC0 timer overflow time has six types (TC0 timer, TC0 event counter, TC0 Fcpu
clock source, TC0 Fosc clock source, PWM mode and no PWM mode). These parameters decide TC0 overflow time
and valid value as follow table.
Example: To set 10ms interval time for TC0 interrupt. TC0 clock source is Fcpu (TC0KS=0, TC0X8=0) and
no PWM output (PWM0=0). High clock is external 8MHz. Fcpu=Fosc/8. Select TC0RATE=010 (Fcpu/64).
TC0R initial value = N - (TC0 interrupt interval time * input clock)
= 256 - (10ms * 8MHz / 8 / 64)
= 256 - (10-2 * 8 * 106 / 8 / 64)
= 100
= 64H

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 81
Version 1.7
8.3.6 TC0 CLOCK FREQUENCY OUTPUT (BUZZER)
Buzzer output (TC0OUT) is from TC0 timer/counter frequency output function. By setting the TC0 clock frequency, the
clock signal is output to P1.1 and the P1.1 general purpose I/O function is auto-disable. The TC0OUT frequency is
divided by 2 from TC0 interval time. TC0OUT frequency is 1/2 TC0 frequency. The TC0 clock has many combinations
and easily to make difference frequency. The TC0OUT frequency waveform is as following.
1 2 3 4
1 2 3 4
TC0 Overflow Clock
TC0OUT (Buzzer) Output Clock
Example: Setup TC0OUT output from TC0 to TC0OUT (P1.1). The external high-speed clock is 8MHz.
(Fcpu=Fosc/8) The TC0OUT frequency is 0.5KHz. Because the TC0OUT signal is divided by 2, set the TC0
clock to 1KHz. The TC0 clock source is from external oscillator clock. T0C rate is Fcpu/4. The
TC0RATE2~TC0RATE1 = 110. TC0C = TC0R = 6.
; Set the TC0 rate to Fcpu/4
; Set the auto-reload reference value
; Enable TC0 output to P1.1 and disable P1.1 I/O function
; Enable TC0 auto-reload function
4.
Note: Buzzer output is enable, and “PWM0OUT” must be “0”.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 82
Version 1.7
8.3.7 TC0 TIMER OPERATION SEQUENCE
TC0 timer operation includes timer interrupt, event counter, TC0OUT and PWM. The sequence of setup TC0 timer is
as following.
Stop TC0 timer counting, disable TC0 interrupt function and clear TC0 interrupt request flag.
; TC0 timer, TC0OUT and PWM stop.
; TC0 interrupt function is disabled.
; TC0 interrupt request flag is cleared.
Set TC0 timer rate. (Besides event counter mode.)
;The TC0 rate control bits exist in bit4~bit6 of TC0M. The
; value is from x000xxxxb~x111xxxxb.
; TC0 interrupt function is disabled.
Set TC0 timer clock source.
; Select TC0 internal / external clock source.
; Select TC0 internal clock source.
; Select TC0 external clock source.
; Select TC0 Fcpu / Fosc internal clock source .
; Select TC0 Fcpu internal clock source.
; Select TC0 Fosc internal clock source.
5.
Note: TC0X8 is useless in TC0 external clock source mode.
Set TC0 timer auto-load mode.
; Enable TC0 auto reload function.
; Disable TC0 auto reload function.
Set TC0 interrupt interval time, TC0OUT (Buzzer) frequency or PWM duty cycle.
; Set TC0 interrupt interval time, TC0OUT (Buzzer) frequency or PWM duty.
; TC0C and TC0R value is decided by TC0 mode.
; Set TC0R value under auto reload mode or PWM mode.
Set TC0 timer function mode.
; Enable TC0 interrupt function.
; Enable TC0OUT (Buzzer) function.
; Enable TC0 green mode wake-up function.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 83
Version 1.7
8.4 PWM0 MODE
8.4.1 OVERVIEW
PWM function is generated by TC0 timer counter and output the PWM signal to PWM0OUT pin (P1.1). The 8-bit
counter counts modulus 256 bits. The value of the 8-bit counter (TC0C) is compared to the contents of the reference
register (TC0R). When the reference register value (TC0R) is equal to the counter value (TC0C), the PWM output goes
low. When the counter reaches zero, the PWM output is forced high. The ratio (duty) of the PWM0 output is TC0R/256.
MAX. PWM
Frequency
(Fcpu = 8MHz)
The Output duty of PWM is with different TC0R. Duty range is from 0/256~255/256.
TC0 Clock
TC0R=00H
TC0R=01H
TC0R=80H
TC0R=FFH
0 1 128 254 255
…… ……
0 1 128 254 255
…… ……
Low
Low
Low
High
High
Low
High

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 84
Version 1.7
8.4.2 TC0IRQ AND PWM DUTY
In PWM mode, the frequency of TC0IRQ is depended on PWM duty range. From following diagram, the TC0IRQ
frequency is related with PWM duty.
8.4.3 PWM PROGRAM EXAMPLE
Example: Setup PWM0 output from TC0 to PWM0OUT (P1.1). The external high-speed oscillator clock is
8MHz. Fcpu = Fosc/8. The duty of PWM is 30/256. The PWM frequency is about 1KHz. The PWM clock
source is from external oscillator clock. TC0 rate is Fcpu/4. The TC0RATE2~TC0RATE1 = 110. TC0C =
TC0R = 30.
; Set the TC0 rate to Fcpu/4
; Set the PWM duty to 30/256
; Enable PWM0 output to P1.1 and disable P1.1 I/O function
Note: The TC0R is write-only register. Don’t process them using INCMS, DECMS instructions.
Example: Modify TC0R registers’ value.
; Input a number using B0MOV instruction.
; Get the new TC0R value from the BUF0 buffer defined by
Note: The PWM can work with interrupt request.
TC0 Overflow,
TC0IRQ = 1
0xFF
TC0C Value
0x00
PWM0 Output
(Duty Range 0~255)

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 85
Version 1.7
8.4.4 PWM0 DUTY CHANGING NOTICE
In PWM mode, the system will compare TC0C and TC0R all the time. When TC0C<TC0R, the PWM will output logic
“High”, when TC0C≧TC0R, the PWM will output logic “Low”. If TC0C is changed in certain period, the PWM duty will
change immediately. If TC0R is fixed all the time, the PWM waveform is also the same.
TC0C overflow
and TC0IRQ set
TC0C = TC0R
0xFF
TC0C Value
0x00
PWM0 Output
1 2 3 4 5 6 7
Period
Above diagram is shown the waveform with fixed TC0R. In every TC0C overflow PWM output “High, when
TC0C≧TC0R PWM output ”Low”.
Note: Setting PWM duty in program processing must be at the new cycle start.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 86
Version 1.7
UART
9.1 OVERVIEW
The UART interface is an universal asynchronous receiver/transmitter method. The serial interface is applied to low
speed data transfer and communicate with low speed peripheral devices. The UART transceiver of Sonix 8-bit MCU
allows RS232 standard and supports one byte data length. The transfer format has start bit, 8-bit data, parity bit and
stop bit. Programmable baud rate supports different speed peripheral devices.
The UART features include the following:
Full-duplex, 2-wire asynchronous data transfer.
Programmable baud rate.
8-bit data length.
Odd and even parity bit.
End-of-Transfer interrupt.
Support break pocket function.
Support wide range baud rate.
9.2 UART OPERATION
The UART RX (P05) and TX (P04) pins are shared with GPIO. When UART enables (RXDEN=1, TXDEN=1), the
UART shared pins transfers to UART purpose and disable GPIO function automatically. When UART disables, the
UART pins returns to GPIO last status. The UART data buffer length supports 1-byte. After UART RX operation
finished, the RXIRQ sets as “1”. After UART TX operation finished, the TXIRQ sets as “1”. The UART IRQ bits are
cleared by program. If the RXIEN or TXIEN set to enable, the RXIRQ and TXIRQ triggers the interrupt request and
program counter jumps to interrupt vector to execute interrupt service routine.
Fhosc
UART Baud Rate
Control Block
(Pre-scaler and Divider)
URRXD1 8-bit Buffer
URX
URXEN
CPUM1,0
UART I/O Counter
Parity
Check
URRXD2 8-bit Buffer
URXM
URXPS URXPEN
URXS1,0 and RX interrupt
TX interrupt
URXEN
URXPC
URTXD1 8-bit Buffer
UTX
UTXEN
CPUM1,0
Parity
Check
URTXD2 8-bit Buffer
UTXM
UTXPS UTXPEN
UTXPC
UTXEN
UART Interface Circuit Diagram

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 87
Version 1.7
9.3 UART TRANSFER FORMAT
The UART also builds in “Busy Bit” to indicate UART bus status. URXBZ bit is UART RX operation indicator. UTXBZ bit
is UART TX operation indicator. If bus is transmitting, the busy bit is “1” status. If bus is finishing operation or in idle
status, the busy bit is “0” status.
UART TX operation is controlled by loading UTXD data buffer. After UART TX configuration, load transmitted data into
UTXD 8-bit buffer, and then UART starts to transmit the pocket following UART TX configuration.
UART RX operation is controlled by receiving the start bit from master terminal. After UART RX configuration, URX pin
detects the falling edge of start bit, and then UART starts to receive the pocket from master terminal.
UART provides URXPC bit and UFMER bit to check received pocket. URXPC bit is received parity bit checker. If
received parity is error, URXPC sets as “1”. If URXPC bit is zero after receiving pocket, the parity is correct. UFMER bit
is received stream frame checker. The stream frame error definition includes “Start bit error”, “Stop bit error”, “Stream
length error”, “UART baud rate error”... Each of frame error conditions makes UFMER bit sets as “1” after receiving
pocket.
The UART transfer format includes “Bus idle status”, “Start bit”, “8-bit Data”, “Parity bit” and “Stop bit” as following.
bit0 bit1 bit2 bit3 bit4 bit5 bit6
Start bit7 Parity Stop
Idle StatusIdle Status
UART Transfer Format with Parity Bit
Start
Stop
Idle Status
Idle Status
bit0 bit1 bit2 bit3 bit4 bit5 bit6
bit7
UART Transfer Format without Parity Bit
Bus Idle Status
The bus idle status is the bus non-operating status. The UART receiver bus idle status of MCU is floating status and
tied high by the transmitter device terminal. The UART transmitter bus idle status of MCU is high status. The UART bus
will be set when URXEN and UTXEN are enabled.
Start Bit
UART is a asynchronous type of communication and need a attention bit to offer receiver the transfer starting. The start
bit is a simple format which is high to low edge change and the duration is one bit period. The start bit is easily
recognized by the receiver.
8-bit Data
The data format is 8-bit length, and LSB transfers first following start bit. The one bit data duration is the unit of UART
baud rate controlled by register.
Parity Bit
The parity bit purpose is to detect data error condition. It is an extra bit following the data stream. The parity bit includes
odd and even check methods controlled by URXPS/UTXPS bits. After receiving data and parity bit, the parity check
executes automatically. The URXPC bit indicates the parity check result. The parity bit function is controlled by
URXPEN/UTXPEN bits. If the parity bit function is disabled, the UART transfer contents remove the parity bit and the
stop bit follows the data stream directly.
Stop Bit
The stop bit is like start bit using a simple format to indicate the end of UART transfer. The stop bit format is low to high
edge change and the duration is one bit period.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 88
Version 1.7
9.4 ABNORMAL POCKET
The abnormal pocket occurs in UART RX mode. Break pocket is one abnormal pocket of the UART architecture. The
abnormal pocket includes Stream period error, start bit error, stop bit error…When UART receives abnormal pocket,
the UFMER bit will be set “1”, and UART issues URXIRQ. The system finds the abnormal pocket through firmware.
UART changes to initial status until detecting next start bit.
bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7
Start
Stop
P
URX Pin
Start bit is error.
UART check the start bit is error and issue UFMER flag, but the UART still finishes receiving the pocket.
bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7
Start Stop
P
URX Pin
Start bit is error.
UART check the stop bit is error and issue UFMER flag, but the UART still finishes receiving the pocket.
b
0
Start
UART RX
Processor
b1b2b3b4b5b6b
7
p
Stop
bit0 bit1 bit2 bit3 bit4 bit5 bit6
URX Pin
Start
If the host’s UART baud rate isn’t match to receiver terminal, the received pocket is error. But it is not easy to
differentiate the pocket is correct or not, because the received error pocket maybe match UART rule, but the data is
error. Use checking UFMER bit and URXPC bit status to decide the stream. If the two conditions seem like correct, but
the pocket is abnormal, UART will accept the pocket as correct one.
9.5 UART BAUD RATE
UART clock is 2-stage structure including a pre-scaler and an 8-bit buffer. UART clock source is generated from
system oscillator called Fhosc. Fhosc passes through UART pre-scaler to get UART main clock called Fuart. UART
pre-scaler has 8 selections (Fhosc/1, Fhosc/2, Fhosc/4, Fhosc/8, Fhosc/16, Fhosc/32, Fhosc/64, Fhosc/128) and 3-bit
control bits (URS[2:0]). UART main clock (Fuart) purposes are the front-end clock and through UART 8-bit buffer
(URCR) to obtain UART processing clock and decide UART baud rate.
UART Pre-scaler
Selection, URS[2:0]

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 89
Version 1.7
The UART baud rate clock source is Fhosc and divided by pre-scalar. The equation is as following.
UART Baud Rate = 1/2 *(Fuart * 1/(256 - URCR))…bps .
Note: We strongly recommend not to set URCR = 0xFF, or UART operation would be error.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 90
Version 1.7
9.6 UART RECEIVER CONTROL REGISTER
Bit [2:0] URS[2:0]: UART per-scalar select bit.
000 = Fhosc/1, 001 = Fhosc/2, 010 = Fhosc/4, 011 = Fhosc/8, 100 = Fhosc/16, 101 = Fhosc/32,
110 = Fhosc/64, 111 = Fhosc/128.
Bit 3 UFMER: UART RX stream frame error flag bit.
0 = Collect UART frame.
1 = UART frame is error including start/stop bit, stream length.
Bit 4 URXPC: UART RX parity bit checking flag.
0 = Parity bit is correct or no parity function.
1 = Parity bit is error.
Bit 5 UTXPS: UART RX parity bit format control bit.
0 = UART RX parity bit format is even parity.
1 = UART RX parity bit format is odd parity.
Bit 6 URXPEN: UART RX parity bit control bit.
0 = Disable UART RX parity bit function. The data stream doesn’t include parity bit.
1 = Enable UART RX parity bit function. The data stream includes parity bit.
Bit 7 URXEN: UART RX control bit.
0 = Disable UART RX. URX pin is GPIO mode or returns to GPIO status.
1 = Enable UART RX. URX pin exchanges from GPIO mode to UART RX mode.
9.7 UART TRANSMITTER CONTROL REGISTER
R/W - R R - - After reset
Bit 2 UTXBZ: UART TX operating status flag.
0 = UART TX is idle or the end of processing.
1 = UART TX is busy and processing.
Bit 3 URXBZ: UART RX operating status flag.
0 = UART RX is idle or the end of processing.
1 = UART RX is busy and processing.
Bit 5 UTXPS: UART TX parity bit format control bit.
0 = UART TX parity bit format is even parity.
1 = UART TX parity bit format is odd parity.
Bit 6 UTXPEN: UART TX parity bit control bit.
0 = Disable UART TX parity bit function. The data stream doesn’t include parity bit.
1 = Enable UART TX parity bit function. The data stream includes parity bit.
Bit 7 UTXEN: UART TX control bit.
0 = Disable UART TX. UTX pin is GPIO mode or returns to GPIO status.
1 = Enable UART TX. UTX pin exchanges from GPIO mode to UART TX mode and idle high status.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 91
Version 1.7
Note: URXBZ and UTXBZ bits are UART operating indicators. After setting UART RX/TX operations, set a
“NOP” instruction is necessary, and then check UART status through URXBZ and UTXBZ bits.
9.8 UART TRANSMITTER CONTROL REGISTER
Bit [7:0] UTXD: UART transmitted data buffer.
Bit [7:0] URXD: UART received data buffer.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 92
Version 1.7
9.9 UART OPERATION EXAMLPE
UART TX Configuration:
; Select parity bit function.
; Disable UART TX parity bit function.
; Enable UART TX parity bit function.
; Select parity bit format.
; UART TX parity bit format is even parity.
; UART TX parity bit format is odd parity.
; Set UART pre-scaler URS[2:0].
; Set UART baud rate 8-bit buffer.
; Enable UART TX function and UART TX pin.
; Enable UART TX interrupt function.
; Clear UART TX interrupt flag.
; Enable UART TX interrupt function.
; Load TX data buffer and execute TX transmitter.
; Load 8-bit data to UTXD data buffer.
;After loading UTXD, UART TX starts to transmit.
; One instruction delay for UTXBZ flag.
; UTXBZ=1, TX is operating.
; UTXBZ=0, the end of TX.
Note: UART TX operation is started through loading UTXD data buffer.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 93
Version 1.7
BUZZER FUNCTION
10.1 OVERVIEW
Buzzer function is controlled by BZRENB bit, which be configured as GPIO mode or Buzzer mode. Buzzer output
square wave signal through P0.3 Pin with 50% duty, and output frequency is controllable by setting the BZRCKS[1:0]
register.
Buzzer frequency Table
Buzzer clock source
From IHRC= 8MHz
10.2 BUZZER CONTROL REGISTER
Bit [1:0] URS[1:0]: Buzzer output frequency.
00 = 0.98 KHz.
01 = 1.96 KHz.
10 = 3.9 KHz.
11 = 7.8 KHz.
Bit 2 BZRENB: Buzzer output control bit.
0 : P03 as GPIO Mode.
1 : P03 as Buzzer Mode. Output Buzzer signal

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 94
Version 1.7
LCD DRIVER
11.1 OVERVIEW
LCD driver includes R-type and C-type structures with 4 common pins and 16 segment pins in the SN8P2977. The
LCD scan timing is 1/4 duty with 1/2 bias or 1/3 bias structure, all support in R-type and C-type mode to yield 64 dots
LCD driver. LCD power and bias voltage can be adjusted by additional external bias circuit in R-type LCD driver, and
adjusted by setting internal charge pump in C-type LCD driver.
11.2 LCD TIMING
LCD Timing Table
LCD Drive Waveform, 1/4 duty, 1/2 bias
COM0
COM1
COM2
COM3
SEG0 (1010b)
SEG0 (0101b)
1 Frame 1 Frame
LCD Clock
VLCD
VSS
1/2*VLCD
VLCD
VSS
1/2*VLCD
VLCD
VSS
1/2*VLCD
VLCD
VSS
1/2*VLCD
VLCD
VSS
1/2*VLCD
OFF ON OFF OFF OFFON ON ON
VLCD
VSS
1/2*VLCD
OFF OFF OFF OFFON ON ON ON

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 95
Version 1.7
LCD Drive Waveform, 1/4 duty, 1/3 bias
VLCD
VSS
1/3*VLCD
2/3*VLCD
VLCD
VSS
1/3*VLCD
2/3*VLCD
VLCD
VSS
1/3*VLCD
2/3*VLCD
VLCD
VSS
1/3*VLCD
2/3*VLCD
VLCD
VSS
1/3*VLCD
2/3*VLCD
VLCD
VSS
1/3*VLCD
2/3*VLCD
COM0
COM1
COM2
COM3
SEG0 (1010b)
SEG0 (0101b)
1 Frame 1 Frame
LCD Clock
OFF ON OFF OFF OFF
OFF OFF OFF OFF
ON ON ON
ON ON ON ON

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 96
Version 1.7
11.3 LCDM1 REGISTER
Bit0 LCDCLK: LCD clock source selection control bit.
0 = LCD clock = Fhosc /64, Frame rate = LCD clock / 4
1 = LCD clock = Flosc /128 or /64. Frame rate = LCD clock / 4
Bit1 LCDRATE: LCD clock rate control when LCDCLK=1.
0 = LCD clock rate = Flosc / 128
1 = LCD clock rate = Flosc / 64
Bit2 LCDBIAS: LCD Bias Selection Bit.
0 = LCD Bias is 1/3 Bias.
1 = LCD Bias is 1/2 Bias.
Bit3 LCDENB: LCD driver enable control bit.
0 = Disable.
1 = Enable.
Bit[5:4] LCDMOD[1:0]: LCD Mode control bit.
00 = C-Type LCD Mode.
01 = R-Type LCD Mode.
10 = ISP Mode.
11 = LCD Mode All OFF
Bit7 LCDBNK: LCD blank control bit.
0 = Normal display.
1 = All of the LCD dots off.
Note1: LCD disable in green or sleep mode, LCDENB is set “0” for power saving.)
Note2: In C-Type LCD start-up procedure, we recommend to set LCDMOD[1:0]=00 with delay 5ms before
LCDENB set “1”.
Bit[2:0] VCP [2:0]: LCD Charge pump output voltage

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 97
Version 1.7
Bit3 VPPINTL: Internal VPP Generation control bit.
0 = VLCD is not short to VPP pin internally.
1 = VLCD is short to VPP pin internally for ISP power from internal VLCD
Bit5 DISQ: VLCD Pin Discharge Control bit.
0 = VLCD Pin no discharge.
1 = VLCD Pin discharge (After the end of ISP, for discharging VLCD 7.5V down to VDD)
Bit[7:6] VAR[1:0]: VLCD pump ripple Control bit.
In C-Type Mode, Please always set VAR[1:0] = 00.
In R-Type Mode, Power saving level III > II > I > Disable.
Note_1: Macro “RomwrtVpp” instruction cover procedures of internal VPP generation and ROMWRT
instruction for ISP function without external 7.5V requirement.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 98
Version 1.7
11.5 C-TYPE LCD DRIVER MODE
The LCD C-type driver mode is support 1/3 and 1/2 bias LCD panel. The LCD power (VLCD) is supplied by internal
LCD charge-pump. The C-Type LCD charge-pump voltage level is following VLCD voltage. In C-type LCD mode, the
LCDMOD[1:0] bits f LCDM1 register must be “0”. The following are shown the 1/3 and 1/2 bias C-Type LCD application
circuit and VLCD output voltage chart.
SN8P2977
VLCD
COM0~COM3
SEG0~SEG15
LCD
PANEL
1uF
1/3 and 1/2 Basic C-type LCD Application Circuit
Note1: In C-type mode, a 1uF capacitor is connected to pin VLCD to VSS.
Note2: VLCD output voltage can be set from 2.6V to 3.3V and with ±0.2V accuracy.

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 99
Version 1.7
11.6 R-TYPE LCD DRIVER MODE
In LCD R-type driver, LCD power (VLCD) is auto connected to VDD via internal circuit. V3 and V2 bias voltage source
from internal voltage division by resistors. The following diagram shows the connection of 1/4 duty with 1/3 bias and 1/2
bias.
1/4 duty with 1/3 bias:
V3
V2
VLCD
LCDMOD [1:0]
VDD
35 kΩ
SN8P2977
1uF
LCDBIAS = 0
( Open )
35 kΩ
35 kΩ
R-Type LCD current consumption =

SN8P2977
8-Bit Micro-Controller with Regulator, PGIA, 24-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 100
Version 1.7
1/4 duty with 1/2 bias:
V3
V2
VLCD
LCDMOD[1:0]
VDD
35 kΩ
SN8P2977
1uF
LCDBIAS = 1
(Short)
35 k Ω
LCD current consumption =
Note_1: In R-Type LCD driver mode, VLCD power is auto connected to VDD via internal circuit. Pin VLCD
do not connect to any power source.