SN8P2602C Sonix
SN8P2602C Sonix
8-Bit Micro-Controller
     SN8P2602C
     USER’S MANUAL
Version 1.2
SN8P2602C
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.
                                   AMENDENT HISTORY
Version     Date                                             Description
VER 0.1   Feb. 2010   First issue.
VER 0.2   May. 2010   Modify EV-Kit version from “B” to “A”.
VER 0.3   Jun. 2010   1. Modify EV-Kit version from “A” to “V1.0”.
                      2. Add SN8P2602C EV-KIT schematic.
VER 1.0   Dec. 2010   Add code option: Low_Power description.
VER 1.1   Mar. 2011   Add “DEVELOPMENT TOOL” description.
VER 1.2   May. 2011   1. Modify “Chapter 2.4.2 STACK REGISTERS” description : 9-bit >> 10-bit data
                          memory.
                      2. Add “Chapter 11.3 CHARACTERISTIC GRAPHS” description : (-40℃~+85℃ curves
                          are for design reference).
                      3. Modify “Chapter 12 DEVELOPMENT TOOL” description.
                                                      Table of Content
     AMENDENT HISTORY ................................................................................................................................ 2
11      PRODUCT OVERVIEW ........................................................................................................................... 6
     1.1      FEATURES ........................................................................................................................................ 6
     1.2      SYSTEM BLOCK DIAGRAM .......................................................................................................... 7
     1.3      PIN ASSIGNMENT ........................................................................................................................... 7
     1.4      PIN DESCRIPTIONS ......................................................................................................................... 8
     1.5      PIN CIRCUIT DIAGRAMS ............................................................................................................... 8
22      CENTRAL PROCESSOR UNIT (CPU) .................................................................................................. 10
     2.1      PROGRAM MEMORY (ROM) ....................................................................................................... 10
        2.1.1     RESET VECTOR (0000H) ...................................................................................................... 11
        2.1.2     INTERRUPT VECTOR (0008H) ............................................................................................. 12
        2.1.3     LOOK-UP TABLE DESCRIPTION ........................................................................................ 14
        2.1.4     JUMP TABLE DESCRIPTION ............................................................................................... 16
        2.1.5     CHECKSUM CALCULATION............................................................................................... 18
     2.2      DATA MEMORY (RAM) ................................................................................................................ 19
        2.2.1     SYSTEM REGISTER .............................................................................................................. 19
           2.2.1.1 SYSTEM REGISTER TABLE ............................................................................................ 19
           2.2.1.2 SYSTEM REGISTER DESCRIPTION ............................................................................... 19
           2.2.1.3 BIT DEFINITION of SYSTEM REGISTER ....................................................................... 20
        2.2.2     ACCUMULATOR ................................................................................................................... 21
        2.2.3     PROGRAM FLAG ................................................................................................................... 22
        2.2.4     PROGRAM COUNTER........................................................................................................... 23
        2.2.5     Y, Z REGISTERS..................................................................................................................... 25
        2.2.6     R REGISTER ........................................................................................................................... 25
     2.3      ADDRESSING MODE .................................................................................................................... 26
        2.3.1     IMMEDIATE ADDRESSING MODE .................................................................................... 26
        2.3.2     DIRECTLY ADDRESSING MODE ....................................................................................... 26
        2.3.3     INDIRECTLY ADDRESSING MODE ................................................................................... 26
     2.4      STACK OPERATION ...................................................................................................................... 27
        2.4.1     OVERVIEW ............................................................................................................................. 27
        2.4.2     STACK REGISTERS ............................................................................................................... 27
        2.4.3     STACK OPERATION EXAMPLE.......................................................................................... 28
     2.5      CODE OPTION TABLE .................................................................................................................. 29
        2.5.1     Fcpu code option ...................................................................................................................... 30
        2.5.2     Reset_Pin code option .............................................................................................................. 30
        2.5.3     Security code option ................................................................................................................. 30
        2.5.4     Noise Filter code option ........................................................................................................... 30
        2.5.5     Low_Power code option ........................................................................................................... 30
33      RESET ...................................................................................................................................................... 31
     3.1      OVERVIEW ..................................................................................................................................... 31
     3.2      POWER ON RESET......................................................................................................................... 32
     3.3      WATCHDOG RESET ...................................................................................................................... 32
     3.4      BROWN OUT RESET ..................................................................................................................... 32
     3.5      THE SYSTEM OPERATING VOLTAGE ....................................................................................... 33
     3.6      LOW VOLTAGE DETECTOR (LVD) ............................................................................................ 33
     3.7      BROWN OUT RESET IMPROVEMENT ....................................................................................... 35
     3.8      EXTERNAL RESET ........................................................................................................................ 36
     3.9      EXTERNAL RESET CIRCUIT ....................................................................................................... 36
1                 PRODUCT OVERVIEW
1.1 FEATURES
     Memory configuration                                  Fcpu (Instruction cycle)
      ROM size: 1K * 16 bits.                                Fcpu = Fosc/1, Fosc/2, Fosc/4, Fosc/8, Fosc/16,
      RAM size: 48 * 8 bits.                                 Fosc/32, Fosc/64, Fosc/128
     4 levels stack buffer.                                One T0 8-bit basic timer with RTC (0.5sec).
     3 interrupt sources                                   One TC0 8-bit timer with external event counter,
      2 internal interrupts: T0, TC0                         Buzzer and PWM.
      1 external interrupt: INT0                            One channel 2K/4K buzzer output.
                                                            On chip watchdog timer and clock source is
     I/O pin configuration                                  Internal low clock RC type (16KHz @3V, 32KHz
      Bi-directional: P0, P1, P5.                            @5V).
      Input only: P1.5.
      Pull-up resisters: P0, P1, P5.                        4 system clocks
      Pull-down resisters: P5.0~P5.3.                        External high clock: RC type up to 10 MHz
      Wakeup: P0, P1 level change.                           External high clock: Crystal type up to 16 MHz
      40mA sink pin: P5.0~P5.3, P5.5.                        Internal high clock: 16MHz RC type.
      Programmable open-drain: P1.0.                         Internal low clock: RC type 16KHz(3V), 32KHz(5V)
      External Interrupt trigger edge:
            P0.0 controlled by PEDGE register.              4 operating modes
                                                             Normal mode: Both high and low clock active
     3-Level LVD.                                           Slow mode: Low clock only
      Reset system and power monitor.                        Sleep mode: Both high and low clock stop
                                                             Green mode: Periodical wakeup by timer
     Powerful instructions
      Instruction’s length is one word.                     Package (Chip form support)
      Most of instructions are one cycle only.               DIP 18 pin
      All ROM area JMP/CALL instruction.                     SOP 18 pin
      All ROM area lookup table function (MOVC).             SSOP 20 pin
                   PC
                                                                      3-Level LVD
                              OTP    INTERNAL                    (Low Voltage Detector)
                   IR                 HIGH RC        INTERNAL
                              ROM      16MHz          LOW RC
                                                                  WATCHDOG TIMER
                 FLAGS
TIMING GENERATOR
                        ALU
                                               RAM
                  INTERRUPT
                   CONTROL             TIMER & COUNTER                 PWM, Buzzer        PWM0, BZ0
P0 P1 P5
PnM PnUR
                                                  Output
                                                                           I/O Output Bus
                                                  Latch
PnM PnUR
PnM PnDR
                            Pull-Down
                             Resistor
PnM
                                               Output
                                                                        I/O Output Bus
                                               Latch
PnM PnUR
                                                               Output
                                                                            I/O Output Bus
                                                               Latch
Open-Drain
        High_Clk
                              PnM              PnUR
       Code Option
                                                      Output
                                                                            I/O Output Bus
                                                      Latch
Oscillator Driver
                                                       ROM
                                                                            User reset vector
                          0000H                    Reset vector
                                                                         Jump to user start address
                          0001H
                             .
                                              General purpose area
                             .
                          0007H
                          0008H                  Interrupt vector           User interrupt vector
                          0009H                                               User program
                             .
                             .
                          000FH
                          0010H               General purpose area
                          0011H
                             .
                             .
                          03FCH                                             End of user program
                          03FDH
                          03FEH                     Reserved
                          03FFH
The ROM includes Reset vector, Interrupt vector, General purpose area and Reserved area. The Reset vector is
program beginning address. The Interrupt vector is the head of interrupt service routine when any interrupt occurring.
The General purpose area is main program area including main loop, sub-routines and data table.
After power on reset, external 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. It is easy to know reset status from NT0, NPD
flags of PFLAG register. The following example shows the way to define the reset vector in the program memory.
                     ORG          0                 ; 0000H
                     JMP          START             ; Jump to user program address.
                     …
                     ORG          10H
START:                                              ; 0010H, The head of user program.
                     …                              ; User program
                     …
    Note: ”PUSH”, “POP” instructions save and load ACC/PFLAG without (NT0, NPD). PUSH/POP buffer is a
     unique buffer and only one level.
 Example: Defining Interrupt Vector. The interrupt service routine is following ORG 8.
.CODE
                     ORG          0                  ; 0000H
                     JMP          START              ; Jump to user program address.
                     …
 Example: Defining Interrupt Vector. The interrupt service routine is following user program.
.CODE
                   ORG          0                 ; 0000H
                   JMP          START             ; Jump to user program address.
                   …
                   ORG          8                 ; Interrupt vector.
                   JMP          MY_IRQ            ; 0008H, Jump to interrupt service routine address.
                   ORG          10H
START:                                            ; 0010H, The head of user program.
                   …                              ; User program.
                   …
                   …
                   JMP          START             ; End of user program.
                   …
MY_IRQ:                                           ;The head of interrupt service routine.
                   PUSH                           ; Save ACC and PFLAG register to buffers.
                   …
                   …
                   POP                            ; Load ACC and PFLAG register from buffers.
                   RETI                           ; 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:
    1. The address 0000H is a “JMP” instruction to make the program starts from the beginning.
    2. The address 0008H is interrupt vector.
    3. User’s program is a loop routine for main purpose application.
     Note: The Y register will not increase automatically when Z register crosses boundary from 0xFF to
      0x00. Therefore, user must be 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.
INC_YZ                MACRO
                      INCMS        Z                  ; Z+1
                      JMP          @F                 ; Not overflow
                      INCMS        Y                  ; Y+1
                      NOP                             ; Not overflow
@@:
                      ENDM
The other example of look-up table is to add Y or Z index register by accumulator. Please be careful if “carry” happen.
    Note: PCH only support PC up counting result and doesn’t support PC down counting. When PCL is
     carry after PCL+ACC, PCH adds one automatically. If PCL borrow after PCL–ACC, PCH keeps value and
     not change.
ORG 0X0100 ; The jump table is from the head of the ROM boundary
                     B0ADD        PCL, A             ; PCL = PCL + ACC, PCH + 1 when PCL overflow occurs.
                     JMP          A0POINT            ; ACC = 0, jump to A0POINT
                     JMP          A1POINT            ; ACC = 1, jump to A1POINT
                     JMP          A2POINT            ; ACC = 2, jump to A2POINT
                     JMP          A3POINT            ; ACC = 3, jump to A3POINT
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.
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).
ROM address
                     B0MOV        A, BUF0           ; “BUF0” is from 0 to 4.
                     @JMP_A       5                 ; The number of the jump table listing is five.
0X00FD               JMP          A0POINT           ; ACC = 0, jump to A0POINT
0X00FE               JMP          A1POINT           ; ACC = 1, jump to A1POINT
0X00FF               JMP          A2POINT           ; ACC = 2, jump to A2POINT
0X0100               JMP          A3POINT           ; ACC = 3, jump to A3POINT
0X0101               JMP          A4POINT           ; ACC = 4, jump to A4POINT
ROM address
                     B0MOV        A, BUF0           ; “BUF0” is from 0 to 4.
                     @JMP_A       5                 ; The number of the jump table listing is five.
0X0100               JMP          A0POINT           ; ACC = 0, jump to A0POINT
0X0101               JMP          A1POINT           ; ACC = 1, jump to A1POINT
0X0102               JMP          A2POINT           ; ACC = 2, jump to A2POINT
0X0103               JMP          A3POINT           ; ACC = 3, jump to A3POINT
0X0104               JMP          A4POINT           ; ACC = 4, jump to A4POINT
 Example: The demo program shows how to calculated Checksum from 00H to the end of user’s code.
                     MOV        A,#END_USER_CODE$L
                     B0MOV      END_ADDR1, A       ; Save low end address to end_addr1
                     MOV        A,#END_USER_CODE$M
                     B0MOV      END_ADDR2, A       ; Save middle end address to end_addr2
                     CLR        Y                  ; Set Y to 00H
                     CLR        Z                  ; Set Z to 00H
@@:
                     MOVC
                     B0BSET     FC                     ; Clear C flag
                     ADD        DATA1, A               ; Add A to Data1
                     MOV        A, R
                     ADC        DATA2, A               ; Add R to Data2
                     JMP        END_CHECK              ; Check if the YZ address =   the end of code
AAA:
                     INCMS      Z                      ; Z=Z+1
                     JMP        @B                     ; If Z != 00H calculate to next address
                     JMP        Y_ADD_1                ; If Z = 00H increase Y
END_CHECK:
                     MOV        A, END_ADDR1
                     CMPRS      A, Z                   ; Check if Z = low end address
                     JMP        AAA                    ; If Not jump to checksum calculate
                     MOV        A, END_ADDR2
                     CMPRS      A, Y                   ; If Yes, check if Y = middle end address
                     JMP        AAA                    ; If Not jump to checksum calculate
                     JMP        CHECKSUM_END           ; If Yes checksum calculated is done.
Y_ADD_1:
                     INCMS      Y                      ; Increase Y
                     NOP
                     JMP        @B                     ; Jump to checksum calculate
CHECKSUM_END:
                     …
                     …
END_USER_CODE:                                         ; Label of program end
The 48-byte general purpose RAM is separated into Bank 0. Sonix provides “Bank 0” type instructions (e.g. b0mov,
b0add, b0bts1, b0bset…) to control Bank 0 RAM directly.
    0      1           2        3       4       5        6      7        8      9          A        B       C        D       E       F
8   -      -           R        Z       Y        -     PFLAG    -        -          -       -       -        -       -        -      -
9   -      -            -       -        -       -        -     -        -          -       -       -        -       -        -      -
A   -      -            -       -        -       -        -     -        -          -       -       -        -       -        -     -
B   -      -            -       -        -       -        -     -       P0M         -       -       -        -       -        -   PEDGE
C P1W     P1M           -       -        -     P5M        -     -      INTRQ INTEN       OSCM       -     WDTR     TC0R     PCL    PCH
D P0       P1           -       -        -      P5        -     -       T0M    T0C       TC0M     TC0C     BZM       -        -    STKP
E P0UR    P1UR          -       -        -    P5UR      P5DR   @YZ       -    P1OC          -       -        -       -        -      -
F   -      -            -       -        -       -        -     -      STK3L STK3H STK2L STK2H STK1L STK1H STK0L STK0H
   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.
2.2.2 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.
MOV BUF, A
MOV A, #0FH
                      MOV            A, BUF
; or
                      B0MOV          A, BUF
The system doesn’t store ACC and PFLAG value when interrupt executed. ACC and PFLAG data must be saved to
other data memories. “PUSH”, “POP” save and load ACC, PFLAG data into buffers.
INT_SERVICE:
                      PUSH                              ; Save ACC and PFLAG to buffers.
                      …
                      …
                      POP                               ; Load ACC and PFLAG from buffers.
Bit 5        LVD36: LVD 3.6V operating flag and only support LVD code option is LVD_H.
              0 = Inactive (VDD > 3.6V).
              1 = Active (VDD ≦ 3.6V).
Bit 4        LVD24: LVD 2.4V operating flag and only support LVD code option is LVD_M.
              0 = Inactive (VDD > 2.4V).
              1 = Active (VDD ≦ 2.4V).
 Note: Refer to instruction set table for detailed information of C, DC and Z flags.
        Bit 15 Bit 14 Bit 13 Bit 12 Bit 11 Bit 10 Bit 9   Bit 8   Bit 7   Bit 6   Bit 5   Bit 4   Bit 3   Bit 2   Bit 1   Bit 0
 PC        -      -      -      -      -      -   PC9     PC8     PC7     PC6     PC5     PC4     PC3     PC2     PC1     PC0
After
          -      -      -      -         -    -     0       0       0      0       0       0         0     0       0       0
reset
                                   PCH                                                         PCL
If the condition of bit test instruction is true, the PC will add 2 steps to skip next instruction.
                       B0BTS1        FC                 ; To skip, if Carry_flag = 1
                       JMP           C0STEP             ; Else jump to C0STEP.
                       …
                       …
C0STEP:                NOP
If the ACC is equal to the immediate data or memory, the PC will add 2 steps to skip next instruction.
                      CMPRS      A, #12H          ; To skip, if ACC = 12H.
                      JMP        C0STEP           ; Else jump to C0STEP.
                      …
                      …
C0STEP:               NOP
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:
                      INCS        BUF0
                      JMP         C0STEP           ; Jump to C0STEP if ACC is not zero.
                      …
                      …
C0STEP:               NOP
INCMS instruction:
                      INCMS         BUF0
                      JMP           C0STEP              ; Jump to C0STEP if BUF0 is not zero.
                      …
                      …
C0STEP:               NOP
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:
                     DECS        BUF0
                     JMP         C0STEP            ; Jump to C0STEP if ACC is not zero.
                     …
                     …
C0STEP:              NOP
DECMS instruction:
                     DECMS        BUF0
                     JMP          C0STEP             ; Jump to C0STEP if BUF0 is not zero.
                     …
                     …
C0STEP:              NOP
 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 supports “ADD M,A”, ”ADC M,A” and “B0ADD M,A” instructions
for carry to PCH when PCL overflow automatically. For jump table or others applications, users can calculate PC value
by the three instructions and don’t care PCL overflow problem.
    Note: PCH only support PC up counting result and doesn’t support PC down counting. When PCL is
     carry after PCL+ACC, PCH adds one automatically. If PCL borrow after PCL–ACC, PCH keeps value and
     not change.
; PC = 0323H
                     MOV          A, #28H
                     B0MOV        PCL, A             ; Jump to address 0328H
                     …
; PC = 0328H
                     MOV          A, #00H
                     B0MOV        PCL, A             ; Jump to address 0300H
                     …
; PC = 0323H
                     B0ADD        PCL, A             ; PCL = PCL + ACC, the PCH cannot be changed.
                     JMP          A0POINT            ; If ACC = 0, jump to A0POINT
                     JMP          A1POINT            ; ACC = 1, jump to A1POINT
                     JMP          A2POINT            ; ACC = 2, jump to A2POINT
                     JMP          A3POINT            ; ACC = 3, jump to A3POINT
                     …
                     …
2.2.5 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.
 Example: Uses the Y, Z register as data pointer to clear the RAM data.
                      B0MOV         Y, #0               ; Y = 0, bank 0
                      B0MOV         Z, #07FH            ; Z = 7FH, the last address of the data memory area
CLR_YZ_BUF:
                      CLR           @YZ                 ; Clear @YZ to be zero
                      CLR           @YZ
END_CLR:                                                ; End of clear general purpose data memory area of bank 0
                      …
2.2.6 R REGISTER
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.
 Note: In immediate addressing mode application, the specific RAM must be 0x80~0x87 working register.
                     B0MOV         A, 12H             ; To get a content of RAM location 0x12 of bank 0 and save in
                                                      ACC.
                     B0MOV         12H, A             ; To get a content of ACC and save in RAM location 12H of
                                                      bank 0.
                 RET /             CALL /
                 RETI           INTERRUPT
                                                                                           PCH                         PCL
       Example: Stack pointer (STKP) reset, we strongly recommended to clear the stack pointers in the
        beginning of the program.
                              MOV                A, #00000011B
                              B0MOV              STKP, A
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.
3            RESET
3.1 OVERVIEW
The system would be reset in three conditions as following.
     Power on reset
     Watchdog reset
     Brown out reset
     External reset (only supports external reset pin enable situation)
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. The NT0, NPD flags
indicate system reset status. The system can depend on NT0, NPD status and go to different paths by program.
     086H         Bit 7        Bit 6       Bit 5         Bit 4          Bit 3        Bit 2        Bit 1        Bit 0
   PFLAG          NT0          NPD        LVD36         LVD24              -           C          DC            Z
 Read/Write       R/W          R/W           R            R                -         R/W          R/W          R/W
  After reset       -            -           0            0                -           0           0             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.
Power VSS
VDD
    Power-up: System detects the power voltage up and waits for power stable.
    External reset (only external reset pin enable): System checks external reset pin status. If external reset pin is
     not high level, the system keeps reset status and waits external reset pin released.
    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 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.
    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.
                                                                         System Work
                                                                          Well Area
                                               V1
                                                                         System Work
                                                    V2
                                                                   V3     Error Area
                           VSS
                                             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
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.
                                                                                               System Mini.
                                                                                             Operating Voltage.
                        Vdd (V)
                                               Normal Operating
                                                    Area
                                                                                    Dead-Band Area
                                                                                                            System Reset
                                                                                                              Voltage.
                                                                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.
                                                                                                   Power On
                                                                                                   Delay Time
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.
The LVD is three levels design (2.0V/2.4V/3.6V) and controlled by LVD code option. The 2.0V LVD is always enable for
power on reset and Brown Out reset. The 2.4V LVD includes LVD reset function and flag function to indicate VDD
status function. The 3.6V includes flag function to indicate VDD status. LVD flag function can be an easy low battery
detector. LVD24, LVD36 flags indicate VDD voltage level. For low battery detect application, only checking LVD24,
LVD36 status to be battery status. This is a cheap and easy solution.
Bit 5       LVD36: LVD 3.6V operating flag and only support LVD code option is LVD_H.
             0 = Inactive (VDD > 3.6V).
              1 = Active (VDD ≦ 3.6V).
Bit 4       LVD24: LVD 2.4V operating flag and only support LVD code option is LVD_M.
             0 = Inactive (VDD > 2.4V).
              1 = Active (VDD ≦ 2.4V).
LVD_L
If VDD < 2.0V, system will be reset.
Disable LVD24 and LVD36 bit of PFLAG register.
LVD_M
If VDD < 2.0V, system will be reset.
Enable LVD24 bit of PFLAG register. If VDD > 2.4V, LVD24 is “0”. If VDD ≦2.4V, LVD24 flag is “1”.
Disable LVD36 bit of PFLAG register.
LVD_H
If VDD < 2.4V, system will be reset.
Enable LVD24 bit of PFLAG register. If VDD > 2.4V, LVD24 is “0”. If VDD ≦2.4V, LVD24 flag is “1”.
Enable LVD36 bit of PFLAG register. If VDD > 3.6V, LVD36 is “0”. If VDD ≦3.6V, LVD36 flag is “1”.
LVD_MAX
If VDD < 3.6V, system will be reset.
       Note:
         1. After any LVD reset, LVD24, LVD36 flags are cleared.
         2. The voltage level of LVD 2.4V or 3.6V is for design reference only. Don’t use the LVD indicator as
              precision VDD measurement.
    LVD reset
    Watchdog reset
    Reduce the system executing rate
    External reset circuit. (Zener diode reset circuit, Voltage bias reset circuit, External reset IC)
    Note:
      1. The “ Zener diode reset circuit”, “Voltage bias reset circuit” and “External reset IC” can completely
           improve the brown out reset, DC low battery and AC slow power down conditions.
      2. For AC power application and enhance EFT performance, the system clock is 4MHz/4 (1 mips) and
           use external reset (“ Zener diode reset circuit”, “Voltage bias reset circuit”, “External reset IC”).
           The structure can improve noise effective and get good EFT characteristic.
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. Watchdog timer application note is as
following.
    External reset (only external reset pin enable): System checks external reset pin status. If external reset pin is
     not high level, the system keeps reset status and waits external reset pin released.
    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.
The external reset can reset the system during power on duration, and good external reset circuit can protect the
system to avoid working at unusual power condition, e.g. brown out reset in AC power application…
VDD
                                                 R1
                                            47K ohm
R2
                                                        100 ohm
                                                                  RST
                                                                        MCU
                                                  C1
                                               0.1uF
                                                                  VSS
VCC
GND
This is the basic reset circuit, and only includes R1 and C1. The RC circuit operation makes a slow rising signal into
reset pin as power up. The reset signal is slower than VDD power up timing, and system occurs a power on signal from
the timing difference.
 Note: The reset circuit is no any protection against unusual power or brown out reset.
                                                    DIODE        R1
                                                                 47K ohm
R2
                                                                 100 ohm
                                                                           RST
                                                                                 MCU
                                                       C1
                                                    0.1uF
                                                                           VSS
VCC
GND
This is the better reset circuit. The R1 and C1 circuit operation is like the simply reset circuit to make a power on signal.
The reset circuit has a simply protection against unusual power. The diode offers a power positive path to conduct
higher power to VDD. It is can make reset pin voltage level to synchronize with VDD voltage. The structure can
improve slight brown out reset condition.
    Note: The R2 100 ohm resistor of “Simply reset circuit” and “Diode & RC reset circuit” is necessary to
     limit any current flowing into reset pin from external capacitor C in the event of reset pin breakdown due
     to Electrostatic Discharge (ESD) or Electrical Over-stress (EOS).
                                               R1
                                          33K ohm                     E
                                                            R2
                                                                 B
                                                                          Q1
                                                      10K ohm
                                                                      C    RST
                                                                                 MCU
                                              Vz
                                                                 R3
                                                            40K ohm
                                                                           VSS
VCC
GND
The zener diode reset circuit is a simple low voltage detector and can improve brown out reset condition
completely. Use zener voltage to be the active level. When VDD voltage level is above “Vz + 0.7V”, the C terminal of
the PNP transistor outputs high voltage and MCU operates normally. When VDD is below “Vz + 0.7V”, the C terminal of
the PNP transistor outputs low voltage and MCU is in reset mode. Decide the reset detect voltage by zener
specification. Select the right zener voltage to conform the application.
                                              R2
                                                                 C    RST
                                                                            MCU
                                         10K ohm            R3
                                                        2K ohm
                                                                      VSS
VCC
GND
The voltage bias reset circuit is a low cost voltage detector and can improve brown out reset condition completely.
The operating voltage is not accurate as zener diode reset circuit. Use R1, R2 bias voltage to be the active level. When
VDD voltage level is above or equal to “0.7V x (R1 + R2) / R1”, the C terminal of the PNP transistor outputs high
voltage and MCU operates normally. When VDD is below “0.7V x (R1 + R2) / R1”, the C terminal of the PNP transistor
outputs low voltage and MCU is in reset mode.
Decide the reset detect voltage by R1, R2 resistances. Select the right R1, R2 value to conform the application. In the
circuit diagram condition, the MCU’s reset pin level varies with VDD voltage variation, and the differential voltage is
0.7V. If the VDD drops and the voltage lower than reset pin detect level, the system would be reset. If want to make the
reset active earlier, set the R2 > R1 and the cap between VDD and C terminal voltage is larger than 0.7V. The external
reset circuit is with a stable current through R1 and R2. For power consumption issue application, e.g. DC power
system, the current must be considered to whole system power consumption.
    Note: Under unstable power condition as brown out reset, “Zener diode rest circuit” and “Voltage bias
     reset circuit” can protects system no any error occurrence as power dropping. When power drops below
     the reset detect voltage, the system reset would be triggered, and then system executes reset sequence.
     That makes sure the system work well under unstable power situation.
                                                      Bypass
                                                    Capacitor
                                              VDD      0.1uF
                                               Reset
                                                IC
                                                       RST            RST   MCU
                                              VSS
                                                                      VSS
VCC
GND
The external reset circuit also use external reset IC to enhance MCU reset performance. This is a high cost and good
effect solution. By different application and system requirement to select suitable reset IC. The reset circuit can
improve all power variation.
4           SYSTEM CLOCK
4.1 OVERVIEW
The micro-controller is a dual clock system including high-speed and low-speed clocks. The high-speed clock includes
internal high-speed oscillator and external oscillators selected by “High_CLK” code option. The low-speed clock is from
internal low-speed oscillator controlled by “CLKMD” bit of OSCM register. Both high-speed clock and low-speed clock
can be system clock source through a divider to decide the system clock rate.
     High-speed oscillator
Internal high-speed oscillator is 16MHz RC type called “IHRC”.
External high-speed oscillator includes crystal/ceramic (4MHz, 12MHz, 32KHz) and RC type.
     Low-speed oscillator
Internal low-speed oscillator is 16KHz @3V, 32KHz @5V RC type called “ILRC”.
                                                                                              Fosc
               XIN                        Fcpu = Fhosc/1 ~ Fhosc/128, Noise Filter Disable.
                           Fhosc.
             XOUT                         Fcpu = Fhosc/4 ~ Fhosc/128, Noise Filter Enable.
                                                                                                               Fcpu
                                                                                              Fosc
                          CPUM[1:0]
SONIX provides a “Noise Filter” controlled by code option. In high noisy situation, the noise filter can isolate noise
outside and protect system works well. The minimum Fcpu of high clock is limited at Fhosc/4 when noise filter enable.
In high noisy environment, enable “Noise_Filter” code option is the strongly recommendation to reduce noise
effect.
    IHRC_16M: The system high-speed clock source is internal high-speed 16MHz RC type oscillator. In the mode,
     XIN and XOUT pins are bi-direction GPIO mode, and not to connect any external oscillator device.
    IHRC_RTC: The system high-speed clock source is internal high-speed 16MHz RC type oscillator. The RTC
     clock source is external low-speed 32768Hz crystal. The XIN and XOUT pins are defined to drive external
     32768Hz crystal and disables GPIO function.
    RC: The system high-speed clock source is external low cost RC type oscillator. The RC oscillator circuit only
     connects to XIN pin, and the XOUT pin is bi-direction GPIO mode.
    32K X’tal: The system high-speed clock source is external low-speed 32768Hz crystal. The option only supports
     32768Hz crystal and the RTC function is workable.
    12M X’tal: The system high-speed clock source is external high-speed crystal/ceramic. The oscillator bandwidth
     is 10MHz~16MHz.
    4M X’tal: The system high-speed clock source is external high-speed crystal/resonator. The oscillator bandwidth
     is 1MHz~10MHz.
For power consumption under “IHRC_RTC” mode, the internal high-speed oscillator and internal low–speed oscillator
stops and only external 32KHz crystal actives under green mode. The condition is the watchdog timer can’t be
“Always_On” option, or the internal low-speed oscillator actives.
    IHRC_16M: The system high-speed clock is internal 16MHz oscillator RC type. XIN/XOUT pins are general
     purpose I/O pins.
    IHRC_RTC: The system high-speed clock is internal 16MHz oscillator RC type, and the real time clock is external
     32768Hz crystal. XIN/XOUT pins connect with external 32768Hz crystal.
CRYSTAL/CERAMIC RC Type
XOUT
XIN XIN
                                                                                          VCC
                                                    VCC
                                                                                          GND
                                                    GND
   Note: Connect the Crystal/Ceramic and C as near as possible to the XIN/XOUT/VSS pins of
    micro-controller. Connect the R and C as near as possible to the VDD pin of micro-controller.
                                              45.00
                                              40.00                                                                                                            40.80
                                                                                                                                                       38.08
                                              35.00                                                                                            35.40
                                Freq. (KHz)
                                                                                                                                       32.52
                                              30.00                                                                            29.20
                                                                                                                       25.96
                                              25.00
                                                                                                               22.24                                               ILRC
                                              20.00                                                    18.88
                                                                                               17.24
                                                                                       16.00
                                              15.00                            14.72
                                              10.00                    10.64
                                                                7.52
                                               5.00
                                               0.00
                                                      2.1 2.5    3     3.1 3.3 3.5              4      4.5      5      5.5      6      6.5      7
VDD (V)
The internal low RC supports watchdog clock source and system slow mode controlled by “CLKMD” bit of OSCM
register.
There are two conditions to stop internal low RC. One is power down mode, and the other is green mode of 32K mode
and watchdog disable. If system is in 32K mode and watchdog disable, only 32K oscillator actives and system is under
low power consumption.
    Note: The internal low-speed clock can’t be turned off individually. It is controlled by CPUM0, CPUM1
     (32K, watchdog disable) bits of OSCM register.
“STPHX” bit controls internal high speed RC type oscillator and external oscillator operations. When “STPHX=0”, the
external oscillator or internal high speed RC type oscillator active. When “STPHX=1”, the external oscillator or internal
high speed RC type oscillator are disabled. The STPHX function is depend on different high clock options to do
different controls.
B0BSET P0M.0 ; Set P0.0 to be output mode for outputting Fcpu toggle signal.
@@:
                           B0BSET           P0.0            ; Output Fcpu toggle signal in low-speed clock mode.
                           B0BCLR           P0.0            ; Measure the Fcpu frequency by oscilloscope.
                           JMP              @B
       Note: Do not measure the RC frequency directly from XIN; the probe impendence will affect the RC
        frequency.
Vdd Vp
      Power On Reset
                Flag
             Oscillator
                                           Tcfg                 Tost             Tosp
                  Fcpu
    (Instruction Cycle)
        External Reset
                  Flag
             Oscillator
                                                                   Tcfg                 Tost     Tosp
                  Fcpu
    (Instruction Cycle)
                                   System is under reset
                                         status.
             Oscillator
                                         Tcfg                Tost             Tosp
                  Fcpu
    (Instruction Cycle)
         Wake-up Pin
          Rising Edge
             Oscillator
                                                             Tost
                                                                              Tosp
                  Fcpu
    (Instruction Cycle)
         Wake-up Pin
          Rising Edge
                                                                Timer overflow.
Timer ... 0xFD 0xFE 0xFF 0x00 0x01 0x02 ... ... ... ... ...
Oscillator
                  Fcpu
    (Instruction Cycle)
         RC Oscillator
                              Tost
    Ceramic/Resonator
                                 Tost
               Crystal
                                        Tost
5.1 OVERVIEW
The chip builds in four operating mode for difference clock rate and power saving reason. These modes control
oscillators, op-code operation and analog peripheral devices’ operation.
                                   Wake-up condition:
                                   P0, P1 input status is level changing.                          Power Down Mode
                                                                                                            CLKMD = 1
          Reset Control Block                                          Normal Mode                          CLKMD = 0            Slow Mode
    Note: If the system is in normal mode, to set STPHX=1 to disable the high clock oscillator. The system is
     under no system clock condition. This condition makes the system stay as power down mode, and can
     be wake-up by P0, P1 level change trigger.
    Note: Sonix provides “GreenMode” macro to control green mode operation. It is necessary to use
     “GreenMode” macro to control system inserting green mode.
     The macro includes three instructions. Please take care the macro length as using BRANCH type
     instructions, e.g. bts0, bts1, b0bts0, b0bts1, ins, incms, decs, decms, cmprs, jmp, or the routine would
     be error.
 Example: Switch slow mode to normal mode (The external high-speed oscillator stops).
 Example: Switch normal/slow mode to green mode and enable T0 wake-up function.
 Example: Switch normal/slow mode to green mode and enable T0 wake-up function with RTC.
5.7 WAKEUP
5.7.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/P1 level change) and
internal trigger (T0 timer overflow).
    Power down mode is waked up to normal mode. The wakeup trigger is only external trigger (P0/P1 level change)
    Green mode is waked up to last mode (normal mode or slow mode). The wakeup triggers are external trigger
     (P0/P1 level change) and internal trigger (T0 timer overflow).
 Note: Wakeup from green mode is no wakeup time because the clock doesn’t stop in green mode.
The value of the internal high clock oscillator RC type wakeup time is as the following.
    Example: In power down mode (sleep mode), the system is waked up. After the wakeup time, the system
     goes into normal mode. The wakeup time is as the following.
 Note: The high clock start-up time is depended on the VDD and oscillator type of high clock.
6              INTERRUPT
6.1 OVERVIEW
This MCU provides three interrupt sources, including two internal interrupt (T0/TC0) and one external interrupt (INT0).
The external interrupt can wakeup the chip while the system is switched from power down mode to high-speed 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 signals are stored in INTRQ register.
 Note: The GIE bit must enable during all interrupt operation.
 Note: The GIE bit must enable during all interrupt operation.
    Note: ”PUSH”, “POP” instructions save and load ACC/PFLAG without (NT0, NPD). PUSH/POP buffer is
     an unique buffer and only one level.
    Example: Store ACC and PAFLG data by PUSH, POP instructions when interrupt service routine
     executed.
                     ORG          0
                     JMP          START
                     ORG          8
                     JMP          INT_SERVICE
                     ORG          10H
START:
                     …
INT_SERVICE:
                     PUSH                            ; Save ACC and PFLAG to buffers.
                     …
                     …
                     POP                             ; Load ACC and PFLAG from buffers.
The external interrupt builds in wake-up latch function. That means when the system is triggered wake-up from power
down mode, the wake-up source is external interrupt source (P0.0), and the trigger edge direction matches interrupt
edge configuration, the trigger edge will be latched, and the system executes interrupt service routine fist after
wake-up.
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.
7 I/O PORT
7.1 OVERVIEW
The micro-controller builds in 16 pin I/O. Most of the I/O pins are mixed with analog pins and special function pins. The
I/O shared pin list is as following.
* DC: Digital Characteristic. AC: Analog Characteristic. HV: High Voltage Characteristic.
     Note:
        Users can program them by bit control instructions (B0BSET, B0BCLR).
        P1.5 input only pin, and the P1M.5 is undefined.
 Note: P1.5 is input only pin and without pull-up resister. The P1UR.5 is undefined.
 Note: The P15 keeps “1” when external reset enable by code option.
8             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.
The watchdog timer has three operating options controlled “WatchDog” code option.
In high noisy environment, the “Always_On” option of watchdog operations is the strongly recommendation
to make the system reset under error situations and re-start again.
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.
Main:
                MOV               A, #5AH              ; Clear the watchdog timer.
                B0MOV             WDTR, A
                …
                CALL              SUB1
                CALL              SUB2
                …
                JMP               MAIN
Main:
                @RST_WDT                               ; Clear the watchdog timer.
                …
                CALL              SUB1
                CALL              SUB2
                …
                JMP               MAIN
      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.
Main:
                  …                                        ; Check I/O.
                  …                                        ; Check RAM
Err:              JMP $                                    ; I/O or RAM error. Program jump here and don’t
                                                           ; clear watchdog. Wait watchdog timer overflow to reset IC.
Correct:                                                   ; I/O and RAM are correct. Clear watchdog timer and
                                                           ; execute program.
                  MOV                A, #5AH               ; Clear the watchdog timer.
                  B0MOV              WDTR, A
                  …
                  CALL               SUB1
                  CALL               SUB2
                  …
                  …
                  …
                  JMP                MAIN
    8-bit programmable up counting timer: Generate time-out at specific time intervals based on the selected clock
     frequency.
    Interrupt function: T0 timer function supports interrupt function. When T0 timer occurs overflow, the T0IRQ
     actives and the system points program counter to interrupt vector to do interrupt sequence.
    RTC function: T0 supports RTC function. The RTC clock source is from external low speed 32K oscillator when
     T0TB=1. RTC function is only available in High_Clk code option = "IHRC_RTC".
    Green mode function: T0 timer keeps running in green mode and wakes up system when T0 timer overflows.
                         T0 Rate
                                                      Load T0C Value by Program.
                    (Fcpu/2~Fcpu/256)   T0ENB
                                                                                         T0TB
             Fcpu
                                                  T0C 8-Bit Binary Up Counting Counter
RTC
T0ENB
 Note: In RTC mode, the T0 interval time is fixed at 0.5 sec and T0C is 256 counts.
                            Clock
                                                                                    ...                                  ...
                           Source
T0IRQ
T0 clock source is Fcpu (instruction cycle) through T0rate[2:0] pre-scaler to decide Fcpu/2~Fcpu/256. T0 length is 8-bit
(256 steps), and the one count period is each cycle of input clock.
                                                                                   T0 Interval Time
                                                   Fhosc=16MHz,                     Fhosc=4MHz,
                                                                                                            IHRC_RTC mode
             T0rate[2:0]      T0 Clock             Fcpu=Fhosc/4                     Fcpu=Fhosc/4
                                                                                                             max.
                                              max. (ms) Unit (us) max. (ms) Unit (us)                                          Unit (ms)
                                                                                                             (sec)
                000b         Fcpu/256             16.384            64             65.536          256         -                  -
                001b         Fcpu/128             8.192             32             32.768          128         -                  -
                010b          Fcpu/64             4.096             16             16.384           64         -                  -
                011b          Fcpu/32             2.048              8             8.192            32         -                  -
                100b          Fcpu/16             1.024              4             4.096            16         -                  -
                101b          Fcpu/8              0.512              2             2.048             8         -                  -
                110b          Fcpu/4              0.256              1             1.024             4         -                  -
                111b          Fcpu/2              0.128             0.5            0.512             2         -                  -
                  -         32768Hz/64               -               -                -              -        0.5               1.953
 Note: T0RATE is not available in RTC mode. The T0 interval time is fixed at 0.5 sec.
T0C initial value = 256 - (T0 interrupt interval time * T0 clock rate)
       Example: To calculation T0C to obtain 10ms T0 interval time. T0 clock source is Fcpu = 4MHz/4 = 1MHz.
        Select T0RATE=001 (Fcpu/128).
        T0 interval time = 10ms. T0 clock rate = 4MHz/4/128
       Note: In RTC mode, T0C is 256 counts and generatesT0 0.5 sec interval time. Don’t change T0C value in
        RTC mode.
 T0 TIMER CONFIGURATION:
; Reset T0 timer.
                MOV                A, #0x00        ; Clear T0M register.
                B0MOV              T0M, A
; Clear T0IRQ
                B0BCLR             FT0IRQ
; Clear T0C.
                CLR                T0C
; Clear T0IRQ
                B0BCLR             FT0IRQ
        8-bit programmable up counting timer: Generate time-out at specific time intervals based on the selected clock
         frequency.
        Interrupt function: TC0 timer function supports interrupt function. When TC0 timer occurs overflow, the TC0IRQ
         actives and the system points program counter to interrupt vector to do interrupt sequence.
        Event Counter: The event counter function counts the external clock counts.
        PWM output: The PWM is duty/cycle programmable controlled by T0rate and TC0R registers.
        Buzzer output: The Buzzer output signal is 1/2 cycle of TC0 interval time.
        Green mode function: All TC0 functions (timer, PWM, Buzzer, event counter, auto-reload) keep running in green
         mode and no wake-up function.
                                                                                                                                        TC0OUT
                                                                  Up Counting        ALOAD0
                                                                  Reload Value
                                                                                                                             Buzzer
                                                                                                    Auto. Reload
                                                 TC0 Time Out                                                              TC0 / 2                    P5.4
                                                                  TC0R Reload
                                                                                                               ALOAD0, TC0OUT
                                                                   Data Buffer
                              TC0 Rate
                          (Fcpu/2~Fcpu/256)                                                                R                           PWM0OUT
                                                                                                                       PWM
                                                                                     Compare
                                              TC0CKS   TC0ENB
                      Fcpu                                                                                 S
                                                                 Load
                                                                        TC0C
                                                                   8-Bit Binary Up                                                     TC0 Time Out
                                                                  Counting Counter
          INT0
    (Schmitter Trigger)
                                                       CPUM0,1
                        Clock
                                                                     ...                             ...
                       Source
                                    0x00
                        TC0C               0x01    0x02      0x03    ...   0xFE        0xFF   TC0R   ...
                                or TC0R
TC0IRQ
TC0 provides different clock sources to implement different applications and configurations. TC0 clock source includes
Fcpu (instruction cycle) and external input pin (P0.0) controlled by TC0CKS bits. TC0CKS bit selects the clock source
is from Fcpu or external input pin. If TC0CKS=0, TC0 clock source is Fcpu through TC0rate[2:0] pre-scaler to decide
Fcpu/2~Fcpu/256. If TC0CKS=1, TC0 clock source is external input pin that means to enable event counter function.
TC0rate[2:0] pre-scaler is unless when TC0CKS=1 condition. TC0 length is 8-bit (256 steps) when PWM disabled, and
the one count period is each cycle of input clock.
Bit 1       TC0OUT: TC0 time out toggle signal output control bit. Only valid when PWM0OUT = 0.
            0 = Disable, P5.4 is I/O function.
            1 = Enable, P5.4 is output TC0OUT signal.
 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).
TC0C initial value = N - (TC0 interrupt interval time * TC0 clock rate)
N is TC0 overflow boundary number. TC0 timer overflow time has five types (TC0 timer, TC0 event counter, TC0 Fcpu
clock source, PWM mode and no PWM mode). These parameters decide TC0 overflow time and valid value as follow
table.
TC0R initial value = 256 - (TC0 interrupt interval time * TC0 clock rate)
N is TC0 overflow boundary number. TC0 timer overflow time has five types (TC0 timer, TC0 event counter, TC0 Fcpu
clock source, PWM mode and no PWM mode). These parameters decide TC0 overflow time and valid value as follow
table.
    Example: To calculation TC0C and TC0R value to obtain 10ms TC0 interval time. TC0 clock source is
     Fcpu = 4MHz/4 = 1MHz. Select TC0RATE=001 (Fcpu/128).
     TC0 interval time = 10ms. TC0 clock rate = 4MHz/4/128
                                         0x00
                            TC0C                 0x01       0x02       0x03       ...    0xFE       0xFF     TC0R    ...
                                     or TC0R
TC0IRQ
TC0IRQ ...
When buzzer outputs, TC0IRQ still actives as TC0 overflows, and TC0 interrupt function actives as TC0IEN = 1. But
strongly recommend be careful to use buzzer and TC0 timer together, and make sure both functions work well.
The buzzer output pin is shared with GPIO and switch to output buzzer signal as TC0OUT=1 automatically. If TC0OUT
bit is cleared to disable buzzer signal, the output pin exchanges to last GPIO mode automatically. It easily to implement
carry signal on/off operation, not to control TC0ENB bit.
Buzzer Output
                   TC0OUT=0.       TC0OUT=1. The pin exchanges to output         TC0OUT=0. The pin exchanges                TC0OUT=1.
                                   mode and outputs Buzzer signal                to last GPIO mode (output low).
                                   automatically.
Buzzer Output
                   TC0OUT=0.       TC0OUT=1. The pin exchanges to output         TC0OUT=0. The pin exchanges                TC0OUT=1.
                                   mode and outputs Buzzer signal                to last GPIO mode (output high).
                                   automatically.
                   TC0OUT=0.       TC0OUT=1. The pin exchanges to output         TC0OUT=0. The pin exchanges                TC0OUT=1.
                                   mode and outputs Buzzer signal                to last GPIO mode (input).
                                   automatically.
 Note: Because the TC0OUT decides the PWM cycle in PWM mode. The PWM0OUT bit must be “0” when
  buzzer output function works.
                                                               TC0R           TC0R
                                0x00   0x01    0x02   ...
                                                                -1
                                                                       TC0R
                                                                               +1
                                                                                         ...   0xFD   0xFE   0xFF   0x00    0x01    0x02   ...
          TC0C
PWM Output
The resolution of PWM includes 1/256, 1/64, 1/32, 1/16 controlled by ALOAD0 and TC0OUT bits to implement high
speed PWM signal. ALOAD0, TC0OUT = 00, the PWM resolution is 1/256. ALOAD0, TC0OUT = 01, the PWM
resolution is 1/64. ALOAD0, TC0OUT = 10, the PWM resolution is 1/32. ALOAD0, TC0OUT = 11, the PWM resolution
is 1/16. If modify the PWM resolution, the TC0R PWM duty control range must be modified to meet resolution. When
PWM outputs, TC0IRQ still actives as TC0 overflows, and TC0 interrupt function actives as TC0IEN = 1. But strongly
recommend be careful to use PWM and TC0 timer together, and make sure both functions work well.
1/256 Duty
1/64 Duty
1/32 Duty
1/16 Duty
The PWM output pin is shared with GPIO and switch to output PWM signal as PWM0OUT=1 automatically. If
PWM0OUT bit is cleared to disable PWM, the output pin exchanges to last GPIO mode automatically. It easily to
implement carry signal on/off operation, not to control TC0ENB bit.
PWM Output
                PWM0OUT=0.       PWM0OUT=1. The pin exchanges to output       PWM0OUT=0. The pin exchanges       PWM0OUT=1.
                                 mode and outputs PWM signal automatically.   to last GPIO mode (output low).
PWM Output
                PWM0OUT=0.       PWM0OUT=1. The pin exchanges to output       PWM0OUT=0. The pin exchanges       PWM0OUT=1.
                                 mode and outputs PWM signal automatically.   to last GPIO mode (output high).
                PWM0OUT=0.       PWM0OUT=1. The pin exchanges to output       PWM0OUT=0. The pin exchanges       PWM0OUT=1.
                                 mode and outputs PWM signal automatically.   to last GPIO mode (input).
; Clear TC0IRQ
                 B0BCLR           FTC0IRQ
; Clear TC0IRQ
                 B0BCLR           FTC0IRQ
                                                Fcpu/256                                    Pin
                                                Fcpu/512
                                 Fcpu
                                                Fcpu/1024
                                                Fcpu/2048
BZEN
The buzzer frequency is divided from Fcpu (instruction cycle) controlled by BZrate bits, and Fcpu decides the buzzer
frequency. The selection table is as following.
The buzzer target frequency is 2KHz and 4KHz. It is important to choice a good Fcpu rate to obtain the correct buzzer
frequency. The above table shows 2KHz/4KHz buzzer frequency configurations.
       Note:
        1. If BZEN=0, the buzzer output pin is GPIO mode and returns to last status after disabling buzzer
            output.
        2. If BZEN=1, the buzzer output pin is buzzer output function and isolates the GPIO function.
10 INSTRUCTION TABLE
Field     Mnemonic                                              Description                           C   DC   Z   Cycle
        MOV     A,M      AM                                                                          -    -        1
 M      MOV     M,A      MA                                                                          -    -   -     1
 O      B0MOV   A,M      A  M (bank 0)                                                               -    -        1
 V      B0MOV   M,A      M (bank 0)  A                                                               -    -   -     1
 E      MOV     A,I      AI                                                                          -    -   -     1
        B0MOV   M,I      M  I, “M” only supports 0x80~0x87 registers (e.g. PFLAG,R,Y,Z…)             -    -   -     1
        XCH     A,M      A M                                                                        -    -   -    1+N
        B0XCH   A,M      A M (bank 0)                                                               -    -   -    1+N
        MOVC             R, A  ROM [Y,Z]                                                             -    -   -     2
        ADC        A,M   A  A + M + C, if occur carry, then C=1, else C=0                                        1
 A      ADC        M,A   M  A + M + C, if occur carry, then C=1, else C=0                                       1+N
 R      ADD        A,M   A  A + M, if occur carry, then C=1, else C=0                                            1
 I      ADD        M,A   M  A + M, if occur carry, then C=1, else C=0                                           1+N
 T      B0ADD      M,A   M (bank 0)  M (bank 0) + A, if occur carry, then C=1, else C=0                         1+N
 H      ADD        A,I   A  A + I, if occur carry, then C=1, else C=0                                            1
 M      SBC        A,M   A  A - M - /C, if occur borrow, then C=0, else C=1                                      1
 E      SBC        M,A   M  A - M - /C, if occur borrow, then C=0, else C=1                                     1+N
 T      SUB        A,M   A  A - M, if occur borrow, then C=0, else C=1                                           1
 I      SUB        M,A   M  A - M, if occur borrow, then C=0, else C=1                                          1+N
 C      SUB        A,I   A  A - I, if occur borrow, then C=0, else C=1                                           1
        AND        A,M   A  A and M                                                                  -   -         1
 L      AND        M,A   M  A and M                                                                  -   -        1+N
 O      AND        A,I   A  A and I                                                                  -   -         1
 G      OR         A,M   A  A or M                                                                   -   -         1
 I      OR         M,A   M  A or M                                                                   -   -        1+N
 C      OR         A,I   A  A or I                                                                   -   -         1
        XOR        A,M   A  A xor M                                                                  -   -         1
        XOR        M,A   M  A xor M                                                                  -   -        1+N
        XOR        A,I   A  A xor I                                                                  -   -         1
       SWAP         M     A (b3~b0, b7~b4) M(b7~b4, b3~b0)                                           -   -    -     1
 P     SWAPM        M     M(b3~b0, b7~b4)  M(b7~b4, b3~b0)                                           -   -    -    1+N
 R     RRC          M     A  RRC M                                                                      -    -     1
 O     RRCM         M     M  RRC M                                                                      -    -    1+N
 C     RLC          M     A  RLC M                                                                      -    -     1
 E     RLCM         M     M  RLC M                                                                      -    -    1+N
 S     CLR          M     M0                                                                         -   -    -     1
 S     BCLR         M.b M.b  0                                                                       -   -    -    1+N
       BSET         M.b M.b  1                                                                       -   -    -    1+N
       B0BCLR       M.b M(bank 0).b  0                                                               -   -    -    1+N
       B0BSET       M.b M(bank 0).b  1                                                               -   -    -    1+N
       CMPRS        A,I   ZF,C  A - I, If A = I, then skip next instruction                             -        1+S
 B     CMPRS        A,M ZF,C  A – M, If A = M, then skip next instruction                               -        1+S
 R     INCS         M     A  M + 1, If A = 0, then skip next instruction                             -   -    -    1+ S
 A     INCMS        M     M  M + 1, If M = 0, then skip next instruction                             -   -    -   1+N+S
 N     DECS         M     A  M - 1, If A = 0, then skip next instruction                             -   -    -    1+ S
 C     DECMS        M     M  M - 1, If M = 0, then skip next instruction                             -   -    -   1+N+S
 H     BTS0         M.b If M.b = 0, then skip next instruction                                        -   -    -    1+S
       BTS1         M.b If M.b = 1, then skip next instruction                                        -   -    -    1+S
       B0BTS0       M.b If M(bank 0).b = 0, then skip next instruction                                -   -    -    1+S
       B0BTS1       M.b If M(bank 0).b = 1, then skip next instruction                                -   -    -    1+S
       JMP           d    PC15/14  RomPages1/0, PC13~PC0  d                                         -   -    -     2
       CALL          d    Stack  PC15~PC0, PC15/14  RomPages1/0, PC13~PC0  d                       -   -    -     2
 M     RET                PC  Stack                                                                  -   -    -     2
  I    RETI               PC  Stack, and to enable global interrupt                                  -   -    -     2
 S     PUSH               To push ACC and PFLAG (except NT0, NPD bit) into buffers.                   -   -    -     1
 C     POP                To pop ACC and PFLAG (except NT0, NPD bit) from buffers.                                1
       NOP                No operation                                                                -   -    -     1
Note: 1. “M” is system register or RAM. If “M” is system registers then “N” = 0, otherwise “N” = 1.
      2. If branch condition is true then “S = 1”, otherwise “S = 0”.
11 ELECTRICAL CHARACTERISTIC
11.1      ABSOLUTE MAXIMUM RATING
Supply voltage (Vdd)…………………………………………………………………………………………………………………….……………… - 0.3V ~ 6.0V
Input in voltage (Vin)…………………………………………………………………………………………………………………….… Vss – 0.2V ~ Vdd + 0.2V
Operating ambient temperature (Topr)
       SN8P2602CP, SN8P2602CS, SN8P2602CX …………………………………………………………………………………………….. 0C ~ + 70C
       SN8P2602CPD, SN8P2602CSD, SN8P2602CXD ………………………………………………………………………………………. –40C ~ + 85C
Storage ambient temperature (Tstor) ………………………………………………………………….………………………………………… –40C ~ + 125C
12 DEVELOPMENT TOOL
SONIX provides ICE (in circuit emulation), IDE (Integrated Development Environment) and EV-kit for SN8P2602C
development. ICE and EV-kit are external hardware devices, and IDE is a friendly user interface for firmware
development and emulation. These development tools’ version is as following.
   ICE: SN8ICE2K Plus II. (Please install 16MHz crystal in ICE to implement IHRC emulation.)
   ICE emulation speed maximum: 8 MIPS @ 5V (e.g. 16Mhz crystal, Fcpu = Fosc/2)
   EV-kit: EV2602C KIT REV: V1.0.
   IDE: SONiX IDE M2IDE_V129 and later version.
   Writer: MPIII writer.
   Writer transition board: SN8P2602C
   CON2: Connect to SN8ICE2K Plus II CON1 (includes GPIO, EV-KIT control signal, and the others).
   CON1: Connect to SN8ICE2K Plus II JP3 (EV-KIT communication bus with ICE, control signal, and the others).
   S1: LVD24V / LVD36V control switch. To emulate LVD2.4V flag / reset function and LVD3.6V / flag function.
48 Pin 48
                                          40
                                          40
                                          28
                                          28
                                          18
                                          18
14
Pin 25
Pin 24
14 Marking Definition
14.1 INTRODUCTION
There are many different types in Sonix 8-bit MCU production line. This note listed the production definition of all 8-bit
MCU for order or obtain information. This definition is only for Blank OTP MCU.
                                                  Temperature       - = 0 ~ 70
                                                                    D = -40 ~ 85
                                                  Range
Device 2602C
     PB-Free Package:
        Name        ROM Type     Device          Package   Temperature       Material
    SN8P2602CPB        OTP       2602C            P-DIP      0℃~70℃      PB-Free Package
    SN8P2602CSB        OTP       2602C             SOP       0℃~70℃      PB-Free Package
    SN8P2602CXB        OTP       2602C            SSOP       0℃~70℃      PB-Free Package
    SN8P2602CPDB       OTP       2602C            P-DIP     -40℃~85℃     PB-Free Package
    SN8P2602CSDB       OTP       2602C             SOP      -40℃~85℃     PB-Free Package
    SN8P2602CXDB       OTP       2602C             SOP      -40℃~85℃     PB-Free Package
                                          1=01
                               Day
                                          2=02
                                          ....
                                          9=09
                                          A=10
                                          B=11
                                          ....
                               Month      1=January
                                          2=February
                                          ....
                                          9=September
                                          A=October
                                          B=November
                                          C=December
15 PACKAGE INFORMATION
15.1   P-DIP 18 PIN
      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.
                                                 Main Office:
                                                 Address: 10F-1, NO.36, Taiyuan Street, Chupei City, Hsinchu, Taiwan R.O.C.
                                                 Tel: 886-3-560 0888
                                                 Fax: 886-3-560 0889
                                                 Taipei Office:
                                                 Address: 15F-2, NO.171, Song Ted Road, Taipei, Taiwan R.O.C.
                                                 Tel: 886-2-2759 1980
                                                 Fax: 886-2-2759 8180
                                                 Hong Kong Office:
                                                 Unit 1519, Chevalier Commercial Centre, NO.8 Wang Hoi Road, Kowloon Bay,
                                                 Hong Kong.
                                                 Tel: 852-2723-8086
                                                 Fax: 852-2723-9179
                                                 Technical Support by Email:
                                                 Sn8fae@sonix.com.tw