0
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
创作中心
发布
  • 发文章

  • 发资料

  • 发帖

  • 提问

  • 发视频

创作活动
S3F8S28XZZ-SK98

S3F8S28XZZ-SK98

  • 厂商:

    ZILOG(齐洛格)

  • 封装:

    SOIC20

  • 描述:

    S3FAMILY8-BITMCU,8KBFLASH

  • 数据手册
  • 价格&库存
S3F8S28XZZ-SK98 数据手册
          S3 Family 8-Bit Microcontrollers S3F8S28/S3F8S24 Product Specification PS031306-0621 Copyright ©2021 Zilog®, Inc. All rights reserved. www.zilog.com S3F8S28/S3F8S24 Product Specification ii Warning: DO NOT USE THIS PRODUCT IN LIFE SUPPORT SYSTEMS. LIFE SUPPORT POLICY ZILOG’S PRODUCTS ARE NOT AUTHORIZED FOR USE AS CRITICAL COMPONENTS IN LIFE SUPPORT DEVICES OR SYSTEMS WITHOUT THE EXPRESS PRIOR WRITTEN APPROVAL OF THE PRESIDENT AND GENERAL COUNSEL OF ZILOG CORPORATION. As used herein Life support devices or systems are devices which (a) are intended for surgical implant into the body, or (b) support or sustain life and whose failure to perform when properly used in accordance with instructions for use provided in the labeling can be reasonably expected to result in a significant injury to the user. A critical component is any component in a life support device or system whose failure to perform can be reasonably expected to cause the failure of the life support device or system or to affect its safety or effectiveness. Document Disclaimer ©2021 Zilog, Inc. All rights reserved. Information in this publication concerning the devices, applications, or technology described is intended to suggest possible uses and may be superseded. ZILOG, INC. DOES NOT ASSUME LIABILITY FOR OR PROVIDE A REPRESENTATION OF ACCURACY OF THE INFORMATION, DEVICES, OR TECHNOLOGY DESCRIBED IN THIS DOCUMENT. ZILOG ALSO DOES NOT ASSUME LIABILITY FOR INTELLECTUAL PROPERTY INFRINGEMENT RELATED IN ANY MANNER TO USE OF INFORMATION, DEVICES, OR TECHNOLOGY DESCRIBED HEREIN OR OTHERWISE. The information contained within this document has been verified according to the general principles of electrical and mechanical engineering. S3 and Z8 are trademarks or registered trademarks of Zilog, Inc. All other product or service names are the property of their respective owners. PS031306-0621 S3F8S28/S3F8S24 Product Specification iii Revision History Each instance in this document’s revision history reflects a change from its previous edition. For more details, refer to the corresponding page(s) or appropriate links furnished in the table below. Date Revision Level Description Page June 2021 06 Updated IDD1 for Run Mode at 0.5MHz. Updated logo. 19-1 All Oct 2017 05 Added Zilog Library-based Development Platform and updated to most current 3rd party tools. Removed ‘Preliminary’ from footer. CH 21 All Jan 2015 04 Modified P0.0 and P0.1 descriptions in Figures 1-1 through 1-3 and Table 1-2 1-5, to include SCLK and SDAT values, respectively. 1-6, 1-7, 1-9 Jan 2015 03 Updated the Third Parties for Development Tools section. Apr 2014 02 8-1, Modifled language in nRESET pin statement, 2nd paragraph of 8.1 System Reset section; corrected misspelling in Figure 8-1; corrected superscript error 8-2, 19-5 in Table 19-5; corrected erroneous note, Figure 19-4. 19-6 Aug 2013 01 Original Zilog issue. n/a May 2012 1.1 Deleted P2.5 and P2.4 open-drain output functions. n/a May 2011 1.0 Released version V1.0. n/a PS031306-0621 22-9 Revision History S3F8S28/S3F8S24 Product Specification Table of Contents Table of Contents Table of Contents....................................................................................................................................................... 1 List of Figures ............................................................................................................................................................ 8 List of Tables ............................................................................................................................................................ 12 List of Examples ....................................................................................................................................................... 14 1 Product Overview................................................................................................................................................. 1-1 1.1 S3C8/S3F8 Series Microcontrollers ......................................................................................................... 1-1 1.2 S3F8S28/S3F8S24 Microcontroller ......................................................................................................... 1-1 1.3 Features ................................................................................................................................................... 1-2 1.4 Block Diagram .......................................................................................................................................... 1-5 1.5 Pin Assignments ...................................................................................................................................... 1-6 1.6 Pin Descriptions ....................................................................................................................................... 1-8 1.7 Pin Circuits ............................................................................................................................................. 1-10 2 Address Spaces ................................................................................................................................................... 2-1 2.1 Overview .................................................................................................................................................. 2-1 2.2 Program Memory (ROM).......................................................................................................................... 2-2 2.2.1 Normal Operating Mode ................................................................................................................... 2-2 2.2.2 Smart Option ..................................................................................................................................... 2-3 2.3 Register Architecture................................................................................................................................ 2-5 2.3.1 Register Page Pointer (PP) .............................................................................................................. 2-7 2.3.2 Register Set 1 ................................................................................................................................... 2-7 2.3.3 Register Set 2 ................................................................................................................................... 2-8 2.3.4 Prime Register Space ....................................................................................................................... 2-8 2.3.5 Working Registers ............................................................................................................................ 2-9 2.3.6 Using the Register Pointers ............................................................................................................ 2-10 2.4 Register Addressing ............................................................................................................................... 2-12 2.4.1 Common Working Register Area (C0H to CFH) ............................................................................. 2-14 2.4.2 4-Bit Working Register Addressing ................................................................................................. 2-15 2.4.3 8-Bit Working Register Addressing ................................................................................................. 2-17 2.5 System and User Stacks ........................................................................................................................ 2-19 2.5.1 Stack Operations ............................................................................................................................ 2-19 2.5.2 User-Defined Stacks ....................................................................................................................... 2-19 2.5.3 Stack Pointers (SPL) ...................................................................................................................... 2-19 3 Addressing Modes ............................................................................................................................................... 3-1 3.1 Overview .................................................................................................................................................. 3-1 3.2 Register Addressing Mode (R) ................................................................................................................. 3-2 3.3 Indirect Register Addressing Mode (IR) ................................................................................................... 3-3 3.4 Indexed Addressing Mode (X).................................................................................................................. 3-7 3.5 Direct Address Mode (DA) ..................................................................................................................... 3-10 3.6 Indirect Address Mode (IA) .................................................................................................................... 3-12 3.7 Relative Address Mode (RA).................................................................................................................. 3-13 3.8 Immediate Mode (IM) ............................................................................................................................. 3-14 PS031305-1017 i S3F8S28/S3F8S24 Product Specification Table of Contents 4 Control Registers ................................................................................................................................................. 4-1 4.1 Overview .................................................................................................................................................. 4-1 4.1.1 ADCON ............................................................................................................................................. 4-6 4.1.2 BTCON ............................................................................................................................................. 4-7 4.1.3 CLKCON ........................................................................................................................................... 4-8 4.1.4 EMT .................................................................................................................................................. 4-9 4.1.5 FLAGS ............................................................................................................................................ 4-10 4.1.6 FMCON ........................................................................................................................................... 4-11 4.1.7 FMSECH ......................................................................................................................................... 4-11 4.1.8 FMSECL ......................................................................................................................................... 4-12 4.1.9 FMUSR ........................................................................................................................................... 4-12 4.1.10 ICCR ............................................................................................................................................. 4-13 4.1.11 ICSR ............................................................................................................................................. 4-14 4.1.12 IMR ............................................................................................................................................... 4-15 4.1.13 IPH ................................................................................................................................................ 4-16 4.1.14 IPL ................................................................................................................................................. 4-16 4.1.15 IPR ................................................................................................................................................ 4-17 4.1.16 IRQ ................................................................................................................................................ 4-18 4.1.17 LVDCON ....................................................................................................................................... 4-19 4.1.18 P0CONH ....................................................................................................................................... 4-20 4.1.19 P0CONL........................................................................................................................................ 4-21 4.1.20 P0PND .......................................................................................................................................... 4-22 4.1.21 P0PUR .......................................................................................................................................... 4-24 4.1.22 P1CON.......................................................................................................................................... 4-25 4.1.23 P2CONH ....................................................................................................................................... 4-26 4.1.24 P2CONL........................................................................................................................................ 4-27 4.1.25 P2PUR .......................................................................................................................................... 4-28 4.1.26 P3CON.......................................................................................................................................... 4-29 4.1.27 P3PND .......................................................................................................................................... 4-30 4.1.28 PP ................................................................................................................................................. 4-31 4.1.29 PWM0CON ................................................................................................................................... 4-32 4.1.30 PWM1CON ................................................................................................................................... 4-33 4.1.31 PWM0EX ...................................................................................................................................... 4-34 4.1.32 PWM1EX ...................................................................................................................................... 4-34 4.1.33 RESETID ...................................................................................................................................... 4-35 4.1.34 ROSCCON.................................................................................................................................... 4-36 4.1.35 RP0 ............................................................................................................................................... 4-36 4.1.36 RP1 ............................................................................................................................................... 4-37 4.1.37 SPL ............................................................................................................................................... 4-37 4.1.38 STOPCON .................................................................................................................................... 4-37 4.1.39 SYM .............................................................................................................................................. 4-38 4.1.40 T1CON .......................................................................................................................................... 4-39 4.1.41 T1PS ............................................................................................................................................. 4-40 4.1.42 TACON ......................................................................................................................................... 4-40 4.1.43 TBCON ......................................................................................................................................... 4-42 4.1.44 UARTCON .................................................................................................................................... 4-43 4.1.45 UARTPND..................................................................................................................................... 4-44 4.1.46 WDTCON ...................................................................................................................................... 4-45 5 Interrupt Structure ................................................................................................................................................ 5-1 5.1 Overview .................................................................................................................................................. 5-1 5.1.1 Levels................................................................................................................................................ 5-1 5.1.2 Vectors .............................................................................................................................................. 5-1 5.1.3 Sources ............................................................................................................................................. 5-1 PS031305-1017 ii S3F8S28/S3F8S24 Product Specification Table of Contents 5.2 Interrupt Types ......................................................................................................................................... 5-2 5.3 S3F8S28/S3F8S24 Interrupt Structure .................................................................................................... 5-3 5.3.1 Interrupt Vector Addresses ............................................................................................................... 5-4 5.3.2 Enable/Disable Interrupt Instructions (EI, DI) ................................................................................... 5-4 5.4 System-Level Interrupt Control Registers ................................................................................................ 5-5 5.5 Interrupt Processing Control Points ......................................................................................................... 5-6 5.6 Peripheral Interrupt Control Registers ..................................................................................................... 5-7 5.7 System Mode Register (SYM).................................................................................................................. 5-8 5.8 Interrupt Mask Register (IMR) .................................................................................................................. 5-9 5.9 Interrupt Priority Register (IPR) .............................................................................................................. 5-10 5.10 Interrupt Request Register (IRQ) ......................................................................................................... 5-12 5.11 Interrupt Pending Function Types ........................................................................................................ 5-13 5.11.1 Overview ....................................................................................................................................... 5-13 5.11.2 Pending Bits Cleared Automatically by Hardware ........................................................................ 5-13 5.11.3 Pending Bits Cleared by the Service Routine............................................................................... 5-13 5.12 Interrupt Source Polling Sequence ...................................................................................................... 5-14 5.13 Interrupt Service Routines.................................................................................................................... 5-14 5.14 Generating Interrupt Vector Addresses ............................................................................................... 5-15 5.15 Nesting of Vectored Interrupts ............................................................................................................. 5-15 5.16 Instruction Pointer (IP) ......................................................................................................................... 5-15 5.17 Fast Interrupt Processing ..................................................................................................................... 5-16 5.18 Procedure for Initiating Fast Interrupts ................................................................................................. 5-16 5.19 Fast Interrupt Service Routine ............................................................................................................. 5-16 5.20 Relationship to Interrupt Pending Bit Types......................................................................................... 5-17 5.21 Programming Guidelines...................................................................................................................... 5-17 6 Instruction Set ...................................................................................................................................................... 6-1 6.1 Overview .................................................................................................................................................. 6-1 6.1.1 Data Types........................................................................................................................................ 6-1 6.1.2 Register Addressing ......................................................................................................................... 6-1 6.1.3 Addressing Modes ............................................................................................................................ 6-1 6.2 Flags Register (FLAGS) ........................................................................................................................... 6-5 6.2.1 Flag Descriptions .............................................................................................................................. 6-6 6.3 Instruction Set Notation ............................................................................................................................ 6-7 6.4 Condition Codes ..................................................................................................................................... 6-11 6.5 Instruction Descriptions .......................................................................................................................... 6-12 6.5.1 ADC (Add with Carry) ..................................................................................................................... 6-13 6.5.2 ADD (Add)....................................................................................................................................... 6-14 6.5.3 AND (Logical AND) ......................................................................................................................... 6-15 6.5.4 BAND (Bit AND) .............................................................................................................................. 6-16 6.5.5 BCP (Bit Compare) ......................................................................................................................... 6-17 6.5.6 BITC (Bit Complement) ................................................................................................................... 6-18 6.5.7 BITR (Bit Reset) .............................................................................................................................. 6-19 6.5.8 BITS (Bit Set) .................................................................................................................................. 6-20 6.5.9 BOR (Bit OR) .................................................................................................................................. 6-21 6.5.10 BTJRF (Bit Test, Jump Relative on False) ................................................................................... 6-22 6.5.11 BTJRT (Bit Test, Jump Relative on True) ..................................................................................... 6-23 6.5.12 BXOR (Bit XOR) ........................................................................................................................... 6-24 6.5.13 CALL (Call Procedure).................................................................................................................. 6-25 6.5.14 CCF (Complement Carry Flag) ..................................................................................................... 6-26 6.5.15 CLR (Clear) ................................................................................................................................... 6-27 6.5.16 COM (Complement) ...................................................................................................................... 6-28 6.5.17 CP (Compare) ............................................................................................................................... 6-29 6.5.18 CPIJE (Compare, Increment, and Jump on Equal) ...................................................................... 6-30 PS031305-1017 iii S3F8S28/S3F8S24 Product Specification Table of Contents 6.5.19 CPIJNE (Compare, Increment, and Jump on Non-Equal) ............................................................ 6-31 6.5.20 DA (Decimal Adjust) ..................................................................................................................... 6-32 6.5.21 DEC (Decrement) ......................................................................................................................... 6-34 6.5.22 DECW (Decrement Word) ............................................................................................................ 6-35 6.5.23 DI (Disable Interrupts) ................................................................................................................... 6-36 6.5.24 DIV (Divide-Unsigned) .................................................................................................................. 6-37 6.5.25 DJNZ (Decrement and Jump if Non-Zero).................................................................................... 6-38 6.5.26 EI (Enable Interrupts) .................................................................................................................... 6-39 6.5.27 ENTER (Enter) .............................................................................................................................. 6-40 6.5.28 EXIT (Exit)..................................................................................................................................... 6-41 6.5.29 IDLE (Idle Operation) .................................................................................................................... 6-42 6.5.30 INC (Increment) ............................................................................................................................ 6-43 6.5.31 INCW (Increment Word) ............................................................................................................... 6-44 6.5.32 IRET (Interrupt Return) ................................................................................................................. 6-45 6.5.33 JP (Jump)...................................................................................................................................... 6-46 6.5.34 JR (Jump Relative) ....................................................................................................................... 6-47 6.5.35 LD (Load) ...................................................................................................................................... 6-48 6.5.36 LDB (Load Bit) .............................................................................................................................. 6-49 6.5.37 LDC/LDE (Load Memory) ............................................................................................................. 6-50 6.5.38 LDCD/LDED (Load Memory and Decrement) .............................................................................. 6-52 6.5.39 LDCI/LDEI (Load Memory and Increment) ................................................................................... 6-53 6.5.40 LDCPD/LDEPD (Load Memory with Pre-Decrement) .................................................................. 6-54 6.5.41 LDCPI/LDEPI (Load Memory with Pre-Increment) ....................................................................... 6-55 6.5.42 LDW (Load Word) ......................................................................................................................... 6-56 6.5.43 MULT (Multiply-Unsigned) ............................................................................................................ 6-57 6.5.44 NEXT (Next).................................................................................................................................. 6-58 6.5.45 NOP (No Operation) ..................................................................................................................... 6-59 6.5.46 OR (Logical OR) ........................................................................................................................... 6-60 6.5.47 POP (Pop from Stack) .................................................................................................................. 6-61 6.5.48 POPUD (Pop User Stack-Decrementing) ..................................................................................... 6-62 6.5.49 POPUI (Pop User Stack-Incrementing) ........................................................................................ 6-63 6.5.50 PUSH (Push to Stack) .................................................................................................................. 6-64 6.5.51 PUSHUD (Push User Stack-Decrementing)................................................................................. 6-65 6.5.52 PUSHUI (Push User Stack-Incrementing) .................................................................................... 6-66 6.5.53 RCF (Reset Carry Flag) ................................................................................................................ 6-67 6.5.54 RET (Return)................................................................................................................................. 6-68 6.5.55 RL (Rotate Left) ............................................................................................................................ 6-69 6.5.56 RLC (Rotate Left Through Carry) ................................................................................................. 6-70 6.5.57 RR (Rotate Right) ......................................................................................................................... 6-71 6.5.58 RRC (Rotate Right Through Carry) .............................................................................................. 6-72 6.5.59 SB0 (Select Bank 0) ..................................................................................................................... 6-73 6.5.60 SB1 (Select Bank 1) ..................................................................................................................... 6-74 6.5.61 SBC (Subtract with Carry) ............................................................................................................ 6-75 6.5.62 SCF (Set Carry Flag) .................................................................................................................... 6-76 6.5.63 SRA (Shift Right Arithmetic) ......................................................................................................... 6-77 6.5.64 SRP/SRP0/SRP1 (Set Register Pointer) ...................................................................................... 6-78 6.5.65 STOP (Stop Operation) ................................................................................................................ 6-79 6.5.66 SUB (Subtract) .............................................................................................................................. 6-80 6.5.67 SWAP (Swap Nibbles) .................................................................................................................. 6-81 6.5.68 TCM (Test Complement under Mask) .......................................................................................... 6-82 6.5.69 TM (Test under Mask) .................................................................................................................. 6-83 6.5.70 WFI (Wait for Interrupt) ................................................................................................................. 6-84 6.5.71 XOR (Logical Exclusive OR)......................................................................................................... 6-85 PS031305-1017 iv S3F8S28/S3F8S24 Product Specification Table of Contents 7 Clock Circuit ......................................................................................................................................................... 7-1 7.1 Overview .................................................................................................................................................. 7-1 7.2 Main Oscillator Logic ................................................................................................................................ 7-2 7.3 Clock Status During Power-Down Modes ................................................................................................ 7-2 7.4 System Clock Control Register (CLKCON) .............................................................................................. 7-3 7.5 Ring Oscillator Control Register (ROSCCON) ......................................................................................... 7-4 8 RESET and Power-Down .................................................................................................................................... 8-1 8.1 System Reset ........................................................................................................................................... 8-1 8.1.1 Overview ........................................................................................................................................... 8-1 8.1.2 External RESET Pin ......................................................................................................................... 8-3 8.1.3 MCU Initialization Sequence............................................................................................................. 8-4 8.2 Power-Down Modes ................................................................................................................................. 8-5 8.2.1 Stop Mode......................................................................................................................................... 8-5 8.2.2 Sources to Release Stop Mode ........................................................................................................ 8-5 8.2.3 Idle Mode .......................................................................................................................................... 8-6 8.3 Hardware Reset Values ........................................................................................................................... 8-7 9 I/O Ports ............................................................................................................................................................... 9-1 9.1 Overview .................................................................................................................................................. 9-1 9.2 Port Data Registers .................................................................................................................................. 9-2 9.2.1 Port 0 ................................................................................................................................................ 9-3 9.2.2 Port 1 ................................................................................................................................................ 9-8 9.2.3 Port 2 .............................................................................................................................................. 9-10 9.2.4 Port 3 .............................................................................................................................................. 9-14 10 Basic Timer and Timer 0 .................................................................................................................................. 10-1 10.1 Module Overview ................................................................................................................................. 10-1 10.1.1 Basic Timer (BT) ........................................................................................................................... 10-1 10.1.2 Timer 0 .......................................................................................................................................... 10-1 10.2 Basic Timer (BT) .................................................................................................................................. 10-2 10.2.1 Basic Timer Control Register (BTCON) ........................................................................................ 10-2 10.2.2 Basic Timer Function Description ................................................................................................. 10-3 10.3 One 16-Bit Timer Mode (Timer 0) ........................................................................................................ 10-7 10.3.1 Overview ....................................................................................................................................... 10-7 10.3.2 Function Description ..................................................................................................................... 10-7 10.3.3 Block Diagram............................................................................................................................. 10-10 10.4 Two 8-Bit Timers Mode (Timer A and B) ........................................................................................... 10-11 10.4.1 Overview ..................................................................................................................................... 10-11 10.4.2 Function Description ................................................................................................................... 10-11 11 16-Bit Timer 1 .................................................................................................................................................. 11-1 11.1 Overview .............................................................................................................................................. 11-1 11.2 Function Description ............................................................................................................................ 11-2 11.2.1 Timer 1 Interrupts ......................................................................................................................... 11-2 11.2.2 Timer 1 Overflow Interrupt ............................................................................................................ 11-2 11.2.3 Interval Mode (Match) ................................................................................................................... 11-2 11.2.4 Capture Mode ............................................................................................................................... 11-3 11.3 Timer 1 Control Register (T1CON) ...................................................................................................... 11-4 12 Watchdog Timer............................................................................................................................................... 12-1 12.1 Overview .............................................................................................................................................. 12-1 12.2 Function Description ............................................................................................................................ 12-2 PS031305-1017 v S3F8S28/S3F8S24 Product Specification Table of Contents 12.2.1 Watchdog Interrupt ....................................................................................................................... 12-2 12.2.2 Release Stop ................................................................................................................................ 12-2 12.2.3 System Reset................................................................................................................................ 12-2 12.3 Watchdog Timer Control Register (WDTCON) .................................................................................... 12-3 12.4 Interrupt ................................................................................................................................................ 12-6 12.5 System Reset ....................................................................................................................................... 12-7 12.6 Interrupt & System Reset ..................................................................................................................... 12-8 13 PWM (Pulse Width Modulation) ....................................................................................................................... 13-1 13.1 Overview .............................................................................................................................................. 13-1 13.2 Function Description ............................................................................................................................ 13-2 13.2.1 PWM ............................................................................................................................................. 13-2 13.2.2 PWM Counter ............................................................................................................................... 13-2 13.2.3 PWM Data and Extension Registers ............................................................................................ 13-2 13.2.4 PWM Clock Rate........................................................................................................................... 13-3 13.2.5 PWM Function Description ........................................................................................................... 13-4 13.2.6 PWM Output Waveform ................................................................................................................ 13-5 13.3 PWM Control Register (PWM0CON/PWM1CON) ............................................................................. 13-11 13.4 PWM Extension Register (PWM0EX/PWM1EX) ............................................................................... 13-12 14 A/D Converter .................................................................................................................................................. 14-1 14.1 Overview .............................................................................................................................................. 14-1 14.2 Using A/D Pins for Standard digital Input ............................................................................................. 14-2 14.3 A/D Converter Control Register (ADCON) ........................................................................................... 14-2 14.4 Internal Reference Voltage Levels ....................................................................................................... 14-4 14.5 Conversion timing ................................................................................................................................ 14-6 14.6 Internal A/D Conversion Procedure ..................................................................................................... 14-7 15 UART ............................................................................................................................................................... 15-1 15.1 Overview .............................................................................................................................................. 15-1 15.1.1 Programming Procedure............................................................................................................... 15-1 15.1.2 UART Control Register (UARTCON) ............................................................................................ 15-2 15.1.3 UART Interrupt Pending Register (UARTPND) ............................................................................ 15-3 15.1.4 UART Data Register (UDATA) ..................................................................................................... 15-4 15.1.5 UART Baud Rate Data Register (BRDATA) ................................................................................. 15-4 15.1.6 Baud Rate Calculations ................................................................................................................ 15-5 15.2 Block Diagram ...................................................................................................................................... 15-6 15.2.1 UART Mode 0 Function Description ............................................................................................. 15-7 15.2.2 UART Mode 1 Function Description ............................................................................................. 15-8 15.2.3 UART Mode 2 Function Description ............................................................................................. 15-9 15.2.4 UART Mode 3 Function Description ........................................................................................... 15-10 15.2.5 Serial Communication for Multiprocessor Configurations .......................................................... 15-11 16 IIC Bus Interface .............................................................................................................................................. 16-1 16.1 Overview .............................................................................................................................................. 16-1 16.1.1 Multi-Master IIC Bus Control Register (ICCR) .............................................................................. 16-2 16.1.2 Multi-Master IIC Bus Control/Status Register (ICSR) ................................................................... 16-4 16.1.3 Multi-Master IIC Bus Transmit/Receive Data Shift Register (IDSR) ............................................. 16-5 16.1.4 Multi-Master IIC Bus Address Register (IAR) ............................................................................... 16-6 16.2 Block Diagram ...................................................................................................................................... 16-7 16.3 The IIC Bus Interface ........................................................................................................................... 16-8 16.4 Start and Stop Conditions .................................................................................................................... 16-8 16.5 Data Transfer Formats ....................................................................................................................... 16-10 16.6 ACK Signal Transmission .................................................................................................................. 16-11 PS031305-1017 vi S3F8S28/S3F8S24 Product Specification Table of Contents 16.7 Read/Write Operations....................................................................................................................... 16-14 16.8 Bus Arbitration Procedures ................................................................................................................ 16-14 16.9 Abort Conditions ................................................................................................................................. 16-14 16.10 Configuring the IIC-Bus .................................................................................................................... 16-14 17 Low Voltage Detector....................................................................................................................................... 17-1 17.1 Overview .............................................................................................................................................. 17-1 17.2 Low Voltage Detector Control Register (LVDCON) ............................................................................. 17-2 17.3 Voltage (VDD) Level Detection Sequence-LVD Usage ....................................................................... 17-4 18 Embedded Flash Memory Interface................................................................................................................. 18-1 18.1 Overview .............................................................................................................................................. 18-1 18.1.1 Flash ROM Configuration ............................................................................................................. 18-1 18.1.2 Tool Program Mode ...................................................................................................................... 18-2 18.1.3 User Program Mode ..................................................................................................................... 18-2 18.2 Flash Memory Control Registers (User Program Mode) ..................................................................... 18-3 18.2.1 Flash Memory Control Register (FMCON) ................................................................................... 18-3 18.2.2 Flash Memory User Programming Enable Register (FMUSR) ..................................................... 18-3 18.2.3 Flash Memory Sector Address Registers ..................................................................................... 18-4 18.3 ISPTM (On-Board Programming) Sector ............................................................................................... 18-5 18.3.1 ISP Reset Vector and ISP Sector Size ......................................................................................... 18-6 18.4 Sector Erase......................................................................................................................................... 18-7 18.5 Programming ........................................................................................................................................ 18-9 18.6 Reading .............................................................................................................................................. 18-14 18.7 Hard Lock Protection.......................................................................................................................... 18-15 19 Electrical Data .................................................................................................................................................. 19-1 19.1 Overview .............................................................................................................................................. 19-1 20 Mechanical Data .............................................................................................................................................. 20-1 20.1 Overview .............................................................................................................................................. 20-1 21 Flash MCU ....................................................................................................................................................... 21-1 21.1 Overview .............................................................................................................................................. 21-1 21.2 On Board Writing .................................................................................................................................. 21-4 22 Development Tools .......................................................................................................................................... 22-6 22.1 Overview .............................................................................................................................................. 22-6 22.2 Emulator-based Development System ................................................................................................ 22-6 22.2.1 Host Software ............................................................................................................................... 22-7 22.2.2 Target Boards ............................................................................................................................... 22-7 22.2.3 SMDS2+ Selection (SAM8) ........................................................................................................ 22-10 22.3 Zilog Library-based Development Platform........................................................................................ 22-14 22.3.1 Zilog Developer Platform Components ....................................................................................... 22-14 22.3.2 Compatibility with 3rd Party Tools ............................................................................................... 22-16 22.3.3 Benefits and Limitations of Zilog Development Tools................................................................. 22-16 22.3.4 Development Tools ..................................................................................................................... 22-16 PS031305-1017 vii S3F8S28/S3F8S24 Product Specification List of Figures List of Figures Figure Number Figure 1-1 Figure 1-2 Figure 1-3 Figure 1-4 Figure 1-5 Figure 1-6 Figure 1-7 Figure 1-8 Figure 1-9 Figure 1-10 Figure 2-1 Figure 2-2 Figure 2-3 Figure 2-4 Figure 2-5 Figure 2-6 Figure 2-7 Figure 2-8 Figure 2-9 Figure 2-10 Figure 2-11 Figure 2-12 Figure 2-13 Figure 2-14 Figure 2-15 Figure 2-16 Figure 3-1 Figure 3-2 Figure 3-3 Figure 3-4 Figure 3-5 Figure 3-6 Figure 3-7 Figure 3-8 Figure 3-9 Figure 3-10 Figure 3-11 Figure 3-12 Figure 3-13 Figure 3-14 Figure 4-1 Figure 5-1 Figure 5-2 Figure 5-3 Title Page Number Block Diagram ................................................................................................................................... 1-5 Pin Assignment Diagram (24-Pin SOP Package) ............................................................................. 1-6 Pin Assignment Diagram (24-Pin DIP/SOP/SSOP Package)........................................................... 1-7 Pin Circuit Type A ........................................................................................................................... 1-10 Pin Circuit Type B ........................................................................................................................... 1-10 Pin Circuit Type C ........................................................................................................................... 1-10 Pin Circuit Type D ........................................................................................................................... 1-11 Pin Circuit Type E ........................................................................................................................... 1-11 Pin Circuit Type E-1 ........................................................................................................................ 1-12 Pin Circuit Type E-2 ...................................................................................................................... 1-12 Program Memory Address Space ..................................................................................................... 2-2 Smart Option ..................................................................................................................................... 2-3 Internal Register File Organization ................................................................................................... 2-6 Register Page Pointer (PP)............................................................................................................... 2-7 Set 1, Set 2 and Prime Area Register Map....................................................................................... 2-8 8-Byte Working Register Areas (Slices) ........................................................................................... 2-9 Contiguous 16-Byte Working Register Block .................................................................................. 2-10 Non-Contiguous 16-Byte Working Register Block .......................................................................... 2-11 16-Bit Register Pair ......................................................................................................................... 2-12 Register File Addressing ............................................................................................................... 2-13 Common Working Register Area .................................................................................................. 2-14 4-Bit Working Register Addressing ............................................................................................... 2-16 4-Bit Working Register Addressing Example ................................................................................ 2-16 8-Bit Working Register Addressing ............................................................................................... 2-17 8-Bit Working Register Addressing Example ................................................................................ 2-18 Stack Operations .......................................................................................................................... 2-19 Register Addressing .......................................................................................................................... 3-2 Working Register Addressing ........................................................................................................... 3-2 Indirect Register Addressing to Register File ................................................................................... 3-3 Indirect Register Addressing to Program Memory ............................................................................ 3-4 Indirect Working Register Addressing to Register File ..................................................................... 3-5 Indirect Working Register Addressing to Program or Data Memory................................................. 3-6 Indexed Addressing to Register File ................................................................................................. 3-7 Indexed Addressing to Program or Data Memory with Short Offset................................................. 3-8 Indexed Addressing to Program or Data Memory ............................................................................ 3-9 Direct Addressing for Load Instructions ........................................................................................ 3-10 Direct Addressing for Call and Jump Instructions ......................................................................... 3-11 Indirect Addressing ....................................................................................................................... 3-12 Relative Addressing ...................................................................................................................... 3-13 Immediate Addressing .................................................................................................................. 3-14 Register Description Format ............................................................................................................. 4-5 S3C8/S3F8 Series Interrupt Types ................................................................................................... 5-2 S3F8S28/S3F8S24 Interrupt Structure ............................................................................................. 5-3 ROM Vector Address Area ............................................................................................................... 5-4 PS031305-1017 viii S3F8S28/S3F8S24 Product Specification Figure 5-4 Figure 5-5 Figure 5-6 Figure 5-7 Figure 5-8 Figure 5-9 Figure 6-1 Figure 7-1 Figure 7-2 Figure 7-3 Figure 7-4 Figure 7-5 Figure 8-1 Figure 8-2 Figure 8-3 Figure 8-4 Figure 9-1 Figure 9-2 Figure 9-3 Figure 9-4 Figure 9-5 Figure 9-6 Figure 9-7 Figure 9-8 Figure 9-9 Figure 9-10 Figure 9-11 Figure 9-12 Figure 9-13 Figure 9-14 Figure 9-15 Figure 10-1 Figure 10-2 Figure 10-3 Figure 10-4 Figure 10-5 Figure 10-6 Figure 10-7 Figure 10-8 Figure 10-9 Figure 11-1 Figure 11-2 Figure 11-3 Figure 11-4 Figure 11-5 Figure 11-6 Figure 11-7 Figure 12-1 Figure 12-2 Figure 12-3 Figure 12-4 Figure 12-5 Figure 13-1 Figure 13-2 Figure 13-3 List of Figures Interrupt Function Diagram ............................................................................................................... 5-6 System Mode Register (SYM) .......................................................................................................... 5-8 Interrupt Mask Register (IMR)........................................................................................................... 5-9 Interrupt Request Priority Groups ................................................................................................... 5-10 Interrupt Priority Register (IPR)....................................................................................................... 5-11 Interrupt Request Register (IRQ) .................................................................................................... 5-12 System Flags Register (FLAGS)....................................................................................................... 6-5 Main Oscillator Circuit (Crystal/Ceramic Oscillator) .......................................................................... 7-1 System Clock Control Register (CLKCON) ...................................................................................... 7-3 Ring Oscillator Control Register (ROSCCON).................................................................................. 7-4 Stop Control Register (STOPCON) .................................................................................................. 7-4 System Clock Circuit Diagram .......................................................................................................... 7-5 Low Voltage Reset Circuit................................................................................................................. 8-2 Recommended External Reset Circuit .............................................................................................. 8-3 Reset Block Diagram ........................................................................................................................ 8-4 Timing for S3F8S28/S3F8S24 After Reset ....................................................................................... 8-4 Port Data Register Format ................................................................................................................ 9-2 Port 0 Circuit Diagram ....................................................................................................................... 9-3 Port 0 Control Register (P0CONH, High Byte) ................................................................................. 9-4 Port 0 Control Register (P0CONL, Low Byte)................................................................................... 9-5 Port 0 Interrupt Pending Registers (P0PND) .................................................................................... 9-6 Port 0 Pull-Up Resistor Enable Registers (P0PUR) ......................................................................... 9-7 Port 1 Circuit Diagram ....................................................................................................................... 9-8 Port 1 Control Register (P1CON) ..................................................................................................... 9-9 Port 2 Circuit Diagram ..................................................................................................................... 9-10 Port 2 Control Register (P2CONH, High Byte) ............................................................................. 9-11 Port 2 Control Register (P2CONL, Low Byte)............................................................................... 9-12 Port 2 Open-Drain Output Mode Register (P2PUR) ..................................................................... 9-13 Port 3 Circuit Diagram................................................................................................................... 9-14 Port 3 Control Register (P3CON) ................................................................................................. 9-15 Port 3 Interrupt Pending Register (P3PND) .................................................................................. 9-16 Basic Timer Control Register (BTCON) ........................................................................................ 10-2 Oscillation Stabilization Time on RESET ...................................................................................... 10-4 Oscillation Stabilization Time on Stop Mode Release .................................................................. 10-5 Timer 0 Control Register (TACON) ............................................................................................... 10-8 Timer 0 Timing Diagram ............................................................................................................... 10-9 Timer 0 Functional Block Diagram .............................................................................................. 10-10 Timer A Control Register (TACON) ............................................................................................ 10-12 Timer B Control Register (TBCON) ............................................................................................ 10-13 Timer A and B Function Block Diagram ...................................................................................... 10-14 Simplified Timer 1 Function Diagram: Interval Mode .................................................................... 11-2 Simplified Timer 1 Function Diagram: Capture Mode ................................................................... 11-3 Timer 1 Control Register (T1CON) ............................................................................................... 11-5 Timer 1 Prescaler Register (T1PS) ............................................................................................... 11-6 Timer 1 Data Register High (T1DATAH) ...................................................................................... 11-6 Timer 1 Data Register Low (T1DATAL) ........................................................................................ 11-6 Timer 1 Functional Block Diagram ................................................................................................ 11-7 Watchdog Timer Control Register (WDTCON) ............................................................................. 12-4 Watchdog Timer Functional Block Diagram ................................................................................. 12-5 Interrupt Operation Sequence....................................................................................................... 12-6 System Reset Operation Sequence ............................................................................................. 12-7 Interrupt & System Reset Operation Sequence............................................................................ 12-8 PWM Data and Extension Registers ............................................................................................ 13-3 PWM Basic Waveform (6-Bit Base) .............................................................................................. 13-5 Extended PWM Waveform (6-Bit Base + 6-Bit Extension) ........................................................... 13-6 PS031305-1017 ix S3F8S28/S3F8S24 Product Specification Figure 13-4 Figure 13-5 Figure 13-6 Figure 13-7 Figure 13-8 Figure 13-9 Figure 13-10 Figure 13-11 Figure 14-1 Figure 14-2 Figure 14-3 Figure 14-4 Figure 14-5 Figure 15-1 Figure 15-2 Figure 15-3 Figure 15-4 Figure 15-5 Figure 15-6 Figure 15-7 Figure 15-8 Figure 15-9 Figure 15-10 Figure 16-1 Figure 16-2 Figure 16-3 Figure 16-4 Figure 16-5 Figure 16-6 Figure 16-7 Figure 16-8 Figure 16-9 Figure 16-10 Figure 16-11 Figure 16-12 Figure 17-1 Figure 17-2 Figure 18-1 Figure 18-2 Figure 18-3 Figure 18-4 Figure 18-5 Figure 18-6 Figure 18-7 Figure 18-8 Figure 18-9 Figure 19-1 Figure 19-2 Figure 19-3 Figure 19-4 Figure 19-5 Figure 19-6 Figure 19-7 Figure 20-1 Figure 20-2 PS031305-1017 List of Figures PWM Basic Waveform (6-Bit Base) .............................................................................................. 13-7 Extended PWM Waveform (6-Bit Base + 2-Bit Extension) ........................................................... 13-8 PWM Basic Waveform (8-Bit Base) .............................................................................................. 13-9 PWM Basic Waveform (8-Bit Base + 6-Bit Extension) ............................................................... 13-10 PWM Control Register (PWM0CON, PWM1CON) ..................................................................... 13-11 PWM Extension Register (PWM0EX, PWM0EX) ....................................................................... 13-12 PWM Data Register (PWM0DATA PWM1DATA) ..................................................................... 13-12 PWM/Capture Module Functional Block Diagram .................................................................... 13-13 A/D Converter Control Register (ADCON).................................................................................... 14-3 A/D Converter Circuit Diagram ..................................................................................................... 14-4 A/D Converter Data Register (ADDATAH/L) ................................................................................ 14-4 A/D Converter Timing Diagram ..................................................................................................... 14-5 Recommended A/D Converter Circuit for Highest Absolute Accuracy ......................................... 14-7 UART Control Register (UARTCON) ............................................................................................ 15-2 UART Interrupt Pending Register (UARTPND) ............................................................................ 15-3 UART Data Register (UDATA)...................................................................................................... 15-4 UART Baud Rate Data Register (BRDATA) ................................................................................. 15-4 UART Functional Block Diagram .................................................................................................. 15-6 Timing Diagram for UART Mode 0 Operation............................................................................... 15-7 Timing Diagram for UART Mode 1 Operation............................................................................... 15-8 Timing Diagram for UART Mode 2 Operation............................................................................... 15-9 Timing Diagram for UART Mode 3 Operation............................................................................. 15-10 Connection Example for Multiprocessor Serial Data Communications .................................... 15-12 Multi-Master IIC Bus Control Register (ICCR) .............................................................................. 16-2 Multi-Master IIC Bus Control/Status Register (ICSR) ................................................................... 16-4 Multi-Master IIC Bus Tx/Rx Data Shift Register (IDSR) ............................................................... 16-5 Multi-Master IIC Bus Address Register (IAR) ............................................................................... 16-6 IIC Bus Block Diagram .................................................................................................................. 16-7 Start and Stop Conditions ............................................................................................................. 16-8 Input Data Protocol ....................................................................................................................... 16-9 Interrupt Pending Information ....................................................................................................... 16-9 IIC Bus Interface Data Formats .................................................................................................. 16-10 Acknowledge Response from Receiver .................................................................................... 16-11 Write Operation Sequence........................................................................................................ 16-12 Read Operation Sequence ....................................................................................................... 16-13 LVD Control Register (LVDCON) ................................................................................................. 17-2 Block Diagram for Low Voltage Detector ...................................................................................... 17-3 Flash Memory Control Register (FMCON) ................................................................................... 18-3 Flash Memory User Programming Enable Register (FMUSR) ..................................................... 18-3 Flash Memory Sector Address Register (FMSECH) .................................................................... 18-4 Flash Memory Sector Address Register (FMSECL) ..................................................................... 18-4 Program Memory Address Space ................................................................................................. 18-5 Sector configurations in User Program Mode ............................................................................... 18-7 Sector Erase Flowchart in User Program Mode ........................................................................... 18-8 Byte Program Flowchart in a User Program Mode ..................................................................... 18-10 Program Flowchart in a User Program Mode ............................................................................. 18-11 Input Timing Measurement Points ................................................................................................ 19-4 Operating Voltage Range ............................................................................................................. 19-5 Schmitt Trigger Input Characteristics Diagram ............................................................................. 19-6 Stop Mode Release Timing When Initiated by a RESET ............................................................. 19-6 Waveform for UART Timing Characteristics ................................................................................. 19-7 LVR Reset Timing ......................................................................................................................... 19-9 The Circuit Diagram to Improve EFT Characteristics ................................................................. 19-10 24-SOP-375 Package Dimensions ............................................................................................... 20-1 24-TSSOP-BD44 Package Dimensions ....................................................................................... 20-2 x S3F8S28/S3F8S24 Product Specification Figure 20-3 Figure 20-4 Figure 20-5 Figure 21-1 Figure 21-2 Figure 21-3 Figure 22-1 Figure 22-2 Figure 22-3 Figure 22-4 Figure 22-5 Figure 22-6 Figure 22-7 PS031305-1017 List of Figures 20-DIP-300A Package Dimensions .............................................................................................. 20-3 20-SOP-375 Package Dimensions ............................................................................................... 20-4 20-SSOP-225 Package Dimensions............................................................................................. 20-5 S3F8S28/S3F8S24 Pin Assignments (24-DIP/24-SOP) .............................................................. 21-2 S3F8S28/S3F8S24 Pin Assignments (20-DIP/20-SOP/20-SSOP) .............................................. 21-2 PCB Design Guide for on Board Programming ............................................................................ 21-4 Emulator-based Development System Configuration ................................................................... 22-6 TB8S19/8S28/8S39 Target Board Configuration ......................................................................... 22-8 DIP Switch for Smart Option ....................................................................................................... 22-12 24-Pin Connector for TB8S19/8S28/8S39 .................................................................................. 22-13 S3F8S28/S3F8S24 Probe Adapter for 24 Pin Package ............................................................. 22-13 Zilog Development Platform........................................................................................................ 22-14 PCB Design Guide for In System Programming ......................................................................... 22-15 xi S3F8S28/S3F8S24 Product Specification List of Tables List of Tables Table Number Table 1-1 Table 1-2 Table 2-1 Table 4-1 Table 4-2 Table 4-3 Table 5-1 Table 5-2 Table 6-1 Table 6-2 Table 6-3 Table 6-4 Table 6-5 Table 6-6 Table 6-7 Table 8-1 Table 8-2 Table 8-3 Table 9-1 Table 9-2 Table 12-1 Table 13-1 Table 13-2 Table 13-3 Table 13-4 Table 15-1 Table 16-1 Table 18-1 Table 18-2 Table 18-3 Table 19-1 Table 19-2 Table 19-3 Table 19-4 Table 19-5 Table 19-6 Table 19-7 Table 19-8 Table 19-9 Table 19-10 Table 19-11 Table 19-12 Table 21-1 Table 21-2 Title Page Number S3F8S28/S3F8S24 Pin Descriptions ................................................................................................. 1-8 Descriptions of Pins Used to Read/Write the Flash ROM ................................................................. 1-9 Register Type Summary .................................................................................................................... 2-5 System and Peripheral Control Registers, Set1 ................................................................................ 4-2 System and Peripheral Control Registers, Set1, Bank0 .................................................................... 4-3 System and Peripheral Control Registers, Set1, Bank1 .................................................................... 4-4 Interrupt Control Register Overview ................................................................................................... 5-5 Interrupt Source Control and Data Registers ..................................................................................... 5-7 Instruction Group Summary ............................................................................................................... 6-2 Flag Notation Conventions ................................................................................................................. 6-7 Instruction Set Symbols ..................................................................................................................... 6-7 Instruction Notation Conventions ....................................................................................................... 6-8 OPCODE Quick Reference ................................................................................................................ 6-9 OPCODE Quick Reference .............................................................................................................. 6-10 Condition Codes ............................................................................................................................... 6-11 Register Values After a Reset, Set1 .................................................................................................. 8-7 Register Values After a Reset, Set1, Bank0 ...................................................................................... 8-8 System and Peripheral Control Registers, Set1, Bank1 .................................................................... 8-9 S3F8S28/S3F8S24 Port Configuration Overview .............................................................................. 9-1 Port Data Register Summary ............................................................................................................. 9-2 Watchdog Timer Presaler Select ................................................................................................... 12-5 PWM Control and Data Registers .................................................................................................. 13-3 PWM Output "Stretch" Values for Extension Data Bits Ext1 (PWM0EX.7–2, PWM1EX.7–2)....... 13-5 PWM Output "Stretch" Values for Extension Data Bits Ext0 (PWM0EX.7–6, PWM1EX.7–6)....... 13-7 PWM Output "Stretch" Values for Extension Data Bits Ext1 (PWM0EX.7–2, PWM1EX.7–2)....... 13-9 Commonly Used Baud Rates Generated by 8-Bit BRDATA.......................................................... 15-5 Sample Timing Calculations for the IIC Bus Transmit Clock (SCL) ............................................... 16-3 Descriptions of Pins Used to Read/Write the Flash in Tool Program Mode .................................. 18-2 ISP Sector Size .............................................................................................................................. 18-6 Reset Vector Address .................................................................................................................. 18-6 Absolute Maximum Ratings ........................................................................................................... 19-1 DC Electrical Characteristics.......................................................................................................... 19-2 AC Electrical Characteristics .......................................................................................................... 19-3 Oscillator Characteristics ............................................................................................................... 19-4 Oscillation Stabilization Time ......................................................................................................... 19-5 Data Retention Supply Voltage in Stop Mode................................................................................ 19-6 UART Timing Characteristics in Mode 0 (10MHz) ......................................................................... 19-7 A/D Converter Electrical Characteristics ........................................................................................ 19-8 LVD Circuit Characteristics ............................................................................................................ 19-9 LVR Circuit Characteristics .......................................................................................................... 19-9 Flash Memory AC Electrical characteristics............................................................................... 19-10 ESD Characteristics ................................................................................................................... 19-11 Descriptions of Pins Used to Read/Write the EPROM................................................................... 21-3 Comparison of S3F8S28/S3F8S24 Features ................................................................................ 21-3 PS031305-1017 xii S3F8S28/S3F8S24 Product Specification Table 21-3 Table 22-1 Table 22-2 Table 22-3 Table 22-4 Table 22-5 Table 22-6 Table 22-7 List of Tables Reference Table for Connection .................................................................................................... 21-5 Components of TB8S19/8S28/8S39 .............................................................................................. 22-9 Device Selection Settings for TB8S19/8S28/8S39 ........................................................................ 22-9 Power Selection Settings for TB8S19/8S28/8S39 ....................................................................... 22-10 The SMDS2+ Tool Selection Setting ........................................................................................... 22-10 Using Single Header Pins to Select Clock Source/PWM/Operation Mode .................................. 22-11 Using Single Header Pins as the Input Path for External Trigger Sources ................................. 22-12 ISP II Circuit Recommended Values ............................................................................................ 22-15 PS031305-1017 xiii S3F8S28/S3F8S24 Product Specification List of Examples List of Examples Example Number Example 2-1 Example 2-2 Example 2-3 Example 2-4 Example 2-5 Example 8-1 Example 10-1 Example 11-1 Example 13-1 Example 14-1 Example 17-1 Example 18-1 Example 18-2 Example 18-3 Example 18-4 PS031305-1017 Title Page Number Smart Option Setting ..................................................................................................................... 2-4 Setting the Register Pointers ...................................................................................................... 2-10 Using the RPs to Calculate the Sum of a Series of Registers .................................................... 2-11 Addressing the Common Working Register Area ....................................................................... 2-15 Standard Stack Operations Using PUSH and POP .................................................................... 2-20 Sample S3F8S28/S3F8S24 Initialization Routine ...................................................................... 8-10 Configuring the Basic Timer ...................................................................................................... 10-6 Using the Timer 1 ...................................................................................................................... 11-8 Programming the PWM Module to Sample Specifications ..................................................... 13-14 Configuring A/D Converter ........................................................................................................ 14-8 LVD Using Method .................................................................................................................... 17-4 Sector Erase ............................................................................................................................. 18-8 1Byte Programming ................................................................................................................ 18-12 Reading ................................................................................................................................... 18-14 Hard Lock Protection............................................................................................................... 18-15 xiv S3F8S28/S3F8S24 Product Specification 1 Chapter 1. Product Overview Product Overview 1.1 S3C8/S3F8 Series Microcontrollers Zilog's S3C8/S3F8 Series of 8-bit single-chip CMOS microcontrollers offers a fast and efficient CPU, a wide range of integrated peripherals, and various mask-programmable ROM sizes. Important CPU features include: • Efficient register-oriented architecture • Selectable CPU clock sources • Idle and Stop power-down mode release by interrupt • Built-in basic timer with watchdog function A sophisticated interrupt structure recognizes up to eight interrupt levels. Each level can have one or more interrupt sources and vectors. Fast interrupt processing (within a minimum of four CPU clocks) can be assigned to specific interrupt levels. 1.2 S3F8S28/S3F8S24 Microcontroller The S3F8S28/S3F8S24 single-chip CMOS micro-controller is fabricated using a highly advanced CMOS process and is based on Zilog's newest CPU architecture. Its design is based on the powerful SAM8RC CPU core. Stop and idle (power-down) modes were implemented to reduce power consumption. The S3F8S28/S3F8S24 is a micro-controller with 8K/4Kbyte multi-time-programmable Flash ROM embedded. Using the SAM8RC design approach, the following peripherals were integrated with the powerful core: • Three configurable I/O ports (22 pins) • 18 interrupt sources with 18 vectors and 8 interrupt levels • A 16-bit Timer 0 with one 16-bit timer or two 8-bit timer mode. • A 16-bit Timer 1 with interval & Capture function. • A free running Watchdog Timer with interrupt and Reset. • Analog to digital converter with thirteen input channels (MAX.) and 12-bit resolution • One UART module • One IIC module • Two PWM outputs with three optional mode: 12-bit (6 + 6); 8-bit (6 + 2); 14-bit (8 + 6); The S3F8S28/S3F8S24 microcontroller is ideal for use in a wide range of electronic applications requiring simple timer/counter, PWM, ADC. S3F8S28/S3F8S24 is available in a 24/20-pin SOP Package and a 24-pin TSSOP package and a 20-pin DIP package. PS031305-1017 1-1 S3F8S28/S3F8S24 Product Specification Chapter 1. Product Overview 1.3 Features • CPU − • SAM8RC CPU core Memory − Internal multi-time program Full-Flash memory: 8K  8 bits program memory (S3F8S28) 4K  8 bits program memory (S3F8S24) o o o o o o o − • • • • 272byte general-purpose register area Instruction Set − 78 instructions − Idle and Stop instructions added for power-down modes Instruction Execution Time − • Sector size: 128 bytes User programmable by "LDC" instruction Sector erase available Fast programming time External serial programming support Endurance: 10,000 erase/program cycles 10 Years data retention 333ns at 12MHz fOSC (minimum) Interrupts − 8 interrupt levels and 17 interrupt sources (8 external interrupt and 9 internal interrupt) − Fast interrupt processing feature − Watchdog interrupt can release Stop Mode. General I/O − Three I/O ports (Max. 22 pins) − Bit programmable ports 2-ch High-speed PWM with Three Selectable Resolutions − 12-bit PWM: 6-bit base + 6-bit extension − 8-bit PWM: 6-bit base + 2-bit extension − 14-bit PWM: 8-bit base + 6-bit extension PS031305-1017 1-2 S3F8S28/S3F8S24 Product Specification • • • • • • • • Chapter 1. Product Overview Timer/Counters − One 8-bit basic timer for watchdog function − One 16-bit timer(Timer 0) or two 8-bit timers A/B with time interval mode − One 16-bit timer/counter (Timer 1) with two operating modes; Interval mode, Capture mode − One free running Watchdog Timer with programmable timer-out period. It can be used to generate RESET or release STOP when clocked by Ring Oscillator. A/D Converter − Thirteen analog input pins (Max.) − 12-bit conversion resolution − Integrated sample and hold circuitry Asynchronous UART − Programmable baud rate generator − Support serial data transmit/receive operations with 8-bit, 9-bit UART Multi-Master IIC-Bus − Serial Peripheral Interface − Serial, 8-bit Data Transfers − Programmable Clock Prescale Oscillation Frequency − 0.1MHz to 1MHz external low gain (LG) crystal oscillator − 0.4MHz to 12MHz external high gain (HG) crystal oscillator − Internal RC: 0.5MHz (typ.), 1 MHz (typ.), 2MHz (typ.), 4MHz (typ.), 8MHz (typ.), in VDD = 5V with 1% tolerance − On-Chip Ring oscillator with 32kHz frequency for free running Watchdog Timer. − Maximum 12MHz CPU clock Built-in RESET Circuit (LVR) − Low-Voltage check to make system reset − VLVR = 1.9/2.3/3.0/3.9V (by Smart Option) Low Voltage Detect Circuit (LVD) − Programmable detection voltage − VLVD = 2.1/2.5/3.2/4.1V − En/Disable S/W selectable. Operating Temperature Range − – 40C to + 85C PS031305-1017 1-3 S3F8S28/S3F8S24 Product Specification • • • Chapter 1. Product Overview Operating Voltage Range − 1.8V to 5.5V @ 0.1 – 4MHz − 2.7V to 5.5V @ 0.1 – 12MHz Smart Option − LVR enable/disable − Oscillator selection Package Types − S3F8S28/F8S24: o 24-SOP-375 o 24-TSSOP-BD44 o 20-DIP-300A o 20-SOP-375 o 20-SSOP-225 PS031305-1017 1-4 S3F8S28/S3F8S24 Product Specification Chapter 1. Product Overview 1.4 Block Diagram Figure 1-1 Block Diagram Note: The Internal Voltage Converter (IVC) for the S3F8S28/S3F8S24 MCU’s 0.13µm process is not configurable. PS031305-1017 1-5 S3F8S28/S3F8S24 Product Specification Chapter 1. Product Overview 1.5 Pin Assignments Figure 1-2 PS031305-1017 Pin Assignment Diagram (24-Pin SOP Package) 1-6 S3F8S28/S3F8S24 Product Specification Figure 1-3 PS031305-1017 Chapter 1. Product Overview Pin Assignment Diagram (24-Pin DIP/SOP/SSOP Package) 1-7 S3F8S28/S3F8S24 Product Specification Chapter 1. Product Overview 1.6 Pin Descriptions Table 1-1 Pin Name S3F8S28/S3F8S24 Pin Descriptions Pin Type Share Pins I/O Bit-programmable I/O port for Schmitt trigger input or push-pull output. Pull-up resistors are assignable by software. Port0 pins can also be used as A/D converter input, PWM output, external interrupt input P0.2-.3 shared with IIC ports SCK and SDA E-1 ADC0 to ADC7 INT0 to INT3 PWM, SCK SDA I/O Bit-programmable I/O port for Schmitt trigger input or push-pull, open-drain output. Pull-up resistors or pulldown resistors are assignable by software. P1.2 is used as Schmitt trigger input port and Open-drain output E-2 B XIN, XOUT RESET I/O Bit-programmable I/O port for Schmitt trigger input or push-pull, open-drain output(P2.6, P2.3-.0). Pull-up resistors are assignable by software. P2.2 can be used for T1CAP input. P2.2-.3 shared with UART ports RxD and TxD E ADC8 to ADC10 CLO T0; T1; T1CAP; RxD,TxD P3.0 to P3.3 I/O Bit-programmable I/O port for Schmitt trigger input or push-pull. Pull-up resistors are assignable by software. Port3 pins can also be used as A/D converter input, external interrupt input E-1 ADC11 to ADC12 INT4 to INT7 XIN, XOUT – Crystal/Ceramic oscillator signal for system clock. – P1.0 to P1.1 nRESET I Internal LVR or external RESET B P1.2 VDD, VSS – Voltage input pin and ground – – CLO O System clock output port E P2.6 INT0 to INT7 I External interrupt input port E-1 P0.0 to P0.3 P3.0 to P3.3 PWM0 O 8-Bit high speed PWM0 output E-1 P0.6 PWM1 O 8-Bit high speed PWM1 output E-1 P0.5 T0 O Timer0/A match output E P2.0 T1 O Timer1 match output E P2.1 T1CAP I T1 capture input E P2.2 ADC0 to DC12 I A/D converter input E-1 E P0.0 to P0.7 P2.4 to P2.6 P3.0 to P3.1 RxD I/O Serial data RXD pin for receive input and transmit output (mode 0) E-1 P2.2 TxD O Serial data TXD pin for transmit output and shift clock output (mode 0) E-1 P2.3 SCK, SDA I/O IIC Pins E-1 P0.2, P0.3 P0.0 to P0.7 P1.0 to P1.2 P2.0 to P2.6 PS031305-1017 Input/ Output Pin Description 1-8 S3F8S28/S3F8S24 Product Specification Table 1-2 Chapter 1. Product Overview Descriptions of Pins Used to Read/Write the Flash ROM Main Chip During Programming Pin Name Pin Name Pin No. I/O P0.1 SDAT 22 (24-pin), 18 (20-pin) I/O P0.0 SCLK 23(24-pin), 19 (20-pin) I Serial clock pin (input only pin) RESET, P1.2 VPP 4 I Power supply pin for Flash ROM cell writing (indicates that MTP enters into tool mode). When 11V is applied, MTP is in tool mode. VDD/VSS VDD/VSS 24 (24-pin), 20 (20-pin) 1 (24-pin), 1 (20-pin) I Logic power supply pin. PS031305-1017 Function Serial data pin (output when reading, Input when writing) Input and push-pull output port can be assigned 1-9 S3F8S28/S3F8S24 Product Specification Chapter 1. Product Overview 1.7 Pin Circuits VDD P-channel IN N-channel Figure 1-4 Data Output Disable Pin Circuit Type A Circuit Type C I/O Digital Input Figure 1-5 Pin Circuit Type B VDD Data Out Output DIsable Figure 1-6 PS031305-1017 Pin Circuit Type C 1-10 S3F8S28/S3F8S24 Product Specification Chapter 1. Product Overview VDD Pull-up Enable Data Output Disable Circuit Type C I/O Digital Input Figure 1-7 Pin Circuit Type D VDD Open-drain Enable P2CONH P2CONL Alternative Output P2.x Pull-up enable VDD P-CH M U X Data I/O N-CH Output Disable (Input Mode) Digital Input Analog Input Enable ADC Figure 1-8 PS031305-1017 Pin Circuit Type E 1-11 S3F8S28/S3F8S24 Product Specification Chapter 1. Product Overview VDD Pull-up enable VDD P0CONH P-CH Alternative Output M U X P0.x Data I/O N-CH Output Disable (Input Mode) Digital Input Interrupt Input Analog Input Enable Analog Input Figure 1-9 Pin Circuit Type E-1 VDD Open-drain Enable Pull-up enable VDD P1.x I/O Output Disable (Input Mode) Pull-down enable Digital Input XIN XOUT Figure 1-10 PS031305-1017 Pin Circuit Type E-2 1-12 S3F8S28/S3F8S24 Product Specification 2 Chapter 2. Address Spaces Address Spaces 2.1 Overview The S3F8S28/S3F8S24 microcontroller has two kinds of address space: • Internal program memory (ROM) • Internal register file A 12-bit address bus supports program memory operations. A separate 8-bit register bus carries addresses and data between the CPU and the internal register file. The S3F8S28/S3F8S24 have 8K/4Kbytes of multi-time-programmable Flash program memory: which is configured as the Internal ROM mode, all of the 8K/4Kbyte internal program memory is used. The S3F8S28/S3F8S24 microcontroller has 272 general-purpose registers in its internal register file. 69bytes in the register file are mapped for system and peripheral control functions. PS031305-0117 2-1 S3F8S28/S3F8S24 Product Specification Chapter 2. Address Spaces 2.2 Program Memory (ROM) 2.2.1 Normal Operating Mode The S3F8S28/S3F8S24 MCU has 8K/4Kbytes (locations 0H to 0FFFH) of internal multi-time-programmable Flash program memory. The first 256 bytes of the ROM (0H to 0FFH) are reserved for interrupt vector addresses. Unused locations (except 3CH, 3DH, 3EH, 3FH) in this address range can be used as normal program memory. If you use the vector address area to store a program code, be careful not to overwrite the vector addresses stored in these locations. 3CH, 3DH, 3EH, 3FH is used as Smart Option ROM cell. The program Reset address in the ROM is 0100H. (Decimal) 4,095 (HEX) 0FFFH 4K-Byte Internal Program Memory Area 255 FFH Interrupt Vector Area 0 Figure 2-1 PS031305-0117 0H Program Memory Address Space 2-2 S3F8S28/S3F8S24 Product Specification Chapter 2. Address Spaces 2.2.2 Smart Option Smart Option is the ROM option for starting condition of the chip. The ROM addresses used by Smart Option are from 003CH to 003FH. The S3F8S28/S3F8S24 only uses 003EH and 003FH. Not used ROM address 003CH, 003DH should be initialized to 0FFH. The default value of ROM is FFH (LVR enable, Internal RC oscillator). ROM Address: 003CH MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB .1 .0 LSB .1 .0 LSB Not Used ROM Address: 003DH MSB .7 .6 .5 .4 .3 .2 Not Used ROM Address: 003EH MSB .7 .6 .5 .4 .3 .2 ISP protection size selection: (note) 00 = 256 bytes 01 = 512 bytes 10 = 1024 bytes 11 = 2048 bytes Not used. ISP reset vector change enable/disable bit: 0 = OBP reset vector address 1 = Normal vector (address 0100H) ISP protection enable/disable bit: 0 = Enable (not erasable by LDC) 1 = Disable (erasable by LDC) ISP reset vector address selection bit: 00 = 200H (ISP area size: 256 byte) 01 = 300H (ISP area size: 512 byte) 10 = 500H (ISP area size: 1024 byte) 11 = 900H (ISP area size: 2048 byte) ROM Address: 003FH MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB LVR Enable/Disable 0 = Disable 1 = Enable LVR Level Selection bits 00 = 1.9V 01 = 2.3V 10 = 3.0V 11 = 3.9V Oscillator selection bits: 0100 = External low gain(LG) crystal/ceramic oscillator 1100 = External high gain(HG) crystal/ceramic oscillator 1010 = Internal RC (1 MHz in VDD = 5 V) 1111 = Internal RC (8 MHz in VDD = 5 V) 1000 = Internal RC (0.5 MHz in VDD = 5 V) 1001 = Internal RC (2 MHz in VDD = 5 V) 1011 = Internal RC (4 MHz in VDD = 5 V) P1.2/RESET pin Selection bit Other values = Not valid 0 = P1.2 pin enable 1 = RESET pin enable NOTES: 1. When you use external oscillator, P1.0, P1.1 must be set to output port to prevent current consumption. 2. Although user can write any value to the unused bits of 3CH, 3DH, 3EH, and 3FH, We recommend that the unused bits be set to "1". 3. After selecting ISP reset vector address in selecting ISP protection size, don't select upper than ISP area size. 4. The data for Smart Option should be written in the Smart Option area (003CH to 003FH) by OTP/MTP tools. When user written any value in the Smart Option area by LDC instruction, the data of the area may be changed, but the Smart Option is not affected. 5. External low gain (LG) crystal/ceramic frequency range from 100KHz to 1MHz with low power consumption External high gain (HG) crystal/ceramic frequency range from 400KHz to 12MHz with high power consumption. Figure 2-2 PS031305-0117 Smart Option 2-3 S3F8S28/S3F8S24 Product Specification Example 2-1 ORG ;---------------- 0000H > 003CH DB 0FFH ; 003CH, must be initialized to 0FFH. DB 0FFH ; 003DH, must be initialized to 0FFH. DB 0FFH ; 003EH, enable LVR (3.0V) DB 0FEH ; 003FH, Internal RC oscillator 1MHz > VECTOR 0F6H, INT_TIMER0 ; Smart Option Setting ORG ;---------------- Chapter 2. Address Spaces ; Timer 0 interrupt > ORG 0100H RESET: DI • • • PS031305-0117 2-4 S3F8S28/S3F8S24 Product Specification Chapter 2. Address Spaces 2.3 Register Architecture In the S3F8S28/S3F8S24 implementation, the upper 64byte area of register files is expanded two 64byte areas, called set 1 and set 2. The upper 32byte area of set 1 is further expanded two 32byte register banks (bank 0 and bank 1), and the lower 32byte area is a single 32byte common area. The 64bytes of set 1 are addressed as working registers, system control registers and peripheral control registers. The 64bytes of set 2 are for general-purpose use, and commonly used for stack operations. You must use Register Indirect addressing mode or Indexed addressing mode to access registers in set 2. In case of S3F8S28/S3F8S24 the total number of addressable 8-bit registers is 341. Of these 341 registers, 69bytes are for CPU and system control registers and peripheral control and data registers, 16 bytes are used as shared working registers, and 256 registers are for general-purpose use. For many SAM8RC microcontrollers, the addressable area of the internal register file is further expanded by additional register pages at the general-purpose register space (00H to BFH: page0). This register file expansion is not implemented in the S3F8S28/S3F8S24 however. The specific register types and the area (in bytes) that they occupy in the internal register file are summarized in Table 2-1. Table 2-1 Register Type Summary Register Type PS031305-0117 Number of Bytes CPU and system control registers, peripherals, I/O, and clock control and data registers 69 General-purpose registers (including the 16-bit common working register area) 272 Total Addressable Bytes 341 2-5 S3F8S28/S3F8S24 Product Specification Set 2 Set1 Page 0 Bank 1 FFH 32 Bytes 64 Bytes System 0 and Bank Peripheral Control Registers and System Peripheral Control Registers (Register Addressing Mode) D0H CFH FFH General Purpose Data Register E0H E0H DFH Chapter 2. Address Spaces (Indirect Register or Indexed Addressing Modes or Stack Operations) System Registers (Register Addressing Mode) 256 Bytes General Purpose Register (Register Addressing Mode) C0H C0H BFH Page 0 192 Bytes Prime Data Register (All Addressing Mode) 00H Figure 2-3 PS031305-0117 Internal Register File Organization 2-6 S3F8S28/S3F8S24 Product Specification Chapter 2. Address Spaces 2.3.1 Register Page Pointer (PP) The S3C8/S3F8 Series architecture supports the logical expansion of the physical 314byte internal register files (using an 8-bit data bus) into as many as 16 separately addressable register pages. Page addressing is controlled by the register page pointer PP (DFH, Set 1, Bank0). In the S3F8S28/S3F8S24 microcontroller, a paged register file expansion is not implemented and the register page pointer settings therefore always point to "page 0". Following a reset, the page pointer's source value (lower nibble) and destination value (upper nibble) are always "0000" automatically. Therefore, S3F8S28/S3F8S24 is always selected page 0 as the source and destination page for register addressing. These page pointer (PP) register settings, as shown in Figure 2-4, should not be modified during normal operation. Register Page Pointer (PP) DFH ,Set 1, R/W MSB .7 .6 .5 .4 .3 Destination Register Page Seleciton Bits: 0 0 0 0 NOTE: Destination: page 0 .2 .1 .0 LSB Source Register Page Selection Bits: 0 0 0 0 Source: page 0 A hardware reset operation writes the 4-bit destination and source values shown above to the register page pointer. These values should not be modified to address other pages. Figure 2-4 Register Page Pointer (PP) 2.3.2 Register Set 1 The term set 1 refers to the upper 64 bytes of the register file, locations C0H to FFH. The upper 32byte area of set 1, (E0H to FFH) contains 27 mapped system and peripheral control registers. The lower 32byte area contains 15 system registers (D0H to DFH) and a 16byte common working register area (C0H to CFH). You can use the common working register area as a "scratch" area for data operations being performed in other areas of the register file. Registers in set 1 locations are directly accessible at all times using the Register addressing mode. The 16byte working register area can only be accessed using working register addressing. (For more information about working register addressing, please refer to 3 Addressing Modes. PS031305-0117 2-7 S3F8S28/S3F8S24 Product Specification Chapter 2. Address Spaces 2.3.3 Register Set 2 The same 64byte physical space that is used for set 1 locations C0H to FFH is logically duplicated to add another 64 bytes of register space. This expanded area of the register file is called set 2. The set 2 locations (C0H to FFH) is accessible on page 0 in the S3F8S28/S3F8S24 register space. The logical division of set 1 and set 2 is maintained by means of addressing mode restrictions: You can use only Register addressing mode to access set 1 locations; to access registers in set 2, you must use Register Indirect addressing mode or Indexed addressing mode. The set 2 register area is commonly used for stack operations. 2.3.4 Prime Register Space The lower 192 bytes of the 256byte physical internal register file (00H to BFH) are called the prime register space or, more simply, the prime area. You can access registers in this address using any addressing mode. (In other words, there is no addressing mode restriction for these registers, as is the case for set 1 and set 2 registers.). The prime register area on page 0 is immediately addressable following a reset. Set 1 Bank 0 Bank 1 FFH Page 0 FFH Set 2 FCH E0H D0H C0H BFH C0H Page 0 Prime Space CPU and system control General-purpose Peripheral and I/O 00H Figure 2-5 PS031305-0117 Set 1, Set 2 and Prime Area Register Map 2-8 S3F8S28/S3F8S24 Product Specification Chapter 2. Address Spaces 2.3.5 Working Registers Instructions can access specific 8-bit registers or 16-bit register pairs using either 4-bit or 8-bit address fields. When 4-bit working register addressing is used, the 256byte register file can be seen by the programmer as consisting of 328byte register groups or "slices." Each slice consists of eight 8-bit registers. Using the two 8-bit register pointers, RP1 and RP0, two working register slices can be selected at any one time to form a 16byte working register block. Using the register pointers, you can move this 16byte register block anywhere in the addressable register file, except for the set 2 area. The terms slice and block are used in this manual to help you visualize the size and relative locations of selected working register spaces: • One working register slice is 8 bytes (eight 8-bit working registers; R0 to R7 or R8 to R15) • One working register block is 16 bytes (sixteen 8-bit working registers; R0 to R15) All of the registers in an 8byte working register slice have the same binary value for their five most significant address bits. This makes it possible for each register pointer to point to one of the 24 slices in the register file. The base addresses for the two selected 8byte register slices are contained in register pointers RP0 and RP1. After a reset, RP0 and RP1 always point to the 16byte common area in set 1 (C0H to CFH). Slice 32 FFH F8H F7H F0H 1 1 1 1 1 X X X Set 1 Only RP1 (Registers R8-R15) Each register pointer points to one 8-byte slice of the register space, selecting a total 16-byte working register block. CFH C0H ~ ~ 0 0 0 0 0 X X X RP0 (Registers R0-R7) Slice 1 Figure 2-6 PS031305-0117 10H 0FH 08H 07H 00H 8-Byte Working Register Areas (Slices) 2-9 S3F8S28/S3F8S24 Product Specification Chapter 2. Address Spaces 2.3.6 Using the Register Pointers Register pointers RP0 and RP1, mapped to addresses D6H and D7H in set 1, are used to select two movable 8byte working register slices in the register file. After a reset, they point to the working register common area: RP0 points to addresses C0H to C7H, and RP1 points to addresses C8H to CFH. To change a register pointer value, you load a new value to RP0 and/or RP1 using an SRP or LD instruction (see Figure 2-7 and Figure 2-8). With working register addressing, you can only access those two 8-bit slices of the register file that are currently pointed to by RP0 and RP1. You cannot, however, use the register pointers to select a working register space in set 2, C0H to FFH, because these locations can be accessed only using the Indirect Register or Indexed addressing modes. The selected 16byte working register block usually consists of two contiguous 8byte slices. As a general programming guideline, we recommend that RP0 point to the "lower" slice and RP1 point to the "upper" slice (see Figure 2-6). In some cases, it may be necessary to define working register areas in different (non-contiguous) areas of the register file. In Figure 2-8, RP0 points to the "upper" slice and RP1 to the "lower" slice. Because a register pointer can point to the either of the two 8byte slices in the working register block, you can define the working register area very flexibly to support program requirements. Example 2-2 SRP #70H ; RP0 SRP1 #48H ; RP0 SRP0 #0A0H ; RP0 CLR RP0 ; RP0 LD RP1, #0F8H ; RP0      70H, RP1 no change, RP1 A0H, RP1 00H, RP1 no change, RP1 Setting the Register Pointers      78H 48H, no change no change 0F8H Register File Contains 32 8-Byte Slices 0 0 0 0 1 X X X 0FH (R15) RP1 8-Byte Slice 0 0 0 0 0 X X X 8-Byte Slice 08H 07H 00H (R0) RP0 Figure 2-7 PS031305-0117 16-byte contiguous working register block Contiguous 16-Byte Working Register Block 2-10 S3F8S28/S3F8S24 Product Specification Chapter 2. Address Spaces F7H (R7) 8-Byte Slice F0H (R0) Register File Contains 32 8-Byte Slices 1 1 1 1 0 X X X 16-byte non-contiguous working register block RP0 07H (R15) 0 0 0 0 0 X X X 8-Byte Slice 00H (R0) RP1 Figure 2-8 Example 2-3 Non-Contiguous 16-Byte Working Register Block Using the RPs to Calculate the Sum of a Series of Registers Calculate the sum of registers 80H to 85H using the register pointer. The register addresses 80H through 85H contains the values 10H, 11H, 12H, 13H, 14H, and 15 H, respectively: SRP0 #80H ; RP0 ADD R0,R1 ; R0 ADC R0,R2 ; R0 ADC R0,R3 ; R0 ADC R0,R4 ; R0 ADC R0,R5 ; R0       80H R0 + R1 R0 + R2 + C R0 + R3 + C R0 + R4 + C R0 + R5 + C The sum of these six registers, 6FH, is located in the register R0 (80H). The instruction string used in this example takes 12 bytes of instruction code and its execution time is 36 cycles. If the register pointer is not used to calculate the sum of these registers, the following instruction sequence would have to be used: ADD 80H,81H ; 80H ADC 80H,82H ; 80H ADC 80H,83H ; 80H ADC 80H,84H ; 80H ADC 80H,85H ; 80H      (80H) + (81H) (80H) + (82H) + C (80H) + (83H) + C (80H) + (84H) + C (80H) + (85H) + C Now, the sum of the six registers is also located in register 80H. However, this instruction string takes 15 bytes of instruction code instead of 12 bytes, and its execution time is 50 cycles instead of 36 cycles. PS031305-0117 2-11 S3F8S28/S3F8S24 Product Specification Chapter 2. Address Spaces 2.4 Register Addressing The S3C8 Series register architecture provides an efficient method of working register addressing that takes full advantage of shorter instruction formats to reduce execution time. With Register (R) addressing mode, in which the operand value is the content of a specific register or register pair, you can access all locations in the register file except for set 2. With working register addressing, you use a register pointer to specify an 8byte working register space in the register file and an 8-bit register within that space. Registers are addressed either as a single 8-bit register or as a paired 16-bit register space. In a 16-bit register pair, the address of the first 8-bit register is always an even number and the address of the next register is always an odd number. The most significant byte of the 16-bit data is always stored in the even-numbered register; the least significant byte is always stored in the next (+ 1) odd-numbered register. Working register addressing differs from Register addressing because it uses a register pointer to identify a specific 8byte working register space in the internal register file and a specific 8-bit register within that space. MSB LSB Rn Rn+1 Figure 2-9 PS031305-0117 n = Even address 16-Bit Register Pair 2-12 S3F8S28/S3F8S24 Product Specification Special-Purpose Registers Bank 1 Chapter 2. Address Spaces General-Purpose Register Bank 0 FFH FFH Control Registers E0H Set 2 System Registers D0H CFH C0H C0H BFH RP1 Register Pointers RP0 Each register pointer (RP) can independently point to one of the 24 8byte "slices" of the register file (other than set 2). After a reset, RP0 points to locations C0H-C7H and RP1 to locations C8H to CFH (that is, to the common working register area). NOTE: Prime Registers In the S3F8S28/F8S24 microcontroller, page 0-1 are implemented. 00H Register Addressing Only Page 0 Page 0 All Addressing Modes Indirect Register, Indexed Addressing Modes Can be Pointed by Register Pointer Figure 2-10 PS031305-0117 Register File Addressing 2-13 S3F8S28/S3F8S24 Product Specification Chapter 2. Address Spaces 2.4.1 Common Working Register Area (C0H to CFH) After a reset, register pointers RP0 and RP1 automatically select two 8byte register slices in set 1, locations C0H to CFH, as the active 16byte working register block: • RP0 → C0H to C7H • RP1 → C8H to CFH This 16byte address range is called common area. That is, locations in this area can be used as working registers by operations that address any location on any page in the register file. Typically, these working registers serve as temporary buffers for data operations. FFH Set 1 FFH Page 0 F0H E0H Set 2 D0H C0H BFH C0H Page 0 Following a hareware reset, register pointers RP0 and RP1 point to the common working register area, locations C0H-CFH. RP0 = 1 1 0 0 0 0 0 0 RP1 = 1 1 0 0 1 0 0 0 Figure 2-11 PS031305-0117 ~ Prime Area ~ 00H Common Working Register Area 2-14 S3F8S28/S3F8S24 Product Specification Example 2-4 Chapter 2. Address Spaces Addressing the Common Working Register Area As the following examples show, you should access working registers in the common area, locations C0H to CFH, using working register addressing mode only. Example 1: LD 0C2H,40H ; Invalid addressing mode! Use working register addressing instead: SRP #0C0H LD R2,40H ; R2 (C2H) 0C3H,#45H ; Invalid addressing mode!  the value in location 40H Example 2: ADD Use working register addressing instead: SRP #0C0H ADD R3,#45H ; R3 (C3H)  R3 + 45H 2.4.2 4-Bit Working Register Addressing Each register pointer defines a movable 8byte slice of working register space. The address information stored in a register pointer serves as an addressing "window" that makes it possible for instructions to access working registers very efficiently using short 4-bit addresses. When an instruction addresses a location in the selected working register area, the address bits are concatenated in the following way to form a complete 8-bit address: • The high-order bit of the 4-bit address selects one of the register pointers ("0" selects RP0; "1" selects RP1); • The five high-order bits in the register pointer select an 8byte slice of the register space; • The three low-order bits of the 4-bit address select one of the eight registers in the slice. As shown in Figure 2-12, the result of this operation is that the five high-order bits from the register pointer are concatenated with the three low-order bits from the instruction address to form the complete address. As long as the address stored in the register pointer remains unchanged, the three bits from the address will always point to an address in the same 8-byte register slice. Figure 2-13 shows a typical example of 4-bit working register addressing. The high-order bit of the instruction "INC R6" is "0", which selects RP0. The five high-order bits stored in RP0 (01110B) are concatenated with the three low-order bits of the instruction's 4-bit address (110B) to produce the register address 76H (01110110B). PS031305-0117 2-15 S3F8S28/S3F8S24 Product Specification Chapter 2. Address Spaces RP0 RP1 Selects RP0 or RP1 Address OPCODE 4-bit address procides three low-order bits Register pointer provides five high-order bits Together they create an 8-bit register address Figure 2-12 4-Bit Working Register Addressing RP1 RP0 0 1 1 1 0 0 0 0 0 1 1 1 1 0 0 0 Selects RP0 0 1 1 1 0 1 1 0 Figure 2-13 PS031305-0117 Register address (76H) R6 OPCODE 0 1 1 0 1 1 1 0 Instruction: 'INC R6' 4-Bit Working Register Addressing Example 2-16 S3F8S28/S3F8S24 Product Specification Chapter 2. Address Spaces 2.4.3 8-Bit Working Register Addressing You can also use 8-bit working register addressing to access registers in a selected working register area. To initiate 8-bit working register addressing, the upper four bits of the instruction address must contain the value 1100B. This 4-bit value (1100B) indicates that the remaining four bits have the same effect as 4-bit working register addressing. As shown in Figure 2-14, the lower nibble of the 8-bit address is concatenated in much the same way as for 4-bit addressing: Bit 3 selects either RP0 or RP1, which then supplies the five high-order bits of the final address. The three low-order bits of the complete address are provided by the original instruction. Figure 2-15 shows an example of 8-bit working register addressing. The four high-order bits of the instruction address (1100B) specify 8-bit working register addressing. Bit 4 ("1") selects RP1 and the five high-order bits in RP1 (10101B) become the five high-order bits of the register address. The three low-order bits of the register address (011) are provided by the three low-order bits of the 8-bit instruction address. The five-address bits from RP1 and the three address bits from the instruction are concatenated to form the complete register address, 0ABH (10101011B). RP0 RP1 Selects RP0 or RP1 Address These address bits indicate 8-bit working register addressing 1 1 0 0 Register pointer provides five high-order bits 8-bit logical address Three loworder bits 8-bit physical address Figure 2-14 PS031305-0117 8-Bit Working Register Addressing 2-17 S3F8S28/S3F8S24 Product Specification Chapter 2. Address Spaces RP1 RP0 0 1 1 1 0 0 0 0 1 0 1 0 1 0 0 0 Selects RP1 R11 1 1 0 0 1 0 1 1 8-bit address from instruction 'LD R11, R2' Specifies working register addressing Register address (0ABH) Figure 2-15 PS031305-0117 1 0 1 0 1 0 1 1 8-Bit Working Register Addressing Example 2-18 S3F8S28/S3F8S24 Product Specification Chapter 2. Address Spaces 2.5 System and User Stacks S3C8 Series microcontrollers use the system stack for subroutine calls and returns and to store data. The PUSH and POP instructions are used to control system stack operations. The S3F8S28/S3F8S24 architecture supports stack operations in the internal register file. 2.5.1 Stack Operations Return addresses for procedure calls, interrupts and data are stored on the stack. The contents of the PC are saved to stack by a CALL instruction and restored by the RET instruction. When an interrupt occurs, the contents of the PC and the FLAGS registers are pushed to the stack. The IRET instruction then pops these values back to their original locations. The stack address value is always decreased by one before a push operation and increased by one after a pop operation. The stack pointer (SP) always points to the stack frame stored on the top of the stack, as shown in Figure 2-16. High Address PCL PCL PCH Top of stack PCH Top of stack Stack contents after a call instruction Flags Stack contents after an interrupt Low Address Figure 2-16 Stack Operations 2.5.2 User-Defined Stacks You can freely define stacks in the internal register file as data storage locations. The instructions PUSHUI, PUSHUD, POPUI, and POPUD support user-defined stack operations. 2.5.3 Stack Pointers (SPL) Register location D9H contains the 8-bit stack pointer (SPL) that is used for system stack operations. After a reset, the SPL value is undetermined. Because only internal memory 256byte is implemented in The S3F8S28/S3F8S24, the SPL must be initialized to an 8-bit value in the range 00 to FFH. PS031305-0117 2-19 S3F8S28/S3F8S24 Product Specification Example 2-5 Chapter 2. Address Spaces Standard Stack Operations Using PUSH and POP The following example shows you how to perform stack operations in the internal register file using PUSH and POP instructions: LD SPL,#0FFH ; SP: FFH (Normally, the SP is set to FFH by the initialization routine) PUSH SYM ; Stack address 0BFH SYM PUSH R15 ; Stack address 0BEH R15 PUSH 20H ; Stack address 0BDH 20H PUSH R3 ; Stack address 0BCH R3 POP R3 ; R3 Stack address 0BCH POP 20H ; 20H Stack address 0BDH POP R15 ; R15 Stack address 0BEH POP SYM ; SYM Stack address 0BFH • • • • • • PS031305-0117 2-20 S3F8S28/S3F8S24 Product Specification 3 Chapter 3. Addressing Modes Addressing Modes 3.1 Overview Instructions that are stored in program memory are fetched for execution using the program counter. Instructions indicate the operation to be performed and the data to be operated on. Addressing mode is the method used to determine the location of the data operand. The operands specified in SAM88RC instructions may be condition codes, immediate data, or a location in the register file, program memory, or data memory. The S3F Series instruction set supports seven explicit addressing modes. Not all of these addressing modes are available for each instruction. The seven addressing modes and their symbols are: • Register (R) • Indirect Register (IR) • Indexed (X) • Direct Address (DA) • Indirect Address (IA) • Relative Address (RA) • Immediate (IM) PS031305-1017 3-1 S3F8S28/S3F8S24 Product Specification Chapter 3. Addressing Modes 3.2 Register Addressing Mode (R) In Register addressing mode (R), the operand value is the content of a specified register or register pair (see Figure 3-1). Working register addressing differs from Register addressing in that it uses a register pointer to specify an 8byte working register space in the register file and an 8-bit register within that space (see Figure 3-2). Program Memory 8-bit Register File Address dst OPCODE Register File OPERAND Point to One Register in Register File One-Operand Instruction (Example) Value used in Instruction Execution Sample Instruction: DEC CNTR ; Where CNTR is the label of an 8-bit register address Figure 3-1 Register Addressing Register File MSB Point to RP0 ot RP1 RP0 or RP1 Selected RP points to start of working register block Program Memory 4-bit Working Register dst 3 LSBs src Point to the Working Register (1 of 8) OPCODE Two-Operand Instruction (Example) OPERAND Sample Instruction: ADD R1, R2 ; Figure 3-2 PS031305-1017 Where R1 and R2 are registers in the currently selected working register area. Working Register Addressing 3-2 S3F8S28/S3F8S24 Product Specification Chapter 3. Addressing Modes 3.3 Indirect Register Addressing Mode (IR) In Indirect Register (IR) addressing mode, the content of the specified register or register pair is the address of the operand. Depending on the instruction used, the actual address may point to a register in the register file, to program memory (ROM), or to an external memory space (see Figure 3-3 through Figure 3-6). You can use any 8-bit register to indirectly address another register. Any 16-bit register pair can be used to indirectly address another memory location. Please note, however, that you cannot access locations C0H to FFH in set 1 using the Indirect Register addressing mode. Program Memory 8-bit Register File Address dst OPCODE One-Operand Instruction (Example) Register File Point to One Register in Register File ADDRESS Address of Operand used by Instruction Value used in Instruction Execution OPERAND Sample Instruction: RL @SHIFT Figure 3-3 PS031305-1017 ; Where SHIFT is the label of an 8-bit register address Indirect Register Addressing to Register File 3-3 S3F8S28/S3F8S24 Product Specification Chapter 3. Addressing Modes Register File Program Memory Example Instruction References Program Memory dst OPCODE REGISTER PAIR Points to Register Pair Program Memory Sample Instructions: CALL JP @RR2 @RR2 Figure 3-4 PS031305-1017 Value used in Instruction 16-Bit Address Points to Program Memory OPERAND Indirect Register Addressing to Program Memory 3-4 S3F8S28/S3F8S24 Product Specification Chapter 3. Addressing Modes Register File MSB Points to RP0 or RP1 RP0 or RP1 Program Memory 4-bit Working Register Address dst src OPCODE ~ ~ 3 LSBs Point to the Working Register (1 of 8) ADDRESS ~ Sample Instruction: OR R3, @R6 Figure 3-5 PS031305-1017 Value used in Instruction Selected RP points to start fo working register block ~ OPERAND Indirect Working Register Addressing to Register File 3-5 S3F8S28/S3F8S24 Product Specification Chapter 3. Addressing Modes Register File MSB Points to RP0 or RP1 RP0 or RP1 Selected RP points to start of working register block Program Memory 4-bit Working Register Address Example Instruction References either Program Memory or Data Memory dst src OPCODE Next 2-bit Point to Working Register Pair (1 of 4) LSB Selects Value used in Instruction Register Pair Program Memory or Data Memory 16-Bit address points to program memory or data memory OPERAND Sample Instructions: LCD LDE LDE Figure 3-6 PS031305-1017 R5,@RR6 R3,@RR14 @RR4, R8 ; Program memory access ; External data memory access ; External data memory access Indirect Working Register Addressing to Program or Data Memory 3-6 S3F8S28/S3F8S24 Product Specification Chapter 3. Addressing Modes 3.4 Indexed Addressing Mode (X) Indexed (X) addressing mode adds an offset value to a base address during instruction execution in order to calculate the effective operand address (see Figure 3-7). You can use Indexed addressing mode to access locations in the internal register file or in external memory. Please note, however, that you cannot access locations C0H to FFH in set 1 using Indexed addressing mode. In short offset Indexed addressing mode, the 8-bit displacement is treated as a signed integer in the range – 128 to + 127. This applies to external memory accesses only (see Figure 3-8.) For register file addressing, an 8-bit base address provided by the instruction is added to an 8-bit offset contained in a working register. For external memory accesses, the base address is stored in the working register pair designated in the instruction. The 8-bit or 16-bit offset given in the instruction is then added to that base address (see Figure 3-9). The only instruction that supports Indexed addressing mode for the internal register file is the Load instruction (LD). The LDC and LDE instructions support Indexed addressing mode for internal program memory and for external data memory, when implemented. Register File RP0 or RP1 ~ Value used in Instruction + Program Memory Two-Operand Instruction Example Base Address dst/src x 3 LSBs Point to One of the Woking Register (1 of 8) OPCODE ~ Selected RP points to start of working register block OPERAND ~ ~ INDEX Sample Instruction: LD R0, #BASE[R1] Figure 3-7 PS031305-1017 ; Where BASE is an 8-bit immediate value Indexed Addressing to Register File 3-7 S3F8S28/S3F8S24 Product Specification Chapter 3. Addressing Modes Register File MSB Points to RP0 or RP1 RP0 or RP1 ~ ~ Program Memory 4-bit Working Register Address OFFSET dst/src x OPCODE Selected RP points to start of working register block NEXT 2 Bits Point to Working Register Pair (1 of 4) LSB Selects + 8-Bits Register Pair Program Memory or Data Memory 16-Bit address added to offset 16-Bits 16-Bits OPERAND Value used in Instruction Sample Instructions: LDC R4, #04H[RR2] LDE R4,#04H[RR2] Figure 3-8 PS031305-1017 ; The values in the program address (RR2 + 04H) are loaded into register R4. ; Identical operation to LDC example, except that external program memory is accessed. Indexed Addressing to Program or Data Memory with Short Offset 3-8 S3F8S28/S3F8S24 Product Specification Chapter 3. Addressing Modes Register File MSB Points to RP0 or RP1 RP0 or RP1 Program Memory ~ ~ OFFSET 4-bit Working Register Address OFFSET dst/src src NEXT 2 Bits Point to Working Register Pair OPCODE Selected RP points to start of working register block LSB Selects + 8-Bits Register Pair Program Memory or Data Memory 16-Bit address added to offset 16-Bits 16-Bits OPERAND Value used in Instruction Sample Instructions: LDC R4, #1000H[RR2] LDE R4,#1000H[RR2] Figure 3-9 PS031305-1017 ; The values in the program address (RR2 + 1000H) are loaded into register R4. ; Identical operation to LDC example, except that external program memory is accessed. Indexed Addressing to Program or Data Memory 3-9 S3F8S28/S3F8S24 Product Specification Chapter 3. Addressing Modes 3.5 Direct Address Mode (DA) In Direct Address (DA) mode, the instruction provides the operand's 16-bit memory address. Jump (JP) and Call (CALL) instructions use this addressing mode to specify the 16-bit destination address that is loaded into the PC whenever a JP or CALL instruction is executed. The LDC and LDE instructions can use Direct Address mode to specify the source or destination address for Load operations to program memory (LDC) or to external data memory (LDE), if implemented. Program or Data Memory Program Memory Upper Address Byte Lower Address Byte dst/src "0" or "1" OPCODE Memory Address Used LSB Selects Program Memory or Data Memory: "0" = Program Memory "1" = Data Memory Sample Instructions: LDC R5,1234H ; LDE R5,1234H ; Figure 3-10 PS031305-1017 The values in the program address (1234H) are loaded into register R5. Identical operation to LDC example, except that external program memory is accessed. Direct Addressing for Load Instructions 3-10 S3F8S28/S3F8S24 Product Specification Chapter 3. Addressing Modes Program Memory Next OPCODE Memory Address Used Upper Address Byte Lower Address Byte OPCODE Sample Instructions: JP CALL C,JOB1 DISPLAY Figure 3-11 PS031305-1017 ; ; Where JOB1 is a 16-bit immediate address Where DISPLAY is a 16-bit immediate address Direct Addressing for Call and Jump Instructions 3-11 S3F8S28/S3F8S24 Product Specification Chapter 3. Addressing Modes 3.6 Indirect Address Mode (IA) In Indirect Address (IA) mode, the instruction specifies an address located in the lowest 256 bytes of the program memory. The selected pair of memory locations contains the actual address of the next instruction to be executed. Only the CALL instruction can use the Indirect Address mode. Because the Indirect Address mode assumes that the operand is located in the lowest 256 bytes of program memory, only an 8-bit address is supplied in the instruction; the upper bytes of the destination address are assumed to be all zeros. Program Memory Next Instruction LSB Must be Zero Current Instruction dst OPCODE Lower Address Byte Upper Address Byte Program Memory Locations 0-255 Sample Instruction: CALL #40H ; The 16-bit value in program memory addresses 40H and 41H is the subroutine start address. Figure 3-12 PS031305-1017 Indirect Addressing 3-12 S3F8S28/S3F8S24 Product Specification Chapter 3. Addressing Modes 3.7 Relative Address Mode (RA) In Relative Address (RA) mode, a two-complement signed displacement between – 128 and + 127 is specified in the instruction. The displacement value is then added to the current PC value. The result is the address of the next instruction to be executed. Before this addition occurs, the PC contains the address of the instruction immediately following the current instruction. Several program control instructions use the Relative Address mode to perform conditional jumps. The instructions that support RA addressing are BTJRF, BTJRT, DJNZ, CPIJE, CPIJNE, and JR. Program Memory Next OPCODE Program Memory Address Used Displacement OPCODE Current Instruction Current PC Value + Signed Displacement Value Sample Instructions: JR ULT,$+OFFSET ; Where OFFSET is a value in the range +127 to -128 Figure 3-13 PS031305-1017 Relative Addressing 3-13 S3F8S28/S3F8S24 Product Specification Chapter 3. Addressing Modes 3.8 Immediate Mode (IM) In Immediate (IM) addressing mode, the operand value used in the instruction is the value supplied in the operand field itself. The operand may be one byte or one word in length, depending on the instruction used. Immediate addressing mode is useful for loading constant values into registers. Program Memory OPERAND OPCODE (The Operand value is in the instruction) Sample Instruction: LD Figure 3-14 PS031305-1017 R0,#0AAH Immediate Addressing 3-14 S3F8S28/S3F8S24 Product Specification 4 Chapter 4. Control Registers Control Registers 4.1 Overview In this section, detailed descriptions of the S3F8S28/S3F8S24 control registers are presented in an easy-to-read format. These descriptions will help familiarize you with the mapped locations in the register file. You can also use them as a quick-reference source when writing application programs. System and peripheral registers are summarized in Table 4-1, Table 4-2, and Table 4-3. Figure 4-1 illustrates the important features of the standard register description format. Control register descriptions are arranged in alphabetical order according to register mnemonic. More information about control registers is presented in the context of the various peripheral hardware descriptions in Part II of this manual. PS031305-1017 4-1 S3F8S28/S3F8S24 Product Specification Table 4-1 Register Name Chapter 4. Control Registers System and Peripheral Control Registers, Set1 Mnemonic Address & Location RESET Value (Bit) Address RW 7 6 5 4 3 2 1 0 TACNT D0H R 0 0 0 0 0 0 0 0 Timer A data register TADATA D1H RW 1 1 1 1 1 1 1 1 Timer 0/A control register TACON D2H RW 0 0 0 0 0 0 0 0 Basic Timer control register BTCON D3H RW 0 0 0 0 0 0 0 0 Clock control register CLKCON D4H RW 0 – – 0 0 – – – System flags register FLAGS D5H RW x x x x x x 0 0 Register Pointer 0 RP0 D6H RW 1 1 0 0 0 – – – Register Pointer 1 RP1 D7H RW 1 1 0 0 1 – – – Stack Pointer register SPL D9H RW x x x x x x x x Instruction Pointer (High Byte) IPH DAH RW x x x x x x x x Instruction Pointer (Low Byte) IPL DBH RW x x x x x x x x Interrupt Request register IRQ DCH R 0 0 0 0 0 0 0 0 Interrupt Mask Register IMR DDH RW 0 0 0 0 0 0 0 0 System Mode Register SYM DEH RW 0 – – x x x 0 0 Register Page Pointer PP DFH RW 0 0 0 0 0 0 0 0 Timer A counter register Location D8H is not mapped NOTE: –: Not mapped or not used, x: Undefined PS031305-1017 4-2 S3F8S28/S3F8S24 Product Specification Table 4-2 Chapter 4. Control Registers System and Peripheral Control Registers, Set1, Bank0 Register Name Mnemonic Address & Location RESET Value (Bit) Address RW 7 6 5 4 3 2 1 0 Port 0 data register P0 E0H RW 0 0 0 0 0 0 0 0 Port 1 data register P1 E1H RW – – – – – 0 0 0 Port 2 data register P2 E2H RW – 0 0 0 0 0 0 0 Port 3 data register P3 E3H RW – – – – 0 0 0 0 Port 2 pull-up resistor enable register P2PUR E4H RW – 0 0 0 0 0 0 0 Port 0 pull-up resistor enable register P0PUR E5H RW 0 0 0 0 0 0 0 0 Port 0 control register (High Byte) P0CONH E6H RW 0 0 0 0 0 0 0 0 Port 0 control register (Low Byte) P0CONL E7H RW 0 0 0 0 0 0 0 0 Port 0 interrupt pending register P0PND E8H RW – – – – 0 0 0 0 Port 1 control register P1CON E9H RW 0 0 – – 0 0 0 0 Port 2 control register (High Byte) P2CONH EAH RW – 0 0 0 0 0 0 0 Port 2 control register (Low Byte) P2CONL EBH RW 0 0 0 0 0 0 0 0 TBCNT ECH R 0 0 0 0 0 0 0 0 Timer B data register TBDATA EDH RW 1 1 1 1 1 1 1 1 Timer B control register TBCON EEH RW – – 0 0 0 0 0 0 Port 3 interrupt pending register P3PND EFH RW 0 0 0 0 0 0 0 0 Port 3 control register P3CON F0H RW 0 0 0 0 0 0 0 0 PWM0EX F1H RW 0 0 0 0 0 0 0 0 PWM0 data register PWM0DATA F2H RW 0 0 0 0 0 0 0 0 PWM0 control register PWM0CON F3H RW 0 0 – 0 0 0 0 0 STOP control register STOPCON F4H RW 0 0 0 0 0 0 0 0 Ring Oscillator control register ROSCCON F5H RW 0 0 0 0 0 0 0 0 WDTCON F6H RW 0 0 0 0 0 0 0 0 ADCON F7H RW 1 1 1 1 0 0 0 0 A/D converter data register (High) ADDATAH F8H R x x x x x x x x A/D converter data register (Low) ADDATAL F9H R 0 0 0 0 0 0 x x BTCNT FDH R 0 0 0 0 0 0 0 0 External memory timing register EMT FEH RW 0 0 0 0 0 0 0 0 Interrupt priority register IPR FFH RW x x x x x x x x Timer B counter register PWM0 extension data register Watchdog Timer control register A/D control register Locations FAH to FCH are not mapped Basic Timer counter NOTE: –: Not mapped or not used, x: Undefined PS031305-1017 4-3 S3F8S28/S3F8S24 Product Specification Table 4-3 Chapter 4. Control Registers System and Peripheral Control Registers, Set1, Bank1 Register Name Mnemonic Address & Location RESET Value (Bit) Address RW 7 6 5 4 3 2 1 0 Timer 1 Data Register (High Byte) T1DATAH E0H RW 1 1 1 1 1 1 1 1 Timer 1 Data Register (Low Byte) T1DATAL E1H RW 1 1 1 1 1 1 1 1 Timer 1 Counter Register (High Byte) T1CNTH E2H R 0 0 0 0 0 0 0 0 Timer 1 Counter Register (Low Byte) T1CNTL E3H R 0 0 0 0 0 0 0 0 Timer 1 Control Register T1CON E4H RW 0 0 0 0 0 0 0 0 Timer 1 prescaler register T1PS E5H RW 0 0 0 0 0 0 0 0 PWM1EX E6H RW 0 0 0 0 0 0 0 0 PWM1 data register PWM1DATA E7H RW 0 0 0 0 0 0 0 0 PWM1 control register PWM1CON E8H RW 0 0 – 0 0 0 0 0 RESETID EAH RW Refer to the detail description Flash memory control register FMCON ECH RW 0 0 0 0 0 – – 0 Flash memory user programming enable register FMUSR EDH RW 0 0 0 0 0 0 0 0 Flash memory sector address register (High Byte) FMSECH EEH RW 0 0 0 0 0 0 0 0 Flash memory sector address register (Low Byte) FMSECL EFH RW 0 0 0 0 0 0 0 0 IIC Control Register ICCR F0H RW 0 0 0 0 1 1 1 1 IIC Status Register ICSR F1H RW 0 0 0 0 0 0 0 0 IIC Data Shift Register IDSR F2H RW x x x x x x x x IAR F3H RW x x x x x x x x LVDCON F4H RW 0 – 0 – – – 0 0 UART control register UARTCON F5H RW 0 0 0 0 0 0 0 0 UART pending register UARTPND F6H RW – – – – – – 0 0 BRDATA F7H RW 1 1 1 1 1 1 1 1 UDATA F8H RW x x x x x x x x PWM1 extension data register Locations E9H are not mapped Reset source indicating register IIC Address Register Low Voltage Detector Control Register UART Baud rate data register UART data register Location F9H to FFH is not mapped NOTE: –: Not mapped or not used, x: Undefined PS031305-1017 4-4 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers Bit number(s) that is/are appended to the register name for bit addressing Name of individual Register bit or related bits Register name ID Register address (hexadecimal) D5H FLAGS - System Flags Register Bit Identifier RESET Value Read/Write .7 .6 .5 .7 .6 .5 .4 .3 .2 .1 .0 x R/W x R/W x R/W x R/W x R/W x R/W 0 R/W 0 R/W Carry Flag (C) 0 Operation dose not generate a carry or borrow condition 1 Operation generates carry-out or borrow into high-order bit7 Zero Flag 0 Operation result is a non-zero value 1 Operation result is zero Sign Flag 0 Operation generates positive number (MSB = "0") 1 Operation generates negative number (MSB = "1") R = Read-only W = Write-only R/W = Read/write ' - ' = Not used Figure 4-1 PS031305-1017 Description of the effect of specific bit settings RESET value notation: '-' = Not used 'x' = Undetermind value '0' = Logic zero '1' = Logic one Bit number: MSB = Bit 7 LSB = Bit 0 Register Description Format 4-5 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.1 ADCON • A/D Converter Control Register: F7H, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 1 1 1 1 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW .7–.4 .3 A/D Converter Input Pin Selection Bits 0 0 0 0 ADC0 (P0.0) 0 0 0 1 ADC1 (P0.1) 0 0 1 0 ADC2 (P0.2) 0 0 1 1 ADC3 (P0.3) 0 1 0 0 ADC4 (P0.4) 0 1 0 1 ADC5 (P0.5) 0 1 1 0 ADC6 (P0.6) 0 1 1 1 ADC7 (P0.7) 1 0 0 0 ADC8 (P2.6) 1 0 0 1 ADC9 (P2.5) 1 0 1 0 ADC10 (P2.) 1 0 1 1 ADC11 (P3.0) 1 1 0 0 ADC12 (P3.1) 1 1 0 1 1 1 1 0 1 1 1 1 Disable ADC (Power Down) End-of-Conversion Status Bit .2–.1 .0 0 A/D conversion is in progress 1 A/D conversion complete Clock Source Selection Bit (NOTE) 0 0 fOSC/16 (fOSC  12MHz) 0 1 fOSC/12 (fOSC  10MHz) 1 0 fOSC/8 (fOSC  4MHz) 1 1 fOSC/4 (fOSC  3.2MHz) Conversion Start Bit 0 No meaning 1 A/D conversion start NOTE: 1. Maximum ADC clock input = 850kHz. PS031305-1017 4-6 S3F8S28/S3F8S24 Product Specification 2. Chapter 4. Control Registers When you select one ADC channel, the ADC module was enabled; when disable ADC, the ADC enter Power Down mode. 4.1.2 BTCON • Basic Timer Control Register: D3H, SET 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW .7–.4 Watchdog Timer Function Enable Bit 1 0 1 0 Others .3–.2 Disable watchdog timer function Enable watchdog timer function Basic Timer Input Clock Selection Code .1 0 0 fOSC/4096 0 1 fOSC/1024 1 0 fOSC/128 1 1 Invalid setting Basic Timer 8-Bit Counter Clear Bit .0 0 No effect 1 Clear the basic timer counter value Basic Timer Divider Clear Bit 0 No effect 1 Clear both dividers NOTE: When you write a "1" to BTCON.0 (or BTCON.1), the basic timer counter (or basic timer divider) is cleared. The bit is then cleared automatically to "0". PS031305-1017 4-7 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.3 CLKCON • Clock Control Register: D4H, SET 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 – – 0 0 – – – Read/Write RW – – RW RW – – – .7 Oscillator IRQ Wake-up Function Enable Bit 0 Enable IRQ for main system oscillator wake-up function 1 Disable IRQ for main system oscillator wake-up function .6–.5 Not used for S3F8S28/S3F8S24 .4–.3 Divided by Selection Bits for CPU Clock frequency .2–.0 PS031305-1017 0 0 Divide by 16 (fOSC/16) 0 1 Divide by 8 (fOSC/8) 1 0 Divide by 2 (fOSC/2) 1 1 Non-divided clock (fOSC) Not used for S3F8S28/S3F8S24 4-8 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.4 EMT • External Memory Timing Register: FEH, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW R R R R R RW R .7 External wait Input Function Enable Bit .6 0 Disable wait input function for external device 1 Disable wait input function for external device Slow Memory Timing Enable Bit .5 and .4 .3 and .2 .1 0 Disable slow memory timing 1 Enable slow memory timing Program Memory Automatic Wait Control Bits 0 0 No wait 0 1 Wait one cycle 1 0 Wait two cycles 1 1 Wait three cycles Data Memory Automatic Wait Control Bits 0 0 No wait 0 1 Wait one cycle 1 0 Wait two cycles 1 1 Wait three cycles Stack Area Selection Bit .0 0 Select internal register file area 1 Select external register file area Not used for the S3F8S28/S3F8S24 NOTE: The EMT register is not used, because an external peripheral interface is not implemented. The program initialization routine should clear the EMT register to "00H" following a reset. Modification of EMT values during normal operation may cause a system malfunction PS031305-1017 4-9 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.5 FLAGS • System Flags Register: D5H, SET 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value x x x x x x 0 0 Read/Write RW RW RW RW RW RW R RW Addressing Mode Register addressing mode only .7 Carry Flag (C) .6 .5 .4 .3 .2 .1 .0 PS031305-1017 0 Operation does not generate a carry or borrow condition 1 Operation generates a carry-out or borrow into high-order bit 7 Zero Flag (Z) 0 Operation result is a non-zero value 1 Operation result is zero Sign Flag (S) 0 Operation generates a positive number (MSB = "0") 1 Operation generates a negative number (MSB = "1") Overflow Flag (V) 0 Operation result is  + 127 or – 128 1 Operation result is  + 127 or  – 128 Decimal Adjust Flag (D) 0 Add operation completed 1 Subtraction operation completed Half-Carry Flag (H) 0 No carry-out of bit 3 or no borrow into bit 3 by addition or subtraction 1 Addition generated carry-out of bit 3 or subtraction generated borrow into bit 3 Fast Interrupt Status Flag (FIS) 0 Interrupt return (IRET) in progress (when read) 1 Fast interrupt service routine in progress (when read) Bank Address Selection Flag (BA) 0 Bank 0 is selected 1 Bank 1 is selected 4-10 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.6 FMCON • Flash Memory Control Register: ECH, SET 1, BANK 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 – – – 0 Read/Write RW RW RW RW – – – RW .7–.4 Flash Memory Mode Selection Bits 0 1 0 1 Programming mode 1 0 1 0 Sector erase mode 0 1 1 0 Hard lock mode Other values Not available .3–.1 Not used for the S3F8S28/S3F8S24 .0 Flash Operation Start Bit 0 Operation stop 1 Operation start (This bit will be cleared automatically just after the corresponding operator completed). 4.1.7 FMSECH • Flash Memory Sector Address Register (High Byte): EEH, SET 1, BANK 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write R/W R/W R/W R/W R/W R/W R/W R/W .7–.0 Flash Memory Sector Address Bits (High Byte) The 15th to 8th bits to select a sector of Flash ROM NOTE: The high-byte Flash memory sector address pointer value is the higher eight bits of the 16-bit pointer address. PS031305-1017 4-11 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.8 FMSECL • Flash Memory Sector Address Register (Low Byte): EFH, SET 1, BANK 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW .7 Flash Memory Sector Address Bit (Low Byte) The 7th bit to select a sector of Flash ROM .6–.0 Bits 6–0 Don't care NOTE: The low-byte Flash memory sector address pointer value is the lower eight bits of the 16-bit pointer address. 4.1.9 FMUSR • Flash Memory User Programming Enable Register: EDH, SET 1, BANK 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW .7–.0 PS031305-1017 Flash Memory User Programming Enable Bits 10100101 Enable user programming mode Other values Disable user programming mode 4-12 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.10 ICCR • Multi-master IIC Bus Clock Control Register: F0H, SET1, BANK1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 nRESET Value 0 0 0 0 1 1 1 1 RW RW RW RW RW RW RW RW Read/Write Addressing Mode Register addressing mode only .7 Acknowledgement Enable Bit .6 .5 .4 .3–.0 0 Acknowledgement disable mode 1 Acknowledgement enable mode Tx Clock Selection Bit 0 fOSC/16 1 fOSC/512 Multi-master IIC Bus Tx/Rx Interrupt Enable Bit 0 Disable 1 Enable Multi-master 0 Interrupt request is not pending; (when read) pending bit clear when write 0 1 Interrupt request is pending (when read) ICCR.3–0: Transmit Clock 4-Bit prescaler Bits SCL clock = IICLK/CCR[3:0] + 1 where, IICLK = fOSC/16 when IICR.6 is "0", IICLK = fOSC/512 when ICCR.6 is "1" PS031305-1017 4-13 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.11 ICSR • IIC Status Register: F1H, SET1, BANK1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 nRESET Value 0 0 0 0 0 0 0 0 RW RW RW RW RW RW RW RW Read/Write Addressing Mode Register addressing mode only .7–.6 IIC Bus Master/Slave Tx/Rx Mode Selection Bits .5 .4 .3 0 0 Slave receiver mode (default mode) 0 1 Slave transmitter mode 1 0 Master receiver mode 1 1 Master transmitter mode IIC Bus Busy Bit 0 IIC-bus is not busy 0 Stop condition generation 1 IIC-bus is busy (when read) 1 Stop condition generation (when write) IIC-bus Interface Module Enable Bit 0 Disable IIC-bus data transmit/receive 1 Enable IIC-bus data transmit/receive Arbitration Lost Bit This bit is set by H/W when the serial I/O interface, in master transmit mode, loses a bus arbitration procedure. In slave mode this flag is set to "1" when ICCR.5 is "1" and ICSR.2 is "0" .2 .1 .0 PS031305-1017 Address Match Bit 0 When Start or Stop or Reset 1 When received slave address matches to IAR register or general call General Call Bit 0 When Start/Stop condition is generated 1 When received slave address is "00000000" (general call) Received Acknowledge Bit 0 ACK is received 1 ACK is not received 4-14 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.12 IMR • Interrupt Mask Register: DDH, SET 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value x x x x x x x x Read/Write RW RW RW RW RW RW RW RW .7 .6 .5 .4 .3 .2 .1 .0 Interrupt Level 7 (IRQ7) 0 Disable (mask) 1 Enable (unmask) Interrupt Level 6 (IRQ6) 0 Disable (mask) 1 Enable (unmask) Interrupt Level 5 (IRQ5) 0 Disable (mask) 1 Enable (unmask) Interrupt Level 4 (IRQ4) 0 Disable (mask) 1 Enable (unmask) Interrupt Level 3 (IRQ3) 0 Disable (mask) 1 Enable (unmask) Interrupt Level 2 (IRQ2) 0 Disable (mask) 1 Enable (unmask) Interrupt Level 1 (IRQ1) 0 Disable (mask) 1 Enable (unmask) Interrupt Level 0 (IRQ0) 0 Disable (mask) 1 Enable (unmask) NOTE: When an interrupt level is masked, the CPU does not recognize any interrupt requests that may be issued. PS031305-1017 4-15 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.13 IPH • Instruction Pointer (High Byte): DAH, SET 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value x x x x x x x x Read/Write RW RW RW RW RW RW RW RW .7–.0 Instruction Pointer Address (High Byte) The high-byte instruction pointer value is the upper eight bits of the 16-bit instruction pointer address (IP15 to IP8). The lower byte of the IP address is located in the IPL register (DBH). 4.1.14 IPL • Instruction Pointer (Low Byte): DBH, SET 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value x x x x x x x x Read/Write RW RW RW RW RW RW RW RW .7–.0 Instruction Pointer Address (Low Byte) The low-byte instruction pointer value is the lower eight bits of the 16-bit instruction pointer address (IP7 to IP0). The upper byte of the IP address is located in the IPH register (DAH). PS031305-1017 4-16 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.15 IPR • Interrupt Priority Register: FFH, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value x x x x x x x x Read/Write RW RW RW RW RW RW RW RW .7, .4 and .1 .6 Priority Control Bits for Interrupt Groups A, B, and C (NOTE) 0 0 0 Group priority undefined 0 0 1 B>C>A 0 1 0 A>B>C 0 1 1 B>A>C 1 0 0 C>A>B 1 0 1 C>B>A 1 1 0 A>C>B 1 1 1 Group priority undefined Interrupt Subgroup C Priority Control Bit .5 0 IRQ6 > IRQ7 1 IRQ7 > IRQ6 Interrupt Group C Priority Control Bit .3 0 IRQ5 > (IRQ6, IRQ7) 1 (IRQ6, IRQ7) > IRQ5 Interrupt Subgroup B Priority Control Bit .2 0 IRQ3 > IRQ4 1 IRQ4 > IRQ3 Interrupt Group B Priority Control Bit .0 0 IRQ2 > (IRQ3, IRQ4) 1 (IRQ3, IRQ4) > IRQ2 Interrupt Group A Priority Control Bit 0 IRQ0 > IRQ1 1 IRQ1 > IRQ0 NOTE: Interrupt Group A: IRQ0, IRQ1 Interrupt Group B: IRQ2, IRQ3, IRQ4 Interrupt Group C: IRQ5, IRQ6, IRQ7 PS031305-1017 4-17 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.16 IRQ • Interrupt Request Register: DCH, SET 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write R R R R R R R R .7 .6 .5 .4 .3 .2 .1 .0 PS031305-1017 Level 7 (IRQ7) Request Pending Bit; 0 Not pending 1 Pending Level 6 (IRQ6) Request Pending Bit; 0 Not pending 1 Pending Level 5 (IRQ5) Request Pending Bit; 0 Not pending 1 Pending Level 4 (IRQ4) Request Pending Bit; 0 Not pending 1 Pending Level 3 (IRQ3) Request Pending Bit; 0 Not pending 1 Pending Level 2 (IRQ2) Request Pending Bit; 0 Not pending 1 Pending Level 1 (IRQ1) Request Pending Bit; 0 Not pending 1 Pending Level 0 (IRQ0) Request Pending Bit; 0 Not pending 1 Pending 4-18 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.17 LVDCON • Interrupt Request Register: F4H, SET 1, BANK 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 – 0 – – – 0 0 Read/Write RW – R – – – RW RW .7 LVD Enable/Disable Bit 0 LVD Disable 1 LVD Enable .6 Not Used in S3F8S28/S3F8S24 .5 LVD Output Bit (Read Only) 0 VDD > VLVD 1 VDD < VLVD .4 Not Used in S3F8S28/S3F8S24 (must be kept as "0") .3-.2 Not Used in S3F8S28/S3F8S24 .1–.0 Detection Voltage Level Selection Bits PS031305-1017 0 0 VLVD0 = 4.1V 0 1 VLVD1 = 3.2V 1 0 VLVD2 = 2.5V 1 1 VLVD3 = 2.1V 4-19 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.18 P0CONH • Port 0 Control Register (High Byte): E6H, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW .7–.6 .5–.4 .3–.2 .1–.0 PS031305-1017 Port 0, P0.7/INT7 Configuration Bits 0 x Schmitt trigger input 1 0 Push-pull output 1 1 A/D converter input (ADC7); Schmitt trigger input off Port 0, P0.6/ADC6/PWM0 Configuration Bits 0 0 Schmitt trigger input 0 1 Alternative function (PWM0 output) 1 0 Push-pull output 1 1 A/D converter input (ADC6); Schmitt trigger input off Port 0, P0.5/ADC5/PWM1 Configuration Bits 0 0 Schmitt trigger input 0 1 Alternative function (PWM1 output) 1 0 Push-pull output 1 1 A/D converter input (ADC5); Schmitt trigger input off Port 0, P0.4/ADC4 Configuration Bits 0 x Schmitt trigger input 1 0 Push-pull output 1 1 A/D converter input (ADC4); Schmitt trigger input off 4-20 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.19 P0CONL • Port 0 Control Register (Low Byte): E7H, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW .7–.6 .5–.4 .3–.2 .1–.0 PS031305-1017 Port 0, P0.3/INT3 Configuration Bits 0 0 Schmitt trigger input/falling edge interrupt input 0 1 Alternative function: SDA input 1 0 Push-pull output 1 1 A/D converter input (ADC3); Schmitt trigger input off Port 0, P0.2/ADC2 Configuration Bits 0 0 Schmitt trigger input/falling edge interrupt input 0 1 Alternative function: SCK input 1 0 Push-pull output 1 1 A/D converter input (ADC2); Schmitt trigger input off Port 0, P0.1/ADC1/INT1 Configuration Bits 0 x Schmitt trigger input/falling edge interrupt input 1 0 Push-pull output 1 1 A/D converter input (ADC1); Schmitt trigger input off Port 0, P0.0/ADC0/INT0 Configuration Bits 0 x Schmitt trigger input/falling edge interrupt input 1 0 Push-pull output 1 1 A/D converter input (ADC0); Schmitt trigger input off 4-21 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.20 P0PND • Port 0 Interrupt Pending Register: E8H, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value – – – – 0 0 0 0 Read/Write – – – – RW RW RW RW .7 .6 .5 .4 .3 .2 .1 PS031305-1017 Port 0.3/ADC3/INT3 Interrupt Enable Bit 0 INT3 falling edge interrupt disable 1 INT3 falling edge interrupt enable Port 0.3/ADC3/INT3 Interrupt Pending Bit 0 No interrupt pending (when read) 0 Pending bit clear (when write) 1 Interrupt is pending (when read) 1 No effect (when write) Port 0.2/ADC2/INT2 Interrupt Enable Bit 0 INT2 falling edge interrupt disable 1 INT2 falling edge interrupt enable Port 0.2/ADC2/INT2 Interrupt Pending Bit 0 No interrupt pending (when read) 0 Pending bit clear (when write) 1 Interrupt pending (when read) 1 No effect (when write) Port 0.1/ADC1/INT1 Interrupt Enable Bit 0 INT1 falling edge interrupt disable 1 INT1 falling edge interrupt enable Port 0.1/ADC1/INT1 Interrupt Pending Bit 0 No interrupt pending (when read) 0 Pending bit clear (when write) 1 Interrupt is pending (when read) 1 No effect (when write) Port 0.0/ADC0/INT0 Interrupt Enable Bit 0 INT0 falling edge interrupt disable 1 INT0 falling edge interrupt enable 4-22 S3F8S28/S3F8S24 Product Specification .0 PS031305-1017 Chapter 4. Control Registers Port 0.0/ADC0/INT0 Interrupt Pending Bit 0 No interrupt pending (when read) 0 Pending bit clear (when write) 1 Interrupt pending (when read) 1 No effect (when write) 4-23 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.21 P0PUR • Port 0 Pull-up Resistor Enable Register: E5H, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW .7 .6 .5 .4 .3 .2 .1 .0 PS031305-1017 Port 0.7 Pull-up Resistor Enable Bit 0 Enable Pull-up Resistor 1 Disable Pull-up Resistor Port 0.6 Pull-up Resistor Enable Bit 0 Enable Pull-up Resistor 1 Disable Pull-up Resistor Port 0.5 Pull-up Resistor Enable Bit 0 Enable Pull-up Resistor 1 Disable Pull-up Resistor Port 0.4 Pull-up Resistor Enable Bit 0 Enable Pull-up Resistor 1 Disable Pull-up Resistor Port 0.3 Pull-up Resistor Enable Bit 0 Disable Pull-up Resistor 1 Enable Pull-up Resistor Port 0.2 Pull-up Resistor Enable Bit 0 Disable Pull-up Resistor 1 Enable Pull-up Resistor Port 0.1 Pull-up Resistor Enable Bit 0 Disable Pull-up Resistor 1 Enable Pull-up Resistor Port 0.0 Pull-up Resistor Enable Bit 0 Disable Pull-up Resistor 1 Enable Pull-up Resistor 4-24 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.22 P1CON • Port 1 Control Register: E9H, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 – – 0 0 0 0 Read/Write RW RW – – RW RW RW RW .7 .6 Part 1.1 N-channel open-drain Enable Bit 0 Configure P1.1 as a push-pull output 1 Configure P1.1 as a n-channel open-drain output Port 1.0 N-channel open-drain Enable Bit 0 Configure P1.0 as a push-pull output 1 Configure P1.0 as a n-channel open-drain output .5 Not used for S3F8S28/S3F8S24 .4 Port 1.2 Configuration Bit .3–.2 .1–.0 0 Configure P1.2 as a Schmitt trigger input; 1 Configure P1.2 as a open-drain output Port 1, P1.1 Configuration Bits 0 0 Schmitt trigger input; 0 1 Schmitt trigger input; pull-up enable 1 0 Output 1 1 Schmitt trigger input; pull-down enable Port 1, P1.0 Configuration Bits 0 0 Schmitt trigger input; 0 1 Schmitt trigger input; pull-up enable 1 0 Output 1 1 Schmitt trigger input; pull-down enable NOTE: When you use external oscillator, P1.0, P1.1 must be set to output port to prevent current consumption. PS031305-1017 4-25 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.23 P2CONH • Port 2 Control Register (High Byte): EAH, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value – 0 0 0 0 0 0 0 Read/Write – RW RW RW RW RW RW RW .7 Not used for the S3F8S28/S3F8S24 .6–.4 Port 2, P2.6/ADC8/CLO Configuration Bits .3–.2 .1–.0 0 0 x Schmitt trigger input 0 1 x ADC input 1 0 0 Push-pull output 1 0 1 Open-drain output; pull-up enable 1 1 0 Open-drain output 1 1 1 Alternative function; CLO output Port 2, 2.5/ADC9 Configuration Bits 0 0 Schmitt trigger input 0 1 Alternative function: ADC Input 1 0 Push-pull output 1 1 Invalid Port 2, 2.4/ADC10 Configuration Bits 0 0 Schmitt trigger input 0 1 Alternative function: ADC Input 1 0 Push-pull output 1 1 Invalid NOTE: When noise problem is important issue, you had better not use CLO output. PS031305-1017 4-26 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.24 P2CONL • Port 2 Control Register (Low Byte): EBH, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW .7–.6 .5–.4 .3–.2 .1–.0 PS031305-1017 Part 2, P2.3 Configuration Bits 0 0 Schmitt trigger input 0 1 Alternative function: TxD output 1 0 Push-pull output 1 1 Open-drain output Port 2, P2.2 Configuration Bits 0 0 Schmitt trigger input T1 capture input; RxD input 0 1 Alternative function: RxD output 1 0 Push-pull output 1 1 Open-drain output Port 2, P2.1 Configuration Bits 0 0 Schmitt trigger input 0 1 Alternative function:T1 match output 1 0 Push-pull output 1 1 Open-drain output Port 2, P2.0 Configuration Bits 0 0 Schmitt trigger input 0 1 Alternative function:T0 match output 1 0 Push-pull output 1 1 Open-drain output 4-27 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.25 P2PUR • Port 2 Pull-up Resistor Enable Register: E4H, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value – 0 0 0 0 0 0 0 Read/Write – RW RW RW RW RW RW RW .7 Not used for the S3F8S28/S3F8S24 .6 Port 2.6 Pull-up Resistor Enable Bit .5 .4 .3 .2 .1 .0 PS031305-1017 0 Enable Pull-up Resistor 1 Disable Pull-up Resistor Port 2.5 Pull-up Resistor Enable Bit 0 Enable Pull-up Resistor 1 Disable Pull-up Resistor Part 2.4 Pull-up Resistor Enable Bit 0 Enable Pull-up Resistor 1 Disable Pull-up Resistor Part 2.3 Pull-up Resistor Enable Bit 0 Enable Pull-up Resistor 1 Disable Pull-up Resistor Part 2.2 Pull-up Resistor Enable Bit 0 Enable Pull-up Resistor 1 Disable Pull-up Resistor Part 2.1 Pull-up Resistor Enable Bit 0 Enable Pull-up Resistor 1 Disable Pull-up Resistor Part 2.0 Pull-up Resistor Enable Bit 0 Enable Pull-up Resistor 1 Disable Pull-up Resistor 4-28 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.26 P3CON • Port 3 Control Register: F0H, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW .7–.6 .5–.4 .3–.2 .1–.0 PS031305-1017 Part 3, P3.3 Configuration Bits 0 0 Schmitt trigger input/falling edge interrupt input 0 1 Schmitt trigger input with pull-up/falling edge interrupt input 1 x Push-pull output Port 3, P3.2 Configuration Bits 0 0 Schmitt trigger input/falling edge interrupt input 0 1 Schmitt trigger input with pull-up /falling edge interrupt input 1 x Push-pull output Port 3, P3.1/ADC12 Configuration Bits 0 0 Schmitt trigger input/falling edge interrupt input 0 1 Schmitt trigger input with pull-up /falling edge interrupt input 1 0 Push-pull output 1 1 Alternative function: ADC input Port 3, P3.0/ADC11 Configuration Bits 0 0 Schmitt trigger input/falling edge interrupt input 0 1 Schmitt trigger input with pull-up /falling edge interrupt input 1 0 Push-pull output 1 1 Alternative function: ADC input 4-29 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.27 P3PND • Port 3 Interrupt Pending Register: EFH, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW .7 .6 .5 .4 .3 .2 .1 PS031305-1017 Port 3.3/ADC12/INT7 Interrupt Enable Bit 0 INT7 falling edge interrupt disable 1 INT7 falling edge interrupt enable Port 3.3/ADC12/INT7 Interrupt Pending Bit 0 No interrupt pending (when read) 0 Pending bit clear (when write) 1 Interrupt is pending (when read) 1 No effect (when write) Port 3.2/ADC11/INT6 Interrupt Enable Bit 0 INT6 falling edge interrupt disable 1 INT6 falling edge interrupt enable Port 3.2/ADC11/INT6 Interrupt Pending Bit 0 No interrupt pending (when read) 0 Pending bit clear (when write) 1 Interrupt pending (when read) 1 No effect (when write) Port 3.1/ADC10/INT5 Interrupt Enable Bit 0 INT5 falling edge interrupt disable 1 INT5 falling edge interrupt enable Port 3.1/ADC10/INT5 Interrupt Pending Bit 0 No interrupt pending (when read) 0 Pending bit clear (when write) 1 Interrupt is pending (when read) 1 No effect (when write) Port 3.0/ADC9/INT4 Interrupt Enable Bit 0 INT4 falling edge interrupt disable 1 INT4 falling edge interrupt enable 4-30 S3F8S28/S3F8S24 Product Specification .0 Chapter 4. Control Registers Port 3.0/ADC9/INT4 Interrupt Pending Bit 0 No interrupt pending (when read) 0 Pending bit clear (when write) 1 Interrupt pending (when read) 1 No effect (when write) 4.1.28 PP • Register Page Pointer: DFH, SET 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW .7–.0 Not used for the S3F8S28/S3F8S24. NOTE: In S3F8S28/S3F8S24, only page 0 settings are valid. Register page pointer values for the source and destination register page are automatically set to "00F" following a hardware reset. These values should not be changed during normal operation. PS031305-1017 4-31 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.29 PWM0CON • PWM0 Control Register: F3H, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 – 0 0 0 0 0 Read/Write RW RW – RW RW RW RW RW .7–.6 PWM Input Clock Selection Bits 0 0 fOSC/64 0 1 fOSC/8 1 0 fOSC/2 1 1 fOSC/1 .5 Not used for S3F8S28/S3F8S24 .4 PWM0DATA Reload Interval Selection Bit .3 .2 .1 .0 0 Reload from extension up counter overflow 1 Reload from base up counter overflow PWM Counter Clear Bit 0 No effect 1 Clear the PWM counter (when write) PWM Counter Enable Bit 0 Stop counter 1 Start (Resume countering) PWM Overflow Interrupt Enable Bit (12-bit overflow) 0 Disable interrupt 1 Enable interrupt PWM Overflow Interrupt Pending Bit 0 No interrupt pending (when read) 0 Clear pending bit (when write) 1 Interrupt is pending (when read) 1 No effect (when write) NOTE: PWM0CON.3 is not autocleared. You must pay attention when clear pending bit. (Refer to page 13-14). PS031305-1017 4-32 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.30 PWM1CON • PWM1 Control Register: E8H, SET 1, BANK 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 – 0 0 0 0 0 Read/Write RW RW – RW RW RW RW RW .7–.6 PWM Input Clock Selection Bits 0 0 fOSC/64 0 1 fOSC/8 1 0 fOSC/2 1 1 fOSC/1 .5 Not used for S3F8S28/S3F8S24 .4 PWM1DATA Reload Interval Selection Bit .3 .2 .1 .0 0 Reload from extension up counter overflow 1 Reload from base up counter overflow PWM Counter Clear Bit 0 No effect 1 Clear the PWM counter (when write) PWM Counter Enable Bit 0 Stop counter 1 Start (Resume countering) PWM Overflow Interrupt Enable Bit (12-bit overflow) 0 Disable interrupt 1 Enable interrupt PWM Overflow Interrupt Pending Bit 0 No interrupt pending (when read) 0 Clear pending bit (when write) 1 Interrupt is pending (when read) 1 No effect (when write) NOTE: PWM1CON.3 is not autocleared. You must pay attention when clear pending bit. (Refer to page 13-14). PS031305-1017 4-33 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.31 PWM0EX • PWM0 Extension Register: F1H, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW .7–.2 PWM Extension Bits PWM extension bits: Bit .7–.2 for 6+6 resolution and 8+6 resolution; Bit .7–.6 for 6+2 resolution .1–.0 PWM Base/extension Control bits: 0 0 1 0 0 1 Base 6-bit (PWM0DATA.5–.0) + Extension 2-bit (PWM0EX.7–.6) 1 1 Base 8-bit (PWM0DATA.7–.0) + Extension 6-bit (PWM0EX.7–.2) Base 6-bit (PWM0DATA.7–.2) + Extension 6-bit (PWM0EX.7–.2) 4.1.32 PWM1EX • PWM1 Extension Register: E6H, SET 1, BANK 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW .7–.2 PWM Extension Bits PWM extension bits: Bit .7–.2 for 6+6 resolution and 8+6 resolution Bit .7–.6 for 6+2 resolution .1–.0 PS031305-1017 PWM Base/extension Control bits: 0 0 1 0 0 1 Base 6-bit (PWM1DATA.5–.0) + Extension 2-bit (PWM1EX.7–.6) 1 1 Base 8-bit (PWM1DATA.7–.0) + Extension 6-bit (PWM1EX.7–.2) Base 6-bit (PWM1DATA.7–.2) + Extension 6-bit (PWM1EX.7–.2) 4-34 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.33 RESETID • Reset Source Indicating Register: EAH, SET 1, BANK1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Read/Write – – – – – RW RW RW Addressing Mode Register addressing mode only .7–.4 Not used for the S3F8S28/S3F8S24 .3 Watchdog Timer Reset Indicating Bit .2 0 Reset is not generated by Watch dog (when read) 1 Reset is generated by Watch dog (when read) nReset pin Indicating Bit .1 0 Reset is not generated by nReset pin (when read) 1 Reset is generated by nReset pin (when read) Basic Timer Reset Indicating Bit .0 0 Reset is not generated by Basic Timer (when read) 1 Reset is generated by Basic Timer (when read) LVR Reset Indicating Bit 0 Reset is not generated by LVR (when read) 1 Reset is generated by LVR (when read) State of RESETID depends on reset source .7 .6 .5 .4 .3 .2 .1 .0 LVR – – – – 0 0 0 1 WDT, or nReset pin – – – – (4) (4) (4) (3) NOTE: 1. When LVR is disabled (Smart Option 3FH.7 = 0), RESETID.0 is invalid; when P1.2 is set to be IO (Smart Option 3FH.4 = 0), RESETID.3 is invalid. 2. To clear an indicating register, write a "0" to indicating flag bit; writing a "1" has no effect. 3. Once a LVR reset happens, RESETID.1 will be set and all the other bits will be cleared to "0" at the same time. 4. Once a WDT reset, Basic Timer reset or nRESET pin reset happens, corresponding bit will be set, but leave all other indicating bits unchanged. PS031305-1017 4-35 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.34 ROSCCON • Ring Oscillator Control Register: F5H, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW .7 Ring OSC Enable Bit .6 0 Disable Ring OSC 1 Enable Ring OSC Free Running Watchdog Timer Clock Source Selection Bit .5–.0 0 System Clock: Fosc 1 Ring OSC clock Ring OSC Frequency Trimming Bits 000000 Maximum frequency 111111 Minimum frequency. 4.1.35 RP0 • Register Pointer 0: D6H, SET 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 1 1 0 0 0 – – – Read/Write RW RW RW RW RW – – – .7–.3 Register Pointer 0 Address Value Register pointer 0 can independently point to one of the 208byte working register areas in the register file. Using the register pointers RP0 and RP1, you can select two 8-byte register slices at one time as active working register space. After a reset, RP0 points to address C0H, selecting the 8byte working register slice C0H to C7H. .2–.0 PS031305-1017 Not used for the S3F8S28/S3F8S24 4-36 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.36 RP1 • Register Pointer 1: D7H, SET 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 1 1 0 0 1 – – – Read/Write RW RW RW RW RW – – – .7–.3 Register Pointer 1 Address Value Register pointer 1 can independently point to one of the 208byte working register areas in the register file. Using the register pointers RP0 and RP1, you can select two 8-byte register slices at one time as active working register space. After a reset, RP1 points to address C8H, selecting the 8byte working register slice C8H to CFH. .2–.0 Not used for the S3F8S28/S3F8S24 4.1.37 SPL • Stack Pointer: D9H, SET 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value x x x x x x x x Read/Write RW RW RW RW RW RW RW RW .7–.0 Stack Pointer Address (Low Byte) The SP value is undefined following a reset. 4.1.38 STOPCON • Stop Mode Control Register: F4H, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW .7–.0 Watchdog Timer Function Enable Bit 10100101 Enable STOP instruction Other value Disable STOP instruction NOTE: 1. Before execute the STOP instruction, set this STPCON register as "10100101b". 2. When STOPCON register is not #0A5H value, if you use STOP instruction, PC is changed to reset address. PS031305-1017 4-37 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.39 SYM • System Mode Register: DEH, SET 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 – – x x x 0 0 Read/Write RW – – RW RW RW RW RW Tri-state External Interface Control Bit (1) .7 0 Normal operation (disable tri-state operation) 1 Set external interface lines to high impedance (enable tri-state operation) .6–.5 Not used for the S3F8S28/S3F8S24 .4–.2 Fast Interrupt Level Selection Bits (2) 0 0 0 IRQ0 0 0 1 IRQ1 0 1 0 IRQ2 0 1 1 IRQ3 1 0 0 IRQ4 1 0 1 IRQ5 1 1 0 IRQ6 1 1 1 IRQ7 Fast Interrupt Enable Bit (3) .1 0 Disable fast interrupt processing 1 Enable fast interrupt processing Global Interrupt Enable Bit (4) .0 0 Disable all interrupt processing 1 Enable all interrupt processing NOTE: 1. Because an external interface is not implemented, SYM.7 must always be "0". 2. You can select only one interrupt level at a time for fast interrupt processing. 3. Setting SYM.1 to "1" enables fast interrupt processing for the interrupt level currently selected by SYM.2 to SYM.4. 4. Following a reset, you must enable global interrupt processing by executing an EI instruction (not by writing a "1" to SYM.0). PS031305-1017 4-38 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.40 T1CON • Timer 1 Control Register: E4H, SET 1, Bank1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW Addressing Mode Register addressing mode only .7–.6 Timer 1 Operating Mode Selection Bits .5 0 0 Interval timer mode (counter cleared by match signal) 0 1 Capture mode (rising edges, counter running, OVF interrupt can occur) 1 0 Capture mode (falling edges, counter running, OVF interrupt can occur) 1 1 Capture mode (both falling edges and rising edges, counter running, OVF interrupt can occur) Timer 1 Counter Run Enable Bit .4 0 Stop Timer 1 (Disable Counter Run) 1 Start Timer 1 (Enable Counter Run) Timer 1 Counter Clear Bit .3 0 No effect 1 Clear T1 counter, T1CNT (when write, After clearing, return to "0") Timer 1 Overflow Interrupt Enable Bit .2 0 Disable T1 overflow interrupt 1 Enable T1 overflow interrupt Timer 1 Overflow Interrupt Pending Bit .1 0 No interrupt pending (when read); Clear pending bit (when write) 1 Interrupt is pending (when read); No effect (when write) Timer 1 Match/Capture Interrupt Enable Bit .0 0 Disable T1 match/capture interrupt 1 Enable T1 match/capture interrupt Timer 1 Match/Capture Interrupt Pending Bit 0 No interrupt pending (when read); Clear pending bit (when write) 1 Interrupt is pending (when read); No effect (when write) NOTE: A Timer 1 overflow interrupt pending condition is automatically cleared by hardware. However, the Timer 1 match/capture interrupt, IRQ3, vector ECH, must be cleared by the interrupt service routine (S/W). PS031305-1017 4-39 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.41 T1PS • Timer 1 Prescaler Register (Low Byte): E5H, SET 1, Bank1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW Addressing Mode Register addressing mode only .7–.4 Not used for the S3F8S28/S3F8S24 .3–.0 Timer 1 prescaler bits T1 clock = FOSC/(2T1PS[3–0]) prescaler values above 12 are invalid 4.1.42 TACON • Timer 0/A Control Register: D2H, SET 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 – 0 0 0 0 0 0 Read/Write RW – RW RW RW RW RW RW .7 Timer 0 Operating Mode Selection Bit 0 Two 8-bit timers mode (Timer A/B) 1 One 16-bit timer mode (Timer 0) .6 Must be always "0" .5–.4 Timer 0/A Clock Selection Bits .3 .2 0 0 fxx/256 0 1 fxx/64 1 0 fxx/8 1 1 fxx Timer 0/A Counter Clear Bit (NOTE) 0 No effect 1 Clear the Timer 0/A counter (when write) Timer 0/A Counter Run Enable Bit 0 PS031305-1017 Disable Counter Running 4-40 S3F8S28/S3F8S24 Product Specification 1 .1 Chapter 4. Control Registers Enable Counter Running Timer 0/A Interrupt Enable Bit .0 0 Disable interrupt 1 Enable interrupt Timer 0/A Interrupt Pending Bit 0 No interrupt pending (when read) 0 Clear pending bit (when write) 1 Interrupt is pending (when read) 1 No effect (when write) NOTE: 1. When you write "1" to TACON.3, the Timer 0/A counter value is cleared to "00H". Immediately following the write operation, the TACON.3 value is automatically cleared to "0". 2. TACON.6 must be always "0" during normal operation. PS031305-1017 4-41 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.43 TBCON • Timer B Control Register: EEH, SET 1, BANK 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value – – 0 0 0 0 0 0 Read/Write – – RW RW RW RW RW RW .7 and .6 Not used for the S3F8S28/S3F8S24 .5 and .4 Timer B Clock Selection Bits 0 0 fxx/256 0 1 fxx/64 1 0 fxx/8 1 1 fxx Timer B Counter Clear Bit (NOTE) .3 .2 0 No effect 1 Clear the timer B counter (when write) Timer B Counter Run Enable Bit .1 0 Disable Counter Running 1 Enable Counter Running Timer B Interrupt Enable Bit .0 0 Disable interrupt 1 Enable interrupt Timer B Interrupt Pending Bit 0 No interrupt pending (when read) 0 Clear pending bit (when write) 1 Interrupt is pending (when read) 1 No effect (when write) NOTE: When you write a "1" to TBCON.3, the Timer B counter value is cleared to "00H". Immediately following the write operation, the TBCON.3 value is automatically cleared to "0". PS031305-1017 4-42 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.44 UARTCON • UART Control Register: F5H, Set 1, Bank 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW Addressing Mode Register addressing mode only .7–.6 Operating mode and baud rate selection bits 0 0 Mode 0: SIO mode [fxx/(16  (BRDATA + 1))] 0 1 Mode 1: 8-bit UART [fxx/(16  (BRDATA + 1))] 1 0 Mode 2: 9-bit UART [fxx/16] 1 1 Mode 3: 9-bit UART [fxx/(16  (BRDATA + 1))] Multiprocessor communication (1) enable bit (for modes 2 and 3 only) .5 .4 0 Disable 1 Enable Serial data receive enable bit 0 Disable 1 Enable .3 Location of the 9th data bit to be transmitted in UART Mode 2 or 3 ("0" or "1") .2 Location of the 9th data bit that was received in UART Mode 2 or 3 ("0" or "1") .1 Receive interrupt enable bit .0 0 Disable Receive interrupt 1 Enable Receive interrupt Transmit interrupt enable bit 0 Disable Transmit interrupt 1 Enable Transmit Interrupt NOTE: 1. In mode 2 or 3, if the MCE (UARTCON.5) bit is set to "1", then the receive interrupt will not be activated if the received 9th data bit is "0". In mode 1, if MCE = "1", then the receive interrupt will not be activated if a valid stop bit was not received. In mode 0, the MCE (UARTCON.5) bit should be "0". 2. The descriptions for 8-bit and 9-bit UART Mode do not include start and stop bits for serial data receive and transmit. PS031305-1017 4-43 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.45 UARTPND • UART Pending and parity control: F6H, Set 1, Bank 1 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value – – – – – – 0 0 Read/Write – – – – – – RW RW .7–.2 Not used for the S3F8S28/S3F8S24 .1 UART receive interrupt pending flag .0 0 Not pending 0 Clear pending bit (when write) 1 Interrupt pending UART transmit interrupt pending flag 0 Not pending 0 Clear pending bit (when write) 1 Interrupt pending NOTE: 1. In order to clear a data transmit or receive interrupt pending flag, you must write a "0" to the appropriate pending bit. 2. To avoid programming errors, we recommend using load instruction (except for LDB), when manipulating UARTPND values. PS031305-1017 4-44 S3F8S28/S3F8S24 Product Specification Chapter 4. Control Registers 4.1.46 WDTCON • Watchdog Timer Control Register: F6H, Set 1, Bank 0 Bit Identifier .7 .6 .5 .4 .3 .2 .1 .0 Reset Value 0 0 0 0 0 0 0 0 Read/Write RW RW RW RW RW RW RW RW .7 .6 .5 .4 .3–.0 Watchdog Timer Enable bit 0 Disable Watchdog Timer 1 Enable Watchdog Timer Watchdog Time Overflow Reset Enable bit 0 Disable Overflow Reset 1 Enable Overflow Reset Watchdog Timer Interrupt Enable bit 0 Disable Interrupt 1 Enable Interrupt Watchdog Timer Counter bit 10 Clear bit 0 No effect 1 Clear counter bit 10 (when write) Watchdog clock prescaler bits Watchdog clock = FLCLK/(2WDPS[3–0]) NOTE: FLCLK means the clock source for free running Watchdog Timer, that was selected by ROSCCON.6 PS031305-1017 4-45 S3F8S28/S3F8S24 Product Specification 5 Chapter 5. Interrupt Structure Interrupt Structure 5.1 Overview The S3C8/S3F8 Series interrupt structure has three basic components: levels, vectors, and sources. The SAM8RC CPU recognizes up to eight interrupt levels and supports up to 128 interrupt vectors. When a specific interrupt level has more than one vector address, the vector priorities are established in hardware. A vector address can be assigned to one or more sources. 5.1.1 Levels Interrupt levels are the main unit for interrupt priority assignment and recognition. All peripherals and I/O blocks can issue interrupt requests. In other words, peripheral and I/O operations are interrupt-driven. There are eight possible interrupt levels: IRQ0 to IRQ7, also called level 0 to level 7. Each interrupt level directly corresponds to an interrupt request number (IRQn). The total number of interrupt levels used in the interrupt structure varies from device to device. The S3F8S28/S3F8S24 interrupt structure recognizes eight interrupt levels. The interrupt level numbers 0 through 7 do not necessarily indicate the relative priority of the levels. They are just identifiers for the interrupt levels that are recognized by the CPU. The relative priority of different interrupt levels is determined by settings in the interrupt priority register, IPR. Interrupt group and subgroup logic controlled by IPR settings let you define more complex priority relationships between different levels. 5.1.2 Vectors Each interrupt level can have one or more interrupt vectors, or it may have no vector address assigned at all. The maximum number of vectors that can be supported for a given level is 128 (The actual number of vectors used for S3C8/S3F8 Series devices is always much smaller). If an interrupt level has more than one vector address, the vector priorities are set in hardware. S3F8S28/S3F8S24 uses 17 vectors. 5.1.3 Sources A source is any peripheral that generates an interrupt. A source can be an external pin or a counter overflow. Each vector can have several interrupt sources. In the S3F8S28/S3F8S24 interrupt structure, there are 17 possible interrupt sources. When a service routine starts, the respective pending bit should be either cleared automatically by hardware or cleared "manually" by program software. The characteristics of the source's pending mechanism determine which method would be used to clear its respective pending bit. PS031305-1017 5-1 S3F8S28/S3F8S24 Product Specification Chapter 5. Interrupt Structure 5.2 Interrupt Types The three components of the S3C8/S3F8 interrupt structure described before - levels, vectors, and sources - are combined to determine the interrupt structure of an individual device and to make full use of its available interrupt logic. There are three possible combinations of interrupt structure components, called interrupt types 1, 2, and 3. The types differ in the number of vectors and interrupt sources assigned to each level (see Figure 5-1): • Type 1: One level (IRQn) + one vector (V1) + one source (S1) • Type 2: One level (IRQn) + one vector (V1) + multiple sources (S1 – Sn) • Type 3: One level (IRQn) + multiple vectors (V1 – Vn) + multiple sources (S1 – Sn, Sn + 1 – Sn + m) In the S3F8S28/S3F8S24 microcontroller, two interrupt types are implemented. Type 1: Levels Vectors Sources IRQn V1 S1 S1 Type 2: IRQn V1 S2 S3 Sn Type 3: IRQn V1 S1 V2 S2 V3 S3 Vn Sn NOTES: 1. The number of Sn and Vn value is expandable. 2. In the S3F8S28/F8S24 implementation, interrupt types 1 and 3 are used. Figure 5-1 PS031305-1017 Sn + 1 Sn + 2 Sn + m S3C8/S3F8 Series Interrupt Types 5-2 S3F8S28/S3F8S24 Product Specification Chapter 5. Interrupt Structure 5.3 S3F8S28/S3F8S24 Interrupt Structure The S3F8S28/S3F8S24 microcontroller supports 17 interrupt sources. Every interrupt source has a corresponding interrupt address. Eight interrupt levels are recognized by the CPU in this device-specific interrupt structure, as shown in Figure 5-2. When multiple interrupt levels are active, the interrupt priority register (IPR) determines the order in which contending interrupts are to be serviced. If multiple interrupts occur within the same interrupt level, the interrupt with the lowest vector address is usually processed first (The relative priorities of multiple interrupts within a single level are fixed in hardware). When the CPU grants an interrupt request, interrupt processing starts. All other interrupts are disabled and the program counter value and status flags are pushed to stack. The starting address of the service routine is fetched from the appropriate vector address (plus the next 8-bit value to concatenate the full 16-bit address) and the service routine is executed. Levels Vectors RESET 100H Basic timer overflow H/W FEH External interrupt 0 S/W FCH External interrupt 1 S/W FAH External interrupt 2 S/W F8H External interrupt 3 S/W F6H Timer 0/A match interrupt S/W F4H Timer B match interrupt S/W F2H PWM0 overflow interrupt S/W F0H PWM1 overflow interrupt S/W ECH Timer 1 match/capture interrupt S/W EAH Timer 1 overflow interrupt H/W E6H Watchdog interrupt H/W E4H UART transmit interrupt S/W E2H UART Receive interrupt S/W E0H IIC transmit / receive interrupt S/W DEH External interrupt 4 S/W DCH External interrupt 5 S/W DAH External interrupt 6 S/W D8H External interrupt 7 S/W IRQ0 IRQ1 IRQ2 IRQ3 IRQ4 IRQ5 IRQ6 IRQ7 NOTE: Reset/Clear External interrupts are triggered by a falling edge. Figure 5-2 PS031305-1017 Sources S3F8S28/S3F8S24 Interrupt Structure 5-3 S3F8S28/S3F8S24 Product Specification Chapter 5. Interrupt Structure 5.3.1 Interrupt Vector Addresses All interrupt vector addresses for the S3F8S28/S3F8S24 interrupt structure is stored in the vector address area of the first 256 bytes of the program memory (ROM). You can allocate unused locations in the vector address area as normal program memory. If you do so, please be careful not to overwrite any of the stored vector addresses. The program reset address in the ROM is 0100H. (Decimal) 8,191 (HEX) 1FFFH S3F8S28: 8K-byte Program Memory Area 0FFFH 4,095 S3F8S24: 4K-byte Program Memory Area 100H FFH 255 Reset Address Interrupt Vector Address Area 0 Figure 5-3 00H ROM Vector Address Area 5.3.2 Enable/Disable Interrupt Instructions (EI, DI) Executing the Enable Interrupts (EI) instruction globally enables the interrupt structure. All interrupts are then serviced as they occur according to the established priorities. NOTE: The system initialization routine executed after a reset must always contain an EI instruction to globally enable the interrupt structure. During the normal operation, you can execute the DI (Disable Interrupt) instruction at any time to globally disable interrupt processing. The EI and DI instructions change the value of bit 0 in the SYM register. PS031305-1017 5-4 S3F8S28/S3F8S24 Product Specification Chapter 5. Interrupt Structure 5.4 System-Level Interrupt Control Registers In addition to the control registers for specific interrupt sources, four system-level registers control interrupt processing: • The interrupt mask register, IMR, enables (un-masks) or disables (masks) interrupt levels. • The interrupt priority register, IPR, controls the relative priorities of interrupt levels. • The interrupt request register, IRQ, contains interrupt pending flags for each interrupt level (as opposed to each interrupt source). • The system mode register, SYM, enables or disables global interrupt processing (SYM settings also enable fast interrupts and control the activity of external interface, if implemented). Table 5-1 Control Register Interrupt mask register Interrupt Control Register Overview ID RW Function Description IMR RW Bit settings in the IMR register enable or disable interrupt processing for each of the eight interrupt levels: IRQ0 to IRQ7. Interrupt priority register IPR RW Controls the relative processing priorities of the interrupt levels. The eight levels of S3F8S28/S3F8S24 are organized into three groups: A, B, and C. Group A is IRQ0 and IRQ1, group B is IRQ2, IRQ3 and IRQ4, and group C is IRQ5, IRQ6, and IRQ7. Interrupt request register IRQ R This register contains a request pending bit for each interrupt level. System mode register SYM RW This register enables/disables fast interrupt processing, and dynamic global interrupt processing. NOTE: All interrupts must be disabled before IMR register is changed to any value. Using DI instruction is recommended. PS031305-1017 5-5 S3F8S28/S3F8S24 Product Specification Chapter 5. Interrupt Structure 5.5 Interrupt Processing Control Points Interrupt processing can therefore be controlled in two ways: globally or by specific interrupt level and source. The system-level control points in the interrupt structure are: • Global interrupt enable and disable (by EI and DI instructions or by direct manipulation of SYM.0) • Interrupt level enable/disable settings (IMR register) • Interrupt level priority settings (IPR register) • Interrupt source enable/disable settings in the corresponding peripheral control registers NOTE: When writing an application program that handles interrupt processing, be sure to include the necessary register file address (register pointer) information. EI S nRESET R Q Interrupt Request Register (Read-only) Polling Cycle IRQ0-IRQ7, Interrupts Interrupt Priority Register Vector Interrupt Cycle Interrupt Mask Register Global Interrupt Control (EI, DI or SYM.0 manipulation) Figure 5-4 PS031305-1017 Interrupt Function Diagram 5-6 S3F8S28/S3F8S24 Product Specification Chapter 5. Interrupt Structure 5.6 Peripheral Interrupt Control Registers For each interrupt source there is one or more corresponding peripheral control registers that let you control the interrupt generated by the related peripheral (see Table 5-2). Table 5-2 Interrupt Source Interrupt Source Control and Data Registers Interrupt Level Register (s) Location (s) P0.0 to P0.3 external interrupt IRQ0 P0CONL P0PND E7H, Bank0 E8H, Bank0 Timer 0/A match interrupt Timer B match interrupt IRQ1 TACON P2CONL TBCON D0H, Bank0 EBH, Bank0 D1H, Bank0 PWM0 overflow interrupt PWM1 overflow interrupt IRQ2 PWM0CON PWM1CON P0CONH F3H, Bank0 E8H, Bank1 E6H, Bank0 Timer 1 match/capture interrupt Timer 1 overflow interrupt IRQ3 T1CON E4H, Bank1 Watchdog interrupt IRQ4 WDTCON F6H, Bank0 IRQ5 UARTCON UARTPND BRDATA UDATA F5H, Bank1 F6H, Bank1 F7H, Bank1 F8H, Bank1 IIC Transmit/Receive interrupt IRQ6 ICCR ICSR IDSR IAR F0H, Bank1 F1H, Bank1 F2H, Bank1 F3H, Bank1 P3.0 to P3.3 external interrupt IRQ7 P3CON P3PND F0H, Bank0 EFH, Bank0 UART Transmit interrupt UART Receive interrupt PS031305-1017 5-7 S3F8S28/S3F8S24 Product Specification Chapter 5. Interrupt Structure 5.7 System Mode Register (SYM) The system mode register, SYM (DEH), is used to globally enable and disable interrupt processing and to control fast interrupt processing (see Figure 5-5). A reset clears SYM.1 and SYM.0 to "0". The 3-bit value for fast interrupt level selection, SYM.4 to SYM.2, is undetermined. The instructions EI and DI enable and disable global interrupt processing, respectively, by modifying the bit 0 value of the SYM register. In order to enable interrupt processing an Enable Interrupt (EI) instruction must be included in the initialization routine, which follows a reset operation. Although you can manipulate SYM.0 directly to enable and disable interrupts during the normal operation, it is recommended to use the EI and DI instructions for this purpose. System Mode Register (SYM) DEH, R/W MSB .7 .6 .5 .3 .4 .2 Always logic "0". Fast interrupt level selection bits: Not used for the S3F8S28/F8S24 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 Figure 5-5 PS031305-1017 0 1 0 1 0 1 0 1 IRQ0 IRQ1 IRQ2 IRQ3 IRQ4 IRQ5 IRQ6 IRQ7 .1 .0 LSB Global interrupt enable bit: 0 = Disable all interrupts processing 1 = Enable all interrupts processing Fast interrupt enable bit: 0 = Disable fast interrupts processing 1 = Enable fast interrupts processing System Mode Register (SYM) 5-8 S3F8S28/S3F8S24 Product Specification Chapter 5. Interrupt Structure 5.8 Interrupt Mask Register (IMR) The interrupt mask register, IMR (DDH) is used to enable or disable interrupt processing for individual interrupt levels. After a reset, all IMR bit values are undetermined and must therefore be written to their required settings by the initialization routine. Each IMR bit corresponds to a specific interrupt level: bit 1 to IRQ1, bit 2 to IRQ2, and so on. When the IMR bit of an interrupt level is cleared to "0", interrupt processing for that level is disabled (masked). When you set a level's IMR bit to "1", interrupt processing for the level is enabled (not masked). The IMR register is mapped to register location DDH. Bit values can be read and written by instructions using the Register addressing mode. Interrupt Mask Register (IMR) DDH, R/W MSB .7 IRQ7 NOTE: .6 IRQ6 .5 IRQ5 IRQ4 .3 IRQ3 .2 IRQ2 .1 IRQ1 .0 LSB IRQ0 Interrupt level enable bit: 0 = Disable (mask) interrupt level 1 = Enable (un-mask) interrupt level Before IMR register is changed to any value, all interrupts must be disable. Using DI instruction is recommended. Figure 5-6 PS031305-1017 .4 Interrupt Mask Register (IMR) 5-9 S3F8S28/S3F8S24 Product Specification Chapter 5. Interrupt Structure 5.9 Interrupt Priority Register (IPR) The interrupt priority register, IPR (FFH), is used to set the relative priorities of the interrupt levels in the microcontroller’s interrupt structure. After a reset, all IPR bit values are undetermined and must therefore be written to their required settings by the initialization routine. When more than one interrupt sources are active, the source with the highest priority level is serviced first. If two sources belong to the same interrupt level, the source with the lower vector address usually has the priority (This priority is fixed in hardware). To support programming of the relative interrupt level priorities, they are organized into groups and subgroups by the interrupt logic. Please note that these groups (and subgroups) are used only by IPR logic for the IPR register priority definitions (see Figure 5-7): • Group A IRQ0, IRQ1 • Group B IRQ2, IRQ3, IRQ4 • Group C IRQ5, IRQ6, IRQ7 IPR Group A A1 IPR Group B A2 B1 B2 B21 IRQ0 IRQ1 IRQ2 IRQ3 Figure 5-7 PS031305-1017 IPR Group C C1 B22 IRQ4 C2 C21 IRQ5 IRQ6 C22 IRQ7 Interrupt Request Priority Groups 5-10 S3F8S28/S3F8S24 Product Specification Chapter 5. Interrupt Structure As you can see in Figure 5-8, IPR.7, IPR.4, and IPR.1 control the relative priority of interrupt groups A, B, and C. For example, the setting "001B" for these bits would select the group relationship B > C > A. The setting "101B" would select the relationship C > B > A. The functions of the other IPR bit settings are as follows: • IPR.5 controls the relative priorities of group C interrupts. • Interrupt group C includes a subgroup that has an additional priority relationship among the interrupt levels 5, 6, and 7. IPR.6 defines the subgroup C relationship. IPR.5 controls the interrupt group C. • IPR.0 controls the relative priority setting of IRQ0 and IRQ1 interrupts. Interrupt Priority Register (IPR) FFH, R/W MSB .7 .6 .5 .4 .3 .2 .1 Group priority: 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 = Undefined =B>C>A =A>B>C =B>A>C =C>A>B =C>B>A =A>C>B = Undefined Group B 0 = IRQ2 > (IRQ3, IRQ4) 1 = (IRQ3, IRQ4) > IRQ2 Subgroup B 0 = IRQ3 > IRQ4 1 = IRQ4 > IRQ3 Group C 0 = IRQ5 > (IRQ6, IRQ7) 1 = (IRQ6, IRQ7) > IRQ5 Subgroup C 0 = IRQ6 > IRQ7 1 = IRQ7 > IRQ6 Figure 5-8 PS031305-1017 LSB Group A 0 = IRQ0 > IRQ1 1 = IRQ1 > IRQ0 D7 D4 D1 0 0 0 0 1 1 1 1 .0 Interrupt Priority Register (IPR) 5-11 S3F8S28/S3F8S24 Product Specification Chapter 5. Interrupt Structure 5.10 Interrupt Request Register (IRQ) You can poll bit values in the interrupt request register, IRQ (DCH), to monitor interrupt request status for all levels in the microcontroller's interrupt structure. Each bit corresponds to the interrupt level of the same number: bit 0 to IRQ0, bit 1 to IRQ1, and so on. A "0" indicates that no interrupt request is currently being issued for that level. A "1" indicates that an interrupt request has been generated for that level. IRQ bit values are read-only addressable using Register addressing mode. You can read (test) the contents of the IRQ register at any time using bit or byte addressing to determine the current interrupt request status of specific interrupt levels. After a reset, all IRQ status bits are cleared to "0". You can poll IRQ register values even if a DI instruction has been executed (that is, if global interrupt processing is disabled). If an interrupt occurs while the interrupt structure is disabled, the CPU will not service it. You can, however, still detect the interrupt request by polling the IRQ register. In this way, you can determine which events occurred while the interrupt structure was globally disabled. Interrupt Request Register (IRQ) DCH, Read-only MSB .7 IRQ7 .6 IRQ6 .5 IRQ5 Figure 5-9 PS031305-1017 .4 .3 IRQ4 IRQ3 .2 IRQ2 .1 IRQ1 .0 LSB IRQ0 Interrupt level request pending bits: 0 = Interrupt level is not pending 1 = Interrupt level is pending Interrupt Request Register (IRQ) 5-12 S3F8S28/S3F8S24 Product Specification Chapter 5. Interrupt Structure 5.11 Interrupt Pending Function Types 5.11.1 Overview There are two types of interrupt pending bits: one type that is automatically cleared by hardware after the interrupt service routine is acknowledged and executed; the other that must be cleared in the interrupt service routine. 5.11.2 Pending Bits Cleared Automatically by Hardware For interrupt pending bits that are cleared automatically by hardware, interrupt logic sets the corresponding pending bit to "1" when a request occurs. It then issues an IRQ pulse to inform the CPU that an interrupt is waiting to be serviced. The CPU acknowledges the interrupt source by sending an IACK, executes the service routine, and clears the pending bit to "0". This type of pending bit is not mapped and cannot, therefore, be read or written by application software. In the S3F8S28/S3F8S24 interrupt structure, Timer 1 overflow interrupt and Watchdog Timer interrupt belong to this category of interrupts in which pending condition is cleared automatically by hardware. 5.11.3 Pending Bits Cleared by the Service Routine The second type of pending bit is the one that should be cleared by program software. The service routine must clear the appropriate pending bit before a return-from-interrupt subroutine (IRET) occurs. To do this, a "0" must be written to the corresponding pending bit location in the source’s mode or control register. PS031305-1017 5-13 S3F8S28/S3F8S24 Product Specification Chapter 5. Interrupt Structure 5.12 Interrupt Source Polling Sequence The interrupt request polling and servicing sequence is as follows: 1. A source generates an interrupt request by setting the interrupt request bit to "1". 2. The CPU polling procedure identifies a pending condition for that source. 3. The CPU checks the source's interrupt level. 4. The CPU generates an interrupt acknowledge signal. 5. Interrupt logic determines the interrupt's vector address. 6. The service routine starts and the source's pending bit is cleared to "0" (by hardware or by software). 7. The CPU continues polling for interrupt requests. 5.13 Interrupt Service Routines Before an interrupt request is serviced, the following conditions must be met: • Interrupt processing must be globally enabled (EI, SYM.0 = "1") • The interrupt level must be enabled (IMR register) • The interrupt level must have the highest priority if more than one level is currently requesting service • The interrupt must be enabled at the interrupt's source (peripheral control register) When all the above conditions are met, the interrupt request is acknowledged at the end of the instruction cycle. The CPU then initiates an interrupt machine cycle that completes the following processing sequence: 1. Reset (clear to "0") the interrupt enable bit in the SYM register (SYM.0) to disable all subsequent interrupts. 2. Save the program counter (PC) and status flags to the system stack. 3. Branch to the interrupt vector to fetch the address of the service routine. 4. Pass control to the interrupt service routine. When the interrupt service routine is completed, the CPU issues an Interrupt Return (IRET). The IRET restores the PC and status flags, setting SYM.0 to "1". It allows the CPU to process the next interrupt request. PS031305-1017 5-14 S3F8S28/S3F8S24 Product Specification Chapter 5. Interrupt Structure 5.14 Generating Interrupt Vector Addresses The interrupt vector area in the ROM (00H to FFH) contains the addresses of interrupt service routines that correspond to each level in the interrupt structure. Vectored interrupt processing follows this sequence: 1. Push the program counter's low-byte value to the stack. 2. Push the program counter's high-byte value to the stack. 3. Push the FLAG register values to the stack. 4. Fetch the service routine's high-byte address from the vector location. 5. Fetch the service routine's low-byte address from the vector location. 6. Branch to the service routine specified by the concatenated 16-bit vector address. NOTE: A 16-bit vector address always begins at an even-numbered ROM address within the range of 00H to FFH. 5.15 Nesting of Vectored Interrupts It is possible to nest a higher-priority interrupt request while a lower-priority request is being serviced. To do this, you must follow these steps: 1. Push the current 8-bit interrupt mask register (IMR) value to the stack (PUSH IMR). 2. Load the IMR register with a new mask value that enables only the higher priority interrupt. 3. Execute an EI instruction to enable interrupt processing (a higher priority interrupt will be processed if it occurs). 4. When the lower-priority interrupt service routine ends, execute DI, restore the IMR to its original value by returning the previous mask value from the stack (POP IMR). 5. Execute an IRET. Depending on the application, you may be able to simplify the procedure above to some extent. 5.16 Instruction Pointer (IP) The instruction pointer (IP) is adopted by all the S3C8/S3F8 Series microcontrollers to control the optional highspeed interrupt processing feature called fast interrupts. The IP consists of register pair DAH and DBH. The names of IP registers are IPH (high byte, IP15 to IP8) and IPL (low byte, IP7 to IP0). PS031305-1017 5-15 S3F8S28/S3F8S24 Product Specification Chapter 5. Interrupt Structure 5.17 Fast Interrupt Processing The feature called fast interrupt processing allows an interrupt within a given level to be completed in approximately 6 clock cycles rather than the usual 16 clock cycles. To select a specific interrupt level for fast interrupt processing, you write the appropriate 3-bit value to SYM.4 to SYM.2. Then, to enable fast interrupt processing for the selected level, you set SYM.1 to "1". Two other system registers support fast interrupt processing: • The instruction pointer (IP) contains the starting address of the service routine (and is later used to swap the program counter values), and • When a fast interrupt occurs, the contents of the FLAGS register are stored in an unmapped, dedicated register called FLAGS' ("FLAGS prime"). NOTE: For the S3F8S28/S3F8S24 microcontroller, the service routine for any one of the eight interrupt levels: IRQ0 to IRQ7, can be selected for fast interrupt processing. 5.18 Procedure for Initiating Fast Interrupts To initiate fast interrupt processing, follow these steps: 1. Load the start address of the service routine into the instruction pointer (IP). 2. Load the interrupt level number (IRQn) into the fast interrupt selection field (SYM.4 to SYM.2) 3. Write a "1" to the fast interrupt enable bit in the SYM register. 5.19 Fast Interrupt Service Routine When an interrupt occurs in the level selected for fast interrupt processing, the following events occur: 1. The contents of the instruction pointer and the PC are swapped. 2. The FLAG register values are written to the FLAGS' ("FLAGS prime") register. 3. The fast interrupt status bit in the FLAGS register is set. 4. The interrupt is serviced. 5. Assuming that the fast interrupt status bit is set, when the fast interrupt service routine ends, the instruction pointer and PC values are swapped back. 6. The content of FLAGS ("FLAGS prime") is copied automatically back to the FLAGS register. 7. The fast interrupt status bit in FLAGS is cleared automatically. PS031305-1017 5-16 S3F8S28/S3F8S24 Product Specification Chapter 5. Interrupt Structure 5.20 Relationship to Interrupt Pending Bit Types As described previously, there are two types of interrupt pending bits: One type that is automatically cleared by hardware after the interrupt service routine is acknowledged and executed; the other that must be cleared by the application program's interrupt service routine. You can select fast interrupt processing for interrupts with either type of pending condition clear function-by hardware or by software. 5.21 Programming Guidelines Remember that the only way to enable/disable a fast interrupt is to set/clear the fast interrupt enable bit in the SYM register, SYM.1. Executing an EI or DI instruction globally enables or disables all interrupt processing, including fast interrupts. If you use fast interrupts, remember to load the IP with a new start address when the fast interrupt service routine ends. PS031305-1017 5-17 S3F8S28/S3F8S24 Product Specification 6 Chapter 6. Instruction Set Instruction Set 6.1 Overview The SAM8RC instruction set is specifically designed to support the large register files that are typical of most SAM8 microcontrollers. There are 78 instructions. The powerful data manipulation capabilities and features of the instruction set include: • A full complement of 8-bit arithmetic and logic operations, including multiply and divide • No special I/O instructions (I/O control/data registers are mapped directly into the register file) • Decimal adjustment included in binary-coded decimal (BCD) operations • 16-bit (word) data can be incremented and decremented • Flexible instructions for bit addressing, rotate, and shift operations 6.1.1 Data Types The SAM8 CPU performs operations on bits, bytes, BCD digits, and two-byte words. Bits in the register file can be set, cleared, complemented, and tested. Bits within a byte are numbered from 7 to 0, where bit 0 is the least significant (right-most) bit. 6.1.2 Register Addressing To access an individual register, an 8-bit address in the range 0 to 255 or the 4-bit address of a working register is specified. Paired registers can be used to construct 16-bit data or 16-bit program memory or data memory addresses. For detailed information about register addressing, please refer to Chapter 2 Address Spaces. 6.1.3 Addressing Modes There are seven explicit addressing modes: Register (R), Indirect Register (IR), Indexed (X), Direct (DA), Relative (RA), Immediate (IM), and Indirect (IA). For detailed descriptions of these addressing modes, please refer to Chapter 3 Addressing Modes. PS031305-1017 6-1 S3F8S28/S3F8S24 Product Specification Table 6-1 Mnemonic Chapter 6. Instruction Set Instruction Group Summary Operands Instruction Load Instructions CLR dst Clear LD dst,src Load LDB dst,src Load bit LDE dst,src Load external data memory LDC dst,src Load program memory LDED dst,src Load external data memory and decrement LDCD dst,src Load program memory and decrement LDEI dst,src Load external data memory and increment LDCI dst,src Load program memory and increment LDEPD dst,src Load external data memory with predecrement LDCPD dst,src Load program memory with predecrement LDEPI dst,src Load external data memory with preincrement LDCPI dst,src Load program memory with preincrement LDW dst,src Load word POP dst Pop from stack POPUD dst,src Pop user stack (decrementing) POPUI dst,src Pop user stack (incrementing) PUSH src Push to stack PUSHUD dst,src Push user stack (decrementing) PUSHUI dst,src Push user stack (incrementing) ADC dst,src Add with carry ADD dst,src Add CP dst,src Compare DA dst Decimal adjust DEC dst Decrement DECW dst Decrement word Arithmetic Instructions DIV dst,src Divide INC dst Increment INCW dst Increment word MULT dst,src Multiply SBC dst,src Subtract with carry SUB dst,src Subtract AND dst,src Logical AND COM dst Complement Logic Instructions PS031305-1017 6-2 S3F8S28/S3F8S24 Product Specification Mnemonic Operands Chapter 6. Instruction Set Instruction OR dst,src Logical OR XOR dst,src Logical exclusive OR BTJRF dst,src Bit test and jump relative on false BTJRT dst,src Bit test and jump relative on true Program Control Instructions CALL dst CPIJE dst,src Compare, increment and jump on equal CPIJNE dst,src Compare, increment and jump on non-equal DJNZ r,dst Call procedure Decrement register and jump on non-zero ENTER – Enter EXIT – Exit IRET – Interrupt return JP cc,dst JP dst JR cc,dst Jump on condition code Jump unconditional Jump relative on condition code NEXT – Next RET – Return WFI – Wait for interrupt Bit Manipulation Instructions BAND dst,src Bit AND BCP dst,src Bit compare BITC dst Bit complement BITR dst Bit reset BITS dst Bit set BOR dst,src Bit OR BXOR dst,src Bit XOR TCM dst,src Test complement under mask TM dst,src Test under mask Rotate and Shift Instructions RL dst Rotate left RLC dst Rotate left through carry RR dst Rotate right RRC dst Rotate right through carry SRA dst Shift right arithmetic SWAP dst Swap nibbles CPU Control Instructions CCF – Complement carry flag DI – Disable interrupts PS031305-1017 6-3 S3F8S28/S3F8S24 Product Specification Mnemonic Operands Instruction EI – Enable interrupts IDLE – Enter Idle mode NOP – No operation RCF – Reset carry flag SB0 – Set bank 0 SB1 – Set bank 1 SCF – Set carry flag SRP src Set register pointers SRP0 src Set register pointer 0 SRP1 src Set register pointer 1 STOP – PS031305-1017 Chapter 6. Instruction Set Enter Stop mode 6-4 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.2 Flags Register (FLAGS) The flags register FLAGS contains eight bits that describe the current status of CPU operations. Four of these bits, FLAGS.7 to FLAGS.4, can be tested and used with conditional jump instructions; two others FLAGS.3 and FLAGS.2 are used for BCD arithmetic. The FLAGS register also contains a bit to indicate the status of fast interrupt processing (FLAGS.1) and a bank address status bit (FLAGS.0) to indicate whether bank 0 or bank 1 is currently being addressed. FLAGS register can be set or reset by instructions as long as its outcome does not affect the flags, such as, Load instruction. Logical and Arithmetic instructions such as, AND, OR, XOR, ADD, and SUB can affect the Flags register. For example, the AND instruction updates the Zero, Sign and Overflow flags based on the outcome of the AND instruction. If the AND instruction uses the Flags register as the destination, then simultaneously, two write will occur to the Flags register producing an unpredictable result. System Flags Register (FLAGS) D5H, R/W MSB .7 .6 .5 .3 .2 .1 .0 LSB Bank address status flag (BA) Carry flag (C) Fast interrupt status flag (FIS) Zero flag (Z) Sign flag (S) PS031305-1017 .4 Half-carry flag (H) Overflow flag (V) Decimal adjust flag (D) Figure 6-1 System Flags Register (FLAGS) 6-5 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.2.1 Flag Descriptions • C: Carry Flag (FLAGS.7) The C flag is set to "1" if the result from an arithmetic operation generates a carry-out from or a borrow to the bit 7 position (MSB). After rotate and shift operations, it contains the last value shifted out of the specified register. Program instructions can set, clear, or complement the carry flag. • Z: Zero Flag (FLAGS.6) For arithmetic and logic operations, the Z flag is set to "1" if the result of the operation is zero. For operations that test register bits, and for shift and rotate operations, the Z flag is set to "1" if the result is logic zero. • S: Sign Flag (FLAGS.5) Following arithmetic, logic, rotate, or shift operations, the sign bit identifies the state of the MSB of the result. A logic zero indicates a positive number and a logic one indicates a negative number. • V: Overflow Flag (FLAGS.4) The V flag is set to "1" when the result of a two's-complement operation is greater than + 127 or less than – 128. It is also cleared to "0" following logic operations. • D: Decimal Adjust Flag (FLAGS.3) The DA bit is used to specify what type of instruction was executed last during BCD operations, so that a subsequent decimal adjust operation can execute correctly. The DA bit is not usually accessed by programmers, and cannot be used as a test condition. • H: Half-Carry Flag (FLAGS.2) The H bit is set to "1" whenever an addition generates a carry-out of bit 3, or when a subtraction borrows out of bit 4. It is used by the Decimal Adjust (DA) instruction to convert the binary result of a previous addition or subtraction into the correct decimal (BCD) result. The H flag is seldom accessed directly by a program. • FIS: Fast Interrupt Status Flag (FLAGS.1) The FIS bit is set during a fast interrupt cycle and reset during the IRET following interrupt servicing. When set, it inhibits all interrupts and causes the fast interrupt return to be executed when the IRET instruction is executed. • BA: Bank Address Flag (FLAGS.0) The BA flag indicates which register bank in the set 1 area of the internal register file is currently selected, bank 0 or bank 1. The BA flag is cleared to "0" (select bank 0) when you execute the SB0 instruction and is set to "1" (select bank 1) when you execute the SB1 instruction. PS031305-1017 6-6 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.3 Instruction Set Notation Table 6-2 Flag Notation Conventions Flag Description C Carry flag Z Zero flag S Sign flag V Overflow flag D Decimal-adjust flag H Half-carry flag 0 Cleared to logic zero 1 Set to logic one * Set or cleared according to operation – Value is unaffected x Value is undefined Table 6-3 Instruction Set Symbols Symbol dst Destination operand src Source operand @ Indirect register address prefix PC Program counter IP Instruction pointer FLAGS RP Flags register (D5H) Register pointer # Immediate operand or register address prefix H Hexadecimal number suffix D Decimal number suffix B Binary number suffix opc PS031305-1017 Description Opcode 6-7 S3F8S28/S3F8S24 Product Specification Table 6-4 Notation cc Chapter 6. Instruction Set Instruction Notation Conventions Description Actual Operand Range Condition code See list of condition codes in Table 6-7. r Working register only Rn (n = 0–15) rb Bit (b) of working register Rn.b (n = 0–15, b = 0–7) r0 Bit 0 (LSB) of working register Rn (n = 0–15) rr Working register pair RRp (p = 0, 2, 4, ..., 14) R Register or working register reg or Rn (reg = 0 to 255, n = 0 to 15) Rb Bit (b) of register or working register reg.b (reg = 0 to 255, b = 0 to 7) RR Register pair or working register pair reg or RRp (reg = 0–254, even number only, where p = 0, 2, ..., 14) IA Indirect addressing mode addr (addr = 0 to 254, even number only) Ir Indirect working register only @Rn (n = 0 to 15) IR Indirect register or indirect working register @Rn or @reg (reg = 0 to 255, n = 0 to 15) Irr Indirect working register pair only @RRp (p = 0, 2, ..., 14) Indirect register pair or indirect working register pair @RRp or @reg (reg = 0 to 254, even only, where p = 0, 2, ..., 14) Indexed addressing mode #reg [Rn] (reg = 0 to 255, n = 0 to 15) XS Indexed (short offset) addressing mode #addr [RRp] (addr = range – 128 to + 127, where p = 0, 2, ..., 14) xl Indexed (long offset) addressing mode #addr [RRp] (addr = range 0 to 65535, where p = 0, 2, ..., 14) da Direct addressing mode addr (addr = range 0 to 65535) ra Relative addressing mode addr (addr = number in the range + 127 to – 128 that is an offset relative to the address of the next instruction) im Immediate addressing mode #data (data = 0 to 255) iml Immediate (long) addressing mode #data (data = range 0 to 65535) IRR X PS031305-1017 6-8 S3F8S28/S3F8S24 Product Specification Table 6-5 Chapter 6. Instruction Set OPCODE Quick Reference OPCODE Map Lower Nibble (HEX) – 0 1 2 3 4 5 6 7 U 0 DEC R1 DEC IR1 ADD r1,r2 ADD r1,Ir2 ADD R2,R1 ADD IR2,R1 ADD R1,IM BOR r0–Rb P 1 RLC R1 RLC IR1 ADC r1,r2 ADC r1,Ir2 ADC R2,R1 ADC IR2,R1 ADC R1,IM BCP r1.b, R2 P 2 INC R1 INC IR1 SUB r1,r2 SUB r1,Ir2 SUB R2,R1 SUB IR2,R1 SUB R1,IM BXOR r0–Rb E 3 JP IRR1 SRP/0/1 IM SBC r1,r2 SBC r1,Ir2 SBC R2,R1 SBC IR2,R1 SBC R1,IM BTJR r2.b, RA R 4 DA R1 DA IR1 OR r1,r2 OR r1,Ir2 OR R2,R1 OR IR2,R1 OR R1,IM LDB r0–Rb 5 POP R1 POP IR1 AND r1,r2 AND r1,Ir2 AND R2,R1 AND IR2,R1 AND R1,IM BITC r1.b N 6 COM R1 COM IR1 TCM r1,r2 TCM r1,Ir2 TCM R2,R1 TCM IR2,R1 TCM R1,IM BAND r0–Rb I 7 PUSH R2 PUSH IR2 TM r1,r2 TM r1,Ir2 TM R2,R1 TM IR2,R1 TM R1,IM BIT r1.b B 8 DECW RR1 DECW IR1 PUSHUD IR1,R2 PUSHUI IR1,R2 MULT R2,RR1 MULT IR2,RR1 MULT IM,RR1 LD r1, x, r2 B 9 RL R1 RL IR1 POPUD IR2,R1 POPUI IR2,R1 DIV R2,RR1 DIV IR2,RR1 DIV IM,RR1 LD r2, x, r1 L A INCW RR1 INCW IR1 CP r1,r2 CP r1,Ir2 CP R2,R1 CP IR2,R1 CP R1,IM LDC r1, Irr2, xL E B CLR R1 CLR IR1 XOR r1,r2 XOR r1,Ir2 XOR R2,R1 XOR IR2,R1 XOR R1,IM LDC r2, Irr2, xL C RRC R1 RRC IR1 CPIJE Ir,r2,RA LDC r1,Irr2 LDW RR2,RR1 LDW IR2,RR1 LDW RR1,IML LD r1, Ir2 H D SRA R1 SRA IR1 CPIJNE Irr,r2,RA LDC r2,Irr1 CALL IA1 LD IR1,IM LD Ir1, r2 E E RR R1 RR IR1 LDCD r1,Irr2 LDCI r1,Irr2 LD R2,R1 LD R2,IR1 LD R1,IM LDC r1, Irr2, xs X F SWAP R1 SWAP IR1 LDCPD r2,Irr1 LDCPI r2,Irr1 CALL IRR1 LD IR2,R1 CALL DA1 LDC r2, Irr1, xs PS031305-1017 6-9 S3F8S28/S3F8S24 Product Specification Table 6-6 Chapter 6. Instruction Set OPCODE Quick Reference OPCODE MAP LOWER NIBBLE (HEX) – 8 9 A B C D E F U 0 LD r1,R2 LD r2,R1 DJNZ r1,RA JR cc,RA LD r1,IM JP cc,DA INC r1 NEXT P 1        ENTER P 2 E 3 R 4 EXIT WFI SB0 SB1 5 N 6 I 7 B 8 B 9 L A E B IDLE        DI EI RET IRET RCF C H D E E X F PS031305-1017 STOP        SCF CCF LD r1,R2 LD r2,R1 DJNZ r1,RA JR cc,RA LD r1,IM JP cc,DA INC r1 NOP 6-10 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.4 Condition Codes The opcode of a conditional jump always contains a 4-bit field called the condition code (cc). This specifies under which conditions it is to execute the jump. For example, a conditional jump with the condition code for "equal" after a compare operation only jumps if the two operands are equal. Condition codes are listed in Table 6-7. The carry (C), zero (Z), sign (S), and overflow (V) flags are used to control the operation of conditional jump instructions. Table 6-7 Binary Mnemonic Condition Codes Description Flags Set 0000 F Always false – 1000 T Always true – 0111 (NOTE) C Carry C=1 1111 (NOTE) NC No carry C=0 Zero Z=1 0110 (NOTE) Z 1110 (NOTE) NZ Not zero Z=0 1101 PL Plus S=0 0101 MI Minus S=1 0100 OV Overflow V=1 1100 NOV No overflow V=0 0110 (NOTE) EQ Equal Z=1 1110 (NOTE) NE Not equal Z=0 1001 GE Greater than or equal (S XOR V) = 0 0001 LT Less than (S XOR V) = 1 1010 GT Greater than (Z OR (S XOR V)) = 0 LE Less than or equal (Z OR (S XOR V)) = 1 0010 (NOTE) UGE Unsigned greater than or equal C=0 0111 (NOTE) ULT Unsigned less than C=1 1011 UGT Unsigned greater than 0011 ULE Unsigned less than or equal 1111 (C = 0 AND Z = 0) = 1 (C OR Z) = 1 NOTE: 1. It indicates condition codes that are related to two different mnemonics but which test the same flag. For example, Z and EQ are both true if the zero flag (Z) is set, but after an ADD instruction, Z would probably be used; after a CP instruction, however, EQ would probably be used. 2. For operations involving unsigned numbers, the special condition codes UGE, ULT, UGT, and ULE must be used. PS031305-1017 6-11 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5 Instruction Descriptions This section contains detailed information and programming examples for each instruction in the SAM8 instruction set. Information is arranged in a consistent format for improved readability and for fast referencing. The following information is included in each instruction description: • Instruction name (mnemonic) • Full instruction name • Source/destination format of the instruction operand • Shorthand notation of the instruction's operation • Textual description of the instruction's effect • Specific flag settings affected by the instruction • Detailed description of the instruction's format, execution time, and addressing mode(s) • Programming example(s) explaining how to use the instruction PS031305-1017 6-12 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.1 ADC (Add with Carry) ADC dst, src Operation: dst  dst + src + c The source operand, along with the setting of the carry flag, is added to the destination operand and the sum is stored in the destination. The contents of the source are unaffected. Two'scomplement addition is performed. In multiple precision arithmetic, this instruction permits the carry from the addition of low-order operands to be carried into the addition of high-order operands. Flags: C: Set if there is a carry from the most significant bit of the result; cleared otherwise. Z: Set if the result is "0"; cleared otherwise. S: Set if the result is negative; cleared otherwise. V: Set if arithmetic overflow occurs, that is, if both operands are of the same sign and the result is of the opposite sign; cleared otherwise. D: Always cleared to "0". H: Set if there is a carry from the most significant bit of the low-order four bits of the result; cleared otherwise. Format: opc opc opc Examples: dst | src src dst dst src Bytes Cycles Opcode (Hex) 2 4 3 3 Addr Mode dst src 12 r r 6 13 r lr 6 14 R R 6 15 R IR 6 16 R IM Given: R1 = 10H, R2 = 03H, C flag = "1", Register 01H = 20H, Register 02H = 03H, and Register 03H = 0AH: ADC ADC ADC ADC ADC R1, R2 R1, @R2 01H, 02H 01H, @02H 01H, #11H → → → → → R1 = 14H, R2 = 03H R1 = 1BH, R2 = 03H Register 01H = 24H, Register 02H = 03H Register 01H = 2BH, Register 02H = 03H Register 01H = 32H In the first example, destination register R1 contains the value 10H, the carry flag is set to "1", and the source working register R2 contains the value 03H. The statement "ADC R1, R2" adds 03H and the carry flag value ("1") to the destination value 10H, leaving 14H in register R1. PS031305-1017 6-13 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.2 ADD (Add) ADD dst, src Operation: dst  dst + src The source operand is added to the destination operand and the sum is stored in the destination. The contents of the source are unaffected. Two's-complement addition is performed. Flags: C: Set if there is a carry from the most significant bit of the result; cleared otherwise. Z: Set if the result is "0"; cleared otherwise. S: Set if the result is negative; cleared otherwise. V: Set if arithmetic overflow occurred, that is, if both operands are of the same sign and the result is of the opposite sign; cleared otherwise. D: Always cleared to "0". H: Set if a carry from the low-order nibble occurred. Format: opc opc opc Examples: dst | src src dst dst src Bytes Cycles Opcode (Hex) 2 4 3 3 Addr Mode dst src 02 r r 6 03 r lr 6 04 R R 6 05 R IR 6 06 R IM Given: R1 = 12H, R2 = 03H, Register 01H = 21H, Register 02H = 03H, Register 03H = 0AH: ADD ADD ADD ADD ADD R1, R2 R1, @R2 01H, 02H 01H, @02H 01H, #25H → → → → → R1 = 15H, R2 = 03H R1 = 1CH, R2 = 03H Register 01H = 24H, Register 02H = 03H Register 01H = 2BH, Register 02H = 03H Register 01H = 46H In the first example, destination working register R1 contains 12H and the source working register R2 contains 03H. The statement "ADD R1, R2" adds 03H to 12H, leaving the value 15H in register R1. PS031305-1017 6-14 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.3 AND (Logical AND) AND dst, src Operation: dst  dst AND src The source operand is logically ANDed with the destination operand. The result is stored in the destination. The AND operation results in a "1" bit being stored whenever the corresponding bits in the two operands are both logic ones; otherwise a "0" bit value is stored. The contents of the source are unaffected. Flags: C: Unaffected. Z: Set if the result is "0"; cleared otherwise. S: Set if the result bit 7 is set; cleared otherwise. V: Always cleared to "0". D: Unaffected. H: Unaffected. Format: opc opc opc Examples: dst | src src dst dst src Bytes Cycles Opcode (Hex) 2 4 52 r r 6 53 r lr 6 54 R R 6 55 R IR 6 56 R IM 3 3 Addr Mode dst src Given: R1 = 12H, R2 = 03H, Register 01H = 21H, Register 02H = 03H, Register 03H = 0AH: AND AND AND AND AND R1, R2 R1, @R2 01H, 02H 01H, @02H 01H, #25H → → → → → R1 = 02H, R2 = 03H R1 = 02H, R2 = 03H Register 01H = 01H, Register 02H = 03H Register 01H = 00H, Register 02H = 03H Register 01H = 21H In the first example, destination working register R1 contains the value 12H and the source working register R2 contains 03H. The statement "AND R1, R2" logically ANDs the source operand 03H with the destination operand value 12H, leaving the value 02H in register R1. PS031305-1017 6-15 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.4 BAND (Bit AND) BAND dst, src.b BAND dst.b, src Operation: dst(0)  dst(0) AND src(b) or dst(b)  dst(b) AND src(0) The specified bit of the source (or the destination) is logically ANDed with the zero bit (LSB) of the destination (or source). The resultant bit is stored in the specified bit of the destination. No other bits of the destination are affected. The source is unaffected. Flags: C: Unaffected. Z: Set if the result is "0"; cleared otherwise. S: Cleared to "0". V: Undefined. D: Unaffected. H: Unaffected. Format: Bytes Cycles Opcode (Hex) Addr Mode dst src opc dst | b | 0 src 3 6 67 r0 Rb opc src | b | 1 dst 3 6 67 Rb r0 NOTE: In the second byte of the 3-byte instruction formats, the destination (or source) address is four bits, the bit address "b" is three bits, and the LSB address value is one bit in length. Examples: Given: R1 = 07H and Register 01H = 05H: BAND R1, 01H.1 BAND 01H.1, R1 → → R1 = 06H, Register 01H = 05H Register 01H = 05H, R1 = 07H In the first example, source register 01H contains the value 05H (00000101B) and destination working register R1 contains 07H (00000111B). The statement "BAND R1, 01H.1" ANDs the1- bit value of the source register ("0") with the 0-bit value of register R1 (destination), leaving the value 06H (00000110B) in register R1. PS031305-1017 6-16 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.5 BCP (Bit Compare) BCP dst, src.b Operation: dst (0) – src (b) The specified bit of the source is compared to (subtracted from) bit zero (LSB) of the destination. The zero flag is set if the bits are the same; otherwise it is cleared. The contents of both operands are unaffected by the comparison. Flags: C: Unaffected. Z: Set if the two bits are the same; cleared otherwise. S: Cleared to "0". V: Undefined. D: Unaffected. H: Unaffected. Format: opc dst | b | 0 src Bytes Cycles Opcode (Hex) 3 6 17 Addr Mode dst src r0 Rb NOTE: In the second byte of the instruction format, the destination address is four bits, the bit address "b" is three bits, and the LSB address value is one bit in length. Example: Given: R1 = 07H and register 01H = 01H: BCP R1, 01H.1 → R1 = 07H, Register 01H = 01H If destination working register R1 contains the value 07H (00000111B) and the source register 01H contains the value 01H (00000001B), the statement "BCP R1, 01H.1" compares bit one of the source register (01H) and bit zero of the destination register (R1). Because the bit values are not identical, the zero flag bit (Z) is cleared in the FLAGS register (0D5H). PS031305-1017 6-17 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.6 BITC (Bit Complement) BITC dst.b Operation: dst (b)  NOT dst (b) This instruction complements the specified bit within the destination without affecting any other bits in the destination. Flags: C: Unaffected. Z: Set if the result is "0"; cleared otherwise. S: Cleared to "0". V: Undefined. D: Unaffected. H: Unaffected. Format: opc dst | b | 0 Bytes Cycles Opcode (Hex) Addr Mode dst 2 4 57 rb NOTE: In the second byte of the instruction format, the destination address is four bits, the bit address "b" is three bits, and the LSB address value is one bit in length. Example: Given: R1 = 7H BITC R1.1 → R1 = 05H If working register R1 contains the value 07H (00000111B), the statement "BITC R1.1" complements bit one of the destination and leaves the value 05H (00000101B) in register R1. Because the result of the complement is not "0", the zero flag (Z) in the FLAGS register (0D5H) is cleared. PS031305-1017 6-18 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.7 BITR (Bit Reset) BITR dst.b Operation: dst (b)  0 The BITR instruction clears the specified bit within the destination without affecting any other bits in the destination. Flags: No flags are affected. Format: opc dst | b | 0 Bytes Cycles Opcode (Hex) Addr Mode dst 2 4 77 rb NOTE: In the second byte of the instruction format, the destination address is four bits, the bit address "b" is three bits, and the LSB address value is one bit in length. Example: Given: R1 = 07H: BITR R1.1 → R1 = 05H If the value of working register R1 is 07H (00000111B), the statement "BITR R1.1" clears bit one of the destination register R1, leaving the value 05H (00000101B). PS031305-1017 6-19 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.8 BITS (Bit Set) BITS dst.b Operation: dst (b)  1 The BITS instruction sets the specified bit within the destination without affecting any other bits in the destination. Flags: No flags are affected. Format: opc dst | b | 1 Bytes Cycles Opcode (Hex) Addr Mode dst 2 4 77 rb NOTE: In the second byte of the instruction format, the destination address is four bits, the bit address "b" is three bits, and the LSB address value is one bit in length. Example: Given: R1 = 07H: BITS R1.3 → R1 = 0FH If working register R1 contains the value 07H (00000111B), the statement "BITS R1.3" sets bit three of the destination register R1 to "1", leaving the value 0FH (00001111B). PS031305-1017 6-20 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.9 BOR (Bit OR) BOR dst, src.b BOR dst.b, src Operation: dst (0)  dst (0) OR src (b) or dst (b)  dst (b) OR src(0) The specified bit of the source (or the destination) is logically ORed with bit zero (LSB) of the destination (or the source). The resulting bit value is stored in the specified bit of the destination. No other bits of the destination are affected. The source is unaffected. Flags: C: Unaffected. Z: Set if the result is "0"; cleared otherwise. S: Cleared to "0". V: Undefined. D: Unaffected. H: Unaffected. Format: Bytes Cycles Opcode (Hex) Addr Mode dst src opc dst | b | 0 src 3 6 07 r0 Rb opc src | b | 1 dst 3 6 07 Rb r0 NOTE: In the second byte of the 3byte instruction formats, the destination (or source) address is four bits, the bit address "b" is three bits, and the LSB address value is one bit. Examples: Given: R1 = 07H and Register 01H = 03H: BOR BOR R1, 01H.1 01H.2, R1 → → R1 = 07H, Register 01H = 03H Register 01H = 07H, R1 = 07H In the first example, destination working register R1 contains the value 07H (00000111B) and source register 01H the value 03H (00000011B). The statement "BOR R1, 01H.1" logically ORs bit one of register 01H (source) with bit zero of R1 (destination). This leaves the same value (07H) in working register R1. In the second example, destination register 01H contains the value 03H (00000011B) and the source working register R1 the value 07H (00000111B). The statement "BOR 01H.2, R1" logically ORs bit two of register 01H (destination) with bit zero of R1 (source). This leaves the value 07H in register 01H. PS031305-1017 6-21 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.10 BTJRF (Bit Test, Jump Relative on False) BTJRF dst, src.b Operation: If src (b) is a "0", then PC  PC + dst The specified bit within the source operand is tested. If it is a "0", the relative address is added to the program counter and control passes to the statement whose address is now in the PC; otherwise, the instruction following the BTJRF instruction is executed. Flags: No flags are affected. Format: (NOTE) opc src | b | 0 dst Bytes Cycles Opcode (Hex) 3 10 37 Addr Mode dst src RA rb NOTE: In the second byte of the instruction format, the source address is four bits, the bit address "b" is three bits, and the LSB address value is one bit in length. Example: Given: R1 = 07H: BTJRF SKIP, R1.3 → PC jumps to SKIP location If working register R1 contains the value 07H (00000111B), the statement "BTJRF SKIP, R1.3" tests 3-bit. Because it is "0", the relative address is added to the PC and the PC jumps to the memory location pointed to by the SKIP. (Remember that the memory location must be within the allowed range of + 127 to – 128.) PS031305-1017 6-22 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.11 BTJRT (Bit Test, Jump Relative on True) BTJRT dst, src.b Operation: If src (b) is a "1", then PC  PC + dst The specified bit within the source operand is tested. If it is a "1", the relative address is added to the program counter and control passes to the statement whose address is now in the PC; otherwise, the instruction following the BTJRT instruction is executed. Flags: No flags are affected. Format: (NOTE) opc src | b | 1 dst Bytes Cycles Opcode (Hex) 3 10 37 Addr Mode dst src RA rb NOTE: In the second byte of the instruction format, the source address is four bits, the bit address "b" is three bits, and the LSB address value is one bit in length. Example: Given: R1 = 07H: BTJRT SKIP, R1.1 If working register R1 contains the value 07H (00000111B), the statement "BTJRT SKIP, R1.1" tests bit one in the source register (R1). Because it is a "1", the relative address is added to the PC and the PC jumps to the memory location pointed to by the SKIP. (Remember that the memory location must be within the allowed range of + 127 to – 128.) PS031305-1017 6-23 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.12 BXOR (Bit XOR) BXOR dst, src.b BXOR dst.b, src Operation: dst (0)  dst (0) XOR src (b) or dst (b)  dst (b) XOR src (0) The specified bit of the source (or the destination) is logically exclusive-ORed with bit zero (LSB) of the destination (or source). The result bit is stored in the specified bit of the destination. No other bits of the destination are affected. The source is unaffected. Flags: C: Unaffected. Z: Set if the result is "0"; cleared otherwise. S: Cleared to "0". V: Undefined. D: Unaffected. H: Unaffected. Format: Bytes Cycles Opcode (Hex) Addr Mode dst src opc dst | b | 0 src 3 6 27 r0 Rb opc src | b | 1 dst 3 6 27 Rb r0 NOTE: In the second byte of the 3byte instruction formats, the destination (or source) address is four bits, the bit address "b" is three bits, and the LSB address value is one bit in length. Examples: Given: R1 = 07H (00000111B) and register 01H = 03H (00000011B): BXOR R1, 01H.1 BXOR 01H.2, R1 → → R1 = 06H, Register 01H = 03H Register 01H = 07H, R1 = 07H In the first example, destination working register R1 has the value 07H (00000111B) and source register 01H has the value 03H (00000011B). The statement "BXOR R1, 01H.1" exclusive-ORs bit one of register 01H (source) with bit zero of R1 (destination). The result bit value is stored in bit zero of R1, changing its value from 07H to 06H. The value of source register 01H is unaffected. PS031305-1017 6-24 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.13 CALL (Call Procedure) CALL dst Operation: SP  SP – 1 @SP  PCL SP  SP –1 @SP  PCH PC  dst The current contents of the program counter are pushed onto the top of the stack. The program counter value used is the address of the first instruction following the CALL instruction. The specified destination address is then loaded into the program counter and points to the first instruction of a procedure. At the end of the procedure the return instruction (RET) can be used to return to the original program flow. RET pops the top of the stack back into the program counter. Flags: No flags are affected. Format: opc Examples: dst Bytes Cycles Opcode (Hex) Addr Mode dst 3 14 F6 DA opc dst 2 12 F4 IRR opc dst 2 14 D4 IA Given: R0 = 35H, R1 = 21H, PC = 1A47H, and SP = 0002H: CALL 3521H → CALL CALL @RR0 → #40H → SP = 000H (Memory locations 0000H = 1AH, 0001H = 4AH, where 4AH is the address that follows the instruction.) SP = 0000H (0000H = 1AH, 0001H = 49H) SP = 0000H (0000H = 1AH, 0001H = 49H) In the first example, if the program counter value is 1A47H and the stack pointer contains the value 0002H, the statement "CALL 3521H" pushes the current PC value onto the top of the stack. The stack pointer now points to memory location 0000H. The PC is then loaded with the value 3521H, the address of the first instruction in the program sequence to be executed. If the contents of the program counter and stack pointer are the same as in the first example, the statement "CALL @RR0" produces the same result except that the 49H is stored in stack location 0001H (because the two-byte instruction format was used). The PC is then loaded with the value 3521H, the address of the first instruction in the program sequence to be executed. Assuming that the contents of the program counter and stack pointer are the same as in the first example, if program address 0040H contains 35H and program address 0041H contains 21H, the statement "CALL #40H" produces the same result as in the second example. PS031305-1017 6-25 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.14 CCF (Complement Carry Flag) CCF Operation: C  NOT C The carry flag (C) is complemented. If C = "1", the value of the carry flag is changed to logic zero; if C = "0", the value of the carry flag is changed to logic one. Flags: C: Complemented. No other flags are affected. Format: opc Example: Bytes Cycles Opcode (Hex) 1 4 EF Given: The carry flag = "0": CCF If the carry flag = "0", the CCF instruction complements it in the FLAGS register (0D5H), changing its value from logic zero to logic one. PS031305-1017 6-26 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.15 CLR (Clear) CLR dst Operation: dst  "0" The destination location is cleared to "0". Flags: No flags are affected. Format: opc Examples: dst Bytes Cycles Opcode (Hex) Addr Mode dst 2 4 B0 R 4 B1 IR Given: Register 00H = 4FH, Register 01H = 02H, and Register 02H = 5EH: CLR CLR 00H → @01H → Register 00H = 00H Register 01H = 02H, Register 02H = 00H In Register (R) addressing mode, the statement "CLR 00H" clears the destination register 00H value to 00H. In the second example, the statement "CLR @01H" uses Indirect Register (IR) addressing mode to clear the 02H register value to 00H. PS031305-1017 6-27 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.16 COM (Complement) COM dst Operation: dst  NOT dst The contents of the destination location are complemented (one's complement); all "1s" are changed to "0s", and vice-versa. Flags: C: Unaffected. Z: Set if the result is "0"; cleared otherwise. S: Set if the result bit 7 is set; cleared otherwise. V: Always reset to "0". D: Unaffected. H: Unaffected. Format: opc Examples: dst Bytes Cycles Opcode (Hex) Addr Mode dst 2 4 60 R 4 61 IR Given: R1 = 07H and Register 07H = 0F1H: COM COM R1 @R1 → → R1 = 0F8H R1 = 07H, Register 07H = 0EH In the first example, destination working register R1 contains the value 07H (00000111B). The statement "COM R1" complements all the bits in R1: all logic ones are changed to logic zeros, and vice-versa, leaving the value 0F8H (11111000B). In the second example, Indirect Register (IR) addressing mode is used to complement the value of destination register 07H (11110001B), leaving the new value 0EH (00001110B). PS031305-1017 6-28 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.17 CP (Compare) CP dst, src Operation: dst – src The source operand is compared to (subtracted from) the destination operand, and the appropriate flags are set accordingly. The contents of both operands are unaffected by the comparison. Flags: C: Set if a "borrow" occurred (src > dst); cleared otherwise. Z: Set if the result is "0"; cleared otherwise. S: Set if the result is negative; cleared otherwise. V: Set if arithmetic overflow occurred; cleared otherwise. D: Unaffected. H: Unaffected. Format: opc dst | src opc src opc Examples: dst dst Bytes Cycles Opcode (Hex) 2 4 A2 r r 6 A3 r lr 6 A4 R R 6 A5 R IR 6 A6 R IM 3 src 3 Addr Mode dst src 1. Given: R1 = 02H and R2 = 03H: CP R1, R2 → Set the C and S flags Destination working register R1 contains the value 02H and source register R2 contains the value 03H. The statement "CP R1, R2" subtracts the R2 value (source/subtrahend) from the R1 value (destination/minuend). Because a "borrow" occurs and the difference is negative, C and S are "1". 2. Given: R1 = 05H and R2 = 0AH: SKIP CP JP INC LD R1, R2 UGE, SKIP R1 R3, R1 In this example, destination working register R1 contains the value 05H which is less than the contents of the source working register R2 (0AH). The statement "CP R1, R2" generates C = "1" and the JP instruction does not jump to the SKIP location. After the statement "LD R3, R1" executes, the value 06H remains in working register R3. PS031305-1017 6-29 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.18 CPIJE (Compare, Increment, and Jump on Equal) CPIJE dst, src, RA Operation: If dst – src = "0", PC  PC + RA Ir  Ir + 1 The source operand is compared to (subtracted from) the destination operand. If the result is "0", the relative address is added to the program counter and control passes to the statement whose address is now in the program counter. Otherwise, the instruction immediately following the CPIJE instruction is executed. In either case, the source pointer is incremented by one before the next instruction is executed. Flags: No flags are affected. Format: opc src dst RA Bytes Cycles Opcode (Hex) 3 12 C2 Addr Mode dst src r Ir NOTE: Execution time is 18 cycles if the jump is taken or 16 cycles if it is not taken. Example: Given: R1 = 02H, R2 = 03H, and register 03H = 02H: CPIJE R1, @R2, SKIP → R2 = 04H, PC jumps to SKIP location In this example, working register R1 contains the value 02H, working register R2 the value 03H, and register 03 contains 02H. The statement "CPIJE R1, @R2, SKIP" compares the @R2 value 02H (00000010B) to 02H (00000010B). Because the result of the comparison is equal, the relative address is added to the PC and the PC then jumps to the memory location pointed to by SKIP. The source register (R2) is incremented by one, leaving a value of 04H. (Remember that the memory location must be within the allowed range of + 127 to – 128.) PS031305-1017 6-30 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.19 CPIJNE (Compare, Increment, and Jump on Non-Equal) CPIJNE dst, src, RA Operation: If dst – src "0", PC  PC + RA Ir  Ir + 1 The source operand is compared to (subtracted from) the destination operand. If the result is not "0", the relative address is added to the program counter and control passes to the statement whose address is now in the program counter; otherwise the instruction following the CPIJNE instruction is executed. In either case the source pointer is incremented by one before the next instruction. Flags: No flags are affected. Format: opc src dst RA Bytes Cycles Opcode (Hex) 3 12 D2 Addr Mode dst src r Ir NOTE: Execution time is 18 cycles if the jump is taken or 16 cycles if it is not taken. Example: Given: R1 = 02H, R2 = 03H, and Register 03H = 04H: CPIJNE R1, @R2, SKIP → R2 = 04H, PC jumps to SKIP location Working register R1 contains the value 02H, working register R2 (the source pointer) the value 03H, and general register 03 the value 04H. The statement "CPIJNE R1, @R2, SKIP" subtracts 04H (00000100B) from 02H (00000010B). Because the result of the comparison is non-equal, the relative address is added to the PC and the PC then jumps to the memory location pointed to by SKIP. The source pointer register (R2) is also incremented by one, leaving a value of 04H. (Remember that the memory location must be within the allowed range of + 127 to – 128.) PS031305-1017 6-31 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.20 DA (Decimal Adjust) DA dst Operation: dst  DA dst The destination operand is adjusted to form two 4-bit BCD digits following an addition or subtraction operation. For addition (ADD, ADC) or subtraction (SUB, SBC), the following table indicates the operation performed. (The operation is undefined if the destination operand was not the result of a valid addition or subtraction of BCD digits): Instruction Carry Before DA Bits 4–7 Value (Hex) H Flag Before DA Bits 0–3 Value (Hex) Number Added to Byte Carry After DA – 0 0–9 0 0–9 00 0 – 0 0–8 0 A–F 06 0 – 0 0–9 1 0–3 06 0 ADD 0 A–F 0 0–9 60 1 ADC 0 9–F 0 A–F 66 1 – 0 A–F 1 0–3 66 1 – 1 0–2 0 0–9 60 1 – 1 0–2 0 A–F 66 1 – 1 0–3 1 0–3 66 1 – 0 0–9 0 0–9 00 = – 00 0 SUB 0 0–8 1 6–F FA = – 06 0 SBC 1 7–F 0 0–9 A0 = – 60 1 – 1 6–F 1 6–F 9A = – 66 1 Flags: C: Set if there was a carry from the most significant bit; cleared otherwise (see table). Z: Set if result is "0"; cleared otherwise. S: Set if result bit 7 is set; cleared otherwise. V: Undefined. D: Unaffected. H: Unaffected. Format: opc PS031305-1017 dst Bytes Cycles Opcode (Hex) Addr Mode dst 2 4 40 R 4 41 IR 6-32 S3F8S28/S3F8S24 Product Specification Example: Chapter 6. Instruction Set Given: Working register R0 contains the value 15 (BCD), working register R1 contains 27 (BCD), and address 27H contains 46 (BCD): ADD DA R1, R0 ; R1 ; C  "0", H  "0", Bits 4–7 = 3, Bits 0–3 = C, R1  3CH R1  3CH + 06 If addition is performed using the BCD values 15 and 27, the result should be 42. The sum is incorrect, however, when the binary representations are added in the destination location using standard binary arithmetic: 0001 + 0010 0011 0101 0111 1100 = 15 27 3CH The DA instruction adjusts this result so that the correct BCD representation is obtained: 0011 + 0000 0100 1100 0110 0010 = 42 Assuming the same values given above, the statements SUB 27H,R0 ; C  "0", H  "0", Bits 4–7 = 3, Bits 0–3 = 1 DA @R1 ; @R1  31–0 Leave the value 31 (BCD) in address 27H (@R1). PS031305-1017 6-33 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.21 DEC (Decrement) DEC dst Operation: dst  dst – 1 The contents of the destination operand are decremented by one. Flags: C: Unaffected. Z: Set if the result is "0"; cleared otherwise. S: Set if result is negative; cleared otherwise. V: Set if arithmetic overflow occurred; cleared otherwise. D: Unaffected. H: Unaffected. Format: opc Examples: dst Bytes Cycles Opcode (Hex) Addr Mode dst 2 4 00 R 4 01 IR Given: R1 = 03H and Register 03H = 10H: DEC DEC R1 @R1 → → R1 = 02H Register 03H = 0FH In the first example, if working register R1 contains the value 03H, the statement "DEC R1" decrements the hexadecimal value by one, leaving the value 02H. In the second example, the statement "DEC @R1" decrements the value 10H contained in the destination register 03H by one, leaving the value 0FH. PS031305-1017 6-34 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.22 DECW (Decrement Word) DECW dst Operation: dst  dst – 1 The contents of the destination location (which must be an even address) and the operand following that location are treated as a single 16-bit value that is decremented by one. Flags: C: Unaffected. Z: Set if the result is "0"; cleared otherwise. S: Set if the result is negative; cleared otherwise. V: Set if arithmetic overflow occurred; cleared otherwise. D: Unaffected. H: Unaffected. Format: opc Examples: dst Bytes Cycles Opcode (Hex) Addr Mode dst 2 8 80 RR 8 81 IR Given: R0 = 12H, R1 = 34H, R2 = 30H, register 30H = 0FH, and Register 31H = 21H: DECW RR0 DECW @R2 → → R0 = 12H, R1 = 33H Register 30H = 0FH, Register 31H = 20H In the first example, destination register R0 contains the value 12H and register R1 the value 34H. The statement "DECW RR0" addresses R0 and the following operand R1 as a 16-bit word and decrements the value of R1 by one, leaving the value 33H. A system malfunction may occur if you use a Zero flag (FLAGS.6) result together with a DECW instruction. To avoid this problem, we recommend that you use DECW as shown in the following example: LOOP: DECW LD OR JR PS031305-1017 RR0 R2, R1 R2, R0 NZ, LOOP 6-35 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.23 DI (Disable Interrupts) DI Operation: SYM (0)  0 Bit zero of the system mode control register, SYM.0, is cleared to "0", globally disabling all interrupt processing. Interrupt requests will continue to set their respective interrupt pending bits, but the CPU will not service them while interrupt processing is disabled. Flags: No flags are affected. Format: opc Example: Bytes Cycles Opcode (Hex) 1 4 8F Given: SYM = 01H: DI If the value of the SYM register is 01H, the statement "DI" leaves the new value 00H in the register and clears SYM.0 to "0", disabling interrupt processing. Before changing IMR, interrupt pending and interrupt source control register, be sure DI state. PS031305-1017 6-36 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.24 DIV (Divide-Unsigned) DIV dst, src Operation: dst ÷ src dst (upper)  REMAINDER dst (lower)  QUOTIENT The destination operand (16 bits) is divided by the source operand (8 bits). The quotient (8 bits) is stored in the lower half of the destination. The remainder (8 bits) is stored in the upper half of the destination. When the quotient is  28, the numbers stored in the upper and lower halves of the destination for quotient and remainder are incorrect. Both operands are treated as unsigned integers. Flags: C: Set if the V flag is set and quotient is between 28 and 29–1; cleared otherwise. Z: Set if divisor or quotient = "0"; cleared otherwise. S: Set if MSB of quotient = "1"; cleared otherwise. V: Set if quotient is  28 or if divisor = "0"; cleared otherwise. D: Unaffected. H: Unaffected. Format: opc src dst Bytes Cycles Opcode (Hex) Addr Mode dst src 3 26/10 94 RR R 26/10 95 RR IR 26/10 96 RR IM NOTE: Execution takes 10 cycles if the divide-by-zero is attempted; otherwise it takes 26 cycles. Examples: Given: R0 = 10H, R1 = 03H, R2 = 40H, Register 40H = 80H: DIV DIV DIV RR0, R2 RR0, @R2 RR0, #20H → → → R0 = 03H, R1 = 40H R0 = 03H, R1 = 20H R0 = 03H, R1 = 80H In the first example, destination working register pair RR0 contains the values 10H (R0) and 03H (R1), and register R2 contains the value 40H. The statement "DIV RR0, R2" divides the 16-bit RR0 value by the 8-bit value of the R2 (source) register. After the DIV instruction, R0 contains the value 03H and R1 contains 40H. The 8-bit remainder is stored in the upper half of the destination register RR0 (R0) and the quotient in the lower half (R1). PS031305-1017 6-37 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.25 DJNZ (Decrement and Jump if Non-Zero) DJNZ r, dst Operation: rr–1 If r  0, PC  PC + dst The working register being used as a counter is decremented. If the contents of the register are not logic zero after decrementing, the relative address is added to the program counter and control passes to the statement whose address is now in the PC. The range of the relative address is +127 to –128, and the original value of the PC is taken to be the address of the instruction byte following the DJNZ statement. NOTE: In case of using DJNZ instruction, the working register being used as a counter should be set at the one of location 0C0H to 0CFH with SRP, SRP0, or SRP1 instruction. Flags: No flags are affected. Format: r | opc Example: dst Bytes Cycles Opcode (Hex) Addr Mode dst 2 8 (jump taken) rA RA 8 (no jump) r = 0 to F Given: R1 = 02H and LOOP is the label of a relative address: SRP DJNZ #0C0H R1, LOOP DJNZ is typically used to control a "loop" of instructions. In many cases, a label is used as the destination operand instead of a numeric relative address value. In the example, working register R1 contains the value 02H, and LOOP is the label for a relative address. The statement "DJNZ R1, LOOP" decrements register R1 by one, leaving the value 01H. Because the contents of R1 after the decrement are non-zero, the jump is taken to the relative address specified by the LOOP label. PS031305-1017 6-38 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.26 EI (Enable Interrupts) EI Operation: SYM (0)  1 An EI instruction sets bit zero of the system mode register, SYM.0 to "1". This allows interrupts to be serviced as they occur (assuming they have highest priority). If an interrupt's pending bit was set while interrupt processing was disabled (by executing a DI instruction), it will be serviced when you execute the EI instruction. Flags: No flags are affected. Format: opc Example: Bytes Cycles Opcode (Hex) 1 4 9F Given: SYM = 00H: EI If the SYM register contains the value 00H, that is, if interrupts are currently disabled, the statement "EI" sets the SYM register to 01H, enabling all interrupts. (SYM.0 is the enable bit for global interrupt processing.) PS031305-1017 6-39 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.27 ENTER (Enter) ENTER Operation: SP  SP – 2 @SP  IP IP  PC PC  @IP IP  IP + 2 This instruction is useful when implementing threaded-code languages. The contents of the instruction pointer are pushed to the stack. The program counter (PC) value is then written to the instruction pointer. The program memory word that is pointed to by the instruction pointer is loaded into the PC, and the instruction pointer is incremented by two. Flags: No flags are affected. Format: Bytes Cycles Opcode (Hex) 1 14 1F opc Example: The diagram below shows one example of how to use an ENTER statement. Before Address After Data IP 0050 PC 0040 SP 0022 Address Address 22 Data Stack PS031305-1017 40 41 42 43 Data IP 0043 PC 0110 SP 0020 20 21 22 IPH IPL Data Data Enter Address H Address L Address H Memory 1F 01 10 Address 40 41 42 43 00 50 110 Data Enter Address H Address L Address H 1F 01 10 Routine Memory Stack 6-40 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.28 EXIT (Exit) EXIT Operation: IP  @SP SP  SP + 2 PC  @IP IP  IP + 2 This instruction is useful when implementing threaded-code languages. The stack value is popped and loaded into the instruction pointer. The program memory word that is pointed to by the instruction pointer is then loaded into the program counter, and the instruction pointer is incremented by two. Flags: No flags are affected. Format: Bytes Cycles Opcode (Hex) 1 14 (internal stack) 2F opc 16 (internal stack) Example: The diagram below shows one example of how to use an EXIT statement. Before Address After Data IP 0050 PC 0040 Address Address 50 51 SP 0022 20 21 22 IPH IPL Data 140 Stack PS031305-1017 00 50 Data IP 0052 PC 0060 Data PCL old PCH Exit Memory Address 60 00 60 SP 0022 22 Data Data Main 2F Memory Stack 6-41 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.29 IDLE (Idle Operation) IDLE Operation: The IDLE instruction stops the CPU clock while allowing system clock oscillation to continue. Idle mode can be released by an interrupt request (IRQ) or an external reset operation. In application programs, a IDLE instruction must be immediately followed by at least three NOP instructions. This ensures an adeguate time interval for the clock to stabilize before the next instruction is executed. If three or more NOP instructons are not used after IDLE instruction, leakage current could be flown because of the floating state in the internal bus. Flags: No flags are affected. Format: opc Example: Bytes Cycles Opcode (Hex) 1 4 6F Addr Mode dst src – – The instruction IDLE ; stops the CPU clock but not the system clock NOP NOP NOP PS031305-1017 6-42 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.30 INC (Increment) INC dst Operation: dst  dst + 1 The contents of the destination operand are incremented by one. Flags: C: Unaffected. Z: Set if the result is "0"; cleared otherwise. S: Set if the result is negative; cleared otherwise. V: Set if arithmetic overflow occurred; cleared otherwise. D: Unaffected. H: Unaffected. Format: dst | opc Bytes Cycles Opcode (Hex) Addr Mode dst 1 4 rE r r = 0 to F opc Examples: dst 2 4 20 R 4 21 IR Given: R0 = 1BH, Register 00H = 0CH, and Register 1BH = 0FH: INC INC INC R0 00H @R0 → → → R0 = 1CH Register 00H = 0DH R0 = 1BH, Register 01H = 10H In the first example, if destination working register R0 contains the value 1BH, the statement "INC R0" leaves the value 1CH in that same register. The next example shows the effect an INC instruction has on register 00H, assuming that it contains the value 0CH. In the third example, INC is used in Indirect Register (IR) addressing mode to increment the value of register 1BH from 0FH to 10H. PS031305-1017 6-43 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.31 INCW (Increment Word) INCW dst Operation: dst  dst + 1 The contents of the destination (which must be an even address) and the byte following that location are treated as a single 16-bit value that is incremented by one. Flags: C: Unaffected. Z: Set if the result is "0"; cleared otherwise. S: Set if the result is negative; cleared otherwise. V: Set if arithmetic overflow occurred; cleared otherwise. D: Unaffected. H: Unaffected. Format: opc Examples: dst Bytes Cycles Opcode (Hex) Addr Mode dst 2 8 A0 RR 8 A1 IR Given: R0 = 1AH, R1 = 02H, Register 02H = 0FH, and Register 03H = 0FFH: INCW RR0 INCW @R1 → → R0 = 1AH, R1 = 03H Register 02H = 10H, Register 03H = 00H In the first example, the working register pair RR0 contains the value 1AH in register R0 and 02H in register R1. The statement "INCW RR0" increments the 16-bit destination by one, leaving the value 03H in register R1. In the second example, the statement "INCW @R1" uses Indirect Register (IR) addressing mode to increment the contents of general register 03H from 0FFH to 00H and register 02H from 0FH to 10H. NOTE: PS031305-1017 A system malfunction may occur if you use a Zero (Z) flag (FLAGS.6) result together with an INCW instruction. To avoid this problem, we recommend that you use INCW as shown in the following example: LOOP: INCW RR0 LD R2, R1 OR R2, R0 JR NZ, LOOP 6-44 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.32 IRET (Interrupt Return) IRET IRET (Normal) IRET (Fast) Operation: FLAGS  @SP PC  IP SP  SP + 1 FLAGS  FLAGS PC  @SP FIS  0 SP  SP + 2 SYM(0)  1 This instruction is used at the end of an interrupt service routine. It restores the flag register and the program counter. It also reenables global interrupts. A "normal IRET" is executed only if the fast interrupt status bit (FIS, bit one of the FLAGS register, 0D5H) is cleared (= "0"). If a fast interrupt occurred, IRET clears the FIS bit that was set at the beginning of the service routine. Flags: All flags are restored to their original settings (that is, the settings before the interrupt occurred). Format: IRET (Normal) Bytes Cycles Opcode (Hex) opc 1 10 (internal stack) BF 12 (internal stack) Example: IRET (Fast) Bytes Cycles Opcode (Hex) opc 1 6 BF In the figure below, the instruction pointer is initially loaded with 100H in the main program before interrupts are enabled. When an interrupt occurs, the program counter and instruction pointer are swapped. This causes the PC to jump to address 100H and the IP to keep the return address. The last instruction in the service routine normally is a jump to IRET at address FFH. This causes the instruction pointer to be loaded with 100H "again" and the program counter to jump back to the main program. Now, the next interrupt can occur and the IP is still correct at 100H. 0H FFH 100H IRET Interrupt Service Routine JP to FFH FFFFH NOTE: PS031305-1017 In the fast interrupt example above, if the last instruction is not a jump to IRET, you must pay attention to the order of the last two instructions. The IRET cannot be immediately proceeded by a clearing of the interrupt status (as with a reset of the IPR register). 6-45 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.33 JP (Jump) JP cc, dst (Conditional) JP dst Operation: If cc is true, PC  dst The conditional JUMP instruction transfers program control to the destination address if the condition specified by the condition code (cc) is true; otherwise, the instruction following the JP instruction is executed. The unconditional JP simply replaces the contents of the PC with the contents of the specified register pair. Control then passes to the statement addressed by the PC. Flags: No flags are affected. (Unconditional) Format: (1) (2) cc | opc dst Bytes Cycles Opcode (Hex) Addr Mode dst 3 8 ccD DA cc = 0 to F opc dst 2 8 30 IRR NOTE: 1. The 3byte format is used for a conditional jump and the 2byte format for an unconditional jump. 2. In the first byte of the three-byte instruction format (conditional jump), the condition code and the opcode are both four bits. Examples: Given: The carry flag (C) = "1", Register 00 = 01H, and Register 01 = 20H: JP JP C, LABEL_W @00H → → LABEL_W = 1000H, PC = 1000H PC = 0120H The first example shows a conditional JP. Assuming that the carry flag is set to "1", the statement "JP C, LABEL_W" replaces the contents of the PC with the value 1000H and transfers control to that location. Had the carry flag not been set, control would then have passed to the statement immediately following the JP instruction. The second example shows an unconditional JP. The statement "JP @00" replaces the contents of the PC with the contents of the register pair 00H and 01H, leaving the value 0120H. PS031305-1017 6-46 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.34 JR (Jump Relative) JR cc, dst Operation: If cc is true, PC  PC + dst If the condition specified by the condition code (cc) is true, the relative address is added to the program counter and control passes to the statement whose address is now in the program counter; otherwise, the instruction following the JR instruction is executed. (See list of condition codes). The range of the relative address is + 127, – 128, and the original value of the program counter is taken to be the address of the first instruction byte following the JR statement. Flags: No flags are affected. Format: (NOTE) cc | opc Bytes Cycles Opcode (Hex) Addr Mode dst 2 6 ccB RA dst cc = 0 to F NOTE: In the first byte of the two-byte instruction format, the condition code and the opcode are each four bits. Example: Given: The carry flag = "1" and LABEL_X = 1FF7H: JR C, LABEL_X → PC = 1FF7H If the carry flag is set (that is, if the condition code is true), the statement "JR C, LABEL_X" will pass control to the statement whose address is now in the PC. Otherwise, the program instruction following the JR would be executed. PS031305-1017 6-47 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.35 LD (Load) LD dst, src Operation: dst  src The contents of the source are loaded into the destination. The source's contents are unaffected. Flags: No flags are affected. Format: dst | opc src | opc src dst Bytes Cycles Opcode (Hex) 2 4 rC r IM 4 r8 r R 4 r9 R r 2 Addr Mode dst src r = 0 to F opc opc opc Examples: PS031305-1017 dst | src src 2 dst dst src 3 3 4 C7 r lr 4 D7 Ir r 6 E4 R R 6 E5 R IR 6 E6 R IM 6 D6 IR IM opc src dst 3 6 F5 IR R opc dst | src x 3 6 87 r x [r] opc src | dst x 3 6 97 x [r] r Given: R0 = 01H, R1 = 0AH, Register 00H = 01H, Register 01H = 20H, Register 02H = 02H, LOOP = 30H, and Register 3AH = 0FFH: → → → → → → → LD LD LD LD LD LD LD R0, #10H R0, 01H 01H, R0 R1, @R0 @R0, R1 00H, 01H 02H, @00H LD LD LD LD LD 00H, #0AH → @00H, #10H → @00H, 02H → R0, #LOOP[R1] → #LOOP[R0], R1 → R0 = 10H R0 = 20H, Register 01H = 20H Register 01H = 01H, R0 = 01H R1 = 20H, R0 = 01H R0 = 01H, R1 = 0AH, Register 01H = 0AH Register 00H = 20H, Register 01H = 20H Register 02H = 20H, Register 00H = 01H Register 00H = 0AH Register 00H = 01H, Register 01H = 10H Register 00H = 01H, Register 01H = 02, Register 02H = 02H R0 = 0FFH, R1 = 0AH Register 31H = 0AH, R0 = 01H, R1 = 0AH 6-48 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.36 LDB (Load Bit) LDB dst, src.b LDB dst.b, src Operation: dst (0)  src (b) or dst (b)  src (0) The specified bit of the source is loaded into bit zero (LSB) of the destination, or bit zero of the source is loaded into the specified bit of the destination. No other bits of the destination are affected. The source is unaffected. Flags: No flags are affected. Format: Bytes Cycles Opcode (Hex) Addr Mode dst src opc dst | b | 0 src 3 6 47 r0 Rb opc src | b | 1 dst 3 6 47 Rb r0 NOTE: In the second byte of the instruction formats, the destination (or source) address is four bits, the bit address "b" is three bits, and the LSB address value is one bit in length. Examples: Given: R0 = 06H and general register 00H = 05H: LDB LDB R0, 00H.2 00H.0, R0 → → R0 = 07H, Register 00H = 05H R0 = 06H, Register 00H = 04H In the first example, destination working register R0 contains the value 06H and the source general register 00H the value 05H. The statement "LD R0, 00H.2" loads the bit two value of the 00H register into bit zero of the R0 register, leaving the value 07H in register R0. In the second example, 00H is the destination register. The statement "LD 00H.0, R0" loads bit zero of register R0 to the specified bit (bit zero) of the destination register, leaving 04H in general register 00H. PS031305-1017 6-49 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.37 LDC/LDE (Load Memory) LDC/LDE dst, src Operation: dst  src This instruction loads a byte from program or data memory into a working register or vice-versa. The source values are unaffected. LDC refers to program memory and LDE to data memory. The assembler makes "Irr" or "rr" values an even number for program memory and odd an odd number for data memory. Flags: No flags are affected. Format: Bytes Cycles Opcode (Hex) Addr Mode dst src 1. opc dst | src 2 10 C3 r Irr 2. opc src | dst 2 10 D3 Irr r 3. opc dst | src XS 3 12 E7 r XS [rr] 4. opc src | dst XS 3 12 F7 XS [rr] r 5. opc dst | src XLL XLH 4 14 A7 r XL [rr] 6. opc src | dst XLL XLH 4 14 B7 XL [rr] r 7. opc dst | 0000 DAL DAH 4 14 A7 r DA 8. opc src | 0000 DAL DAH 4 14 B7 DA r 9. opc dst | 0001 DAL DAH 4 14 A7 r DA 10. opc src | 0001 DAL DAH 4 14 B7 DA r NOTE: 1. The source (src) or working register pair [rr] for formats 5 and 6 cannot use register pair 0–1. 2. For formats 3 and 4, the destination address "XS [rr]" and the source address "XS [rr]" are each one byte. 3. For formats 5 and 6, the destination address "XL [rr]" and the source address "XL [rr]" are each two bytes. 4. The DA and r source values for formats 7 and 8 are used to address program memory; the second set of values, used in formats 9 and 10, are used to address data memory. PS031305-1017 6-50 S3F8S28/S3F8S24 Product Specification Examples: Chapter 6. Instruction Set Given: R0 = 11H, R1 = 34H, R2 = 01H, R3 = 04H; Program memory locations 0103H = 4FH, 0104H = 1A, 0105H = 6DH, and 1104H = 88H. External data memory locations 0103H = 5FH, 0104H = 2AH, 0105H = 7DH, and 1104H = 98H: LDC R0, @RR2 LDE R0, @RR2 LDC (NOTE) @RR2, R0 LDE @RR2, R0 LDC R0, #01H[RR2] LDE R0, #01H[RR2] LDC (NOTE) #01H[RR2], R0 LDE #01H[RR2], R0 LDC R0, #1000H[RR2] LDE R0, #1000H[RR2] LDC R0, 1104H LDE R0, 1104H LDC (NOTE) 1105H, R0 LDE 1105H, R0 ; R0  contents of program memory location 0104H ; R0 = 1AH, R2 = 01H, R3 = 04H ; R0  contents of external data memory location 0104H ; R0 = 2AH, R2 = 01H, R3 = 04H ; 11H (contents of R0) is loaded into program memory ; location 0104H (RR2), ; working registers R0, R2, R3 → no change ; 11H (contents of R0) is loaded into external data memory ; location 0104H (RR2), ; working registers R0, R2, R3 → no change ; R0  contents of program memory location 0105H ; (01H + RR2), ; R0 = 6DH, R2 = 01H, R3 = 04H ; R0  contents of external data memory location 0105H ; (01H + RR2), R0 = 7DH, R2 = 01H, R3 = 04H ; 11H (contents of R0) is loaded into program memory location ; 0105H (01H + 0104H) ; 11H (contents of R0) is loaded into external data memory ; location 0105H (01H + 0104H) ; R0  contents of program memory location 1104H ; (1000H + 0104H), R0 = 88H, R2 = 01H, R3 = 04H ; R0  contents of external data memory location 1104H ; (1000H + 0104H), R0 = 98H, R2 = 01H, R3 = 04H ; R0  contents of program memory location 1104H, ; R0 = 88H ; R0  contents of external data memory location 1104H, ; R0 = 98H ; 11H (contents of R0) is loaded into program memory location ; 1105H, (1105H)  11H ; 11H (contents of R0) is loaded into external data memory ; location 1105H, (1105H)  11H NOTE: These instructions are not supported by masked ROM type devices. PS031305-1017 6-51 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.38 LDCD/LDED (Load Memory and Decrement) LDCD/LDED dst, src Operation: dst  src rr  rr – 1 These instructions are used for user stacks or block transfers of data from program or data memory to the register file. The address of the memory location is specified by a working register pair. The contents of the source location are loaded into the destination location. The memory address is then decremented. The contents of the source are unaffected. LDCD references program memory and LDED references external data memory. The assembler makes "Irr" an even number for program memory and an odd number for data memory. Flags: No flags are affected. Format: opc Examples: dst | src Cycles Opcode (Hex) 2 10 E2 Addr Mode dst src r Irr Given: R6 = 10H, R7 = 33H, R8 = 12H, program memory location 1033H = 0CDH, and external data memory location 1033H = 0DDH: LDCD R8, @RR6 LDED R8, @RR6 PS031305-1017 Bytes ; 0CDH (contents of program memory location 1033H) is loaded ; into R8 and RR6 is decremented by one ; R8 = 0CDH, R6 = 10H, R7 = 32H (RR6  RR6 – 1) ; 0DDH (contents of data memory location 1033H) is loaded ; into R8 and RR6 is decremented by one (RR6  RR6 – 1) ; R8 = 0DDH, R6 = 10H, R7 = 32H 6-52 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.39 LDCI/LDEI (Load Memory and Increment) LDCI/LDEI dst,src Operation: dst  src rr  rr + 1 These instructions are used for user stacks or block transfers of data from program or data memory to the register file. The address of the memory location is specified by a working register pair. The contents of the source location are loaded into the destination location. The memory address is then incremented automatically. The contents of the source are unaffected. LDCI refers to program memory and LDEI refers to external data memory. The assembler makes "Irr" even for program memory and odd for data memory. Flags: No flags are affected. Format: opc Examples: PS031305-1017 dst | src Bytes Cycles Opcode (Hex) 2 10 E3 Addr Mode dst src r Irr Given: R6 = 10H, R7 = 33H, R8 = 12H, program memory locations 1033H = 0CDH and 1034H = 0C5H; external data memory locations 1033H = 0DDH and 1034H = 0D5H: LDCI R8, @RR6 LDEI R8, @RR6 ; 0CDH (contents of program memory location 1033H) is loaded ; into R8 and RR6 is incremented by one (RR6  RR6 + 1) ; R8 = 0CDH, R6 = 10H, R7 = 34H ; 0DDH (contents of data memory location 1033H) is loaded ; into R8 and RR6 is incremented by one (RR6  RR6 + 1) ; R8 = 0DDH, R6 = 10H, R7 = 34H 6-53 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.40 LDCPD/LDEPD (Load Memory with Pre-Decrement) LDCPD/ LDEPD dst, src Operation: rr  rr – 1 dst  src These instructions are used for block transfers of data from program or data memory from the register file. The address of the memory location is specified by a working register pair and is first decremented. The contents of the source location are then loaded into the destination location. The contents of the source are unaffected. LDCPD refers to program memory and LDEPD refers to external data memory. The assembler makes "Irr" an even number for program memory and an odd number for external data memory. Flags: No flags are affected. Format: opc Examples: src | dst Cycles Opcode (Hex) 2 14 F2 Addr Mode dst src Irr r Given: R0 = 77H, R6 = 30H, and R7 = 00H: LDCPD @RR6, R0 LDEPD @RR6, R0 PS031305-1017 Bytes ; (RR6  RR6 – 1) ; 77H (contents of R0) is loaded into program memory location ; 2FFFH (3000H to 1H) ; R0 = 77H, R6 = 2FH, R7 = 0FFH ; (RR6  RR6 – 1) ; 77H (contents of R0) is loaded into external data memory ; location 2FFFH (3000H to 1H) ; R0 = 77H, R6 = 2FH, R7 = 0FFH 6-54 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.41 LDCPI/LDEPI (Load Memory with Pre-Increment) LDCPI/LDEPI dst, src Operation: rr  rr + 1 dst  src These instructions are used for block transfers of data from program or data memory from the register file. The address of the memory location is specified by a working register pair and is first incremented. The contents of the source location are loaded into the destination location. The contents of the source are unaffected. LDCPI refers to program memory and LDEPI refers to external data memory. The assembler makes "Irr" an even number for program memory and an odd number for data memory. Flags: No flags are affected. Format: opc Examples: src | dst Cycles Opcode (Hex) 2 14 F3 Addr Mode dst src Irr r Given: R0 = 7FH, R6 = 21H, and R7 = 0FFH: LDCPI @RR6, R0 LDEPI @RR6, R0 PS031305-1017 Bytes ; (RR6  RR6 + 1) ; 7FH (contents of R0) is loaded into program memory ; location 2200H (21FFH + 1H) R0 = 7FH, R6 = 22H, R7 = 00H ; (RR6  RR6 + 1) ; 7FH (contents of R0) is loaded into external data memory ; location 2200H (21FFH + 1H) R0 = 7FH, R6 = 22H, R7 = 00H 6-55 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.42 LDW (Load Word) LDW dst, src Operation: dst  src The contents of the source (a word) are loaded into the destination. The contents of the source are unaffected. Flags: No flags are affected. Format: opc opc Examples: src dst dst src Bytes Cycles Opcode (Hex) 3 8 C4 RR RR 8 C5 RR IR 8 C6 RR IML 4 Addr Mode dst src Given: R4 = 06H, R5 = 1CH, R6 = 05H, R7 = 02H, Register 00H = 1AH, Register 01H = 02H, Register 02H = 03H, and Register 03H = 0FH: LDW LDW RR6, RR4 00H, 02H → → LDW LDW LDW LDW RR2, @R7 04H, @01H RR6, #1234H 02H, #0FEDH → → → → R6 = 06H, R7 = 1CH, R4 = 06H, R5 = 1CH Register 00H = 03H, Register 01H = 0FH, Register 02H = 03H, Register 03H = 0FH R2 = 03H, R3 = 0FH Register 04H = 03H, Register 05H = 0FH R6 = 12H, R7 = 34H Register 02H = 0FH, Register 03H = 0EDH In the second example, please note that the statement "LDW 00H,02H" loads the contents of the source word 02H, 03H into the destination word 00H, 01H. This leaves the value 03H in general register 00H and the value 0FH in register 01H. The other examples show how to use the LDW instruction with various addressing modes and formats. PS031305-1017 6-56 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.43 MULT (Multiply-Unsigned) MULT dst, src Operation: dst  dst  src The 8-bit destination operand (even register of the register pair) is multiplied by the source operand (8 bits) and the product (16 bits) is stored in the register pair specified by the destination address. Both operands are treated as unsigned integers. Flags: C: Set if result is  255; cleared otherwise. Z: Set if the result is "0"; cleared otherwise. S: Set if MSB of the result is a "1"; cleared otherwise. V: Cleared. D: Unaffected. H: Unaffected. Format: opc Examples: src dst Bytes Cycles Opcode (Hex) Addr Mode dst src 3 22 84 RR R 22 85 RR IR 22 86 RR IM Given: Register 00H = 20H, Register 01H = 03H, register 02H = 09H, Register 03H = 06H: MULT 00H, 02H MULT 00H, @01H MULT 00H, #30H → → → Register 00H = 01H, Register 01H = 20H, Register 02H = 09H Register 00H = 00H, Register 01H = 0C0H Register 00H = 06H, Register 01H = 00H In the first example, the statement "MULT 00H, 02H" multiplies the 8-bit destination operand (in the register 00H of the register pair 00H, 01H) by the source register 02H operand (09H). The 16bit product, 0120H, is stored in the register pair 00H, 01H. PS031305-1017 6-57 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.44 NEXT (Next) NEXT Operation: PC  @ IP IP  IP + 2 The NEXT instruction is useful when implementing threaded-code languages. The program memory word that is pointed to by the instruction pointer is loaded into the program counter. The instruction pointer is then incremented by two. Flags: No flags are affected. Format: Bytes Cycles Opcode (Hex) 1 10 0F opc Example: The following diagram shows one example of how to use the NEXT instruction. Before Address IP After Data Address 0043 IP Address PC 0120 43 44 45 120 Data Address H Address L Address H Next Memory PS031305-1017 Data 0045 01 10 Address PC 0130 43 44 45 130 Data Address H Address L Address H Routine Memory 6-58 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.45 NOP (No Operation) NOP Operation: No action is performed when the CPU executes this instruction. Typically, one or more NOPs are executed in sequence in order to effect a timing delay of variable duration. Flags: No flags are affected. Format: opc Example: Bytes Cycles Opcode (Hex) 1 4 FF When the instruction NOP Is encountered in a program, no operation occurs. Instead, there is a delay in instruction execution time. PS031305-1017 6-59 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.46 OR (Logical OR) OR dst,src Operation: dst  dst OR src The source operand is logically ORed with the destination operand and the result is stored in the destination. The contents of the source are unaffected. The OR operation results in a "1" being stored whenever either of the corresponding bits in the two operands is a "1"; otherwise a "0" is stored. Flags: C: Unaffected. Z: Set if the result is "0"; cleared otherwise. S: Set if the result bit 7 is set; cleared otherwise. V: Always cleared to "0". D: Unaffected. H: Unaffected. Format: opc opc opc Examples: dst | src src dst dst src Bytes Cycles Opcode (Hex) 2 4 42 r r 6 43 r lr 6 44 R R 6 45 R IR 6 46 R IM 3 3 Addr Mode dst src Given: R0 = 15H, R1 = 2AH, R2 = 01H, Register 00H = 08H, Register 01H = 37H, and Register 08H = 8AH: OR OR OR OR OR R0, R1 R0, @R2 00H, 01H 01H, @00H 00H, #02H → → → → → R0 = 3FH, R1 = 2AH R0 = 37H, R2 = 01H, Register 01H = 37H Register 00H = 3FH, Register 01H = 37H Register 00H = 08H, Register 01H = 0BFH Register 00H = 0AH In the first example, if working register R0 contains the value 15H and register R1 the value 2AH, the statement "OR R0, R1" logical-ORs the R0 and R1 register contents and stores the result (3FH) in destination register R0. The other examples show the use of the logical OR instruction with the various addressing modes and formats. PS031305-1017 6-60 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.47 POP (Pop from Stack) POP dst Operation: dst  @SP SP  SP + 1 The contents of the location addressed by the stack pointer are loaded into the destination. The stack pointer is then incremented by one. Flags: No flags affected. Format: opc Examples: dst Bytes Cycles Opcode (Hex) Addr Mode dst 2 8 50 R 8 51 IR Given: Register 00H = 01H, Register 01H = 1BH, SPH (0D8H) = 00H, SPL (0D9H) = 0FBH, and Stack Register 0FBH = 55H: POP POP 00H → @00H → Register 00H = 55H, SP = 00FCH Register 00H = 01H, Register 01H = 55H, SP = 00FCH In the first example, general register 00H contains the value 01H. The statement "POP 00H" loads the contents of location 00FBH (55H) into destination register 00H and then increments the stack pointer by one. Register 00H then contains the value 55H and the SP points to location 00FCH. PS031305-1017 6-61 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.48 POPUD (Pop User Stack-Decrementing) POPUD dst, src Operation: dst  src IR  IR – 1 This instruction is used for user-defined stacks in the register file. The contents of the register file location addressed by the user stack pointer are loaded into the destination. The user stack pointer is then decremented. Flags: No flags are affected. Format: opc Example: src dst Bytes Cycles Opcode (Hex) 3 8 92 Addr Mode dst src R IR Given: Register 00H = 42H (user stack pointer register), Register 42H = 6FH, and Register 02H = 70H: POPUD 02H, @00H → Register 00H = 41H, Register 02H = 6FH, Register 42H = 6FH If general register 00H contains the value 42H and register 42H the value 6FH, the statement "POPUD 02H, @00H" loads the contents of register 42H into the destination register 02H. The user stack pointer is then decremented by one, leaving the value 41H. PS031305-1017 6-62 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.49 POPUI (Pop User Stack-Incrementing) POPUI dst, src Operation: dst  src IR  IR + 1 The POPUI instruction is used for user-defined stacks in the register file. The contents of the register file location addressed by the user stack pointer are loaded into the destination. The user stack pointer is then incremented. Flags: No flags are affected. Format: opc Example: src dst Bytes Cycles Opcode (Hex) 3 8 93 Addr Mode dst src R IR Given: Register 00H = 01H and Register 01H = 70H: POPUI 02H, @00H → Register 00H = 02H, Register 01H = 70H, Register 02H = 70H If general register 00H contains the value 01H and register 01H the value 70H, the statement "POPUI 02H, @00H" loads the value 70H into the destination general register 02H. The user stack pointer (register 00H) is then incremented by one, changing its value from 01H to 02H. PS031305-1017 6-63 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.50 PUSH (Push to Stack) PUSH src Operation: SP  SP – 1 @SP  src A PUSH instruction decrements the stack pointer value and loads the contents of the source (src) into the location addressed by the decremented stack pointer. The operation then adds the new value to the top of the stack. Flags: No flags are affected. Format: opc src Bytes Cycles Opcode (Hex) Addr Mode dst 2 8 (internal clock) 70 R 71 IR 8 (external clock) 8 (internal clock) 8 (external clock) Examples: Given: Register 40H = 4FH, register 4FH = 0AAH, SPH = 00H, and SPL = 00H: PUSH 40H → PUSH @40H → Register 40H = 4FH, Stack Register 0FFH = 4FH, SPH = 0FFH, SPL = 0FFH Register 40H = 4FH, Register 4FH = 0AAH, Stack Register 0FFH = 0AAH, SPH = 0FFH, SPL = 0FFH In the first example, if the stack pointer contains the value 0000H, and general register 40H the value 4FH, the statement "PUSH 40H" decrements the stack pointer from 0000 to 0FFFFH. It then loads the contents of register 40H into location 0FFFFH and adds this new value to the top of the stack. PS031305-1017 6-64 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.51 PUSHUD (Push User Stack-Decrementing) PUSHUD dst, src Operation: IR  IR – 1 dst  src This instruction is used to address user-defined stacks in the register file. PUSHUD decrements the user stack pointer and loads the contents of the source into the register addressed by the decremented stack pointer. Flags: No flags are affected. Format: opc Example: dst src Bytes Cycles Opcode (Hex) 3 8 82 Addr Mode dst src IR R Given: Register 00H = 03H, Register 01H = 05H, and Register 02H = 1AH: PUSHUD @00H, 01H → Register 00H = 02H, Register 01H = 05H, Register 02H = 05H If the user stack pointer (register 00H, for example) contains the value 03H, the statement "PUSHUD @00H, 01H" decrements the user stack pointer by one, leaving the value 02H. The 01H register value, 05H, is then loaded into the register addressed by the decremented user stack pointer. PS031305-1017 6-65 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.52 PUSHUI (Push User Stack-Incrementing) PUSHUI dst, src Operation: IR  IR + 1 dst  src This instruction is used for user-defined stacks in the register file. PUSHUI increments the user stack pointer and then loads the contents of the source into the register location addressed by the incremented user stack pointer. Flags: No flags are affected. Format: opc Example: dst src Bytes Cycles Opcode (Hex) 3 8 83 Addr Mode dst src IR R Given: Register 00H = 03H, Register 01H = 05H, and Register 04H = 2AH: PUSHUI @00H, 01H → Register 00H = 04H, Register 01H = 05H, Register 04H = 05H If the user stack pointer (register 00H, for example) contains the value 03H, the statement "PUSHUI @00H, 01H" increments the user stack pointer by one, leaving the value 04H. The 01H register value, 05H, is then loaded into the location addressed by the incremented user stack pointer. PS031305-1017 6-66 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.53 RCF (Reset Carry Flag) RCF RCF Operation: C0 The carry flag is cleared to logic zero, regardless of its previous value. Flags: C: Cleared to "0". No other flags are affected. Format: opc Example: Bytes Cycles Opcode (Hex) 1 4 CF Given: C = "1" or "0": The instruction RCF clears the carry flag (C) to logic zero. PS031305-1017 6-67 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.54 RET (Return) RET Operation: PC  @SP SP  SP + 2 The RET instruction is normally used to return to the previously executing procedure at the end of a procedure entered by a CALL instruction. The contents of the location addressed by the stack pointer are popped into the program counter. The next statement that is executed is the one that is addressed by the new program counter value. Flags: No flags are affected. Format: opc Bytes Cycles Opcode (Hex) 1 8 (internal stack) AF 10 (internal stack) Example: Given: SP = 00FCH, (SP) = 101AH, and PC = 1234: RET → PC = 101AH, SP = 00FEH The statement "RET" pops the contents of stack pointer location 00FCH (10H) into the high byte of the program counter. The stack pointer then pops the value in location 00FEH (1AH) into the PC's low byte and the instruction at location 101AH is executed. The stack pointer now points to memory location 00FEH. PS031305-1017 6-68 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.55 RL (Rotate Left) RL dst Operation: C  dst (7) dst (0)  dst (7) dst (n + 1)  dst (n), n = 0–6 The contents of the destination operand are rotated left one bit position. The initial value of bit 7 is moved to the bit zero (LSB) position and also replaces the carry flag. 7 0 C Flags: C: Set if the bit rotated from the most significant bit position (bit 7) was "1". Z: Set if the result is "0"; cleared otherwise. S: Set if the result bit 7 is set; cleared otherwise. V: Set if arithmetic overflow occurred; cleared otherwise. D: Unaffected. H: Unaffected. Format: opc Examples: dst Bytes Cycles Opcode (Hex) Addr Mode dst 2 4 90 R 4 91 IR Given: Register 00H = 0AAH, register 01H = 02H and register 02H = 17H: RL RL 00H → @01H → Register 00H = 55H, C = "1" Register 01H = 02H, Register 02H = 2EH, C = "0" In the first example, if general register 00H contains the value 0AAH (10101010B), the statement "RL 00H" rotates the 0AAH value left one bit position, leaving the new value 55H (01010101B) and setting the carry and overflow flags. PS031305-1017 6-69 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.56 RLC (Rotate Left Through Carry) RLC dst Operation: dst (0)  C C dst (7) dst (n + 1)  dst (n), n = 0 to 6 The contents of the destination operand with the carry flag are rotated left one bit position. The initial value of bit 7 replaces the carry flag (C); the initial value of the carry flag replaces bit zero. 7 0 C Flags: C: Set if the bit rotated from the most significant bit position (7-bit) was "1". Z: Set if the result is "0"; cleared otherwise. S: Set if the result 7-bit is set; cleared otherwise. V: Set if arithmetic overflow occurred, that is, if the sign of the destination changed during rotation; cleared otherwise. D: Unaffected. H: Unaffected. Format: opc Examples: dst Bytes Cycles Opcode (Hex) Addr Mode dst 2 4 10 R 4 11 IR Given: Register 00H = 0AAH, Register 01H = 02H, and Register 02H = 17H, C = "0": RLC RLC 00H → @01H → Register 00H = 54H, C = "1" Register 01H = 02H, Register 02H = 2EH, C = "0" In the first example, if general register 00H has the value 0AAH (10101010B), the statement "RLC 00H" rotates 0AAH one bit position to the left. The initial value of 7-bit sets the carry flag and the initial value of the C flag replaces bit zero of register 00H, leaving the value 55H (01010101B). The MSB of register 00H resets the carry flag to "1" and sets the overflow flag. PS031305-1017 6-70 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.57 RR (Rotate Right) RR dst Operation: C  dst (0) dst (7)  dst (0) dst (n)  dst (n + 1), n = 0 to 6 The contents of the destination operand are rotated right one bit position. The initial value of bit zero (LSB) is moved to bit 7 (MSB) and also replaces the carry flag (C). 7 0 C Flags: C: Set if the bit rotated from the least significant bit position (bit zero) was "1". Z: Set if the result is "0"; cleared otherwise. S: Set if the result bit 7 is set; cleared otherwise. V: Set if arithmetic overflow occurred, that is, if the sign of the destination changed during rotation; cleared otherwise. D: Unaffected. H: Unaffected. Format: opc Examples: dst Bytes Cycles Opcode (Hex) Addr Mode dst 2 4 E0 R 4 E1 IR Given: Register 00H = 31H, Register 01H = 02H, and Register 02H = 17H: RR RR 00H → @ 01H → Register 00H = 98H, C = "1" Register 01H = 02H, Register 02H = 8BH, C = "1" In the first example, if general register 00H contains the value 31H (00110001B), the statement "RR 00H" rotates this value one bit position to the right. The initial value of bit zero is moved to bit 7, leaving the new value 98H (10011000B) in the destination register. The initial bit zero also resets the C flag to "1" and the sign flag and overflow flag are also set to "1". PS031305-1017 6-71 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.58 RRC (Rotate Right Through Carry) RRC dst Operation: dst (7)  C C  dst (0) dst (n)  dst (n + 1), n = 0 to 6 The contents of the destination operand and the carry flag are rotated right one bit position. The initial value of bit zero (LSB) replaces the carry flag; the initial value of the carry flag replaces bit 7 (MSB). 7 0 C Flags: C: Set if the bit rotated from the least significant bit position (bit zero) was "1". Z: Set if the result is "0" cleared otherwise. S: Set if the result bit 7 is set; cleared otherwise. V: Set if arithmetic overflow occurred, that is, if the sign of the destination changed during rotation; cleared otherwise. D: Unaffected. H: Unaffected. Format: opc Examples: dst Bytes Cycles Opcode (Hex) Addr Mode dst 2 4 C0 R 4 C1 IR Given: Register 00H = 55H, Register 01H = 02H, Register 02H = 17H, and C = "0": RRC RRC 00H @01H → → Register 00H = 2AH, C = "1" Register 01H = 02H, Register 02H = 0BH, C = "1" In the first example, if general register 00H contains the value 55H (01010101B), the statement "RRC 00H" rotates this value one bit position to the right. The initial value of bit zero ("1") replaces the carry flag and the initial value of the C flag ("1") replaces bit 7. This leaves the new value 2AH (00101010B) in destination register 00H. The sign flag and overflow flag are both cleared to "0". PS031305-1017 6-72 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.59 SB0 (Select Bank 0) SB0 Operation: BANK  0 The SB0 instruction clears the bank address flag in the FLAGS register (FLAGS.0) to logic zero, selecting bank 0 register addressing in the set 1 area of the register file. Flags: No flags are affected. Format: opc Example: Bytes Cycles Opcode (Hex) 1 4 4F The statement SB0 Clears FLAGS.0 to "0", selecting bank 0 register addressing. PS031305-1017 6-73 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.60 SB1 (Select Bank 1) SB1 Operation: BANK  1 The SB1 instruction sets the bank address flag in the FLAGS register (FLAGS.0) to logic one, selecting bank 1 register addressing in the set 1 area of the register file. (Bank 1 is not implemented in some S3C8 Series microcontrollers.) Flags: No flags are affected. Format: opc Example: Bytes Cycles Opcode (Hex) 1 4 5F The statement SB1 Sets FLAGS.0 to "1", selecting bank 1 register addressing, if implemented. PS031305-1017 6-74 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.61 SBC (Subtract with Carry) SBC dst, src Operation: dst  dst – src – c The source operand, along with the current value of the carry flag, is subtracted from the destination operand and the result is stored in the destination. The contents of the source are unaffected. Subtraction is performed by adding the two's-complement of the source operand to the destination operand. In multiple precision arithmetic, this instruction permits the carry ("borrow") from the subtraction of the low-order operands to be subtracted from the subtraction of high-order operands. Flags: C: Set if a borrow occurred (src  dst); cleared otherwise. Z: Set if the result is "0"; cleared otherwise. S: Set if the result is negative; cleared otherwise. V: Set if arithmetic overflow occurred, that is, if the operands were of opposite sign and the sign of the result is the same as the sign of the source; cleared otherwise. D: Always set to "1". H: Cleared if there is a carry from the most significant bit of the low-order four bits of the result; set otherwise, indicating a "borrow". Format: opc opc opc Examples: dst | src src dst dst src Bytes Cycles Opcode (Hex) 2 4 32 r r 6 33 r lr 6 34 R R 6 35 R IR 6 36 R IM 3 3 Addr Mode dst src Given: R1 = 10H, R2 = 03H, C = "1", Register 01H = 20H, Register 02H = 03H, and Register 03H = 0AH: SBC SBC SBC SBC SBC R1, R2 R1, @R2 01H, 02H 01H, @02H 01H, #8AH → → → → → R1 = 0CH, R2 = 03H R1 = 05H, R2 = 03H, Register 03H = 0AH Register 01H = 1CH, Register 02H = 03H Register 01H = 15H,Register 02H = 03H, Register 03H = 0AH Register 01H = 95H; C, S, and V = "1" In the first example, if working register R1 contains the value 10H and register R2 the value 03H, the statement "SBC R1, R2" subtracts the source value (03H) and the C flag value ("1") from the destination (10H) and then stores the result (0CH) in register R1. PS031305-1017 6-75 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.62 SCF (Set Carry Flag) SCF Operation: C1 The carry flag (C) is set to logic one, regardless of its previous value. Flags: C: Set to "1". No other flags are affected. Format: opc Example: Bytes Cycles Opcode (Hex) 1 4 DF The statement SCF Sets the carry flag to logic one. PS031305-1017 6-76 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.63 SRA (Shift Right Arithmetic) SRA dst Operation: dst (7)  dst (7) C  dst (0) dst (n)  dst (n + 1), n = 0 to 6 An arithmetic shift-right of one bit position is performed on the destination operand. Bit zero (the LSB) replaces the carry flag. The value of bit 7 (the sign bit) is unchanged and is shifted into bit position 6. 7 6 0 C Flags: C: Set if the bit shifted from the LSB position (bit zero) was "1". Z: Set if the result is "0"; cleared otherwise. S: Set if the result is negative; cleared otherwise. V: Always cleared to "0". D: Unaffected. H: Unaffected. Format: opc Examples: dst Bytes Cycles Opcode (Hex) Addr Mode dst 2 4 D0 R 4 D1 IR Given: Register 00H = 9AH, register 02H = 03H, register 03H = 0BCH, and C = "1": SRA SRA 00H @02H → → Register 00H = 0CD, C = "0" Register 02H = 03H, Register 03H = 0DEH, C = "0" In the first example, if general register 00H contains the value 9AH (10011010B), the statement "SRA 00H" shifts the bit values in register 00H right one bit position. Bit zero ("0") clears the C flag and bit 7 ("1") is then shifted into the bit 6 position (bit 7 remains unchanged). This leaves the value 0CDH (11001101B) in destination register 00H. PS031305-1017 6-77 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.64 SRP/SRP0/SRP1 (Set Register Pointer) SRP src SRP0 src SRP1 src Operation: If src (1) = 1 and src (0) = 0 then: If src (1) = 0 and src (0) = 1 then: If src (1) = 0 and src (0) = 0 then: Flags: No flags are affected. RP0 (3–7)  src (3–7) RP1 (3–7)  src (3–7) RP0 (4–7)  src (4–7), RP0 (3)  0 RP1 (4–7)  src (4–7), RP1 (3)  1 The source data bits one and zero (LSB) determine whether to write one or both of the register pointers, RP0 and RP1. Bits 3 to 7 of the selected register pointer are written unless both register pointers are selected. RP0.3 is then cleared to logic zero and RP1.3 is set to logic one. Format: opc Examples: src Bytes Cycles Opcode (Hex) Addr Mode src 2 4 31 IM The statement SRP #40H Sets register pointer 0 (RP0) at location 0D6H to 40H and register pointer 1 (RP1) at location 0D7H to 48H. The statement "SRP0 #50H" sets RP0 to 50H, and the statement "SRP1 #68H" sets RP1 to 68H. PS031305-1017 6-78 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.65 STOP (Stop Operation) STOP Operation: The STOP instruction stops the both the CPU clock and system clock and causes the microcontroller to enter Stop mode. During Stop mode, the contents of on-chip CPU registers, peripheral registers, and I/O port control and data registers are retained. Stop mode can be released by an external reset operation or by external interrupts. For the reset operation, the nRESET pin must be held to Low level until the required oscillation stabilization interval has elapsed. In application programs, a STOP instruction must be immediately followed by at least three NOP instructions. This ensures an adeguate time interval for the clock to stabilize before the next instruction is executed. If three or more NOP instructons are not used after STOP instruction, leakage current could be flown because of the floating state in the internal bus. Flags: No flags are affected. Format: opc Example: Bytes Cycles Opcode (Hex) 1 4 7F Addr Mode dst src – – The statement STOP ; Halts all microcontroller operations NOP NOP NOP PS031305-1017 6-79 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.66 SUB (Subtract) SUB dst, src Operation: dst  dst – src The source operand is subtracted from the destination operand and the result is stored in the destination. The contents of the source are unaffected. Subtraction is performed by adding the two's complement of the source operand to the destination operand. Flags: C: Set if a "borrow" occurred; cleared otherwise. Z: Set if the result is "0"; cleared otherwise. S: Set if the result is negative; cleared otherwise. V: Set if arithmetic overflow occurred, that is, if the operands were of opposite signs and the sign of the result is of the same as the sign of the source operand; cleared otherwise. D: Always set to "1". H: Cleared if there is a carry from the most significant bit of the low-order four bits of the result; set otherwise indicating a "borrow". Format: opc opc opc Examples: dst | src src dst dst src Bytes Cycles Opcode (Hex) 2 4 22 r r 6 23 r lr 6 24 R R 6 25 R IR 6 26 R IM 3 3 Addr Mode dst src Given: R1 = 12H, R2 = 03H, Register 01H = 21H, Register 02H = 03H, Register 03H = 0AH: SUB SUB SUB SUB SUB SUB R1, R2 R1, @R2 01H, 02H 01H, @02H 01H, #90H 01H, #65H → → → → → → R1 = 0FH, R2 = 03H R1 = 08H, R2 = 03H Register 01H = 1EH, Register 02H = 03H Register 01H = 17H, Register 02H = 03H Register 01H = 91H; C, S, and V = "1" Register 01H = 0BCH; C and S = "1", V = "0" In the first example, if working register R1 contains the value 12H and if register R2 contains the value 03H, the statement "SUB R1, R2" subtracts the source value (03H) from the destination value (12H) and stores the result (0FH) in destination register R1. PS031305-1017 6-80 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.67 SWAP (Swap Nibbles) SWAP dst Operation: dst (0–3)  dst (4–7) The contents of the lower four bits and upper four bits of the destination operand are swapped. 7 Flags: 4 3 0 C: Undefined. Z: Set if the result is "0"; cleared otherwise. S: Set if the result bit 7 is set; cleared otherwise. V: Undefined. D: Unaffected. H: Unaffected. Format: opc Examples: dst Bytes Cycles Opcode (Hex) Addr Mode dst 2 4 F0 R 4 F1 IR Given: Register 00H = 3EH, Register 02H = 03H, and Register 03H = 0A4H: SWAP 00H SWAP @02H → → Register 00H = 0E3H Register 02H = 03H, Register 03H = 4AH In the first example, if general register 00H contains the value 3EH (00111110B), the statement "SWAP 00H" swaps the lower and upper four bits (nibbles) in the 00H register, leaving the value 0E3H (11100011B). PS031305-1017 6-81 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.68 TCM (Test Complement under Mask) TCM dst, src Operation: (NOT dst) AND src This instruction tests selected bits in the destination operand for a logic one value. The bits to be tested are specified by setting a "1" bit in the corresponding position of the source operand (mask). The TCM statement complements the destination operand, which is then ANDed with the source mask. The zero (Z) flag can then be checked to determine the result. The destination and source operands are unaffected. Flags: C: Unaffected. Z: Set if the result is "0"; cleared otherwise. S: Set if the result bit 7 is set; cleared otherwise. V: Always cleared to "0". D: Unaffected. H: Unaffected. Format: opc opc opc Examples: dst | src src dst dst src Bytes Cycles Opcode (Hex) 2 4 62 r r 6 63 r lr 6 64 R R 6 65 R IR 6 66 R IM 3 3 Addr Mode dst src Given: R0 = 0C7H, R1 = 02H, R2 = 12H, Register 00H = 2BH, Register 01H = 02H, and Register 02H = 23H: TCM TCM TCM TCM R0, R1 R0, @R1 00H, 01H 00H, @01H → → → → TCM 00H, #34 → R0 = 0C7H, R1 = 02H, Z = "1" R0 = 0C7H, R1 = 02H, Register 02H = 23H, Z = "0" Register 00H = 2BH, Register 01H = 02H, Z = "1" Register 00H = 2BH, Register 01H = 02H, Register 02H = 23H, Z = "1" Register 00H = 2BH, Z = "0" In the first example, if working register R0 contains the value 0C7H (11000111B) and register R1 the value 02H (00000010B), the statement "TCM R0, R1" tests bit one in the destination register for a "1" value. Because the mask value corresponds to the test bit, the Z flag is set to logic one and can be tested to determine the result of the TCM operation. PS031305-1017 6-82 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.69 TM (Test under Mask) TM dst, src Operation: dst AND src This instruction tests selected bits in the destination operand for a logic zero value. The bits to be tested are specified by setting a "1" bit in the corresponding position of the source operand (mask), which is ANDed with the destination operand. The zero (Z) flag can then be checked to determine the result. The destination and source operands are unaffected. Flags: C: Unaffected. Z: Set if the result is "0"; cleared otherwise. S: Set if the result bit 7 is set; cleared otherwise. V: Always reset to "0". D: Unaffected. H: Unaffected. Format: opc opc opc Examples: dst | src src dst dst src Bytes Cycles Opcode (Hex) 2 4 72 r r 6 73 r lr 6 74 R R 6 75 R IR 6 76 R IM 3 3 Addr Mode dst src Given: R0 = 0C7H, R1 = 02H, R2 = 18H, Register 00H = 2BH, Register 01H = 02H, and Register 02H = 23H: TM TM TM TM R0, R1 R0, @R1 00H, 01H 00H, @01H → → → → TM 00H, #54H → R0 = 0C7H, R1 = 02H, Z = "0" R0 = 0C7H, R1 = 02H, Register 02H = 23H, Z = "0" Register 00H = 2BH, Register 01H = 02H, Z = "0" Register 00H = 2BH, Register 01H = 02H, Register 02H = 23H, Z = "0" Register 00H = 2BH, Z = "1" In the first example, if working register R0 contains the value 0C7H (11000111B) and register R1 the value 02H (00000010B), the statement "TM R0, R1" tests bit one in the destination register for a "0" value. Because the mask value does not match the test bit, the Z flag is cleared to logic zero and can be tested to determine the result of the TM operation. PS031305-1017 6-83 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.70 WFI (Wait for Interrupt) WFI Operation: The CPU is effectively halted until an interrupt occurs, except that DMA transfers can still take place during this wait state. The WFI status can be released by an internal interrupt, including a fast interrupt. Flags: No flags are affected. Format: Bytes Cycles Opcode (Hex) 1 4n 3F opc NOTE: n = 1, 2, 3, … Example: The following sample program structure shows the sequence of operations that follow a "WFI" statement: Main program . . . EI WFI (Next instruction) (Enable global interrupt) (Wait for interrupt) . . . Interrupt occurs Interrupt service routine . . . Clear interrupt flag IRET Service routine completed PS031305-1017 6-84 S3F8S28/S3F8S24 Product Specification Chapter 6. Instruction Set 6.5.71 XOR (Logical Exclusive OR) XOR dst, src Operation: dst  dst XOR src The source operand is logically exclusive-ORed with the destination operand and the result is stored in the destination. The exclusive-OR operation results in a "1" bit being stored whenever the corresponding bits in the operands are different; otherwise, a "0" bit is stored. Flags: C: Unaffected. Z: Set if the result is "0"; cleared otherwise. S: Set if the result bit 7 is set; cleared otherwise. V: Always reset to "0". D: Unaffected. H: Unaffected. Format: opc opc opc Examples: dst | src src dst dst src Bytes Cycles Opcode (Hex) 2 4 B2 r r 6 B3 r lr 6 B4 R R 6 B5 R IR 6 B6 R IM 3 3 Addr Mode dst src Given: R0 = 0C7H, R1 = 02H, R2 = 18H, Register 00H = 2BH, Register 01H = 02H, and Register 02H = 23H: XOR XOR XOR XOR XOR R0, R1 R0, @R1 00H, 01H 00H, @01H 00H, #54H → → → → → R0 = 0C5H, R1 = 02H R0 = 0E4H, R1 = 02H, register 02H = 23H Register 00H = 29H, register 01H = 02H Register 00H = 08H, register 01H = 02H, Register 02H = 23H Register 00H = 7FH In the first example, if working register R0 contains the value 0C7H and if register R1 contains the value 02H, the statement "XOR R0, R1" logically exclusive-ORs the R1 value with the R0 value and stores the result (0C5H) in the destination register R0. PS031305-1017 6-85 S3F8S28/S3F8S24 Product Specification 7 Chapter 7. Clock Circuit Clock Circuit 7.1 Overview By Smart Option (3FH.3–.0 in ROM), user can select internal RC oscillator or external oscillator. In using internal oscillator, XIN (P1.0), XOUT (P1.1) can be used by normal I/O pins. An internal RC oscillator source provides a typical 8MHz, 4MHz, 3.2MHz, 2MHz, 1MHz or 0.5MHz (in VDD = 5V) depending on Smart Option. An external RC oscillation source provides a typical 4MHz clock for S3F8S28/S3F8S24. An internal capacitor supports the RC oscillator circuit. A low gain external crystal or ceramic oscillation source provides a maximum 1 MHz clock with low system power consumption. A high gain external crystal or ceramic oscillation source provides a maximum 12MHz clock, these two different crystal/ceramic oscillation is selected by Smart Option (3F.3–3F.0). The XIN and XOUT pins connect the oscillation source to the on-chip clock circuit. Simplified external RC oscillator and crystal/ceramic oscillator circuits are shown in Figure 7-1 and Figure 7-2. When you use external oscillator, P1.0, P1.1 must be set to output port to prevent current consumption C1 XIN S3F8S28/F8S24 C2 Figure 7-1 PS031305-1017 XOUT Main Oscillator Circuit (Crystal/Ceramic Oscillator) 7-1 S3F8S28/S3F8S24 Product Specification Chapter 7. Clock Circuit 7.2 Main Oscillator Logic To increase processing speed and to reduce clock noise, non-divided logic is implemented for the main oscillator circuit. For this reason, very high resolution waveforms (square signal edges) must be generated in order for the CPU to efficiently process logic operations. 7.3 Clock Status During Power-Down Modes The two power-down modes, Stop mode and Idle mode, affect clock oscillation as follows: • In Stop mode, the main oscillator "freezes", halting the CPU and peripherals. The contents of the register file and current system register values are retained. Stop mode is released, and the oscillator started, by a reset operation, by Watchdog Timer interrupt by an external interrupt with RC-delay noise filter (for S3F8S28/S3F8S24, INT0 to INT7). • In Idle mode, the internal clock signal is gated off to the CPU, but not to interrupt control and the timer. The current CPU status is preserved, including stack pointer, program counter, and flags. Data in the register file is retained. Idle mode is released by a reset or by an interrupt (external or internally-generated). PS031305-1017 7-2 S3F8S28/S3F8S24 Product Specification Chapter 7. Clock Circuit 7.4 System Clock Control Register (CLKCON) The system clock control register, CLKCON, is located in location D4H. It is read/write addressable and has the following functions: • Oscillator IRQ wake-up function enable/disable (CLKCON.7) • Oscillator frequency divide-by value: non-divided, 2, 8, or 16 (CLKCON.4 and CLKCON.3) The CLKCON register controls whether or not an external interrupt can be used to trigger a Stop mode release (This is called the "IRQ wake-up" function). The IRQ wake-up enable bit is CLKCON.7. After a reset, the external interrupt oscillator wake-up function is enabled, the main oscillator is activated, and the fOSC/16 (the slowest clock speed) is selected as the CPU clock. If necessary, you can then increase the CPU clock speed to fOSC, fOSC/2 or fOSC/8. System Clock Control Register (CLKCON) D4H, R/W, Reset Value: 00H MSB .7 .6 .5 Not used Oscillator IRQ wake-up enable bit: 0 = Enable IRQ for main system oscillator wake-up function in power mode. 1 = Disable IRQ for main system oscillator wake-up function in power down mode. Figure 7-2 PS031305-1017 .4 .3 .2 .1 .0 LSB Not used Divide-by selection bits for CPU clock frequency: 00 = fosc/16 01 = fosc/8 10 = fosc/2 11 = fosc (non-divided) System Clock Control Register (CLKCON) 7-3 S3F8S28/S3F8S24 Product Specification Chapter 7. Clock Circuit 7.5 Ring Oscillator Control Register (ROSCCON) S3F8S28/S3F8S24 has an internal 32K (typ.) Ring oscillator for Watchdog Timer, that can be enabled and run in Stop Mode, it is useful for system wakeup in Stop Mode within setting period. The frequency distribution of the Ring oscillator is very large, so the trimming bits (ROSCCON.5–.0) are provided to adjust the frequency; the reset value of ROSCCON.5-.0 is "000000b", which set the max frequency, so user need to adjust the frequency by setting the trimming bits. The Ring oscillator control register, ROSCCON, is located in location F5H, Set 1, Bank 0. It is read/write addressable and has the following functions: • Ring OSC Enable/Disable (ROSCCON.7) • Free running Watchdog Timer clock source select (ROSCCON.6) • Ring OSC frequency trimming bits (ROSCCON.5–.0) Oscillator Control Register (ROSCCON) F5H, Set 1, Bank 0, R/W, Reset Value: 00H MSB .7 .6 .5 .4 Free Running Watchdog Timer Clock Source (FLCLK) Selection bit 0 = System clock: Fosc 1 = Ring OSC clock .3 .2 .1 .0 LSB Trimming Bits 000000b = Max. Frequency 111111b = Min. Frequency Ring OSC Enable bit: 0 = Disable Ring OSC 1 = Enable Ring OSC Figure 7-3 Ring Oscillator Control Register (ROSCCON) STOP Control Register (STOPCON) F4H, Set 1, Bank 0, R/W; Reset Value: 00H MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB STOP Control bits: Other values = Disable STOP instruction 10100101 = Enable STOP instruction Figure 7-4 PS031305-1017 Stop Control Register (STOPCON) 7-4 S3F8S28/S3F8S24 Product Specification Smart Option (3F.3-0 in ROM) Chapter 7. Clock Circuit Stop Instruction CLKCON.4-.3 Internal RC(8 MHz) Oscillator Stop Internal RC(4 MHz) Internal RC(3.2 MHz) Internal RC(2 MHz) Internal RC(1 MHz) Selected OSC MUX Fosc 1/2 M U X 1/8 Internal RC(0.5 MHz) Oscillator Wake-up External RC Oscillator External LG Crystal/Cermic CPU Clock 1/16 Noise Filter External HG Crystal/Cermic P2.6/CLO CLKCON.7 INT Pin P2CONH.6-.4 WDTINT Ring OSC M U X ROSCCON.7 ROSCCON.6 NOTE: Free Running Watchdog Timer An external interrupt (with RC-delay noise filter) can be used to release stop mode and "wake-up" The main oscillator. In the S3F8S28/F8S24, the INT0 to INT7 external interrupts are of this type. When Watchdog Timer clock source is Ring OSC, WDTINT also can release stop mode Figure 7-5 PS031305-1017 FLCLK System Clock Circuit Diagram 7-5 S3F8S28/S3F8S24 Product Specification 8 Chapter 8. RESET and Power-Down RESET and Power-Down 8.1 System Reset 8.1.1 Overview By Smart Option (3EH.7 in ROM), user can select internal RESET (LVR) or external RESET. In using internal RESET (LVR), nRESET pin (P1.2) can be used by normal I/O pin. The S3F8S28/S3F8S24 can be RESET in five ways: • By external power-on-reset • By the external nRESET input pin pulled low • By the digital Basic Timer overflow • By the digital free-running watchdog peripheral timing out • By Low Voltage Reset (LVR) During a external power-on reset, the voltage at VDD is High level and the nRESET pin is forced to Low level. The nRESET signal is input through a Schmitt trigger circuit where it is then synchronized with the CPU clock. This brings the S3F8S28/S3F8S24 into a known operating status. To ensure correct start-up, the user should take care that nRESET signal is not released before the VDD level is sufficient to allow MCU operation at the chosen frequency. After the nRESET pin is released, the S3F8S28/S3F8S24 MCU will enter an idle state for a minimum time interval to allow time for internal CPU clock oscillation to stabilize. The minimum required oscillation stabilization time for a reset is approximately 52.4ms (@ 219/fOSC, fOSC = 10MHz). When a reset occurs during normal operation (with both VDD and nRESET at High level), the signal at the nRESET pin is forced Low and the Reset operation starts. All system and peripheral control registers are then set to their default hardware Reset values (see Table 8-1 to Table 8-3). The Basic Timer provides a watchdog function in order to ensure graceful recovery from software malfunction in RUN & IDLE modes. If Basic Timer counter is not refreshed before an end-of-counter condition (overflow) is reached, the internal reset will be activated. The free running Watchdog Timer also can be used generate Reset to ensure system recovery, it’s clock source can be set to free running Ring Oscillator, so it can reset chip in Stop Mode. The on-chip Low Voltage Reset, features static Reset when supply voltage is below a reference value (Typ. 1.9, 2.3, 3.0, 3.9V). Thanks to this feature, external reset circuit can be removed while keeping the application safety. As long as the supply voltage is below the reference value, there is a internal and static RESET. The MCU can start only when the supply voltage rises over the reference value. When you calculate power consumption, please remember that a static current of LVR circuit should be added a CPU operating current in any operating modes such as Stop, Idle, and normal RUN mode when LVR enable in Smart Option. PS031305-1017 8-1 S3F8S28/S3F8S24 Product Specification Figure 8-1 Chapter 8. RESET and Power-Down Low Voltage Reset Circuit NOTE: To program the duration of the oscillation stabilization interval, you must make the appropriate settings to the basic timer control register, BTCON, before entering Stop mode. Also, if you do not want to use the basic timer watchdog function (which causes a system reset if a basic timer counter overflow occurs), you can disable it by writing "1010B" to the upper nibble of BTCON. PS031305-1017 8-2 S3F8S28/S3F8S24 Product Specification Chapter 8. RESET and Power-Down 8.1.2 External RESET Pin When the nRESET pin transiting from VIL (low input level of reset pin) to VIH (high input level of reset pin), the reset pulse is generated. VDD XIN R nRESET C XOUT S3F8S28/F8S24 VSS Notes: 1. R < 100Kohm is recommended to make sure that the voltage drop across R does not violate the detection of reset pulse. Figure 8-2 PS031305-1017 Recommended External Reset Circuit 8-3 S3F8S28/S3F8S24 Product Specification Chapter 8. RESET and Power-Down 8.1.3 MCU Initialization Sequence The following sequence of events occurs during a Reset operation: • All interrupts are disabled. • The watchdog function (basic timer) is enabled. • Ports 0 to 2 are set to input mode • Peripheral control and data registers are disabled and reset to their initial values (see Table 8-1 to Table 8-3). • The program counter is loaded with the ROM reset address 0100H. • When the programmed oscillation stabilization time interval has elapsed, the address stored in ROM location 0100H and 0101H is fetched and executed. Smart Option (3EH.7) nRESET MUX Internal nRESET LVR nRESET Basic Timer nRESET Watchdog nRESET Figure 8-3 Reset Block Diagram Oscillation Stabilization Wait Time (52.4 ms/at 10 MHz) nRESET Input Idle Mode Normal Mode or Power-Down Mode Operation Mode RESET Operation Figure 8-4 PS031305-1017 Timing for S3F8S28/S3F8S24 After Reset 8-4 S3F8S28/S3F8S24 Product Specification Chapter 8. RESET and Power-Down 8.2 Power-Down Modes 8.2.1 Stop Mode Stop mode is invoked by the instruction STOP (OPCODE 7FH). In Stop mode, the operation of the CPU and all peripherals is halted. That is, the on-chip main oscillator stops and the supply current is reduced to less than 4A except that the LVR (Low Voltage Reset) is enable. All system functions are halted when the clock "freezes", but data stored in the internal register file is retained. Stop mode can be released in one of three ways: by a nRESET signal, by an external interrupt or by Watchdog Timer interrupt. NOTE: Before execute the STOP instruction, must set the STPCON register as "10100101b". 8.2.2 Sources to Release Stop Mode Stop mode is released when following sources go active: • System Reset by external reset pin (nRESET) • External Interrupt (INT0 to INT7) • Watchdog Timer Interrupt (WDTINT) 8.2.2.1 Using RESET to Release Stop Mode Stop mode is released when the nRESET signal is released and returns to High level. All system and peripheral control registers are then Reset to their default values and the contents of all data registers are retained. A Reset operation automatically selects a slow clock (fOSC/16) because CLKCON.3 and CLKCON.4 are cleared to "00B". After the oscillation stabilization interval has elapsed, the CPU executes the system initialization routine by fetching the 16-bit address stored in ROM locations 0100H and 0101H. 8.2.2.2 Using an External Interrupt to Release Stop Mode External interrupts with an RC-delay noise filter circuit can be used to release Stop mode (Clock-related external interrupts cannot be used). External interrupts INT0 to INT7 in the S3F8S28/S3F8S24 interrupt structure meet this criterion. PS031305-1017 8-5 S3F8S28/S3F8S24 Product Specification Chapter 8. RESET and Power-Down 8.2.2.3 Using Watchdog Timer Interrupt to Release Stop Mode Watchdog timer overflow interrupt can be used to release stop mode: WDTINT Please note the following conditions for Stop mode release: • If you release Stop mode using an external interrupt or Watchdog Timer interrupt, the current values in system and peripheral control registers are unchanged. • If you use an external interrupt or Watchdog Timer interrupt for Stop mode release, you can also program the duration of the oscillation stabilization interval. To do this, you must make the appropriate control and clock settings before entering Stop mode. • When the Stop mode is released by external interrupt or Watchdog Timer interrupt, the CLKCON.4 and CLKCON.3 bit-pair setting remains unchanged and the currently selected clock value is used. The CLKCON.1 and CLKCON.0 bits are also remain previous values for Ring OSC setting and Watchdog Timer clock source selection. • The external interrupt or Watchdog Timer interrupt is serviced when the Stop mode release occurs. Following the IRET from the service routine, the instruction immediately following the one that initiated Stop mode is executed. 8.2.2.4 How to Enter into Stop Mode There are two steps to enter into Stop mode: • Handling STOPCON register to appropriate value (10100101B). • Writing Stop instruction (keep the order). • Waiting several clocks (insert several "NOP" instructions) 8.2.3 Idle Mode Idle mode is invoked by the instruction IDLE (opcode 6FH). In Idle mode, CPU operations are halted while select peripherals remain active. During Idle mode, the internal clock signal is gated off to the CPU, but not to interrupt logic and timer/counters. Port pins retain the mode (input or output) they had at the time Idle mode was entered. There are two ways to release Idle mode: 1. Execute a Reset. All system and peripheral control registers are Reset to their default values and the contents of all data registers are retained. The Reset automatically selects a slow clock (fOSC/16) because CLKCON.3 and CLKCON.4 are cleared to "00B". If interrupts are masked, a Reset is the only way to release Idle mode. 2. Activate any enabled interrupt, causing Idle mode to be released. When you use an interrupt to release Idle mode, the CLKCON.3 and CLKCON.4 register values remain unchanged, and the currently selected clock value is used. The interrupt is then serviced. Following the IRET from the service routine, the instruction immediately following the one that initiated Idle mode is executed. NOTE: 1. External interrupts that are not clock-related and interrupts of free running Watchdog Timer can be used to release stop mode. To release Idle mode, however, any type of interrupt (that is, internal or external) can be used. 2. Before enter the STOP or IDLE mode, the ADC must be disabled. Otherwise, the STOP or IDLE current will be increased significantly. PS031305-1017 8-6 S3F8S28/S3F8S24 Product Specification Chapter 8. RESET and Power-Down 8.3 Hardware Reset Values Table 8-1 to Table 8-3 lists the values for CPU and system registers, peripheral control registers, and peripheral data registers following a Reset operation in normal operating mode. • A "1" or a "0" shows the Reset bit value as logic one or logic zero, respectively. • An "x" means that the bit value is undefined following a reset. • A dash "–" means that the bit is either not used or not mapped. Table 8-1 Register Name Register Values After a Reset, Set1 Mnemonic Address & Location RESET Value (Bit) Address RW 7 6 5 4 3 2 1 0 TACNT D0H R 0 0 0 0 0 0 0 0 Timer A data register TADATA D1H RW 1 1 1 1 1 1 1 1 Timer 0/A control register TACON D2H RW 0 0 0 0 0 0 0 0 Basic Timer control register BTCON D3H RW 0 0 0 0 0 0 0 0 Clock control register CLKCON D4H RW 0 – – 0 0 – – – System flags register FLAGS D5H RW x x x x x x 0 0 Register Pointer 0 RP0 D6H RW 1 1 0 0 0 – – – Register Pointer 1 RP1 D7H RW 1 1 0 0 1 – – – Stack Pointer register SPL D9H RW x x x x x x x x Instruction Pointer (High Byte) IPH DAH RW x x x x x x x x Instruction Pointer (Low Byte) IPL DBH RW x x x x x x x x Interrupt Request register IRQ DCH R 0 0 0 0 0 0 0 0 Interrupt Mask Register IMR DDH RW 0 0 0 0 0 0 0 0 System Mode Register SYM DEH RW 0 – – x x x 0 0 Register Page Pointer PP DFH RW 0 0 0 0 0 0 0 0 Timer A counter register Location D8H is not mapped NOTE: –: Not mapped or not used, x: Undefined PS031305-1017 8-7 S3F8S28/S3F8S24 Product Specification Table 8-2 Register Name Chapter 8. RESET and Power-Down Register Values After a Reset, Set1, Bank0 Mnemonic Address & Location Bit Values After RESET Address RW 7 6 5 4 3 2 1 0 Port 0 data register P0 E0H RW 0 0 0 0 0 0 0 0 Port 1 data register P1 E1H RW – – – – – 0 0 0 Port 2 data register P2 E2H RW – 0 0 0 0 0 0 0 Port 3 data register P3 E3H RW – – – – 0 0 0 0 Port 2 pull-up resistor enable register P2PUR E4H RW – 0 0 0 0 0 0 0 Port 0 pull-up resistor enable register P0PUR E5H RW 0 0 0 0 0 0 0 0 Port 0 control register (High Byte) P0CONH E6H RW 0 0 0 0 0 0 0 0 Port 0 control register (Low Byte) P0CONL E7H RW 0 0 0 0 0 0 0 0 Port 0 interrupt pending register P0PND E8H RW – – – – 0 0 0 0 Port 1 control register P1CON E9H RW 0 0 – – 0 0 0 0 Port 2 control register (High Byte) P2CONH EAH RW – 0 0 0 0 0 0 0 Port 2 control register (Low Byte) P2CONL EBH RW 0 0 0 0 0 0 0 0 TBCNT ECH R 0 0 0 0 0 0 0 0 Timer B data register TBDATA EDH RW 1 1 1 1 1 1 1 1 Timer B control register TBCON EEH RW – – 0 0 0 0 0 0 Port 3 interrupt pending register P3PND EFH RW 0 0 0 0 0 0 0 0 Port 3 control register P3CON F0H RW 0 0 0 0 0 0 0 0 PWM0EX F1H RW 0 0 0 0 0 0 0 0 PWM0 data register PWM0DATA F2H RW 0 0 0 0 0 0 0 0 PWM0 control register PWM0CON F3H RW 0 0 – 0 0 0 0 0 PWMEX F1H RW 0 0 0 0 0 0 0 0 PWM data register PWMDATA F2H RW 0 0 0 0 0 0 0 0 PWM control register PWMCON F3H RW 0 0 – 0 0 0 0 0 STOP control register STOPCON F4H RW 0 0 0 0 0 0 0 0 Ring Oscillator control register ROSCCON F5H RW 0 0 0 0 0 0 0 0 WDTCON F6H RW 0 0 0 0 0 0 0 0 ADCON F7H RW 1 1 1 1 0 0 0 0 A/D converter data register (High) ADDATAH F8H R x x x x x x x x A/D converter data register (Low) ADDATAL F9H R 0 0 0 0 0 0 x x BTCNT FDH R 0 0 0 0 0 0 0 0 External memory timing register EMT FEH RW 0 0 0 0 0 0 0 0 Interrupt priority register IPR FFH RW x x x x x x x x Timer B counter register PWM0 extension data register PWM extension data register Watchdog Timer control register A/D control register Locations FAH to FCH are not mapped Basic Timer counter NOTE: –: Not mapped or not used, x: Undefined PS031305-1017 8-8 S3F8S28/S3F8S24 Product Specification Table 8-3 Chapter 8. RESET and Power-Down System and Peripheral Control Registers, Set1, Bank1 Register Name Mnemonic Address & Location RESET Value (Bit) Address RW 7 6 5 4 3 2 1 0 Timer 1 Data Register (High Byte) T1DATAH E0H RW 1 1 1 1 1 1 1 1 Timer 1 Data Register (Low Byte) T1DATAL E1H RW 1 1 1 1 1 1 1 1 Timer 1 Counter Register (High Byte) T1CNTH E2H R 0 0 0 0 0 0 0 0 Timer 1 Counter Register (Low Byte) T1CNTL E3H R 0 0 0 0 0 0 0 0 Timer 1 Control Register T1CON E4H RW 0 0 0 0 0 0 0 0 T1PS E5H RW – – – – 0 0 0 0 PWM1EX E6H RW 0 0 0 0 0 0 0 0 PWM1 data register PWM1DATA E7H RW 0 0 0 0 0 0 0 0 PWM1 control register PWM1CON E8H RW 0 0 – 0 0 0 0 0 RESETID EAH RW Refer to the detail description Flash memory control register FMCON ECH RW 0 0 0 0 0 – – 0 Flash memory user programming enable register FMUSR EDH RW 0 0 0 0 0 0 0 0 Flash memory sector address register (High Byte) FMSECH EEH RW 0 0 0 0 0 0 0 0 Flash memory sector address register (Low Byte) FMSECL EFH RW 0 0 0 0 0 0 0 0 IIC Control Register ICCR F0H RW 0 0 0 0 1 1 1 1 IIC Status Register ICSR F1H RW 0 0 0 0 0 0 0 0 IIC Data Shift Register IDSR F2H RW x x x x x x x x IAR F3H RW x x x x x x x x LVDCON F4H RW 0 – 0 – – – 0 0 UART control register UARTCON F5H RW 0 0 0 0 0 0 0 0 UART pending register UARTPND F6H RW – – – – – – 0 0 BRDATA F7H RW 1 1 1 1 1 1 1 1 UDATA F8H RW x x x x x x x x Timer 1 Prescaler Register PWM1 extension data register Locations E9H are not mapped Reset source indicating register IIC Address Register Low Voltage Detector Control Register UART Baud rate data register UART data register Location F9H to FFH is not mapped NOTE: –: Not mapped or not used, x: Undefined PS031305-1017 8-9 S3F8S28/S3F8S24 Product Specification Example 8-1 Chapter 8. RESET and Power-Down Sample S3F8S28/S3F8S24 Initialization Routine ;--------------> ORG 0000H VECTOR 0F2H, PWM0OVF_INT ; VECTOR 0F4H, INT_TIMERB ; VECTOR 0F6H, INT_TIMERA ; VECTOR 0FCH, INT_EXT1 ; VECTOR 0FEH, INT_EXT0 ; ;--------------> ORG 003CH DB 0FFH ; 003CH, must be initialized to 0 DB 0FFH ; 003DH, must be initialized to 0 DB 0FFH ; 003EH, enable LVR DB 0FEH ; 003FH, External RC oscillator ;--------------> ORG RESET: 0100H DI ; Disable interrupt LD BTCON,#10100011B ; Watch-dog disable LD CLKCON,#00011000B ; Select non-divided CPU clock LD SP,#0C0H ; Stack pointer must be set LD P0CONH,#10101010B ; LD P0CONL,#10101010B ; P0.0–P0.7 push-pull output LD P0PND,#00001010B ; P0.0, P0.1 interrupt enable LD P1CON,#00001000B ; P1.1 push-pull output LD P2CONH,#01001010B ; LD P2CONL,#10101010B ; P2.0–P2.6 push-pull output LD IMR,#00000111B ; Enable IRQ0, IRQ1, IRQ2 interrupt LD IPR,#00010011B ; IRQ2>IRQ1>IRQ0 ;--------------> LD TADATA,#50H LD TBDATA,#50H ; CPU = 4MHz, interrupt interval = 6.4msec LD TACON,#00000110B ; fOSC/256, Timer A interrupt enable LD TBCON,#00000110B ; fOSC/256, Timer B interrupt enable ;--------------> • • EI ; Enable interrupt ;--------------> MAIN: NOP LD ; Start main loop BTCON,#02H ; Enable watchdog function ; Basic counter (BTCNT) clear • • CALL KEY_SCAN ; • PS031305-1017 8-10 S3F8S28/S3F8S24 Product Specification Chapter 8. RESET and Power-Down • • CALL LED_DISPLAY ; JOB ; T,MAIN ; • • • CALL • • • JR ;--------------> KEY_SCAN: NOP ; • • • RET LED_DISPLAY: NOP ; • • • RET JOB: NOP ; • • • RET ;--------------< Timer A interrupt service routine > INT_TIMERA: • • AND ; TACON,#11111110B IRET ; Pending bit clear ; Interrupt return ;--------------< Timer B interrupt service routine > INT_TIMERB: • • AND ; TBCON,#11111110B ; Pending bit clear IRET ;--------------< PWM overflow interrupt service routine > PWM0OVF_INT: • • AND IRET PWM0CON,#11111110B ; Pending bit clear ; Interrupt return ;--------------< External interrupt0 service routine > INT_EXT0: • • PS031305-1017 8-11 S3F8S28/S3F8S24 Product Specification AND P0PND,#11111110B IRET Chapter 8. RESET and Power-Down ; EXT0 Pending bit clear ; Interrupt return ;--------------< External interrupt1 service routine > INT_EXT1: • • AND IRET P0PND,#11111011B ; EXT1 Pending bit clear ; Interrupt return • • END PS031305-1017 ; 8-12 S3F8S28/S3F8S24 Product Specification 9 Chapter 9. I/O Ports I/O Ports 9.1 Overview The S3F8S28/S3F8S24 has three I/O ports: with 22 pins total. You access these ports directly by writing or reading port data register addresses. All ports can be configured as LED drive (High current output: typical 10mA). Table 9-1 S3F8S28/S3F8S24 Port Configuration Overview Port Function Description Programmability 0 Bit-programmable I/O port for schmitt trigger input or push-pull output. Pull-up resistors are assignable by software. Port 0 pins can also be used as alternative function. (ADC input, external interrupt input). Bit 1 Bit-programmable I/O port for schmitt trigger input or push-pull, open-drain output. Pull-up or pull-down resistors are assignable by software. Port 1 pins can also oscillator input/output or reset input by Smart Option. Bit 2 Bit-programmable I/O port for schmitt trigger input or push-pull, open-drain output. Pull-up resistors are assignable by software. Port 2 can also be used as alternative function (ADC input, CLO, T0,T1 output,T1 capture input) Bit 3 Bit-programmable I/O port for schmitt trigger input or push-pull output. Pull-up resistors are assignable by software. Port 3 pins can also be used as alternative function. (ADC input, external interrupt input). Bit PS031305-1017 9-1 S3F8S28/S3F8S24 Product Specification Chapter 9. I/O Ports 9.2 Port Data Registers Table 9-2 gives you an overview of the port data register names, locations, and addressing characteristics. Data registers for ports 0 to 2 have the structure shown in Figure 9-1. Table 9-2 Port Data Register Summary Register Name Mnemonic Hex RW Port 0 data register P0 E0H RW Port 1 data register P1 E1H RW Port 2 data register P2 E2H RW Port 3 data register P3 E3H RW NOTE: A reset operation clears the P0 to P2 data register to "00H". I/O Port n Data Register (n = 0-2) MSB .7 Pn.7 .6 Pn.6 .5 Pn.5 Figure 9-1 PS031305-1017 .4 Pn.4 .3 Pn.3 .2 Pn.2 .1 Pn.1 .0 LSB Pn.0 Port Data Register Format 9-2 S3F8S28/S3F8S24 Product Specification Chapter 9. I/O Ports 9.2.1 Port 0 Port 0 is a bit-programmable, general-purpose, I/O ports. You can select normal input or push-pull output mode. In addition, you can configure a pull-up resistor to individual pins using pull-up control register settings. It is designed for high-current functions such as LED direct drive. Part 0 pins can also be used as alternative functions (ADC input, external interrupt input and PWM output). Three control registers are used to control Port 0: P0CONH (E6H), P0CONL (E7H), P0PND (E8H) and P0PUR (E5H). You access port 0 directly by writing or reading the corresponding port data register, P0 (E0H). VDD Pull-up Enable Pull-up register (50 k? typical) VDD P0CONH PWM P0 Data Output Disable (input mode) Input Data M U X In/Out MUX D1 D0 Circuit type A External Interrupt Input Noise Filter Analog Input NOTE: I/O pins have protection diodes through VDD and VSS. Figure 9-2 PS031305-1017 Mode Input Data Output D0 Input D1 Port 0 Circuit Diagram 9-3 S3F8S28/S3F8S24 Product Specification Chapter 9. I/O Ports Port 0 Control Register (High Byte) E6H, Bank 0, R/W; Reset Value: 00H MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB [.7-.6] Port, P0.7/ADC7 Configuration Bits 0 x = Schmitt trigger input 1 0 = Push-pull output 1 1 = A/D converter input (ADC7); schmitt trigger input off [.5-.4] Port 0, P0.6/ADC6/PWM0 Configuration Bits 0 0 = Schmitt trigger input 0 1 = Alternative function: PWM0 output 1 0 = Push-pull output 1 1 = A/D converter input (ADC6); schmitt trigger input off [.3-.2] Port 0, P0.5/ADC5/PWM1 Configuration Bits 0 0 = Schmitt trigger input 0 1 = Alternative function: PWM1 output 1 0 = Push-pull output 1 1 = A/D converter input (ADC5); schmitt trigger input off [.1-.0] Port 0, P0.4/ADC4 Configuration Bits 0 x = Schmitt trigger input 1 0 = Push-pull output 1 1 = A/D converter input (ADC4); schmitt trigger input off Figure 9-3 PS031305-1017 Port 0 Control Register (P0CONH, High Byte) 9-4 S3F8S28/S3F8S24 Product Specification Chapter 9. I/O Ports Port 0 Control Register (Low Byte) E7H, Bank 0, R/W; Reset Value: 00H MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB [.7-.6] Port 0, P0.3/ADC3/INT3 Configuration Bits 0 0 = Schmitt trigger input/falling edge interrupt input 0 1 = Alternative function: SDA 1 0 = Push-pull output 1 1 = A/D converter input (ADC3); Schmitt trigger input off [.5-.4] Port 0, P0.2/ADC2/INT2 Configuration Bits 0 0 = Schmitt trigger input/falling edge interrupt input 0 1 = Alternative function: SCK 1 0 = Push-pull output 1 1 = A/D converter input (ADC2); Schmitt trigger input off [.3-.2] Port 0, P0.1/ADC1/INT1 Configuration Bits 0 x = Schmitt trigger input/falling edge interrupt input 1 0 = Push-pull output 1 1 = A/D converter input (ADC1); Schmitt trigger input off [.1-.0] Port 0, P0.0/ADC0/INT0 Configuration Bits 0 x = Schmitt trigger input/falling edge interrupt input 1 0 = Push-pull output 1 1 = A/D converter input (ADC0); Schmitt trigger input off Figure 9-4 PS031305-1017 Port 0 Control Register (P0CONL, Low Byte) 9-5 S3F8S28/S3F8S24 Product Specification Chapter 9. I/O Ports Port 0 Interrupt Pending Register E8H, Bank 0, R/W; Reset Value: 00H MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB [.7] Port 0.3/ADC3/INT3, Interrupt Enable Bit 0 = INT3 falling edge interrupt disable 1 = INT3 falling edge interrupt enable [.6] Port 0.3/ADC3/INT3, Interrupt Pending Bit 0 = No interrupt pending (when read) 0 = Pending bit clear (when write) 1 = Interrupt is pending (when read) 1 = No effect (when write) [.5] Port 0.2/ADC2/INT2, Interrupt Enable Bit 0 = INT2 falling edge interrupt disable 1 = INT2 falling edge interrupt enable [.4] Port 0.2/ADC2/INT2, Interrupt Pending Bit 0 = No interrupt pending (when read) 0 = Pending bit clear (when write) 1 = Interrupt is pending (when read) 1 = No effect (when write) [.3] Port 0.1/ADC1/INT1, Interrupt Enable Bit 0 = INT1 falling edge interrupt disable 1 = INT1 falling edge interrupt enable [.2] Port 0.1/ADC1/INT1, Interrupt Pending Bit 0 = No interrupt pending (when read) 0 = Pending bit clear (when write) 1 = Interrupt is pending (when read) 1 = No effect (when write) [.1] Port 0.0/ADC0/INT0, Interrupt Enable Bit 0 = INT0 falling edge interrupt disable 1 = INT0 falling edge interrupt enable [.0] Port 0.0/ADC0/INT0, Interrupt Pending Bit 0 = No interrupt pending (when read) 0 = Pending bit clear (when write) 1 = Interrupt is pending (when read) 1 = No effect (when write) Figure 9-5 PS031305-1017 Port 0 Interrupt Pending Registers (P0PND) 9-6 S3F8S28/S3F8S24 Product Specification Chapter 9. I/O Ports Port 0 Pull-up Resistor Enable Register E5H, Bank 0, R/W; Reset Value: 00H MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB [.7] P0.7 Pull-up Resistor Enable bit 0 = Enable Pull-up Resistor 1 = Disable Pull-up Resistor [.6] P0.6 Pull-up Resistor Enable bit 0 = Enable Pull-up Resistor 1 = Disable Pull-up Resistor [.5] P0.5 Pull-up Resistor Enable bit 0 = Enable Pull-up Resistor 1 = Disable Pull-up Resistor [.4] P0.4 Pull-up Resistor Enable bit 0 = Enable Pull-up Resistor 1 = Disable Pull-up Resistor [.3] P0.3 Pull-up Resistor Enable bit 0 = Disable Pull-up Resistor 1 = Enable Pull-up Resistor [.2] P0.2 Pull-up Resistor Enable bit 0 = Disable Pull-up Resistor 1 = Enable Pull-up Resistor [.1] P0.1 Pull-up Resistor Enable bit 0 = Disable Pull-up Resistor 1 = Enable Pull-up Resistor [.0] P0.0 Pull-up Resistor Enable bit 0 = Disable Pull-up Resistor 1 = Enable Pull-up Resistor Figure 9-6 PS031305-1017 Port 0 Pull-Up Resistor Enable Registers (P0PUR) 9-7 S3F8S28/S3F8S24 Product Specification Chapter 9. I/O Ports 9.2.2 Port 1 Port 1, is a 3-bit I/O port with individually configurable pins. It can be used for general I/O port (Schmitt trigger input mode, push-pull output mode or n-channel open-drain output mode). In addition, you can configure a pull-up and pull-down resistor to individual pin using control register settings. It is designed for high-current functions such as LED direct drive. P1.0, P1.1 are used for oscillator input/output by Smart Option. Also, P1.2 is used for RESET pin by Smart Option. NOTE: When P1.2 is configured as a general I/O port, it can be used only Schmitt trigger input without pull-up or open-drain output. One control register is used to control port 1: P1CON (E9H).You address port 1 bits directly by writing or reading the port 1 data register, P1 (E1H). When you use external oscillator, P1.0 and P1.1 must be set to output port to prevent current consumption. VDD Pull-Up Register (50 k typical) Pull-up Enable Open-Drain VDD Smart option P1 Data MUX In/Out Output DIsable (input mode) Input Data MUX D1 D0 Circuit type A XIN, XOUT or RESET Pull-Down Enable Pull-Down Register (50 k typical) NOTE: I/O pins have protection diodes through VDD and VSS. Figure 9-7 PS031305-1017 Mode Input Data Output D0 Input D1 Port 1 Circuit Diagram 9-8 S3F8S28/S3F8S24 Product Specification Chapter 9. I/O Ports Port 1 Control Register E9H, Bank 0, R/W; Reset Value: 00H MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB [.7] Port 1.1 N-Channel Open-Drain Enable Bit 0 = Configure P1.1 as a push-pull output 1 = Configure P1.1 as a n-channel open-drain output [.6] Port 1.0 N-Channel Open-Drain Enable Bit 0 = Configure P1.0 as a push-pull output 1 = Configure P1.0 as a N-channel open-drain output [.5] Not used for S3F8S28/F8S24 [.4] Port 1.2 Configuration Bit 0 = Schmitt trigger input; 1 = Open-drain output [.3-.2] Port 1, P1.1 Configuration Bits 0 0 = Schmitt trigger input; 0 1 = Schmitt trigger input; pull-up enable 1 0 = Push-pull output 1 1 = Schmitt trigger input; pull-down enable [.1-.0] Port 1, P1.0 Configuration Bits 0 0 = Schmitt trigger input; 0 1 = Schmitt trigger input; pull-up enable 1 0 = Push-pull output 1 1 = Schmitt trigger input; pull-down enable NOTE: When you use external oscillator, P1.0, P1.1 must be set to output port to prevent current consumption. Figure 9-8 PS031305-1017 Port 1 Control Register (P1CON) 9-9 S3F8S28/S3F8S24 Product Specification Chapter 9. I/O Ports 9.2.3 Port 2 Port 2 is a 7-bit I/O port with individually configurable pins. It can be used for general I/O port (schmitt trigger input mode, push-pull output mode or N-channel open-drain output mode). You can also use some pins of port 2 as ADC input, CLO output, T0 match output, T1 capture input, UART ports (RxD, TxD). In addition, you can configure a pull-up resistor to individual pins using control register settings. It is designed for high-current functions such as LED direct drive. You address port 2 bits directly by writing or reading the port 2 data register, P2 (E2H, Bank 0). The port 2 control registers, P2CONH, P2CONL and P2PUR are located at addresses EAH, EBH and E4H of Bank 0 respectively. VDD Pull-up Enable Pull-up register (50 k typical) Open-Drain VDD P2CONH/L CLO, T0 P2 Data M U X In/Out Output Disable (input mode) Input Data MUX D1 D0 Circuit Type A to ADC NOTE: I/O pins have protection diodes through VDD and VSS. Figure 9-9 Mode Input Data Output D0 Input D1 Port 2 Circuit Diagram NOTE: 1. P2.2/T1CAP has a T1CAP input module, and without ADC module. 2. When use P2.2/T1CAP as T1CAP, you must set P2.2/T1CAP in input mode. 3. P2.5 and P2.4 have not Open-drain function. PS031305-1017 9-10 S3F8S28/S3F8S24 Product Specification Chapter 9. I/O Ports Port 2 Control Register (High Byte) EAH, Bank 0, R/W; Reset Value: 00H MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB [.7] Not used in S3F8S28/F8S24 [.6-.4] Port 2, P2.6/ADC8/CLO Configuration Bits 0 0 x = Schmitt trigger input 0 1 x = ADC input 1 0 0 = Push-pull output 1 0 1 = Open-drain output; pull-up enable 1 1 0 = Open-drain output 1 1 1 = Alternative function; CLO output [.3-.2] Port 2, P2.5/ADC9 Configuration Bits 0 0 = Schmitt trigger input 0 1 = Alternative function: ADC Input 1 0 = Push-pull output 1 1 = Invalid [.1-.0] Port 2, P2.4/ADC10 Configuration Bits 0 0 = Schmitt trigger input 0 1 = Alternative function: ADC Input 1 0 = Push-pull output 1 1 = Invalid NOTE: When noise problem is important issue, you had better not use CLO output Figure 9-10 PS031305-1017 Port 2 Control Register (P2CONH, High Byte) 9-11 S3F8S28/S3F8S24 Product Specification Chapter 9. I/O Ports Port 2 Control Register (Low Byte) EBH, Bank 0, R/W; Reset Value: 00H MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB [.7-.6] Port 2, P2.3/TxD Configuration Bits 0 0 = Schmitt trigger input 0 1 = Alternative function: TxD output 1 0 = Push-pull output 1 1 = Open-drain output [.5-.4] Port 2, P2.2/T1CAP/RxD Configuration Bits 0 0 = Schmitt trigger input; T1 Capture input; RxD input; 0 1 = Alternative function: RxD output 1 0 = Push-pull output 1 1 = Open-drain output [.3-.2] Port 2, P2.1/T1OUT Configuration Bits 0 0 = Schmitt trigger input 0 1 = Alternative function: T1 match output 1 0 = Push-pull output 1 1 = Open-drain output [.1-.0] Port 2, P2.0/T0OUT Configuration Bits 0 0 = Schmitt trigger input 0 1 = Alternative function: T0 match output 1 0 = Push-pull output 1 1 = Open-drain output Figure 9-11 PS031305-1017 Port 2 Control Register (P2CONL, Low Byte) 9-12 S3F8S28/S3F8S24 Product Specification Chapter 9. I/O Ports Port 2 Pull-up Resistor Enable Register E4H, Bank 0, R/W; Reset Value: 00H MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB [.7] Not used in S3F8S28/F8S24 [.6] Port 2.6 Pull-up Resistor Enable Bit 0 = Enable Pull-up Resistor 1 = Disable Pull-up Resistor [.5] Port 2.5 Pull-up Resistor Enable Bit 0 = Enable Pull-up Resistor 1 = Disable Pull-up Resistor [.4] Port 2.4 Pull-up Resistor Enable Bit 0 = Enable Pull-up Resistor 1 = Disable Pull-up Resistor [.3] Port 2.3 Pull-up Resistor Enable Bit 0 = Enable Pull-up Resistor 1 = Disable Pull-up Resistor [.2] Port 2.2 Pull-up Resistor Enable Bit 0 = Enable Pull-up Resistor 1 = Disable Pull-up Resistor [.1] Port 2.1 Pull-up Resistor Enable Bit 0 = Enable Pull-up Resistor 1 = Disable Pull-up Resistor [.0] Port 2.0 Pull-up Resistor Enable Bit 0 = Enable Pull-up Resistor 1 = Disable Pull-up Resistor Figure 9-12 PS031305-1017 Port 2 Open-Drain Output Mode Register (P2PUR) 9-13 S3F8S28/S3F8S24 Product Specification Chapter 9. I/O Ports 9.2.4 Port 3 Port 3 is a 4-bit I/O port with individually configurable pins. It can be used for general I/O port (schmitt trigger input mode, push-pull output mode or N-channel open-drain output mode). You can also use some pins of port 3 as ADC input, external interrupt input. In addition, you can configure a pull-up resistor to individual pins using control register settings. It is designed for high-current functions such as LED direct drive. You address port 3 bits directly by writing or reading the port 3 data register, P3 (E3H, Bank 0). The port 3 control registers, P3CON and P3PND are located at addresses F0H and EFH of Bank 0 respectively. You access port 3 directly by writing or reading the corresponding port data register, P0 (E0H). VDD Pull-up Enable Pull-up register (50 k? typical) VDD P0CONH PWM P0 Data Output Disable (input mode) Input Data M U X In/Out MUX D1 D0 Circuit type A External Interrupt Input Noise Filter Analog Input NOTE: I/O pins have protection diodes through VDD and VSS. Figure 9-13 PS031305-1017 Mode Input Data Output D0 Input D1 Port 3 Circuit Diagram 9-14 S3F8S28/S3F8S24 Product Specification Chapter 9. I/O Ports Port 3 Control Register F0H, Bank 0, R/W; Reset Value: 00H MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB [.7-.6] Port 3, P3.3/INT7 Configuration Bits 0 0 = Schmitt trigger input / external falling edge interrupt input 0 1 = Schmitt trigger input with pull-up / external falling edge interrupt input 1 x = Push-pull output [.5-.4] Port 3, P3.2/INT6 Configuration Bits 0 0 = Schmitt trigger input / external falling edge interrupt input 0 1 = Schmitt trigger input with pull-up / external falling edge interrupt input 1 x = Push-pull output [.3-.2] Port 3, P3.1/ADC12/INT5 Configuration Bits 0 0 = Schmitt trigger input / external falling edge interrupt input 0 1 = Schmitt trigger input with pull-up / external falling edge interrupt input 1 0 = Push-pull output 1 1 = Alternative function: ADC Input [.1-.0] Port 3, P3.0/ADC11/INT4 Configuration Bits 0 0 = Schmitt trigger input / external falling edge interrupt input 0 1 = Schmitt trigger input with pull-up / external falling edge interrupt input 1 0 = Push-pull output 1 1 = Alternative function: ADC Input Figure 9-14 PS031305-1017 Port 3 Control Register (P3CON) 9-15 S3F8S28/S3F8S24 Product Specification Chapter 9. I/O Ports Port 3 Interrupt Pending Register EFH, Bank 0, R/W; Reset Value: 00H MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB [.7] Port 3.3/ADC12/INT7, Interrupt Enable Bit 0 = INT7 falling edge interrupt disable 1 = INT7 falling edge interrupt enable [.6] Port 3.3/ADC12/INT7 Interrupt Pending Bit 0 = No interrupt pending (when read) 0 = Pending bit clear (when write) 1 = Interrupt is pending (when read) 1 = No effect (when write) [.5] Port 3.2/ADC11/INT6, Interrupt Enable Bit 0 = INT6 falling edge interrupt disable 1 = INT6 falling edge interrupt enable [.4] Port 3.2/ADC11/INT6, Interrupt Pending Bit 0 = No interrupt pending (when read) 0 = Pending bit clear (when write) 1 = Interrupt is pending (when read) 1 = No effect (when write) [.3] Port 3.1/ADC10/INT5, Interrupt Enable Bit 0 = INT5 falling edge interrupt disable 1 = INT5 falling edge interrupt enable [.2] Port 3.1/ADC10/INT5, Interrupt Pending Bit 0 = No interrupt pending (when read) 0 = Pending bit clear (when write) 1 = Interrupt is pending (when read) 1 = No effect (when write) [.1] Port 3.0/ADC9/INT4, Interrupt Enable Bit 0 = INT4 falling edge interrupt disable 1 = INT4 falling edge interrupt enable [.0] Port 3.0/ADC9/INT4, Interrupt Pending Bit 0 = No interrupt pending (when read) 0 = Pending bit clear (when write) 1 = Interrupt is pending (when read) 1 = No effect (when write) Figure 9-15 PS031305-1017 Port 3 Interrupt Pending Register (P3PND) 9-16 S3F8S28/S3F8S24 Product Specification 10 Chapter 10. Basic Timer and Timer 0 Basic Timer and Timer 0 10.1 Module Overview The S3F8S28/S3F8S24 has two default timers: an 8-bit basic timer, and a 16-bit general-purpose timer, called Timer 0. 10.1.1 Basic Timer (BT) You can use the basic timer (BT) in two different ways: • As a watchdog timer to provide an automatic Reset mechanism in the event of a system malfunction. • To signal the end of the required oscillation stabilization interval after a Reset or a Stop mode release. The functional components of the basic timer block are: • Clock frequency divider (fOSC divided by 4096, 1024, or 128) with multiplexer • 8-bit basic timer counter, BTCNT (FDH, read-only) • Basic Timer control register, BTCON (D3H, read/write) 10.1.2 Timer 0 The 16-bit Timer 0 is used in one 16-bit timer or two 8-bit timers mode. When TACON.7 is set to "1", it is in one 16-bit timer mode. When TACON.7 is set to "0", the Timer 0 is used as two 8-bit timers. • One 16-bit timer mode (Timer 0) • Two 8-bit timers mode (Timer A and B) PS031305-1017 PRELIMINARY 10-1 S3F8S28/S3F8S24 Product Specification Chapter 10. Basic Timer and Timer 0 10.2 Basic Timer (BT) 10.2.1 Basic Timer Control Register (BTCON) The basic timer control register, BTCON, is used to select the input clock frequency, to clear the basic timer counter and frequency dividers, and to enable or disable the watchdog timer function. A Reset clears BTCON to "00H". This enables the watchdog function and selects a basic timer clock frequency of FOSC/4096. To disable the watchdog function, you must write the signature code "1010B" to the basic timer register control bits BTCON.7 to BTCON.4. The 8-bit basic timer counter, BTCNT, can be cleared during normal operation by writing a "1" to BTCON.1. To clear the frequency dividers for both the basic timer input clock and the Timer 0 clock, you write a "1" to BTCON.0. Basic Timer Control Register (BTCON) D3H, R/W MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB Divider clear bit for basic timer and timer 0: 0 = No effect 1 = Clear both dividers Watchdog timer enable bits: 1010B = Disable watchdog function Other value = Enable watchdog function Basic timer counter clear bits: 0 = No effect 1 = Clear basic timer counter Basic timer input clock selection bits: 00 = fosc/4096 01 = fosc/1024 10 = fosc/128 11 = Invalid selection NOTE: When you write a 1 to BTCON.0 (or BTCON.1), the basic timer divider (or basic timer counter) is cleared. The bit is then cleared automatically to 0. Figure 10-1 PS031305-1017 Basic Timer Control Register (BTCON) PRELIMINARY 10-2 S3F8S28/S3F8S24 Product Specification Chapter 10. Basic Timer and Timer 0 10.2.2 Basic Timer Function Description 10.2.2.1 Watchdog Timer Function You can program the basic timer overflow signal (BTOVF) to generate a Reset by setting BTCON.7–BTCON.4 to any value other than "1010B" (The "1010B" value disables the watchdog function). A Reset clears BTCON to "00H", automatically enabling the watchdog timer function. A Reset also selects the oscillator clock divided by 4096 as the BT clock. A Reset whenever a basic timer counter overflow occurs. During normal operation, the application program must prevent the overflow, and the accompanying reset operation, from occurring. To do this, the BTCNT value must be cleared (by writing a "1" to BTCON.1) at regular intervals. If a system malfunction occurs due to circuit noise or some other error condition, the BT counter clear operation will not be executed and a basic timer overflow will occur, initiating a Reset. In other words, during normal operation, the basic timer overflow loop (a bit 7 overflow of the 8-bit basic timer counter, BTCNT) is always broken by a BTCNT clear instruction. If a malfunction does occur, a Reset is triggered automatically. 10.2.2.2 Oscillation Stabilization Interval Timer Function You can also use the basic timer to program a specific oscillation stabilization interval following a Reset or when Stop mode has been released by an external interrupt. In Stop mode, whenever a Reset or an external interrupt occurs, the oscillator starts. The BTCNT value then starts increasing at the rate of fOSC/4096 (for Reset), or at the rate of the preset clock source (for an external interrupt). When BTCNT.7 is set, a signal is generated to indicate that the stabilization interval has elapsed and to gate the clock signal off to the CPU so that it can resume normal operation. In summary, the following events occur when Stop mode is released: 1. During Stop mode, an external power-on Reset or an external interrupt occurs to trigger the Stop mode release and oscillation starts. 2. If an external power-on Reset occurred, the basic timer counter will increase at the rate of fOSC/4096. If an external interrupt is used to release Stop mode, the BTCNT value increases at the rate of the preset clock source. 3. Clock oscillation stabilization interval begins and continues until bit 7 of the basic timer counter is set. 4. When a BTCNT.7 is set, normal CPU operation resumes. Figure 10-2 and Figure 10-3 shows the oscillation stabilization time on RESET and Stop Mode release PS031305-1017 PRELIMINARY 10-3 S3F8S28/S3F8S24 Product Specification Chapter 10. Basic Timer and Timer 0 Oscillation Stabilization Time Normal Operating mode 0.8 V DD VDD Reset Release Voltage RESET trst ~ ~ RC Internal Reset Release 0.8 V DD Oscillator (X OUT ) Oscillator Stabilization Time BTCNT clock BTCNT value 10000000B 00000000B t WAIT = (4096x128)/f OSC Basic timer increment and CPU operations are IDLE mode NOTE: Duration of the oscillator stabilization wait time, t WAIT , when it is released by a Power-on-reset is 4096 x 128/fOSC. tRST ~ ~ RC (R and C are value of external power on Reset) Figure 10-2 PS031305-1017 Oscillation Stabilization Time on RESET PRELIMINARY 10-4 S3F8S28/S3F8S24 Product Specification STOP Mode Normal Operating Mode Chapter 10. Basic Timer and Timer 0 Normal Operating Mode Oscillation Stabilization Time VDD STOP Instruction Execution STOP Mode Release Signal External Interrupt RESET STOP Release Signal Oscillator (X OUT ) BTCNT clock 10000000B BTCNT Value 00000000B tWAIT Basic Timer Increment NOTE: Duration of the oscillator stabilzation wait time, t WAIT , it is released by an interrupt is determined by the setting in basic timer control register, BTCON. BTCON.3 BTCON.2 t WAIT 0 0 (4096 x 128)/fosc 52.4 ms 0 1 (1024 x 128)/fosc 13.1 ms 1 0 (128 x 128)/fosc 1.63 ms 1 1 Invalid setting Figure 10-3 PS031305-1017 t WAIT (When f OSC is 10 MHz) Oscillation Stabilization Time on Stop Mode Release PRELIMINARY 10-5 S3F8S28/S3F8S24 Product Specification Example 10-1 Chapter 10. Basic Timer and Timer 0 Configuring the Basic Timer This example shows how to configure the basic timer to sample specification. ORG 0000H ;--------------> ORG 003CH DB 0FFH ; 003CH, must be initialized to 1 DB 0FFH ; 003DH, must be initialized to 1 DB 0FFH ; 003EH, enable LVR DB 0FEH ; 003FH, External RC oscillator ;--------------> ORG RESET: 0100H DI ; Disable interrupt LD CLKCON,#00011000B ; Select non-divided CPU clock LD SP,#0C0H ; Stack pointer must be set BTCON,#02H ; Enable watchdog function • • LD ; Basic Timer clock: fOSC/4096 ; Basic counter (BTCNT) clear • • • EI ; Enable interrupt ;--------------> MAIN: • LD BTCON,#02H ; Enable watchdog function ; Basic counter (BTCNT) clear • • • JR PS031305-1017 T,MAIN ; PRELIMINARY 10-6 S3F8S28/S3F8S24 Product Specification Chapter 10. Basic Timer and Timer 0 10.3 One 16-Bit Timer Mode (Timer 0) The 16-bit Timer 0 is used in one 16-bit timer or two 8-bit timers mode. When TACON.7 is set to "1", it is in one 16-bit timer mode. When TACON.7 is set to "0", the Timer 0 is used as two 8-bit timers. • One 16-bit timer mode (Timer 0) • Two 8-bit timers mode (Timer A and B) 10.3.1 Overview The 16-bit Timer 0 is a 16-bit general-purpose timer. Timer 0 includes interval timer mode using appropriate TACON setting. Timer 0 has the following functional components: • Clock frequency divider (fxx divided by 256, 64, 8, or 1) with multiplexer • 16-bit counter (TACNT, TBCNT), 16-bit comparator, and 16-bit reference data register (TADATA, TBDATA) • Timer 0 match interrupt (IRQ1, vector F6H) generation • Timer 0 control register, TACON (D2H, read/write) 10.3.2 Function Description 10.3.2.1 Interval Timer Function The Timer 0 module can generate an interrupt, the Timer 0 match interrupt (T0INT). T0INT belongs to the interrupt level IRQ1, and is assigned a separate vector address, F6H. The T0INT pending condition should be cleared by software after IRQ1 is serviced. The T0INT pending bit must be cleared by the application sub-routine by writing a "0" to the TACON.0 pending bit. In interval timer mode, a match signal is generated when the counter value is identical to the values written to the T0 reference data registers, TADATA and TBDATA. The match signal generates a Timer 0 match interrupt (T1INT, vector F6H) and clears the counter. If, for example, you write the value 10H and 32H to TADATA and TBDATA, respectively, and 8EH to TACON, the counter will increment until it reaches 3210H. At this point, the T0 interrupt request is generated, the counter value is reset, and counting resumes. PS031305-1017 PRELIMINARY 10-7 S3F8S28/S3F8S24 Product Specification Chapter 10. Basic Timer and Timer 0 10.3.2.2 Timer 0 Control Register (TACON) You use the Timer 0 control register, TACON, to: • Enable the Timer 0 operating (interval timer) • Select the Timer 0 input clock frequency • Clear the Timer 0 counter, TACNT and TBCNT • Enable the Timer 0 interrupt • Clear Timer 0 interrupt pending condition TACON is located at address D0H, and is read/write addressable using register addressing mode. A reset clears TACON to "00H". This sets Timer 0 to disable interval timer mode, selects an input clock frequency of fxx/256, and disables Timer 0 interrupt. You can clear the Timer 0 counter at any time during the normal operation by writing a "1" to TACON.3. To enable the Timer 0 interrupt (IRQ1, vector F6H), you must write TACON.7, TACON.2, and TACON.1 to "1". To generate the exact time interval, you should set TACON.3 and TACON.0 to "10B", which clear counter and interrupt pending bit. When the T0INT sub-routine is serviced, the pending condition must be cleared by software by writing a "0" to the Timer 0 interrupt pending bit, TACON.0. Timer 0 Control Register (TACON) D2H, R/W MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB Timer 0 interrupt pending bit: 0 = No interrupt pending Always "0" 0 = Clear pending bit (when write) 1 = Interrupt is pending (when read) Timer 0 clock selection bits: Timer 0 operation mode selection bit: 00 = fxx/256 0 = Two 8-bit timers mode (Timer A/B) 01 = fxx/64 1 = One 16-bit timer mode (Timer 0) 10 = fxx/8 11 = fxx 1 = No effect (when write) Timer 0 interrupt enable bit: 0 = Disable interrupt 1 = Enable interrupt Timer 0 counter run enable bit: 0 = Disable counter running 1 = Enable counter running Timer 0 counter clear bit: 0 = No affect 1 = Clear the timer 0 counter (when write) NOTE: TACON.6 must be always "0" during normal operation. Figure 10-4 PS031305-1017 Timer 0 Control Register (TACON) PRELIMINARY 10-8 S3F8S28/S3F8S24 Product Specification Compare Value (TBDATA,TADATA) Up Counter Value (TBCNT,TACNT) Chapter 10. Basic Timer and Timer 0 Match Match Match Match Match Match Match 00H Clear Clear Count start TACON.3 1 TBDATA,TADATA Value change Clear Counter Clear (TACON.3) Interrupt Request (TACON.0) T0 Match Output (P2.0) Figure 10-5 PS031305-1017 Timer 0 Timing Diagram PRELIMINARY 10-9 S3F8S28/S3F8S24 Product Specification Chapter 10. Basic Timer and Timer 0 10.3.3 Block Diagram Bits 5, 4 Data Bus 8 fxx/256 fxx/64 fxx/8 Bit 3 16-Bit Up-Counter Clear (Read Only) MSB LSB MUX fxx/1 Bit 2 16-Bit Comparator Match Pending Bit 0 Bit 1 Timer 0 Buffer Register (16-bit) T0INT IRQ1 P2.0/T0 P2CONL.1-.0 Counter Clear Signal Match Signal 16 Timer 0 Data Register (Read/Write) MSB LSB NOTE: When TACON.7 is "1", 16-bit timer 0. Figure 10-6 PS031305-1017 Timer 0 Functional Block Diagram PRELIMINARY 10-10 S3F8S28/S3F8S24 Product Specification Chapter 10. Basic Timer and Timer 0 10.4 Two 8-Bit Timers Mode (Timer A and B) 10.4.1 Overview The 8-bit timer A and B are the 8-bit general-purpose timers. Timer A and B support interval timer mode using the appropriate TACON and TBCON setting, respectively. Timer A and Timer B have the following functional components: • Clock frequency divider with multiplexer − fxx divided by 256, 64, 8, or 1 for timer A − fxx divided by 256, 64, 8, or 1 for timer B • 8-bit counter (TACNT, TBCNT), 8-bit comparator, and 8-bit reference data register (TADATA, TBDATA) • Timer A match interrupt (IRQ1, vector F6H) generation • Timer A control register, TACON (D2H, read/write) • Timer B match interrupt (IRQ1, vector F4H) generation • Timer B control register, TBCON (EEH, read/write) 10.4.2 Function Description 10.4.2.1 Interval Timer Function The timer A and B module can generate an interrupt: the timer A match interrupt (TAINT) and the timer B match interrupt (TBINT). TAINT belongs to the interrupt level IRQ1, and is assigned a separate vector address, F6H. TBINT belongs to the interrupt level IRQ1 and is assigned a separate vector address, F4H. The TAINT and TBINT pending condition should be cleared by software after they are serviced. In interval timer mode, a match signal is generated when the counter value is identical to the values written to the TA or TB reference data registers, TADATA or TBDATA. The match signal generates corresponding match interrupt (TAINT, vector F6H; TBINT, vector F4H) and clears the counter. If, for example, you write the value 10H to TBDATA, "0" to TACON.7, and 0EH to TBCON, the counter will increment until it reaches 10H. At this point, the TB interrupt request is generated, the counter value is reset, and counting resumes. PS031305-1017 PRELIMINARY 10-11 S3F8S28/S3F8S24 Product Specification Chapter 10. Basic Timer and Timer 0 10.4.2.2 Timer A and B Control Register (TACON, TBCON) You use the timer A and B control register, TACON and TBCON, to: • Enable the timer A and B operating (interval timer) • Select the timer A and B input clock frequency • Clear the timer A and B counter, TACNT and TBCNT • Enable the timer A and B interrupts • Clear timer A and B interrupt pending conditions TACON and TBCON are located at address D2H and EEH, and is read/write addressable using register addressing mode. A reset clears TACON and TBCON to "00H". This sets timer A and B to disable interval timer mode, selects an input clock frequency of fxx/256, and disables timer A and B interrupt. You can clear the timer A and B counter at any time during normal operation by writing a "1" to TACON.3 and TBCON.3. To enable the timer A and B interrupt (IRQ1, vector F6H, F4H), you must write TACON.7 to "0", TACON.2 (TBCON.2) and TACON.1 (TBCON.1) to "1". To generate the exact time interval, you should set TACON.3 (TBCON.3) and TACON.0 (TBCON.0) to "10B", which clear counter and interrupt pending bit, respectively. When the TAINT or TBINT sub-routine is serviced, the pending condition must be cleared by software by writing a "0" to the timer A or B interrupt pending bits, TACON.0 or TBCON.0. Timer A Control Register (TACON) D2H, R/W MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB Timer A interrupt pending bit: 0 = No interrupt pending Always "0" 0 = Clear pending bit (when write) 1 = Interrupt is pending (when read) Timer A clock selection bits: Timer A operation mode selection bit: 00 = fxx/256 0 = Two 8-bit timers mode (Timer A/B) 01 = fxx/64 1 = One 16-bit timer mode (Timer 0) 10 = fxx/8 11 = fxx 1 = No effect (when write) Timer A interrupt enable bit: 0 = Disable interrupt 1 = Enable interrupt Timer A counter run enable bit: 0 = Disable counter running 1 = Enable counter running Timer A counter clear bit: 0 = No affect 1 = Clear the timer A counter (when write) NOTE: TACON.6 must be always "0" during normal operation. Figure 10-7 PS031305-1017 Timer A Control Register (TACON) PRELIMINARY 10-12 S3F8S28/S3F8S24 Product Specification Chapter 10. Basic Timer and Timer 0 Timer B Control Register (TBCON) EEH MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB Timer B interrupt pending bit: 0 = No interrupt pending Not used for S3F8S28/F8S24 Timer B clock selection bits: 00 = fxx/256 01 = fxx/64 10 = fxx/8 11 = fxx 0 = Clear pending bit (when write) 1 = Interrupt is pending (when read) 1 = No effect (when write) Timer B interrupt enable bit: 0 = Disable interrupt 1 = Enable interrupt Timer B counter run enable bit: 0 = Disable counter running 1 = Enable counter running Timer B counter clear bit: 0 = No affect 1 = Clear the timer B counter (when write) Figure 10-8 PS031305-1017 Timer B Control Register (TBCON) PRELIMINARY 10-13 S3F8S28/S3F8S24 Product Specification Chapter 10. Basic Timer and Timer 0 TACON.5-.4 TACON.3 Clear fxx/256 TACNT fxx/64 fxx/8 MUX R P2.0/T0 Match Comparator fxx P2CONL.1-.0 TACON.2 TACON.0 Pending TA Buffer Register TACON.1 TA Counter Clear Signal, TA Match Signal TADATA TB Counter Clear Signal, TB Match Signal TBDATA IRQ1 TBCON.1 TB Buffer Register fxx/256 Pending TBCON.2 fxx/64 fxx/8 TBCON.0 Comparator Match MUX fxx TBCNT R Clear TBCON.3 TBCON.5-.4 NOTE: When TACON.7 is "0", two 8-bit timer A/B. Figure 10-9 PS031305-1017 Timer A and B Function Block Diagram PRELIMINARY 10-14 S3F8S28/S3F8S24 Product Specification 11 Chapter 11. 16-Bit Timer 1 16-Bit Timer 1 11.1 Overview The S3F8S28/S3F8S24 has a 16-bit timer/counters-Timer 1. The 16-bit Timer 1 is a 16-bit general-purpose timer/counter. Timer 1 has two operating modes, one of which you select using the appropriate T1CON setting is: • Interval timer mode • Capture input mode with a rising or falling edge trigger at the T1CAP pin Timer 1 has the following functional components: • Precalar for clock frequency programmable from fOSC to fOSC/4096 • A 16-bit counter, 16-bit comparator, and two 16-bit reference data register (T1DATAH/L) • I/O pins for capture input (T1CAP) • Timer 1 overflow interrupt and match/capture interrupt generation • Timer 1 control register, T1CON • Timer 1 Prescaler register, T1PS You can use Timer 1 in three ways: • As a normal counter, generating a Timer 1 overflow interrupt (IRQ3, vector EAH) at programmed time intervals. • To generate a Timer 1 match interrupt (IRQ3, vector ECH) when the 16-bit Timer 1 count value matches the 16-bit value written to the reference data registers. • To generate a Timer 1 capture interrupt (IRQ3, vector ECH) when a triggering condition exists at the T1CAP (P2.2) PS031305-1017 11-1 S3F8S28/S3F8S24 Product Specification Chapter 11. 16-Bit Timer 1 11.2 Function Description 11.2.1 Timer 1 Interrupts The Timer 1 module can generate two interrupts, the Timer 1 overflow interrupt (T1OVF), and the Timer 1 match/capture interrupt (T1INT). A Timer 1 overflow interrupt pending condition is cleared by software when it has been serviced. A Timer 1 match/capture interrupt, T1INT pending condition is also cleared by software when it has been serviced. 11.2.2 Timer 1 Overflow Interrupt Timer 1 can be programmed to generate an overflow interrupt (IRQ3, vector EAH) whenever an overflow occurs in the 16-bit up counter. When you set the Timer 1 overflow interrupt enable bit, T1CON.3, to "1", the overflow interrupt is generated each time the 16-bit up counter reaches "FFFFH". After the interrupt request is generated, the counter value is automatically cleared to "00H" and up counting resumes. By writing a "1" to T1CON.4, you can clear/reset the 16-bit counter value at any time during program operation. 11.2.3 Interval Mode (Match) Timer 1 can also be used to generate a match interrupt T1INT (IRQ3, vector ECH) whenever the 16-bit counter value matches the value that is written to the Timer 1 reference data registers, T1DATAH and T1DATAL. When a match condition is detected by the 16-bit comparator, the match interrupt is generated, the counter value is cleared, and up counting resumes from "00H". In match mode, program software can poll the Timer 1 match/capture interrupt pending bit, T1CON.0, to detect when a Timer 1 match interrupt pending condition exists (T1CON.0 = "1"). When the interrupt request is acknowledged by the CPU and the service routine starts, the interrupt service routine for vector ECH must clear the interrupt pending condition by writing a "0" to T1CON.0. IRQ3 (T1INT) Pending (T1CON.0) Interrupt Enable/Disable (T1CON.1) 16-Bit Up Counter CLK 16-Bit Comparator Timer 1 High/Low Buffer Register R (Clear) Match CTL P2.1 T1CON.7 T1CON.6 Match Signal T1CON.4 Timer 1 Data High/Low Buffer Register Figure 11-1 PS031305-1017 Simplified Timer 1 Function Diagram: Interval Mode 11-2 S3F8S28/S3F8S24 Product Specification Chapter 11. 16-Bit Timer 1 11.2.4 Capture Mode Timer 1 also gives you capture input source, the signal edge at the T1CAP (P2.2) pin. You select the capture input by setting the input mode in the port 2 control register, P2CONL Timer 1 can be used to generate a capture interrupt (IRQ3, vector ECH) whenever a triggering condition is detected at the T1CAP (P2.2) pin. The T1CON.7 and T1CON.6 bit-pair setting is used to select the trigger condition for capture mode operation: rising edges, falling edges or on both falling and rising edge. In capture mode for Timer 1, a signal edge that is detected at the T1CAP pin opens a gate and loads the current counter value into the T1 data register (T1DATAH/L for rising edge, or falling edge or on both falling and rising edge). Both kinds of Timer 1 interrupts (T1OVF, T1INT) can be used in capture mode, the Timer 1 overflow interrupt is generated whenever a counter overflow occurs, the Timer 1 capture interrupt is generated whenever the counter value is loaded into the T1 data register (T1DATAH/L). By reading the captured data value in T1DATAH/L, and assuming a specific value for the Timer 1 clock frequency, you can calculate the pulse width (duration) of the signal that is being input at the T1CAP pin In capture mode, program software can poll the Timer 1 match/capture interrupt pending bit, T1CON.0, to detect when a Timer 1 capture interrupt pending condition exists (T1CON.0 = "1"). When the interrupt request is acknowledged by the CPU and the service routine starts, the interrupt service routine for vector ECH must clear the interrupt pending condition by writing a "0" to T1CON.0 T1CON.3 CLK 16-Bit Up Counter IRQ3 (T1OVF) Pending (T1CON.0) P2.2/ T1CAP T1CON.7 T1CON.6 Figure 11-2 PS031305-1017 Timer 1 Data IRQ3 (T1INT) Interrupt Enable/Disable (T1CON.1) Simplified Timer 1 Function Diagram: Capture Mode 11-3 S3F8S28/S3F8S24 Product Specification Chapter 11. 16-Bit Timer 1 11.3 Timer 1 Control Register (T1CON) You use the TIMER 1 control register, T1CON, to • Select the TIMER 1 operating mode (interval timer, capture mode) • Timer1 Start/Stop • Clear the TIMER 1 counter. • Enable/Disable the Timer 1 overflow interrupt or Timer 1 match/capture interrupt • Clear Timer1 overflow interrupt or match/capture pending bit You can use Timer 1 prescaler register, T1PS to • Program clock prescaler T1CON is located at address E4H, Bank 1, Set 1, and is read/write addressable using register addressing mode. A reset clears T1CON to "00H". This sets TIMER 1 to normal interval timer mode, disable Timer 1 run; disable Timer 1 overflow and match/capture interrupt. You can start Timer 1 counter by writing a "1" to T1CON.5.You can clear the Timer 1 counter at any time during normal operation by writing a "1" to T1CON.4. To generate the exact time interval, you should write "1" to T1CON.4 and clear appropriate pending bits of the T1CON register. Timer 1 match/capture interrupt is controlled by T1CON.1; you can enable Timer 1 match/capture interrupt by writing a "1" to T1CON.1 or disable it by writing "0" to T1CON.1. Timer 1 overflow (T1OVF) is set by T1CON.3, you can enable Timer 1 overflow interrupt by writing a "1" to T1CON.3 or disable it by writing "0" to T1CON.3. To detect a match/capture or overflow interrupt pending condition when T1INT or T1OVF is disabled, the application program should poll the pending bit T1CON.0 and T1CON.2. When a "1" is detected, a Timer 1 match/capture or overflow interrupt is pending. When the sub-routine has been serviced, the pending condition must be cleared by software by writing a "0" to the interrupt pending bit. T1PS is located at address E5H, Bank 1, Set 1, and is read/write addressable using Register addressing mode. A reset clears T1PS to "00H". This selects the clock frequency of Timer 1 as FLCLK. The clock prescaler value of T1PS should be kept to not larger than 12, the values larger than 12 is not valid. PS031305-1017 11-4 S3F8S28/S3F8S24 Product Specification Chapter 11. 16-Bit Timer 1 Timer 1 Control Register (T1CON) E4H, Bank 1, R/W; Reset Value: 00H MSB .7 .6 .5 .4 Timer 1 Operating Mode Selection Bits: 00 = Interval mode 01 = Capture mode (capture on rising edge, counter running, OVF can occur) 10 = Capture mode (capture on falling edge, counter running, OVF can occur) 11 = Capture mode (capture on rising and falling edge, counter running, OVF can occur) .3 .2 .1 .0 LSB Timer 1 Interrupt Match/capture Pending Bit: 0 = No interrupt pending 0 = Clear pending bit (when write) 1 = Interrupt is pending Timer 1 Interrupt Match/capture Enable Bit: 0 = Disable interrupt 1 = Enable interrupt Timer 1 Counter Run enable bit: 0- Stop Timer 1 1- Start Timer 1 Timer 1 Counter Clear Bits: 0 = No effect 1 = Clear Timer 1 Counter (when write) Timer 1 Overflow Interrupt Pending Bit: 0 = No interrupt pending 0 = Clear pending bit (when write) 1 = Interrupt is pending Timer 1 Overflow Interrupt Enable Bit: 0 = Disable overflow interrupt 1 = Enable overflow interrupt NOTE: When the counter clear bit(.4) is set, the 16-bit counter is cleared and T1CON.4 will be cleared to ‘0’automatically . Figure 11-3 PS031305-1017 Timer 1 Control Register (T1CON) 11-5 S3F8S28/S3F8S24 Product Specification Chapter 11. 16-Bit Timer 1 Timer 1 Prescaler Register (T1PS) E5H, Bank 1, R/W, Reset Value: 00H MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB Not used in S3F8S28/F8S24 Timer 1 prescaler bit (T1PSB) T1CLK = Fosc/(2^T1PSB) Note: 1. Prescaler values(T1PSB) above 12 are not valid. Figure 11-4 Timer 1 Prescaler Register (T1PS) Timer 1 Data Register High (T1DATAH) E0H, Set1, Bank1; R/W; Reset Value: FFH MSB .7 .6 Figure 11-5 .5 .4 .3 .2 .1 .0 LSB Timer 1 Data Register High (T1DATAH) Timer 1 Data Register Low (T1DATAL) E1H, Set1, Bank1; R/W; Reset Value: FFH MSB .7 .6 Figure 11-6 PS031305-1017 .5 .4 .3 .2 .1 .0 LSB Timer 1 Data Register Low (T1DATAL) 11-6 S3F8S28/S3F8S24 Product Specification Chapter 11. 16-Bit Timer 1 T1PS.3-.0 Data Bus P R E S C A L E R FOSC Overflow 16-bit Up-Counter (Read Only) M U X T1OVF Pending T1CON.2 8 T1CON.5 P2.1/ T1CAP T1CON.3 16-bit Comparator Clear Match T1CON.4 T1CON.1 M U X T1INT Pending T1CON.0 16-bit Timer Buffer T1OUT T1CON.7-.6 16-bit Timer Data Register (T1DATAH/L) T1CON.7-.6 8 Data Bus Figure 11-7 PS031305-1017 Timer 1 Functional Block Diagram 11-7 S3F8S28/S3F8S24 Product Specification Example 11-1 ORG Chapter 11. 16-Bit Timer 1 Using the Timer 1 003Ch VECTOR 0ECh, INT_Timer1_match ORG 0100h INITIAL: LD SYM,#00h ; Disable Global/Fast interrupt LD SP,#0C0H ; Set stack area LD BTCON, #10100011b ; Disable Watch-dog LD T1DATAH, #00H LD T1DATAL, #0F0H LD T1CON, #00100010b ; Interval, timer start run; clear counter, Enable interrupt LD T1PS, #00000100b ; Timer 1 clock = FOSC/16 EI MAIN: • • • MAIN ROUTINE • • • JR T, MAIN INT_Timer1_match: • • • Interrupt service routine • • • IRET END PS031305-1017 11-8 S3F8S28/S3F8S24 Product Specification 12 Chapter 12. Watchdog Timer Watchdog Timer 12.1 Overview The S3F8S28/S3F8S24 has an free running enhanced 11-bit Watchdog Timer (WDT), the main features are: • Selectable clock: system clock or free running ring oscillator (by ROSCCON.6) • Interrupt generation if INTEN is enable • Overflow reset generation if RSTEN is enabled • Selectable clock divider The Watchdog Timer (WDT) is a timer counting cycles of the Low Power Ring Oscillator or system clock. The WDT gives an pending interrupt when the counter reach to 0x3FF (half of the full counter value) or a system reset when the counter overflow. In normal operation mode, it is required that the system writing "1" to bit 4 of WDTCON to clear bit 10 of the counter before the time-out value is reached. If the system doesn't clear the counter, a system reset will be issued if the overflow Reset (RSTEN) is enabled. PS031305-1017 12-1 S3F8S28/S3F8S24 Product Specification Chapter 12. Watchdog Timer 12.2 Function Description 12.2.1 Watchdog Interrupt The WDT can work as a general system timer that gives an interrupt when the 11-bit counter reach to 0x3FF (the half of the full counter value). One example is to limit the maximum time allowed for certain operations, giving an interrupt when the operation has run longer than expected. 12.2.2 Release Stop The Watchdog Timer interrupt can be used to wake up the device from Stop Mode when the watchdog timer is clocked by free running Ring Oscillator. 12.2.3 System Reset The WDT gives a reset when the 11-bit counter expires if the RSTEN is set. This is typically used to prevent system hang-up in case of runaway code. In order to prevent an internal reset (if RSTEN bit is set), the software must clear the half of the counter before it reaches 0x7FF by writing "1" to bit 4 of Watchdog Control Register (WDTCON). There is a possibility to set a pending window where users can restart the watchdog counter within this window. When the interrupt occurred, User can clear the counter to prevent the internal reset. If the reset is needed, User still can save some critical parameters before a system reset. This is useful for allowing a safe shutdown. PS031305-1017 12-2 S3F8S28/S3F8S24 Product Specification Chapter 12. Watchdog Timer 12.3 Watchdog Timer Control Register (WDTCON) You use the Watchdog Timer Control Register, WDTCON, to • Enable/Disable Watchdog Timer • Interrupt Enable/Disable • Overflow Reset Enable/Disable • Counter clear • Program the clock prescaler for watchdog timer WDTCON is located at address E6H, Bank 0, Set 1, and is read/write addressable using Register addressing mode. A reset clears WDTCON to "00H". This disable Watchdog Timer, disable Watchdog interrupt and Reset. You can enable Watchdog Timer by writing a "1" to WDTCON.7. Writing a "1" to the enable bit clear the counter and restart to counting at any time. Watchdog Overflow Reset is controlled by WDTCON.6, if it is set, when the counter overflow, the system reset will occur. Watchdog Timer’s interrupt is controlled by WDTCON.5, if it is set, the watchdog timer interrupt will generated when counter reach to 0x3FF. You can clear the Watchdog Timer counter bit 10 of the counter at any time during normal operation by writing a "1" to WDTCON.4. WDTCON.3-0 are used to set select the clock prescaler of Watchdog Timer. The clock prescaler value of WDTPS should be kept to not larger than 12, the values larger than 12 is not valid. The clock source of Watchdog Timer is selected by ROSCCON.6 to choose system clock or Ring Oscillator as the clock for Watchdog Timer. PS031305-1017 12-3 S3F8S28/S3F8S24 Product Specification Chapter 12. Watchdog Timer Watchdog Timer Control Register (WDTCON) F6H, Bank 0, R/W; Reset Value: 00H MSB .7 .6 Watchdog Timer enable bit: 0- Disable Watchdog Timer (clear counter) 1- Enable Watchdog Timer Overflow Reset Enable bit: 0- Disable Overflow Reset 1- Enable Overflow Reset .5 .4 .3 .2 .1 .0 LSB Watchdog Timer prescaler bit (WDTPSB) WDTCLK = FLCLK/(2^WDTPSB) Watchdog Timer Counter Clear bit 0- No effect 1- Clear bit 10 of the Counter (when write) Watchdog Interrupt Enable bit: 0- Disable Interrupt 1- Enable Interrupt Note: 1. Prescaler values(WDTPSB) above 12 are not valid. 2. When the counter clear bit(.4) is set, the bit 10 of the counter is cleared and WDTCON.4 will be cleared to ‘0’automatically. Figure 12-1 PS031305-1017 Watchdog Timer Control Register (WDTCON) 12-4 S3F8S28/S3F8S24 Product Specification Chapter 12. Watchdog Timer WDTPS.3-.0 WDTCON.4 ROSCCON.6 Fxx Ring OSC M FLCLK U X Clear bit 10 P R E S C A L E R Overflow System Reset = 0x7FF 11-bit Up-Counter WDTCON.6 WDTCON.7 = 0x3FF Interrupt WDTCON.5 Figure 12-2 Table 12-1 Watchdog Timer Functional Block Diagram Watchdog Timer Presaler Select WDTCON.3 WDTCON.2 WDTCON.1 WDTCON.0 Number of 32kHz Ring OSC Cycles Typical Time-out 0 0 0 0 2048 32ms 0 0 0 1 4096 64ms 0 0 1 0 8109 128ms 0 0 1 1 16384 256ms 0 1 0 0 32768 512ms 0 1 0 1 65536 1024ms 0 1 1 0 131072 2048ms 0 1 1 1 262144 4096ms 1 0 0 0 524288 8192ms 1 0 0 1 1048576 16384ms 1 0 1 0 2097152 32768ms 1 0 1 1 10485760 65536ms 1 1 0 0 20971520 131072ms PS031305-1017 12-5 S3F8S28/S3F8S24 Product Specification Chapter 12. Watchdog Timer 12.4 Interrupt User can use Watchdog Timer as general timer/counter to generate interval interrupt with programmable period. Enable the interrupt by setting the WDTCON.5 to "1", If the global interrupt is enabled, after you enable the Watchdog (Set WDTCON.7 to "1"), the 11-bit counter start to counting, when the counter reach to 0x3FF, the interrupt will be generated and the counter will keep counting. If the Overflow Reset is disabled, when the counter overflow, it counter value reset to "0" and continues to up count. This is to be used to generate periodic interrupts. Watchdog Timer interrupt pending bit will be cleared automatically by hardware when the interrupt request is served. One example is to limit the maximum time allowed for certain operations, giving an interrupt when the operation has run longer than expected. It can be used to Release Stop Mode with setting the clock source as Ring Oscillator. After enter Stop Mode, the system clock (External crystal or Internal RC OSC) is stopped, but the Ring Oscillator can be set to run to provide clock for Watchdog Timer, when the 11-bit counter of Watchdog Timer interrupt generated, the interrupt will release Stop Mode. Enable WDT and interrupt, disable OVF Reset Select Clock source, Start Counting Main routine No = 0x3FF? Yes Clear pending bit (by Hardware) Interrupt routine Interrupt Service Routine Return Figure 12-3 PS031305-1017 Interrupt Operation Sequence 12-6 S3F8S28/S3F8S24 Product Specification Chapter 12. Watchdog Timer 12.5 System Reset Watchdog Timer is typically used to prevent system hang-up in case of runaway code. That’s similar with the basic timer overflow reset, but, as the clock source of Watchdog Timer is selectable, so when it is clocked by Ring Oscillator, it can be used in Stop Mode to reset chip, it is useful when the main system is stopped and the basic timer overflow reset is not available. The typical time-out period of the Watchdog Timer is listed as Table 12-1. It similar with a 10-bit Basic Timer’s watchdog function, user should clear the counter (write "1" to WDTCON.4) for prevent system reset. When the WDTCON.6 is set to "1", after you enable the Watchdog Timer to start counting, the chip will be reset immediately at the 11-bit counter overflow. Enable WDT OVF Reset, disable Interrupt Select Clock source and Start Counting Main routine No OVF? Yes System Reset Figure 12-4 PS031305-1017 System Reset Operation Sequence 12-7 S3F8S28/S3F8S24 Product Specification Chapter 12. Watchdog Timer 12.6 Interrupt & System Reset If all the watchdog interrupt and overflow reset are enabled, and when you enable the watchdog, the counter start to counting, the interrupt will be generated at the counter reach to 0x3FF, and the counter continuous to counting, if the counter overflow, the overflow reset will generated. This operating mechanism combines the two events by first giving an interrupt and then giving a reset. This will for instance allow a safe shutdown by saving critical parameters before a system reset. There is a possibility to set a pending window where users can restart the watchdog counter within this window. When the interrupt occurred, user can clear the counter to prevent the internal reset. Enable WDT interrupt & Reset Select Clock source, Start Counting Main routine No =0x3FF Yes Clear pending bit (by Hardware) Clear Counter? Interrupt routine No Yes Return Figure 12-5 PS031305-1017 Wait Counter Overflow Reset Interrupt & System Reset Operation Sequence 12-8 S3F8S28/S3F8S24 Product Specification 13 Chapter 13. PWM (Pulse Width Modulation) PWM (Pulse Width Modulation) 13.1 Overview This microcontroller has 2 PWM modules: PWM0 & PWM1. These two PWM modules are totally same, the output pin of PWM0 is P0.6, the output pin of PWM1 is P0.5. The PWM can be configured as one of these three resolutions: • 12-bit resolution: 6-bit base + 6-bit extension • 8-bit resolution: 6-bit base + 2-bit extension • 14-bit resolution: 8-bit base + 6-bit extension These three resolutions are mutually exclusive; only one resolution can work at any time. And which resolution is used is selected via PWM extension register, PWM0EX.1–0. PWM1EX.1–0. The operation of all PWM circuits is controlled by the control register, PWM0CON, PWM1CON. The PWM counter is an incrementing counter. It is used by the PWM circuits. To start the counter and enable the PWM circuits, you set PWM start bit (PWM0CON.2, PWM1CON.2) to "1". If the counter is stopped, it retains its current count value; when restarted, it resumes counting from the retained count value. When there is a need to clear the counter you set the counter clear bit (PWM0CON.3, PWM1CON.3) to "1". You can select a clock for the PWM counter by set PWM0CON.7–6, PWM1CON.7–6. Clocks which you can select are fOSC/64, fOSC/8, fOSC/2, fOSC/1. PS031305-1017 13-1 S3F8S28/S3F8S24 Product Specification Chapter 13. PWM (Pulse Width Modulation) 13.2 Function Description 13.2.1 PWM The PWM circuits have the following components: • PWM mode selection (PWM0EX.1–0, PWM1EX.1–0) • Base comparator and extension cycle circuit • Base reference data registers (PWM0DATA, PWM1DATA) • Extension data registers (PWM0EX.7–2, PWM1EX.7–2) • PWM output pins (P0.6/PWM0; P0.5/PWM1) 13.2.2 PWM Counter The PWM counter is an incrementing counter comprised of a lower base counter and an upper extension counter. To determine the PWM module's base operating frequency, the lower base counter is compared to the PWM base data register value. In order to achieve higher resolutions, the extension bits of the upper counter can be used to modulate the "stretch" cycle. To control the "stretching" of the PWM output duty cycle at specific intervals, the extended counter value is compared with the value that you write to the module's extension bits. 13.2.3 PWM Data and Extension Registers PWM (duty) data consist of base data bits and extension data bits; determine the output value generated by the PWM circuit. For each PWM resolution, the location of base data bits and extension data bits are different combination of PWM data register and PWM extension register: • • • 12-bit resolution, 6-bit base + 6-bit extension: − Base 6 data bits: PWM0DATA.5–0, PWM1DATA.5–0 − Extension 6 bits: PWM0EX.7–2, PWM1EX.7–2 8-bit resolution, 6-bit base + 2-bit extension: − Base 6 data bits: PWM0DATA.5–0, PWM0DATA.5–0 − Extension 2 bits: PWM1EX.7–6, PWM1EX.7–6 14-bit resolution, 8-bit base + 6-bit extension: − Base 8 data bits: PWM0DATA.7–0, PWM0DATA.7–0 − Extension 6 bits: PWM1EX.7–2, PWM1EX.7–2 PS031305-1017 13-2 S3F8S28/S3F8S24 Product Specification Chapter 13. PWM (Pulse Width Modulation) Base 0 (for 12-bit PWM) PWM Data Register .6 .7 .4 .5 .3 .2 .1 .0 LSB .0 LSB Base 1 (for 8-bit PWM) Base 2 (for 14-bit PWM) PWM Ex. Register .6 .7 .4 .5 .3 Ext 1 (for 8-bit PWM) .2 .1 Base/Ext Control Ext 0 (for 12/14-bit PWM) PWM EX.1-.0 (base/ext control): “x0”= 12-bit resolution: Base 0 (DATA.5-.0) + Ext 0 (EX.7-.2) “01”= 8-bit resolution: Base 1 (DATA.5-.0) + Ext 1 (EX.7-.6) “11”= 14-bit resolution: Base 2 (DATA.7-.0) + Ext 0 (EX.7-.2) Reset Value = “00”(12-bit resolution selected). Figure 13-1 PWM Data and Extension Registers To program the required PWM output, you load the appropriate initialization values into the data registers (PWM0DATA, PWM1DATA) and the extension registers (PWM0EX, PWM1EX). To start the PWM counter, or to resume counting, you set the PWM counter enable bit (PWM0CON.2, PWM1CON.2) to "1". A reset operation disables all PWM output. The current counter value is retained when the counter stops. When the counter starts, counting resumes at the retained value. 13.2.4 PWM Clock Rate The timing characteristic of PWM output is based on the fOSC clock frequency. The PWM counter clock value is determined by the setting input clock setting bits: PWM0CON.6–7, PWM1CON.6–7. Table 13-1 Register Name PWM data registers PWM control registers PS031305-1017 PWM Control and Data Registers Mnemonic Address PWM0DATA PWM1DATA F2H, Bank 0 E7H, Bank 1 PWM0EX PWM1EX F1H, Bank 0 E6H, Bank 1 PWM0CON PWM1CON F3H, Bank 0 E8H, Bank 1 Function PWM waveform la output setting registers. PWM counter stop/start (resume), and fOSC clock settings 13-3 S3F8S28/S3F8S24 Product Specification Chapter 13. PWM (Pulse Width Modulation) 13.2.5 PWM Function Description The PWM output signal toggles to Low level whenever the lower base counter matches the reference value stored in the module's data register (PWM0DATA, PWM1DATA). If the value in the data register is not zero, an overflow of the lower counter causes the PWM output to toggle to High level. In this way, the reference value written to the data register determines the module's base duty cycle. The value in the extension counter is compared with the extension settings in the extension data bits. This extension counter value, together with extension logic and the PWM module's extension bits, is then used to "stretch" the duty cycle of the PWM output. The "stretch" value is one extra clock period at specific intervals, or cycles (see Table 13-2). If, for example, in 8-bit base + 6-bit extension mode, the value in the extension register is "04H", the 32nd cycle will be one pulse longer than the other 63 cycles. If the base duty cycle is 50%, the duty of the 32nd cycle will therefore be "stretched" to approximately 51% duty. For example, if you write 80H to the extension register, all odd-numbered cycles will be one pulse longer. If you write FCH to the extension register, all cycles will be stretched by one pulse except the 64th cycle. PWM output goes to an output buffer and then to the corresponding PWM output pin. In this way, you can obtain high output resolution at high frequencies. PS031305-1017 13-4 S3F8S28/S3F8S24 Product Specification Chapter 13. PWM (Pulse Width Modulation) 13.2.6 PWM Output Waveform 6-bit base + 6-bit extension mode: Table 13-2 PWM Output "Stretch" Values for Extension Data Bits Ext1 (PWM0EX.7–2, PWM1EX.7–2) PWM EX. Bit "Stretched" Cycle Number 7 1, 3, 5, 7, 9, ..., 55, 57, 59, 61, 63 6 2, 6, 10, 14, ..., 50, 54, 58, 62 5 4, 12, 20, ..., 44, 52, 60 4 8, 24, 40, 56 3 16, 48 2 32 0H PWM Clock: 4MHz 0H PWM Data Register Values: 1H 20H 40H 250ns 8 μs 3FH Figure 13-2 PS031305-1017 80H 250ns 8 μs 250ns PWM Basic Waveform (6-Bit Base) 13-5 S3F8S28/S3F8S24 Product Specification 0H PWM Clock: PWM Data Register Values: 02H Chapter 13. PWM (Pulse Width Modulation) 40H 4MHz 500ns 2H PWM Extension 1st Register Values: 000100 00B (Extended Value is 04H) 64th 1st 32th 64th 32th 40H 0H 4MHz 750ns Figure 13-3 PS031305-1017 Extended PWM Waveform (6-Bit Base + 6-Bit Extension) 13-6 S3F8S28/S3F8S24 Product Specification Chapter 13. PWM (Pulse Width Modulation) 6-bit base + 2-bit extension mode: Table 13-3 PWM Output "Stretch" Values for Extension Data Bits Ext0 (PWM0EX.7–6, PWM1EX.7–6) PWM Ex. Bit (7-Bit 6-Bit) "Stretched" Cycle Number 00 – 01 2 10 1, 3 11 1, 2, 3 0H PWM Clock: 4 MHz 40H 80H xx000000B 250 ns xx000001B PWM Data Register Values: xx100000B 8 us 250 ns 8 us xx111111B 250 ns Figure 13-4 PS031305-1017 PWM Basic Waveform (6-Bit Base) 13-7 S3F8S28/S3F8S24 Product Specification 0H Chapter 13. PWM (Pulse Width Modulation) 40H PWM Clock: 4MHz 500 ns PWMDATA: xx000010B PWMEX: 0100 0001B Extended waveform 1st 2nd 3th 0H 4th 1st 2nd 3th 4th 40H 4MHz 750 ns Figure 13-5 PS031305-1017 Extended PWM Waveform (6-Bit Base + 2-Bit Extension) 13-8 S3F8S28/S3F8S24 Product Specification Chapter 13. PWM (Pulse Width Modulation) 8-bit base + 6-bit extension mode: Table 13-4 PWM Output "Stretch" Values for Extension Data Bits Ext1 (PWM0EX.7–2, PWM1EX.7–2) PWMEX Bit "Stretched" Cycle Number 7 1, 3, 5, 7, 9, ..., 55, 57, 59, 61, 63 6 2, 6, 10, 14, ..., 50, 54, 58, 62 5 4, 12, 20, ..., 44, 52, 60 4 8, 24, 40, 56 3 16, 48 2 32 0H PWM Clock: 4MHz 0H PWM Data Register Values: 1H 80H 200H Pulse 250ns 32 μs EFH Figure 13-6 PS031305-1017 100H Cycle 250ns 32 μs 250ns PWM Basic Waveform (8-Bit Base) 13-9 S3F8S28/S3F8S24 Product Specification 0H PWM Clock: PWM Data Register Values: 02H Chapter 13. PWM (Pulse Width Modulation) 100H 4MHz 500ns 2H PWM Ex. 1st Register Values: 000100 11B (Extended Value is 04H) 64th 1st 32th 64th 32th 100H 0H 4MHz 750ns Figure 13-7 PS031305-1017 PWM Basic Waveform (8-Bit Base + 6-Bit Extension) 13-10 S3F8S28/S3F8S24 Product Specification Chapter 13. PWM (Pulse Width Modulation) 13.3 PWM Control Register (PWM0CON/PWM1CON) The control register for the PWM modules, PWM0CON and PWM1CON, are located at register address F3H, Bank 0 and E8H, Bank 1. The control register (PWM0CON, PWM1CON) is used for all three PWM resolutions. Bit settings in the register control the following functions: • PWM counter clock selection • PWM data reload interval selection • PWM counter clear • PWM counter stop/start (or resume) operation • PWM counter overflow (upper counter overflow) interrupt control A reset clears all PWMCON bits to logic zero, disabling the entire PWM module. PWM Control Registers (PWM0CON):F3H, Bank 0, R/W, Reset: 00H (PWM1CON):E8H, Bank 1, R/W, Reset: 00H MSB .7 .6 .5 PWM input clock selection bits: 00 = fosc/64 01 = fosc/8 10 = fosc/2 11 = fosc/1 Not Used .4 .3 .2 .1 .0 LSB PWM extension counter OVF Interrupt pending bit: 0 = No interrupt pending 0 = Clear pending condition (when write) 1 = Interrupt is pending PWM counter interrupt enable bit: 0 = Disable PWM OVF interrupt 1 = Enable PWM OVF interrupt PWM counter enable bit: 0 = Stop counter 1 = Start (resume countering) PWMDATA reload interval selection bit: 0 = Reload from extension up counter overflow PWM counter clear bit: 1 = Reload from base up counter 0 = No effect overflow 1 = Clear the PWM counter (When write) NOTE: 3-bit is not auto-cleared. You must pay attention when clear pending bit. (refer to page 11-12). Figure 13-8 PS031305-1017 PWM Control Register (PWM0CON, PWM1CON) 13-11 S3F8S28/S3F8S24 Product Specification Chapter 13. PWM (Pulse Width Modulation) 13.4 PWM Extension Register (PWM0EX/PWM1EX) The extension register for the PWM module, PWM0EX and PWM1EX, are located at register address F1H, Bank 0 and E6H, Bank 1. PWM extension register is used for resolution selection and extension bits of PWM waveform. Bit settings in the PWM extension register (PWM0EX, PWM1EX) control the following functions: • PWM extension bits • PWM resolution selection • A reset clears all PWM extension register's to "00H", choose 6 + 2 as default resolution, no extension. PWM Extension Registers (PWM0EX) F1H, Bank 0, R/W, Reset: 00H (PWM1EX) E6H, Bank 1, R/W, Reset: 00H MSB .7 .6 .5 .4 .3 .2 .1 PWM Extension bits For 6 + 2 resolution PWM Extension bits For 6 + 6 and 8 + 6 resolutions .0 LSB PWM resolution selection bits: x0 = 12-bit PWM: 6 + 6 resolution 01 = 8-bit PWM: 6 + 2 resolution 11 = 14-bit PWM: 8 + 6 resolution NOTE: Only one resolution mode can work at any time. Figure 13-9 PWM Extension Register (PWM0EX, PWM0EX) Base data for 6 + 6 resolution PWM Data Register: MSB (PWM0DATA, F2H, Bank 0) (PWM1DATA, E7H, Bank 1) .7 .6 .5 .4 .3 .2 .1 .0 LSB Base data for 6 + 2 resolution Base data for 8 + 6 resolution Figure 13-10 PS031305-1017 PWM Data Register (PWM0DATA PWM1DATA) 13-12 S3F8S28/S3F8S24 Product Specification Chapter 13. PWM (Pulse Width Modulation) fOSC/8 fOSC fOSC/64 fOSC/2 PWMCON.6-.7 OVFINT From base-bit up counter extension-bit Counter base-bit Counter PENDING PWMCON.0 PWMCON.1 P0.6/PWM From extension-bit up counter MUX PWMCON.2 "1" When base data > Counter "0" When base data ORG 003CH DB 000H ; 003CH, must be initialized to 1. DB 000H ; 003DH, must be initialized to 1. DB 0FFH ; 003EH, Enable LVR (2.3) DB 000H ; 003FH, External Crystal oscillator ;--------------> VECTOR F2H, PWM0_INT ; S3F8S28/S3F8S24 interrupt vector ;--------------> ORG RESET: 0100H DI LD ; disable interrupt BTCON, #10100011B ; Watchdog disable LD PWM0EX,#00000000B ; Configure PWM0 as 6-bit base +6-bit extension LD P0CONH,#10011010B ; Configure P0.6 PWM output LD PWM0CON,#00000110B ; fOSC/64, counter/interrupt enable AND PWM0EX,#00000011B ; set extension bits as 00(basic output) LD PWM0DATA,#80H ; • • • • EI ; Enable interrupt ;--------------> MAIN: • • • • JR t,MAIN PWM0_INT: ; ; 94C4 interrupt service routine • • • AND IRET PWM0CON,#11110110B ; pending bit clear ; • • END PS031305-1017 13-14 S3F8S28/S3F8S24 Product Specification 14 Chapter 14. A/D Converter A/D Converter 14.1 Overview The 12-bit A/D converter (ADC) module uses successive approximation logic to convert analog levels entering at one of the nine input channels to equivalent 12-bit digital values. The analog input level must lie between the VDD and VSS values. The A/D converter has the following components: • Analog comparator with successive approximation logic • Sample and Hold circuit • D/A converter logic • ADC control register (ADCON) • Thirteen multiplexed analog data input pins (ADC0 to ADC12) • 12-bit A/D conversion data output register (ADDATAH/L) The ADC contains a Sample and Hold circuit which ensures that the input voltage to the ADC is held at a constant level during conversion. To enable and initiate an analog-to-digital conversion procedure, you write the channel selection data in the A/D converter control register ADCON to select one of the nine analog input pins (ADCn, n = 0–12) and set the conversion start bit, ADCON.0. The read-write ADCON register is located at address F7H. During a normal conversion, ADC logic initially sets the successive approximation register to 800H (the approximate half-way point of an 12-bit register). This register is then updated automatically during each conversion step. The successive approximation block performs 12-bit conversions for one input channel at a time. You can dynamically select different channels by manipulating the channel selection bit value (ADCON.7–4) in the ADCON register. To start the A/D conversion, you should set the enable bit, ADCON.0. When a conversion is completed, ACON.3, the end-of-conversion (EOC) bit is automatically set to 1 and the result is dumped into the ADDATA register where it can be read. The A/D converter then enters an idle state. Remember to read the contents of ADDATA before another conversion starts. Otherwise, the previous result will be overwritten by the next conversion result. NOTE: Normally, when a conversion is completed, the A/D converter then enters an idle state and will still work with power consumption. For power saving, when a conversion is completed, you can set the channel selection bit value (ADCON.7–4) to "1111B" to disable the ADC module, then the ADC module will be stopped and without any power consumption. PS031305-1017 14-1 S3F8S28/S3F8S24 Product Specification Chapter 14. A/D Converter 14.2 Using A/D Pins for Standard digital Input The ADC module's input pins are alternatively used as digital input in port 0, P2.6–P2.4 and P3.0–P3.1. 14.3 A/D Converter Control Register (ADCON) The A/D converter control register, ADCON, is located at address F7H. ADCON has four functions: • Bits 7 to 4 select an analog input pin (ADC0 to ADC12) and enable/disable ADC module meanwhile. • Bit 3 indicates the status of the A/D conversion. • Bits 2 to 1 select a conversion speed. • Bit 0 starts the A/D conversion. Only one analog input channel can be selected at a time. You can dynamically select any one of the nine analog input pins (ADC0 to ADC12) by manipulating the 4-bit value for ADCON.7 to ADCON.4. PS031305-1017 14-2 S3F8S28/S3F8S24 Product Specification Chapter 14. A/D Converter A/D Converter Control Register (ADCON) F7H, Bank 0, R/W; Reset Value: F0H MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB A/D Conversion input pin selection bits 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 ADC0 (P0.0) ADC1 (P0.1) ADC2 (P0.2) ADC3 (P0.3) ADC4 (P0.4) ADC5 (P0.5) ADC6 (P0.6) ADC7 (P0.7) ADC8 (P2.6) ADC9 (P2.5) ADC10 (P2.4) ADC11 (P3.0) ADC12 (P3.1) Conversion start bit: 0 = No effect 1 = A/D conversion start Conversion speed selection bits: 00 = fOSC/16 (fOSC < 12 MHz) 01 = fOSC/12 (fOSC < 10 MHz) 10 = fOSC/8 (fOSC < 6 MHz) 11 = fOSC/4 (fOSC < 3.2MHz) End-of-conversion (EOC) status bit: 0 = A/D conversion is in progress Disable ADC (Power Down) 1 = A/D conversion complete NOTE: 1. Maximum ADC clock input = 850kHz 2. When you select one ADC channel (0 to 12), the ADC module was enabled at the same time. 3. When the value of ADC input pin selection bits(7-bIt To 4-bIt) equal or larger than “1101”, the ADC module will be stopped without any power consumption. The reset value of 7-bit to 4bit is “1111B”, that disable ADC module. When ADC is needed, you must set proper value to 7-bit to 4-bit to enable ADC and select ADC channel according to your application system. Figure 14-1 PS031305-1017 A/D Converter Control Register (ADCON) 14-3 S3F8S28/S3F8S24 Product Specification Chapter 14. A/D Converter 14.4 Internal Reference Voltage Levels In the ADC function block, the analog input voltage level is compared to the reference voltage. The analog input level must remain within the range VSS to VDD. Different reference voltage levels are generated internally along the resistor tree during the analog conversion process for each conversion step. The reference voltage level for the first bit conversion is always 1/2VDD. A/D Converter Control Register ADCON (F7H, Bank 0) ADCON.0 (ADEN) ADCON.7-.4 ADC0/P0.0 ADC1/P0.1 ADC2/P0.2 … ADC7/P0.7 ADC8/P2.6 ADC9/P3.0 ADC10/P3.1 ADC11/P3.2 ADC12/P3.3 Control Circuit Clock Selector ADCON.2-.1 R M U L T I P L E X E R ADCON.3 (EOC Flag) Successive Approximation Circuit + CHold - Analog Comparator Conversion Result VDD D/A Converter VSS ADDATAH ADDATAL (F8H,Bank 0) (F9H, Bank 0) To data bus Figure 14-2 ADDATAH MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB ADDATAL MSB - - - - .3 .2 .1 .0 LSB Figure 14-3 PS031304-0115 A/D Converter Circuit Diagram A/D Converter Data Register (ADDATAH/L) PRELIMINARY 14-4 S3F8S28/S3F8S24 Product Specification ADCON.0 Chapter 14. A/D Converter 1 17 ADC clock Conversion Start EOC ADDATA 9 Privious Value 7 6 5 4 3 2 1 ADDATAH (8-bit) + ADDATAL (4-bit) Sample time 5 clock Figure 14-4 PS031304-0115 8 12 clock 0 Valid data A/D Converter Timing Diagram PRELIMINARY 14-5 S3F8S28/S3F8S24 Product Specification Chapter 14. A/D Converter 14.5 Conversion timing The A/D conversion process requires 1 step (1 clock edge) to convert each bit and 5 clocks to step-up A/D conversion. Therefore, total of 17 clocks are required to complete a 12-bit conversion: With an 10MHz CPU clock frequency, one clock cycle is 1.2s (12/fOSC). If each bit conversion requires 1 clock, the conversion rate is calculated as follows: • 1 clock/bit  12-bits + Sample time (5 clock) = 17 clocks • 17 clock  1.2s = 20.4s at 10MHz, 1 clock time = 12/fOSC (assuming ADCON.2–.1 = 01) PS031304-0115 PRELIMINARY 14-6 S3F8S28/S3F8S24 Product Specification Chapter 14. A/D Converter 14.6 Internal A/D Conversion Procedure 1. Analog input must remain between the voltage range of VSS and VDD. 2. Configure the analog input pins to input mode by making the appropriate settings in P0CONH, P0CONL and P2CONH registers. 3. Before the conversion operation starts, you must first select one of the thirteen input pins (ADC0 to ADC12) by writing the appropriate value to the ADCON register. 4. When conversion has been completed, (17 clocks have elapsed), the EOC flag is set to "1", so that a check can be made to verify that the conversion was successful. 5. The converted digital value is loaded to the output register, ADDATAH (8-bit) and ADDATAL (4-bit), then the ADC module enters an idle state. 6. The digital conversion result can now be read from the ADDATAH and ADDATAL register. VDD XIN Analog Input Pin ADC0-ADC12 XOUT 101 S3F8S28/F8S24 VSS Figure 14-5 PS031304-0115 Recommended A/D Converter Circuit for Highest Absolute Accuracy PRELIMINARY 14-7 S3F8S28/S3F8S24 Product Specification Example 14-1 Configuring A/D Converter ORG 003CH DB 0FFH ; 003CH, must be initialized to 0 DB 0FFH ; 003DH, must be initialized to 0 DB 0FFH ; 003EH, enable LVR DB 0FEH ; 003FH, external RC oscillator VECTOR 0F6H,INT_TIMER0 ORG RESET: Chapter 14. A/D Converter 0100H DI LD ; Timer 0 interrupt vector ; disable interrupt BTCON,#10100011B ; Watchdog disable • LD P0CONH,#11111111B ; Configure P0.4–P0.7 AD input LD P0CONL,#11111111B ; Configure P0.0–P0.3 AD input LD P2CONH,#00100000B ; Configure P2.6 AD input • • EI ; Enable interrupt ;--------------> MAIN: • • • CALL AD_CONV ; Subroutine for AD conversion • JR t,MAIN ; LD ADCON,#00000001B ; Select analog input channel • • AD_CONV: ; select conversion speed → → P0.0, and enable ADC. fOSC/16 ; set conversion start bit NOP CONV_LOOP: NOP ; If you select conversion speed to fOSC/16 NOP ; At least three nop must be included TM ADCON,#00001000B ; Check EOC flag JR Z,CONV_LOOP ; If EOC flag = 0, jump to CONV_LOOP until EOC flag = 1 LD R0,ADDATAH ; High 8 bits of conversion result are stored LD R1,ADDATAL LD ADCON,#00010011B ; to ADDATAH register ; Low 4 bits of conversion result are stored ; to ADDATAL register ; Select analog input channel ; Select conversion speed → → P0.1 fOSC/8 ; Set conversion start bit CONV_LOOP2: TM ADCON,#00001000B JR Z,CONV_LOOP2 LD R2,ADDATAH LD R3,ADDATAL ; Check EOC flag • PS031304-0115 PRELIMINARY 14-8 S3F8S28/S3F8S24 Product Specification Chapter 14. A/D Converter • INT_TIMER0: • RET ; • ; Interrupt enable bit and pending bit check • ; • ; Pending bit clear IRET ; • • END PS031304-0115 PRELIMINARY 14-9 S3F8S28/S3F8S24 Product Specification 15 Chapter 15. UART UART 15.1 Overview The UART block has a full-duplex serial port with programmable operating modes: There is one synchronous mode and three UART (Universal Asynchronous Receiver/Transmitter) modes: • Shift Register I/O with baud rate of fxx/(16  (8-bit BRDATA + 1)) • 8-bit UART Mode; variable baud rate, fxx/(16  (8-bit BRDATA + 1)) • 9-bit UART Mode; fxx/16 • 9-bit UART Mode; variable baud rate, fxx/(16  (8-bit BRDATA + 1)) UART receive and transmit buffers are both accessed via the data register, UDATA, is at address F8H, Set 1, Bank 1. Writing to the UART data register loads the transmit buffer; reading the UART data register accesses a physically separate receive buffer. When accessing a receive data buffer (shift register), reception of the next byte can begin before the previously received byte has been read from the receive register. However, if the first byte has not been read by the time the next byte has been completely received, the first data byte will be lost (Overrun error). In all operating modes, transmission is started when any instruction (usually a write operation) uses the UDATA register as its destination address. In mode 0, serial data reception starts when the receive interrupt pending bit (UARTPND.1) is "0" and the receive enable bit (UARTCON.4) is "1". In mode 1 and 2, reception starts whenever an incoming start bit ("0") is received and the receive enable bit (UARTCON.4) is set to "1". 15.1.1 Programming Procedure To program the UART modules, follow these basic steps: 1. Configure P2.2 and P2.3 to alternative function (RxD (P2.2), TxD (P2.3)) for UART module by setting the P2CONL register to appropriately value. 2. Load an 8-bit value to the UARTCON control register to properly configure the UART I/O module. 3. For interrupt generation, set the UART interrupt enable bit (UARTCON.1 or UARTCON.0) to "1". 4. When you transmit data to the UART buffer, write transmit data to UDATA, the shift operation starts. 5. When the shift operation (transmit/receive) is completed, UART pending bit (UARTPND.1 or UARTPND.0) is set to "1" and an UART interrupt request is generated • PS031305-1017 15-1 S3F8S28/S3F8S24 Product Specification Chapter 15. UART 15.1.2 UART Control Register (UARTCON) The control register for the UART is called UARTCON at address F5H, Set1 Bank1. It has the following control functions: • Operating mode and baud rate selection • Multiprocessor communication and interrupt control • Serial receive enable/disable control • 9th data bit location for transmit and receive operations (mode 2) • UART transmit and receive interrupt control A reset clears the UARTCON value to "00H". So, if you want to use UART module, you must write appropriate value to UARTCON. UART Control Register (UARTCON) F5H, Set1, Bank1, R/W, Reset Value: 00H MSB MS1 MS0 MCE RE TB8 RB8 Operating mode and baud rate selection bits (see table below) RIE TIE LSB Transmit interrupt enable bit: 0 = Disable 1 = Enable Multiprocessor communication(1) enable bit (for modes 2 and 3 only): 0 = Disable 1 = Enable Received interrupt enable bit: 0 = Disable 1 = Enable Serial data receive enable bit: 0 = Disable 1 = Enable Location of the 9th data bit that was received in UART mode 2 or 3 ("0" or "1") Location of the 9th data bit to be transmitted in UART mode 2 or 3 ("0" or "1") MS1 MS0 Mode Description(2) Baud Rate 0 0 1 1 0 1 0 1 0 1 2 3 Shift register fxx/(16 x (BRDATA +1)) 8-bit UART fxx/(16 x (BRDATA +1)) 9-bit UART fxx/16 9-bit UART fxx/(16 x (BRDATA +1)) NOTES: 1. In mode 2 or 3, if the UARTCON.5 bit is set to "1" then the receive interrupt will not be activated if the received 9th data bit is "0". In mode 1, if UARTCON.5 = "1" then the receive interrut will not be activated if a valid stop bit was not received. In mode 0, the UARTCON.5 bit should be "0" 2. The descriptions for 8-bit and 9-bit UART mode do not include start and stop bits for serial data receive and transmit. Figure 15-1 PS031305-1017 UART Control Register (UARTCON) 15-2 S3F8S28/S3F8S24 Product Specification Chapter 15. UART 15.1.3 UART Interrupt Pending Register (UARTPND) The UART interrupt pending register, UARTPND is located at address F6H, Set1 Bank1. It contains the UART data transmit interrupt pending bit (UARTPND.0) and the receive interrupt pending bit (UARTPND.1). In mode 0 of the UART module, the receive interrupt pending flag UARTPND.1 is set to "1" when the 8th receive data bit has been shifted. In mode 1 or 2, the UARTPND.1 bit is set to "1" at the halfway point of the stop bit's shift time. When the CPU has acknowledged the receive interrupt pending condition, the UARTPND.1 flag must be cleared by software in the interrupt service routine. In mode 0 of the UART module, the transmit interrupt pending flag UARTPND.0 is set to "1" when the 8th transmit data bit has been shifted. In mode 1 or 2, the UARTPND.0 bit is set at the start of the stop bit. When the CPU has acknowledged the transmit interrupt pending condition, the UARTPND.0 flag must be cleared by software in the interrupt service routine. UART Pending Register (UARTPND) F6H, Set1, Bank1, R/W, Reset Value: 00H MSB .7 .6 .5 .4 Not used .3 .2 RIP TIP LSB UART transmit interrupt pending flag: 0 = Not pending 0 = Clear pending bit (when write) 1 = Interrupt pending UART receive interrupt pending flag: 0 = Not pending 0 = Clear pending bit (when write) 1 = Interrupt pending NOTES: 1. In order to clear a data transmit or receive interrupt pending flag, you must write a "0" to the appropriate pending bit. 2. To avoid errors, we recommend using load instruction (except for LDB), when manipulating UARTPND values. Figure 15-2 PS031305-1017 UART Interrupt Pending Register (UARTPND) 15-3 S3F8S28/S3F8S24 Product Specification Chapter 15. UART 15.1.4 UART Data Register (UDATA) UART Data Register (UDATA) F8H, Set1, Bank1, R/W, Reset Value: Undefined MSB .7 .6 .4 .5 .3 .2 .1 .0 LSB Transmit or Receive data Figure 15-3 UART Data Register (UDATA) 15.1.5 UART Baud Rate Data Register (BRDATA) The value stored in the UART baud rate register, (BRDATA), lets you determine the UART clock rate (baud rate). UART Baud Rate Data Register (BRDATA) F7H, Set1, Bank1, R/W, Reset Value: FFH MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB Brud rate data Figure 15-4 PS031305-1017 UART Baud Rate Data Register (BRDATA) 15-4 S3F8S28/S3F8S24 Product Specification Chapter 15. UART 15.1.6 Baud Rate Calculations The baud rate is determined by the baud rate data register, 8-bit BRDATA • Mode 0 baud rate = fxx/(16  (8-bit BRDATA + 1)) • Mode 1 baud rate = fxx/(16  (8-bit BRDATA + 1)) • Mode 2 baud rate = fxx/16 • Mode 3 baud rate = fxx/(16  (8-bit BRDATA + 1)) Table 15-1 Commonly Used Baud Rates Generated by 8-Bit BRDATA Mode Baud Rate Oscillation Clock Mode 2 0.5MHz Mode 0 BRDATA Decimal Hex 8MHz x x 62,500Hz 10MHz 09 09H Mode 1 9,615Hz 10MHz 64 40H Mode 3 38,461Hz 8MHz 12 0CH – 12,500Hz 8MHz 39 27H – 19,230Hz 4MHz 12 0CH – 9,615Hz 4MHz 25 19H PS031305-1017 15-5 S3F8S28/S3F8S24 Product Specification Chapter 15. UART 15.2 Block Diagram SAM8 Internal Data Bus TB8 fxx MS0 MS1 8 BIT BRDATA S D Q CLK Baud Rate Generator Write to UDATA UDATA CLK Zero Detector MS0 MS1 TxD (P2.3) Shift Start Tx Control Tx Clock RxD (P2.2) EN Send TIP TxD (P2.3) TIE Interrupt RIE Rx Clock RE RIE 1-to-0 Transition Detector Shift Clock RIP Receive Rx Control Shift Start Shift Value Bit Detector Shift Register MS0 MS1 UDATA RxD (P2.2) SAM8 Internal Data Bus Figure 15-5 PS031305-1017 UART Functional Block Diagram 15-6 S3F8S28/S3F8S24 Product Specification Chapter 15. UART 15.2.1 UART Mode 0 Function Description In mode 0, UART is input and output through the RxD (P2.2) pin and TxD (P2.3) pin outputs the shift clock. Data is transmitted or received in 8-bit units only. The LSB of the 8-bit value is transmitted (or received) first. 15.2.1.1 Mode 0 Transmit Procedure 1. Select mode 0 by setting UARTCON.6 and .7 to "00B". 2. Write transmission data to the shift register UDATA (F8H, set1, bank 1) to start the transmission operation. 15.2.1.2 Mode 0 Receive Procedure 1. Select mode 0 by setting UARTCON.6 and .7 to "00B". 2. Clear the receive interrupt pending bit (UARTPND.1) by writing a "0" to UARTPND.1. 3 Set the UART receive enable bit (UARTCON.4) to "1". 4 The shift clock will now be output to the TxD (P2.3) pin and will read the data at the RxD (P2.2) pin. A UART receive interrupt (vector FAH) occurs when UARTCON.1 is set to "1". Write to Shift Register (UDATA) RxD (Data Out) D0 D1 D2 D3 D4 D5 D6 Transmit Shift D7 TxD (Shift Clock) TIP Write to UARTPND (Clear RIP and set RE) RIP Receive RE Shift D0 RxD (Data In) D1 D2 D3 D4 D5 D6 D7 TxD (Shift Clock) 1 2 Figure 15-6 PS031305-1017 3 4 5 6 7 8 Timing Diagram for UART Mode 0 Operation 15-7 S3F8S28/S3F8S24 Product Specification Chapter 15. UART 15.2.2 UART Mode 1 Function Description In mode 1, 10 bits are transmitted (through the TxD (P2.3) pin) or received (through the RxD (P2.2) pin). Each data frame has three components: • Start bit ("0") • 8 data bits (LSB first) • Stop bit ("1") When receiving, the stop bit is written to the RB8 bit in the UARTCON register. The baud rate for mode 1 is variable. 15.2.2.1 Mode 1 Transmit Procedure 1. Select the baud rate generated by 8-bit BRDATA. 2. Select mode 1 (8-bit UART) by setting UARTCON bits 7 and 6 to "01B". 3. Write transmission data to the shift register UDATA (F8H, Set1, and Bank 1). The start and stop bits are generated automatically by hardware. 15.2.2.2 Mode 1 Receive Procedure 1. Select the baud rate to be generated by 8-bit BRDATA. 2. Select mode 1 and set the RE (Receive Enable) bit in the UARTCON register to "1". 3. The start bit low ("0") condition at the RxD (P2.2) pin will cause the UART module to start the serial data receive operation. Tx Clock Shift TxD D0 D1 D2 D3 D4 D5 D6 D7 Start Bit D0 D1 D2 D3 D4 D5 D6 Start Bit Stop Bit Transmit Write to Shift Register (UDATA) TIP Rx Clock RxD D7 Stop Bit Receive Bit Detect Sample Time Shift RIP Figure 15-7 PS031305-1017 Timing Diagram for UART Mode 1 Operation 15-8 S3F8S28/S3F8S24 Product Specification Chapter 15. UART 15.2.3 UART Mode 2 Function Description In mode 2, 11-bit are transmitted through the TxD pin or received through the RxD pin. In mode 2, the baud rate is fixed at fxx/16. Each data frame has three components: • Start bit ("0") • 8 data bits (LSB first) • Programmable 9th data bit • Stop bit ("1") The 9th data bit to be transmitted can be assigned a value of "0" or "1" by writing the TB8 bit (UARTCON0.3). When receiving, the 9th data bit that is received is written to the RB8 bit (UARTCON0.2), while the stop bit is ignored. The baud rate for mode 2 is fOSC/16 clock frequency. 15.2.3.1 Mode 2 Transmit Procedure 1. Select mode 2 (9-bit UART0) by setting UARTCON bits 6 and 7 to "10B". Also, select the 9th data bit to be transmitted by writing TB8 to "0" or "1". 2. Write transmission data to the shift register, UDATA (F8H, Set1, Bank 1), to start the transmit operation. 15.2.3.2 Mode 2 Receive Procedure 1. Select mode 2 and set the receive enable bit (RE) in the UARTCON register to "1". 2. The receive operation starts when the signal at the RxD pin goes to low level. Tx Clock Write to Shift Register (UARTDATA) TxD Start Bit D0 D1 D2 D3 D4 D5 D6 TIP D7 Transmit Shift Stop Bit TB8 or Parity bit RB8 or Parity bit Rx Clock RxD Start Bit D0 D1 D2 D3 D4 D5 D6 D7 Stop Bit Receive Bit Detect Sample Time Shift RIP Figure 15-8 PS031305-1017 Timing Diagram for UART Mode 2 Operation 15-9 S3F8S28/S3F8S24 Product Specification Chapter 15. UART 15.2.4 UART Mode 3 Function Description In mode 3, 11 bits are transmitted (through the TxD) or received (through the RxD). Mode 3 is identical to mode 2 but can be configured to variable baud rate. Each data frame has four components: • Start bit ("0") • 8 data bits (LSB first) • Programmable 9th data bit • Stop bit ("1") 15.2.4.1 Mode 3 Transmit Procedure 1. Select the baud rate generated by setting BRDATA. 2. Select mode 3 (9-bit UART) by setting UARTCON bits 6 and 7 to "11B". Also, select the 9th data bit to be transmitted by writing TB8 to "0" or "1" 3. Write transmission data to the shift register, UDATA (F8H, Set 1, Bank 1), to start the transmit operation. 15.2.4.2 Mode 3 Receive Procedure 1. Select the baud rate to be generated by setting BRDATA. 2. Select mode 3 and set the receive enable bit (RE) in the UARTCON register to "1". 3. The receive operation starts when the signal at the RxD pin goes to low level. Tx Clock Shift TxD Start Bit D0 D1 D2 D3 D4 D5 D6 TIP D7 Stop Bit Transmit Write to Shift Register (UARTDATA) TB8 or Parity bit RB8 or Parity bit Rx Clock RxD Start Bit D0 D1 D2 D3 D4 D5 D6 D7 Stop Bit Receive Bit Detect Sample Time Shift RIP Figure 15-9 PS031305-1017 Timing Diagram for UART Mode 3 Operation 15-10 S3F8S28/S3F8S24 Product Specification Chapter 15. UART 15.2.5 Serial Communication for Multiprocessor Configurations The S3F8 Series multiprocessor communication features let a "master" S3F8S28/S3F8S24 send a multiple-frame serial message to a "slave" device in a multi S3F8S28/S3F8S24 configuration. It does this without interrupting other slave devices that may be on the same serial line. This feature can be used only in UART Mode 2 or 3 with the parity disable mode. In mode 2 and 3, 9 data bits are received. The 9th bit value is written to RB8 (UARTCON.2). The data receive operation is concluded with a stop bit. You can program this function so that when the stop bit is received, the serial interrupt will be generated only if RB8 = "1". To enable this feature, you set the MCE bit in the UARTCON registers. When the MCE bit is "1", serial data frames that are received with the 9th bit = "0" do not generate an interrupt. In this case, the 9th bit simply separates the address from the serial data. 15.2.5.1 Sample Protocol for Master/Slave Interaction When the master device wants to transmit a block of data to one of several slaves on a serial line, it first sends out an address byte to identify the target slave. Note that in this case, an address byte differs from a data byte: In an address byte, the 9th bit is "1" and in a data byte, it is "0". The address byte interrupts all slaves so that each slave can examine the received byte and see if it is being addressed. The addressed slave then clears its MCE bit and prepares to receive incoming data bytes. The MCE bits of slaves that were not addressed remain set, and they continue operating normally while ignoring the incoming data bytes. While the MCE bit setting has no effect in mode 0, it can be used in mode 1 to check the validity of the stop bit. For mode 1 reception, if MCE is "1", the receive interrupt will be issue unless a valid stop bit is received. 15.2.5.2 Setup Procedure for Multiprocessor Communications Follow these steps to configure multiprocessor communications: 1. Set all S3F8S28/S3F8S24 devices (masters and slaves) to UART Mode 2 or 3 2. Write the MCE bit of all the slave devices to "1". 3. The master device's transmission protocol is: – First byte: the address identifying the target slave device (9th bit = "1") – Next bytes: data (9th bit = "0") 4. When the target slave receives the first byte, all of the slaves are interrupted because the 9th data bit is "1". The targeted slave compares the address byte to its own address and then clears its MCE bit in order to receive incoming data. The other slaves continue operating normally. PS031305-1017 15-11 S3F8S28/S3F8S24 Product Specification Chapter 15. UART Full-Duplex Multi-S3F8S24 Interconnect TxD RxD TxD RxD TxD Master Slave 1 Slave 2 S3F8S28/F8S24 S3F8S28/F8S24 S3F8S28/F8S24 Figure 15-10 PS031305-1017 TxD RxD ... RxD Slave n S3F8S28/F8S24 Connection Example for Multiprocessor Serial Data Communications 15-12 S3F8S28/S3F8S24 Product Specification 16 Chapter 16. IIC Bus Interface IIC Bus Interface 16.1 Overview The S3F8S28/S3F8S24 microcontrollers support a multi-master IIC-bus serial interface. A dedicated serial data line (SDA) and a serial clock line (SCL) carry information between bus masters and peripheral devices which are connected to the IIC-bus. The SDA and SCL lines are bi-directional. In multi-master IIC-bus mode, multiple S3F8S28/S3F8S24 microcontrollers can receive or transmit serial data to or from slave devices. The master S3F8S28/S3F8S24 which initiates a data transfer over the IIC-bus is responsible for terminating the transfer. Standard bus arbitration functions are supported. To control multi-master IIC-bus operations, you write values to the following registers: • IIC-bus control register, ICCR • IIC-bus control/status register, ICSR • IIC-bus Tx/Rx data shift register, IDSR • IIC-bus address register, IAR When the IIC-bus is free, the SDA and SCL lines are both at High level. A High-to-Low transition of SDA initiates a Start condition. A Low-to-High transition of SDA while SCL remains steady at High level initiates a Stop condition. Start and Stop conditions are always generated by the bus master. A 7-bit address value in the first data byte that is put onto the bus after the Start condition is initiated determines which slave device the bus master selects. The 8th bit determines the direction of the transfer (read or write). Every data byte that is put onto the SDA line must total eight bits. The number of bytes which can be sent or received per bus transfer operation is unlimited. Data is always sent most-significant bit (MSB) first and every byte must be immediately followed by an acknowledge (ACK) bit. PS031305-1017 16-1 S3F8S28/S3F8S24 Product Specification Chapter 16. IIC Bus Interface 16.1.1 Multi-Master IIC Bus Control Register (ICCR) The multi-master IIC-bus control register, ICCR, is located at address F0H, bank 1. It is read/write addressable. ICCR settings control the following IIC-bus functions: • CPU acknowledge signal (ACK) enable or suppress • IIC-bus clock source selection (fOSC/16 or fOSC/512) • Transmit/receive interrupt enable or disable • Transmit/receive interrupt pending control • 4-bit prescaler for the serial transmit clock (SCL) In the S3F8S28/S3F8S24 interrupt structure, the IIC-bus Tx/Rx interrupt is assigned level IRQ6, vector E0H. To enable this interrupt, you set ICCR.5 to "1". Program software can then poll the IIC-bus Tx/Rx interrupt pending bit (ICCR.4) to detect IIC-bus receive or transmit requests. When the CPU acknowledges the interrupt request from the IIC-bus, the interrupt service routine must clear the interrupt pending condition by writing a "0" to ICCR.4. The SCL frequency is determined by the IIC-bus clock source selection (fOSC/16 or fOSC/512) and the 4-bit prescaler value in the ICCR register (see Figure 16-1). IIC Control Register(ICCR) F0H, Set 1, Bank 1, R/W MSB .7 .6 .5 Acknowledgement Enable Bit: 0 = Acknowledgement disable mode 1 = Acknowledgement enable mode Tx Clock Selection Bit: 0 = fosc/16 1 = fosc/512 .4 .3 .2 .1 .0 LSB IIC-bus transmit (Tx) clock prescaler: The IIC-bus transmit clock (SCLK) frequency is determined by the clock source selection (ICCR.6) and this 4-bit prescaler value, according to the following formula: Tx clock (SCL) = IICLK/(ICCR.3-ICCR.0) + 1 where IICLK = fosc/16 (ICCR.6 = "0") or IICLK = fosc /512 (ICCR.6 = "1") IIC-Bus Tx/Rx Interrupt Enable Bit: 0 = Disable 1 = Enable IIC Interrupt Pending Bit: 0 = Interrupt request is not pending; (when read) pending bit clear when write 0 1 = Interrupt request is pending (when read) NOTE: A IIC-bus interrupt occurs 1. When a 1-byte transmit or receive operation is terminated 2. When a general call or a slave address match occurs, or 3. If bus arbitration fails. Figure 16-1 PS031305-1017 Multi-Master IIC Bus Control Register (ICCR) 16-2 S3F8S28/S3F8S24 Product Specification Table 16-1 Chapter 16. IIC Bus Interface Sample Timing Calculations for the IIC Bus Transmit Clock (SCL) ICCR.3–ICCR.0 Value IICLK (ICCR.3–ICCR.0, Settings + 1) (fOSC = 8MHz) ICCR.6 = 0 (fOSC/16) IICLK = 500kHz (fOSC = 8MHz) ICCR.6 = 1 (fOSC/512) IICLK = 15.625kHz 0000 IICLK/1 400kHz (Note) 15.625kHz 0001 IICLK/2 250kHz 7.1825kHz 0010 IICLK/3 16.7kHz 5.2038kHz 0011 IICLK/4 125kHz 3.9063kHz 0100 IICLK/5 100kHz 3.1250kHz 0101 IICLK/6 83.3kHz 2.6042kHz 0110 IICLK/7 71.4kHz 2.2321kHz 0111 IICLK/8 62.5kHz 1.9531kHz 1000 IICLK/9 55.6kHz 1.7361kHz 1001 IICLK/10 50kHz 1.5625kHz 1010 IICLK/11 45.5kHz 1.4205kHz 1011 IICLK/12 41.7kHz 1.3021kHz 1100 IICLK/13 38.5kHz 1.2019kHz 1101 IICLK/14 35.7kHz 1.1160kHz 1110 IICLK/15 33.3kHz 1.0417kHz 1111 IICLK/16 31.25kHz 0.9766kHz NOTE: Max. IICLK = 400kHz. PS031305-1017 16-3 S3F8S28/S3F8S24 Product Specification Chapter 16. IIC Bus Interface 16.1.2 Multi-Master IIC Bus Control/Status Register (ICSR) The multi-master IIC-bus control/status register, ICSR, is located at address F1H, BANK1. Four bits in this register, ICSR.3 to ICSR.0, are read-only status flags. ICSR register settings are used to control or monitor the following IIC-bus functions (see Figure 16-2): • Master/slave transmit or receive mode selection • IIC-bus busy status flag • Serial output enable/disable • Failed bus arbitration procedure status flag • Slave address/address register match or general call received status flag • Slave address 00000000B (general call) received status flag • Last received bit status flag (not ACK = "1", ACK = "0") MULTI-MASTER IIC-BUS CONTROL/STATUS REGISTERS (ICSR) F1H, Set 1, Bank 1, R/W (Bit 3-0: read-only) MSB .7 .6 .5 .4 IIC-Bus Master/Slave Tx/Rx Mode Selection Bits:: 00 = Slave receiver mode (Default mode) 01 = Slave transmitter mode 10 = Master receiver mode 11 = Master transmitter mode .3 .2 .1 .0 LSB IIC-bus last-received bit status flag: 0 = Last-received bit is "0" (ACK was received) 1 = Last-received bit is "1" (ACK wsa not received) IIC-bus address zero status flag: 0 = START/STOP condition was generated 1 = Received slave address is "00000000B" (general call) IIC-bus address-as-slave status flag: 0 = START/STOP condition was generated 1 = Received slave address matches the address value in the IAR IIC-bus arbitration procedure status flag: 0 = Bus arbitration status okay IIC-bus serial output 1 = Bus arbitration failed during serial I/O enable/disable bit: 0 = Disable serial Tx/Rx 1 = Enable serial Tx/Rx IIC-bus busy signal status bit: 0 = IIC-bus not busy (when read), IIC interface STOP signal generation (when write) 1 = IIC-bus is busy (when read), IIC interface START signal generation (when write) NOTE: ICSR.3 is automatically set to "1" when a bus arbitration procedure fails over serial I/O interface, while the IIC-bus is set to "master transmit mode" (ICSR.7 and ICSR.6 = "11B"). If slave transmit or receive mode is selected, ICSR.3 is automatically set to "1" if data is written to the shift register (IDSR) when the busy signal bit, ICSR.5 is "1". Figure 16-2 PS031305-1017 Multi-Master IIC Bus Control/Status Register (ICSR) 16-4 S3F8S28/S3F8S24 Product Specification Chapter 16. IIC Bus Interface 16.1.3 Multi-Master IIC Bus Transmit/Receive Data Shift Register (IDSR) The IIC-bus data shift register, IDSR, is located at address F2H, Bank 1. In a transmit operation, data that is written to the IDSR is transmitted serially, MSB first. (For receive operations, the input data is written into the IDSR register LSB first.) The ICSR.4 setting enables or disables serial transmit/receive operations. When ICSR.4 = "1", data can be written to the shift register. The IIC-bus shift register can, however, be read at any time, regardless of the current ICSR.4 setting. MULTI-MASTER IIC-BUS Tx/Rx DATA SHIFT REGISTERS (IDSR) F2H,Set 1, Bank 1, R/W MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB 8-bit data shift register for IIC-bus Tx/Rx operations: When ICSR.4 = "1", IDSR is write-enabled. You can read the IDSR value at any time, regardless of the current ICSR.4 setting. Figure 16-3 PS031305-1017 Multi-Master IIC Bus Tx/Rx Data Shift Register (IDSR) 16-5 S3F8S28/S3F8S24 Product Specification Chapter 16. IIC Bus Interface 16.1.4 Multi-Master IIC Bus Address Register (IAR) The address register for the IIC-bus interface, IAR, is located at address F3H, Bank 1. It is used to store a latched 7-bit slave address. This address is mapped to IAR.7 to IAR.1; bit 0 is not used (see Figure 16-4). The latched slave address is compared to the next received slave address. If a match condition is detected, and if the latched value is 00000000B, a general call status is detected. MULTI-MASTER IIC-BUS ADDRESS REGISTERS (IAR) F3H,Set 1, Bank 1, R/W MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB Not used for the S3F8S28/F8S24 7-bit slave address, latch from the IIC-bus: When ICSR.4 = "1", IAR is write-enabled. You can read the IAR value at any time, regardless of the current ICSR.4 setting. NOTE: IAR must be written before ICSR. Figure 16-4 PS031305-1017 Multi-Master IIC Bus Address Register (IAR) 16-6 S3F8S28/S3F8S24 Product Specification Chapter 16. IIC Bus Interface 16.2 Block Diagram Address Register (IAR) Comparator IIC-Bus Control Logic SCL ICCR ICSR Shift Register (IDSR) IRQ6 SDA 8 Data Bus NOTE: The IIC-bus interrupt (IRQ6) is generated when a 1byte receive or transmit operation is terminated before the shift operation has been completed. Figure 16-5 PS031305-1017 IIC Bus Block Diagram 16-7 S3F8S28/S3F8S24 Product Specification Chapter 16. IIC Bus Interface 16.3 The IIC Bus Interface The S3F8S28/S3F8S24 IIC-bus interface has four operating modes: • Master transmitter mode • Master receive mode • Slave transmitter mode • Slave receive mode Functional relationships between these operating modes are described below. 16.4 Start and Stop Conditions When the IIC-bus interface is inactive, it is in slave mode. The interface is therefore always in slave mode when a start condition is detected on the SDA line. (A start condition is a High-to-Low transition of the SDA line while the clock signal, SCL, is high level.) When the interface enters master mode, it initiates a data transfer and generates the SCL signal. A start condition initiates a one-byte serial data transfer over the SDA line and a stop condition ends the transfer. (A stop condition is a Low-to-High transition of the SDA line while SCL is High level.) Start and stop conditions are always generated by the master. The IIC-bus is "busy" when a start condition is generated. A few clocks after a stop condition is generated, the IIC-bus is again "free". When a master initiates a start condition, it sends its slave address onto the bus. The address byte consists of a 7bit address and a 1-bit transfer direction indicator (that is, write or read). If bit 8 is "0", a transmit operation (write) is indicated; if bit 8 is "1", a request for data (read) is indicated. The master ends the indicated transfer operation by transmitting a stop condition. If the master wants to continue sending data over the bus, it can generate another slave address and another start condition. In this way, read write operations can be performed in various formats. SCL SDA START Condition STOP Condition Figure 16-6 PS031305-1017 Start and Stop Conditions 16-8 S3F8S28/S3F8S24 Product Specification Chapter 16. IIC Bus Interface SCL Data must remain stable while clock is HIGH Change of data allowed Data must remain stable while clock is HIGH SDA Start condition hold time Figure 16-7 1 SCL 2 Stop condition setup Start condition hold time Input Data Protocol 1 9 2 SDA Acknowledgement low High or low state is possible according to data. If stop signal is not generated in interval A, next clock is generated. Interrupt pending bit set point Interrupt pending bit clear point NOTE: In IIC operation, interrupt pending information is indispensable, therefore it Is not possible to control IIC operation only in Main routine without interrupt. Figure 16-8 PS031305-1017 Interrupt Pending Information 16-9 S3F8S28/S3F8S24 Product Specification Chapter 16. IIC Bus Interface 16.5 Data Transfer Formats Every byte put on the SDA line must be eight bits in length. The number of bytes which can be transmitted per transfer is unlimited. The first byte following a start condition is the address byte. This address byte is transmitted by the master when the IIC-bus is operating in master mode. Each byte must be followed by an acknowledge (ACK) bit. Serial data and addresses are always sent MSB first. Single Byte Write Mode Format S Slave Address W A DATA A P Data Transferred (Data + Acknowledge) "0" (write) Multigle Byte Write Mode Format S Slave Address W A Sub Address A R A P Auto Increment of Sub Address Single Byte Read Mode Format S DATA Data Transferred (Data n + Acknowledge) "0" (write) Slave Address DATA A A DATA A P Data Transferred (Data + Acknowledge) "1" (read) Multigle Byte Read Mode Format S Slave Address R A Sub Address S Slave Address R A DATA A DATA A P Data Transferred (Data n + Acknowledge) "1" (read) NOTE: 1. S: start, A: acknowledge, P: stop 2. The "Sub Address" indicates the internal address of the slave device. Figure 16-9 PS031305-1017 IIC Bus Interface Data Formats 16-10 S3F8S28/S3F8S24 Product Specification Chapter 16. IIC Bus Interface 16.6 ACK Signal Transmission To complete a one-byte transfer operation, the receiver must send an ACK bit to the transmitter. The ACK pulse occurs at the ninth clock of the SCL line (eight clocks are required to complete the one-byte transfer). The clock pulse required for the transmission of the ACK bit is always generated by the master. The transmitter releases the SDA line (that is, it sends the SDA line High) when the ACK clock pulse is received. The receiver must drive the SDA line Low during the ACK clock pulse so that SDA is Low during the High period of the ninth SCL pulse. The ACK bit transmit function can be enabled and disabled by software (ICCR.7). However, the ACK pulse on the ninth clock of SCL is required to complete a one-byte data transfer operation. 1 SCLK from Master 8 9 Start Condition Data Output from Transmitter Clock to output Data Output from Receiver ACK Figure 16-10 PS031305-1017 Clock to output Acknowledge Response from Receiver 16-11 S3F8S28/S3F8S24 Product Specification Chapter 16. IIC Bus Interface Slave address transmission with write condition Main routine Start signal generation No ACK? Yes Sub address of slave transmission No ACK? Interrupt routine Yes Transmit data No ACK? Stop signal generation Figure 16-11 PS031305-1017 Write Operation Sequence 16-12 S3F8S28/S3F8S24 Product Specification Chapter 16. IIC Bus Interface Slave address transmission with write condition Main routine Start signal generation No ACK? Yes Sub address of slave transmission No ACK? Interrupt routine Yes Slave address transmission with read condition No ACK? Yes Transmit data No ACK? Stop signal generation Figure 16-12 PS031305-1017 Read Operation Sequence 16-13 S3F8S28/S3F8S24 Product Specification Chapter 16. IIC Bus Interface 16.7 Read/Write Operations When operating in transmitter mode, the IIC-bus interface interrupt routine waits for the master (the S3F8S28/S3F8S24) to write a data byte into the IIC-bus data shift register (IDSR). To do this, it holds the SCL line Low prior to transmission. In receive mode, the IIC-bus interface waits for the master to read the byte from the IIC-bus data shift register (IDSR). It does this by holding the SCL line Low following the complete reception of a data byte. 16.8 Bus Arbitration Procedures Arbitration takes place on the SDA line to prevent contention on the bus between two masters. If a master with a SDA High level detects another master with an SDA active Low level, it will not initiate a data transfer because the current level on the bus does not correspond to its own. The master which loses the arbitration can generate SCL pulses only until the end of the last-transmitted data byte. The arbitration procedure can continue while data continues to be transferred over the bus. The first stage of arbitration is the comparison of address bits. If a master loses the arbitration during the addressing stage of a data transfer, it is possible that the master which won the arbitration is attempting to address the master which lost. In this case, the losing master must immediately switch to slave receiver mode. 16.9 Abort Conditions If a slave receiver does not acknowledge the slave address, it must hold the level of the SDA line High. This signals the master to generate a stop condition and to abort the transfer. If a master receiver is involved in the aborted transfer, it must also signal the end of the slave transmit operation. It does this by not generating an ACK after the last data byte received from the slave. The slave transmitter must then release the SDA to allow a master to generate a stop condition. 16.10 Configuring the IIC-Bus To control the frequency of the serial clock (SCL), you program the 4-bit prescaler value in the ICCR register. The IIC-bus interface address is stored in IIC-bus address register, IAR. (By default, the IIC-bus interface address is an unknown value). PS031305-1017 16-14 S3F8S28/S3F8S24 Product Specification 17 Chapter 17. Low Voltage Detector Low Voltage Detector 17.1 Overview The S3F8S28/S3F8S24 micro-controller has a built-in LVD (Low Voltage Detector) circuit which allows detection of power voltage drop to generate flag: • Generate flag when VDD less than one selected level from 4.1, 3.2, 2.5 or 2.1V Low voltage detector circuits have following functional components: • Enable or disable LVD module • LVD Flag when detector setting level. Turning the LVD operation on and off can be controlled by software. Because the IC consumes a large amount of current during LVD operation, it is recommended that the LVD operation should be kept OFF unless it is necessary. Also the LVD criteria voltage can be set by the software. The LVD flag criteria voltage can be set by matching to one of the 4 kinds of voltage 2.1V, 2.5V, 3.2V,4.1V (VDD reference voltage). The LVD block works only when LVDCON.7 is set. If VDD level is lower than the reference voltage selected with LVDCON.1-0, LVDCON.5 will be set. If VDD level is higher, LVDCON.5 will be cleared. PS031305-1017 17-1 S3F8S28/S3F8S24 Product Specification Chapter 17. Low Voltage Detector 17.2 Low Voltage Detector Control Register (LVDCON) You use the Low Voltage Detector control register, LVDCON, to • Enable low voltage detector circuit • Check LVD flag • Set low voltage detector flag level LVDCON is located at address F4H, Set1, Bank 1, and is read/write addressable using register addressing mode. A reset clears LVDCON to "00H". This disable Low Voltage Detector Circuit, set Low voltage detector level as 4.1V. You can disable LVD at any time during normal operation by writing a "0" to LVDCON.7 for lower power consumption. Write specific value to LVDCON.1–0 to select LVD flag level. To check a voltage detector result the application program should poll the Flag bit LVDCON.5. When a "1" is detected, VDD level has drop below LVD level. Low Voltage Detector Control Register (LVDCON) F4H, Set 1, BANK 1, R/W; Reset Value: 00H MSB .7 .6 .5 Not used LVD operation enable bit 0 = Operation off 1 = Operation on .4 .3 .2 .1 .0 LSB Not used LVD Flag Level: 00 = 4.1 V 01 = 3.2 V 10 = 2.5 V 11 = 2.1 V Not used (Must be kept as “0”) LVD detector Flag bit (read only) 0 = VDD is higher than reference voltage 1 = VDD is lower than reference voltage Figure 17-1 PS031305-1017 LVD Control Register (LVDCON) 17-2 S3F8S28/S3F8S24 Product Specification Chapter 17. Low Voltage Detector VDD Pin Low Voltage Detector LVDCON.5 Flag LVD out LVDCON.7 LVD run Flag Voltage Level Setting LVDCON.1 to LVDCON.0 Set the Flag level Figure 17-2 PS031305-1017 Block Diagram for Low Voltage Detector 17-3 S3F8S28/S3F8S24 Product Specification Chapter 17. Low Voltage Detector 17.3 Voltage (VDD) Level Detection Sequence-LVD Usage • STEP 0: Don’t make LVD on in normal conditions for small current consumption. • STEP 1: For initializing analog comparator, write #80h to LVDCON. (Comparator initialization, LVD enable) • STEP 2: Write value to reference voltage setting bits in LVDCON. (Voltage setting, LVD enable) • STEP 3: Wait 10 to 20usec for comparator operation time (Wait compare time) • STEP 4: Check result by loading voltage level set bit in LVDCON. (Check result) • STEP 5: For another measurement, repeat above steps. Example 17-1 LVD Using Method LD LVDCON, #80H ; Comparator initialization, LVD enable (STEP 1) LD LVDCON, #10000011B ; 2.1V detection voltage setting, LVD enable (STEP 2) NOP NOP NOP • ; Wait 10 to 20usec (STEP 3) • • LD R0, LVDCON ; Load LVDCON to R0 (STEP 4) TM R0, #00010000B ; Check bit 5 of R0. If bit 5 is "H", VDD is lower than 2.1V. JP NZ, LOW_VDD ; If not zero (bit 5 is "H"), jump to "LOW_VDD" routine. LOW_VDD: ; Take action when Low VDD detected. • • • PS031305-1017 17-4 S3F8S28/S3F8S24 Product Specification 18 Chapter 18. Embedded Flash Memory Interface Embedded Flash Memory Interface 18.1 Overview The S3F8S28/S3F8S24 has an on-chip Flash memory internally instead of masked ROM. The Flash memory is accessed by instruction "LDC". This is a sector erasable and a byte programmable Flash. User can program the data in a Flash memory area any time you want. The S3F8S28/S3F8S24 embedded 8K / 4Kbyte memory has two operating features as below: • Tool Program Mode: Refer to the chapter 18. S3F8S28/S3F8S24 Flash MCU • User Program Mode 18.1.1 Flash ROM Configuration The S3F8S28/S3F8S24 Flash memory consists of 64 sectors. Each sector consists of 128bytes. So, the total size of Flash memory is 64  128 (8KB) or 32 128bytes (4KB). User can erase the Flash memory by a sector unit at a time and write the data into the Flash memory by a byte unit at a time. • 8K/4Kbyte Internal Flash memory • Sector size: 128 bytes • 10years data retention − Fast programming Time: − Sector Erase: 8ms (min.) − Byte Program: 25us (min.) • Byte programmable • User programmable by "LDC" instruction • Sector (128 bytes) erase available • Endurance: 100,000 Erase/Program cycles (min.) PS031305-1017 18-1 S3F8S28/S3F8S24 Product Specification Chapter 18. Embedded Flash Memory Interface 18.1.2 Tool Program Mode This mode is for erasing and programming full area of Flash memory by external programming tools. The 5 pins of S3F8S28/S3F8S24 are connected to a programming tool and then internal Flash memory of S3F8S28/S3F8S24 can be programmed by serial OTP/MTP Tools, SPW2 plus single programmer or GW-PRO2 gang programmer and so on. The other modules except Flash memory module are at a reset state. This mode doesn’t support the sector erase but chip erase (all Flash memory erased at a time) and two protection modes (Hard lock protection/Read protection). The read protection mode is available only in tool program mode. So in order to make a chip into read protection, you need to select a read protection option when you write a program code to a chip in tool program mode by using a programming tool. After read protect, all data of Flash memory read "00". This protection is released by chip erase execution in the tool program mode. Table 18-1 Main Chip Pin Name Descriptions of Pins Used to Read/Write the Flash in Tool Program Mode During Programming Pin Name Pin No. I/O Function Serial data pin (output when reading, Input when writing) Input and push-pull output port can be assigned P0.1 SDAT 22 (24-pin), 18 (20-pin) I/O P0.0 SCLK 23 (24-pin), 19 (20-pin) I Serial clock pin (input only pin) RESET/P1.2 VPP 4 I Power supply pin for Tool mode entering (indicates that MTP enters into the Tool mode). When 11V is applied, MTP is in Tool mode. 24 (24-pin), 20 (20-pin), 1 (24-pin), 1 (20-pin), I Logic power supply pin. VDD/VSS VDD/VSS 18.1.3 User Program Mode This mode supports sector erase, byte programming, byte read and one protection mode (Hard Lock Protection). The S3F8S28/S3F8S24 has the internal pumping circuit to generate high voltage. To program a Flash memory in this mode several control registers will be used. There are four kind functions in user program mode-programming, reading, sector erase, and one protection mode (Hard lock protection). PS031305-1017 18-2 S3F8S28/S3F8S24 Product Specification Chapter 18. Embedded Flash Memory Interface 18.2 Flash Memory Control Registers (User Program Mode) 18.2.1 Flash Memory Control Register (FMCON) FMCON register is available only in user program mode to select the Flash memory operation mode; sector erase, byte programming, and to make the Flash memory into a hard lock protection. Flash Memory Control Register (FMCON) ECH, Bank 1, R/W MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB Flash (Erase or Hard Lock Protection) Operation Start Bit Flash Memory Mode Selection Bits 0101 = Programming mode 1010 = Erase mode 0110 = Hard lock mode Others = Not used for S3F8S24 0 = Operation stop 1 = Operation start (This bit will be cleared automatically just after erase operation.) Not used for S3F8S28/F8S24. Figure 18-1 Flash Memory Control Register (FMCON) The bit 0 of FMCON register (FMCON.0) is a bit for the operation start of Erase and Hard Lock Protection. Therefore, operation of Erase and Hard Lock Protection is activated when you set FMCON.0 to "1". If you write FMCON.0 to 1 for erasing, CPU is stopped automatically for erasing time (min.4ms). After erasing time, CPU is restarted automatically. When you read or program a byte data from or into Flash memory, this bit is not needed to manipulate. 18.2.2 Flash Memory User Programming Enable Register (FMUSR) The FMUSR register is used for a safe operation of the Flash memory. This register will protect undesired erase or program operation from malfunctioning of CPU caused by an electrical noise. After reset, the user-programming mode is disabled, because the value of FMUSR is "00000000B" by reset operation. If necessary to operate the Flash memory, you can use the user programming mode by setting the value of FMUSR to "10100101B". The other value of "10100101B", user program mode is disabled. Flash Memory User Programming Enable Register (FMUSR) EDH, Bank1 R/W MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB Flash Memory User Programming Enable Bits 10100101 = Enable user programming mode Other values: Disable user programming mode Figure 18-2 PS031305-1017 Flash Memory User Programming Enable Register (FMUSR) 18-3 S3F8S28/S3F8S24 Product Specification Chapter 18. Embedded Flash Memory Interface 18.2.3 Flash Memory Sector Address Registers There are two sector address registers for the erase or programming Flash memory. The FMSECL (Flash Memory Sector Address Register Low Byte) indicates the low byte of sector address and FMSECH (Flash Memory Address Sector Register High Byte) indicates the high byte of sector address. The FMSECH is needed for S3F8S28/F8S24 because it has 32 sectors. One sector consists of 128bytes. Each sector's address starts XX00H or XX80H, that is, a base address of sector is XX00H or XX80H. So bit.6–0 of FMSECL don't mean whether the value is "1" or "0". We recommend that it is the simplest way to load the sector base address into FMSECH and FMSECL register. When programming the Flash memory, user should program after loading a sector base address, which is located in the destination address to write data into FMSECH and FMSECL register. If the next operation is also to write one byte data, user should check whether next destination address is located in the same sector or not. In case of other sectors, user should load sector address to FMSECH and FMSECL Register according to the sector. (Refer to Example 18-2 Programming the PWM Module to Sample Specifications). Flash Memory Sector Address Register (FMSECH) EEH, Bank 1 R/W MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB Flash Memory Sector Address(High Byte) NOTE: The High- Byte flash memory sector address pointer value is the higher eight bits of the 16-bit pointer address. Figure 18-3 Flash Memory Sector Address Register (FMSECH) Flash Memory Sector Address Register (FMSECL) EFH, Bank 1 R/W MSB .7 .6 .5 .4 .3 .2 .1 .0 LSB Don't Care Flash Memory Sector Address(Low Byte) NOTE: The Low- Byte flash memory sector address pointer value is the lower eight bits of the 16-bit pointer address. Figure 18-4 PS031305-1017 Flash Memory Sector Address Register (FMSECL) 18-4 S3F8S28/S3F8S24 Product Specification Chapter 18. Embedded Flash Memory Interface 18.3 ISPTM (On-Board Programming) Sector ISPTM sectors located in program memory area can store on board program software (boot program code for upgrading application code by interfacing with I/O pin). The ISPTM sectors cannot be erased or programmed by LDC instruction for the safety of On Board Program software. The ISP sectors are available only when the ISP enable/disable bit is set 0, that is, enable ISP at the Smart Option. If you don't like to use ISP sector, this area can be used as a normal program memory (can be erased or programmed by LDC instruction) by setting ISP disable bit ("1") at the Smart Option. Even if ISP sector is selected, ISP sector can be erased or programmed in the Tool Program mode, by Serial programming tools. The size of ISP sector can be varied by settings of Smart Option. You can choose appropriate ISP sector size according to the size of On Board Program software. (Decimal) 4,095 (HEX) 0FFFH 4K-bytes Internal Program Memory Area 8FFH 255 Available ISP Sector Area FFH Interrupt Vector Area 3FH Smart Option Area 3CH 0 00H S3F8S28/F8S24 Figure 18-5 PS031305-1017 Program Memory Address Space 18-5 S3F8S28/S3F8S24 Product Specification Table 18-2 Chapter 18. Embedded Flash Memory Interface ISP Sector Size Smart Option (003EH) ISP Size Selection Bit Area of ISP Sector ISP Sector Size x – 0 0 0 100H to 1FFH (256byte) 256bytes 0 0 1 100H to 2FFH (512byte) 512bytes 0 1 0 100H to 4FFH (1024byte) 1024bytes 0 1 1 100H to 8FFH (2048byte) 2048bytes Bit 2 Bit 1 Bit 0 1 x 0 NOTE: The area of the ISP sector selected by Smart Option bit (003EH.2 to 003EH.0) cannot be erased and programmed by LDC instruction in user program mode. 18.3.1 ISP Reset Vector and ISP Sector Size If you use ISP sectors by setting the ISP enable/disable bit to "0" and the Reset Vector Selection bit to "0" at the Smart Option, you can choose the reset vector address of CPU as shown in Table 18-3 by setting the ISP Reset Vector Address Selection bits. Table 18-3 Smart Option (003EH) ISP Reset Vector Address Selection Bit Reset Vector Address Reset Vector Address After POR Usable Area for ISP Sector ISP Sector Size Bit 7 Bit 6 Bit 5 1 x x 0100H – – 0 0 0 0200H 100H to 1FFH 256 bytes 0 0 1 0300H 100H to 2FFH 512 bytes 0 1 0 0500H 100H to 4FFH 1024 bytes 0 1 1 0900H 100H to 8FFH 2048 bytes NOTE: The selection of the ISP reset vector address by Smart Option (003EH.7 to 003EH.5) is not dependent of the selection of ISP sector size by Smart Option (003EH.2 to 003EH.0). PS031305-1017 18-6 S3F8S28/S3F8S24 Product Specification Chapter 18. Embedded Flash Memory Interface 18.4 Sector Erase User can erase a Flash memory partially by using sector erase function only in user program mode. The only unit of Flash memory to be erased in the user program mode is a sector. The program memory of S3F8S28/S3F8S24 8K/4Kbytes Flash memory is divided into 64/32 sectors. Every sector has all 128byte sizes. So the sector to be located destination address should be erased first to program a new data (one byte) into Flash memory. Minimum 4ms delay time for the erase is required after setting sector address and triggering erase start bit (FMCON.0).Sector erase is not supported in tool program modes (MDS mode tool or programming tool). Sector 63 (128 byte) Sector 32 (128 byte) Sector 31 (128 byte) Sector 0 (128 byte) Figure 18-6 1FFFH (S3F8S28) 1F7FH 0FFFH (S3F8S24) 0F7FH 007FH 0000H Sector configurations in User Program Mode The sector erase procedure in user program mode 1. Set Flash Memory User Programming Enable Register (FMUSR) to "10100101B". 2. Set Flash Memory Sector Address Register (FMSECH and FMSECL). 3. Set Flash Memory Control Register (FMCON) to "10100001B". 4. Set Flash Memory User Programming Enable Register (FMUSR) to "00000000B" PS031305-1017 18-7 S3F8S28/S3F8S24 Product Specification Chapter 18. Embedded Flash Memory Interface Start SB1 FMUSR FMSECH FMSECL #0A5H ; User Programimg Mode Enable High Address of Sector Low Address of Sector ; Set Sector Base Address #10100001B ; Mode Select & Start Erase FMCON FMUSR ; Select Bank1 #00H ; User Prgramming Mode Disable SB0 ; Select Bank0 Finish One Sector Erase Figure 18-7 Sector Erase Flowchart in User Program Mode NOTE: 1. it 2. If user erases a sector selected by Flash Memory Sector Address Register FMSECH and FMSECL, FMUSR should be enabled just before starting sector erase operation. And to erase a sector, Flash Operation Start Bit of FMCON register is written from operation stop "0" to operation start "1". That bit will be cleared automatically just after the corresponding operation completed. In other words, when S3F8S28/S3F8S24 is in the condition that Flash memory user programming enable bits is enabled and executes start operation of sector erase, will get the result of erasing selected sector as user’s a purpose and Flash Operation Start Bit of FMCON register is also clear automatically. If user executes sector erase operation with FMUSR disabled, FMCON.0 bit, Flash Operation Start Bit, remains "High", which means start operation, and is not cleared even though next instruction is executed. So user should be careful to set FMUSR when executing sector erase, for no effect on other Flash sectors. Example 18-1 Sector Erase Case1. Erase one sector • • ERASE_ONESECTOR: SB1 ERASE_STOP: LD FMUSR,#0A5H ; User program mode enable LD FMSECH,#04H ; Set sector address 0400H, sector8 LD FMSECL,#00H ; among sector 0 to 32 LD FMCON,#10100001B ; Select erase mode enable & Start sector erase LD FMUSR,#00H ; User program mode disable SB0 PS031305-1017 18-8 S3F8S28/S3F8S24 Product Specification Chapter 18. Embedded Flash Memory Interface 18.5 Programming A Flash memory is programmed in one-byte unit after sector erase. The write operation of programming starts by "LDC" instruction. The program procedure in user program mode: 1. Must erase target sectors before programming. 2. Set Flash Memory User Programming Enable Register (FMUSR) to "10100101B". 3. Set Flash Memory Control Register (FMCON) to "0101000XB". 4. Set Flash Memory Sector Address Register (FMSECH and FMSECL) to the sector base address of destination address to write data. 5. Load a transmission data into a working register. 6. Load a Flash memory upper address into upper register of pair working register. 7. Load a Flash memory lower address into lower register of pair working register. 8. Load transmission data to Flash memory location area on "LDC" instruction by indirectly addressing mode 9. Set Flash Memory User Programming Enable Register (FMUSR) to "00000000B". NOTE: In programming mode, it doesn't care whether FMCON.0’s value is "0" or "1". PS031305-1017 18-9 S3F8S28/S3F8S24 Product Specification Chapter 18. Embedded Flash Memory Interface Start SB1 ; Select Bank1 FMSECH FMSECL High Address of Sector Low Address of Sector R(n) R(n+1) R(data) High Address to Write Low Address to Write 8-bit Data FMUSR #0A5H FMCON LDC #01010000B @RR(n),R(data) FMUSR #00H SB0 ; Set Secotr Base Address ; Set Address and Data ; User Program Mode Enable ; Mode Select ; Write data at flash ; User Program Mode Disable ; Select Bank0 Finish 1-BYTE Writing Figure 18-8 PS031305-1017 Byte Program Flowchart in a User Program Mode 18-10 S3F8S28/S3F8S24 Product Specification Chapter 18. Embedded Flash Memory Interface Start SB1 ; Select Bank1 High Address of Sector Low Address of Sector FMSECH FMSECL R(n) R(n+1) R(data) High Address to Write Low Address to Write 8-bit Data FMUSR #0A5H FMCON #01010000B ; Set Secotr Base Address ; Set Address and Data ; User Program Mode Enable ; Mode Select ; Write data at flash LDC @RR(n),R(data) ; User Program Mode Disable YES Write again? NO NO Same Sector? FMUSR #00H ; User Program Mode Disable ;; Check Sector YES NO SB0 Continuous address? ; Select Bank0 ;; Check Address Finish Writing YES INC ;; Increse Address R(n+1) YES Different Data? R(data) New 8-bit Data ;; Update Data to Write NO Figure 18-9 PS031305-1017 Program Flowchart in a User Program Mode 18-11 S3F8S28/S3F8S24 Product Specification Example 18-2 Chapter 18. Embedded Flash Memory Interface 1Byte Programming Case1. 1-Byte Programming • • WR_BYTE: ; Write data "AAH" to destination address 0310H SB1 LD FMUSR,#0A5H ; User program mode enable LD FMCON,#01010000B ; Selection programming mode LD FMSECH,#03H ; Set the base address of sector (0300H) LD FMSECL,#00H LD R9,#0AAH ; Load data "AA" to write LD R10,#03H ; Load Flash memory upper address into upper register of LD R11,#10H LDC @RR10,R9 ; Write data "AAH" at Flash memory location (0310H) LD FMUSR,#00H ; User program mode disable ; pair working; register ; Load Flash memory lower address into lower register of ; pair working; register SB0 Case2. Programming in the same sector • • ; RR10 → Address copy (R10-high address, R11-low address) WR_INSECTOR: LD R0, #40H SB1 LD FMUSR,#0A5H ; User program mode enable LD FMCON,#0101000 ; Selection programming mode and Start programming LD FMSECH,#06H ; Set the base address of sector located in target address ; to write data LD FMSECL,#00H ; The sector 12’s base address is 0600H. LD R9,#33H ; Load data "33H" to write LD R10,#06H ; Load Flash memory upper address into upper register of LD R11, #00H ; pair working register ; Load Flash memory lower address into lower register of ; pair working register WR_BYTE: LDC @RR10,R9 INC R11 DEC R0 JP NZ,WR_BYTE LD FMUSR,#00H ; Write data "33H" at Flash memory location ; Reset address in the same sector by INC instruction ; Check whether the end address for programming reach 0640H ; or not. ; User Program mode disable SB0 PS031305-1017 18-12 S3F8S28/S3F8S24 Product Specification Chapter 18. Embedded Flash Memory Interface Case3. Programming to the Flash memory space located in other sectors • • WR_INSECTOR2: LD R0, #40H LD R1, #40H SB1 LD LD FMUSR, #0A5H LD FMCON, #01010000B FMSECH, #01H ; User program mode enable ; Selection programming mode and Start programming ; Set the base address of sector located in target address ; to write data LD FMSECL, #00H ; The sector 2’s base address is 100H LD R9, #0CCH LD R10, #01H LD R11, #40H CALL WR_BYTE LD R0, #40H LD FMSECH, #02H LD FMSECL, #80H LD R9, # 55H LD R10, #02H ; Load Flash memory upper address into upper R11, #90H ; Load Flash memory lower address into lower ; Load data "CCH" to write ; Load Flash memory upper address into upper register of ; pair working register ; Load Flash memory lower address into lower register of ; pair working register WR_INSECTOR5: ; Set the base address of sector located in target address to write data ; The sector 5’s base address is 0280H ; Load data "55H" to write register of pair working register LD register of pair working register CALL WR_BYTE WR_INSECTOR12: LD FMSECH,#06H ; Set the base address of sector located in target address LD FMSECL,#00H ; The sector 12’s base address is 0600H LD R9,#0A3H ; Load data "A3H" to write LD R10,#06H LD R11,#40H ; to write data ; Load Flash memory upper address into upper register of ; pair working register ; Load Flash memory lower address into lower register of ; pair working register WR_BYTE1: LDC @RR10, R9 INC R11 DEC R1 JP NZ, WR_BYTE1 LD FMUSR,#00H ; Write data "A3H" at Flash memory location ; User Program mode disable SB0 • PS031305-1017 18-13 S3F8S28/S3F8S24 Product Specification Chapter 18. Embedded Flash Memory Interface • WR_BYTE: LDC @RR10,R9 INC R11 DEC R0 JP NZ, WR_BYTE ; Write data written by R9 at Flash memory location RET 18.6 Reading The read operation starts by "LDC" instruction. The program procedure in user program mode: 1. Load a Flash memory upper address into upper register of pair working register. 2. Load a Flash memory lower address into lower register of pair working register. 3. Load receive data from Flash memory location area on "LDC" instruction by indirectly addressing mode Example 18-3 Reading • • LD R2,#03H LD R3,#00H ; Load Flash memory’s upper address to upper register of pair working ; register ; Load Flash memory’s lower address to lower register of pair working ; register LOOP: LDC R0,@RR2 INC R3 CP R3,#0FFH JP NZ,LOOP ; Read data from Flash memory location (Between 300H and 3FFH) • • • • PS031305-1017 18-14 S3F8S28/S3F8S24 Product Specification Chapter 18. Embedded Flash Memory Interface 18.7 Hard Lock Protection User can set Hard Lock Protection by writing "0110B" in FMCON7–4. This function prevents the changes of data in a Flash memory area. If this function is enabled, the user cannot write or erase the data in a Flash memory area. This protection can be released by the chip erase execution in the tool program mode. In terms of user program mode, the procedure of setting Hard Lock Protection is following that. In tool mode, the manufacturer of serial tool writer could support Hardware Protection. Please refer to the manual of serial program writer tool provided by the manufacturer. The program procedure in user program mode: 1. Set Flash Memory User Programming Enable Register (FMUSR) to "10100101B". 2. Set Flash Memory Control Register (FMCON) to "01100001B". 3. Set Flash Memory User Programming Enable Register (FMUSR) to "00000000B". Example 18-4 Hard Lock Protection • • SB1 LD FMUSR,#0A5H ; User program mode enable LD FMCON,#01100001B ; Select Hard Lock Mode and Start protection LD FMUSR,#00H ; User program mode disable SB0 • • PS031305-1017 18-15 S3F8S28/S3F8S24 Product Specification 19 Chapter 19. Electrical Data Electrical Data 19.1 Overview In this section, the following S3F8S28/S3F8S24 electrical characteristics are presented in tables and graphs: • Absolute maximum ratings • D.C. electrical characteristics • A.C. electrical characteristics • Input timing measurement points • Oscillator characteristics • Oscillation stabilization time • Operating voltage range • Schmitt trigger input characteristics • Data retention supply voltage in stop mode • Stop mode release timing when initiated by a RESET • UART Timing Characteristics • A/D converter electrical characteristics • LVD circuit characteristics • LVR circuit characteristics • LVR reset timing Table 19-1 Absolute Maximum Ratings (TA = 25C) Parameter Supply voltage Symbol Conditions Rating Unit VDD – – 0.3 to + 6.5 V Input voltage VI All ports – 0.3 to VDD + 0.3 V Output voltage VO All output ports – 0.3 to VDD + 0.3 V Output current high IOH One I/O pin active – 25 mA – All I/O pins active – 80 – IOL One I/O pin active + 30 mA – All I/O pins active + 150 – – Output current low – Operating temperature Storage temperature PS031305-1017 TA – – 40 to + 85 C TSTG – – 65 to + 150 C 19-1 S3F8S28/S3F8S24 Product Specification Table 19-2 Chapter 19. Electrical Data DC Electrical Characteristics (TA = – 40C to + 85C, VDD = 1.8V to 5.5V) Parameter Operating voltage Symbol VDD HG main crystal or ceramic frequency fHGmain LG Main crystal or ceramic frequency fLGmain Conditions Min. Typ. Max. fHGmain = 0.4 – 4MHz 1.8 – 5.5 fHGmain = 0.4 – 12MHz 2.7 – 5.5 fLGmain = 0.1 – 1MHz 1.8 – 5.5 VDD = 2.7V to 5.5V 0.4 – 12 VDD = 1.8V to 5.5V 0.4 – 4 Unit V MHz – 1 – VDD VDD = 1.8V to 5.5V 0.4 VIH1 Ports 0, 1, 2 and RESET 0.8 VDD VIH2 XIN and XOUT VIL1 Ports 0, 1, 2 and RESET VIL2 XIN and XOUT Output high voltage VOH IOH = – 10mA Ports 0,2, P1.0-P1.1 VDD = 4.5 to 5.5V VDD – 1.5 VDD – 0.4 – V Output low voltage VOL IOL = 25mA Ports 0,2, P1.0-P1.1 VDD = 4.5 to 5.5V – 0.4 2.0 V ILIH1 All input except ILIH2, P1.21 VIN = VDD – – ILIH2 XIN VIN = VDD ILIL1 All input except ILIL2 VIN = 0V Input high voltage Input low voltage Input high leakage current Input low leakage current VDD = 1.8 to 5.5V VDD = 1.8 to 5.5V VDD – 0.1 – – 0.2VDD V V 0.1 1 A 20 – –1 A – 20 – – ILIL2 XIN VIN = 0V Output high leakage current ILOH All output pins VOUT = VDD – – 2 A Output low leakage current ILOL All output pins VOUT = 0V – – –2 A Pull-up resistors RP1 VIN = 0V, TA = 25C Ports 0, 1, 2 VDD = 5V 25 50 100 Pull-down resistors RP2 VIN = 0V, TA = 25C P1.0-P1.11 VDD = 5V 25 50 100 Run mode 10MHz CPU clock HG oscillator mode VDD = 4.5 to 5.5V – 2 4 Run mode 0.5MHz CPU clock LG oscillator mode VDD = 3.0V Supply current (2) PS031305-1017 IDD1 k mA – 0.13 – 19-2 S3F8S28/S3F8S24 Product Specification Parameter Symbol IDD2 Conditions Idle mode 10MHz clock HG oscillator mode Stop mode with Ring OSC clock (LVR disable) IDD3 Stop mode Chapter 19. Electrical Data Min. Typ. Max. VDD = 4.5 to 5.5V – 1.5 3.0 VDD = 3.0V – 1.8 3.6 VDD = 2.0V – 1.2 2.4 VDD = 3.0 (LVR disable) TA = 25C 0.3 1.0 VDD = 4.5 to 5.5V (LVR disable) TA = 25C 0.3 2.0 VDD = 4.5 to 5.5V (LVR disable) TA = – 40C to + 85C Unit A – VDD = 4.5 to 5.5V (LVR enable) TA = – 40C to + 85C 1.0 4.0 40 80 NOTE: 1. P1.2 have intrinsic internal pull-down resistor (Internal VPP circuit), the typical value is about 300Kohm. 2. Supply current does not include current drawn through internal pull-up resistors or external output current loads and ADC module. Table 19-3 AC Electrical Characteristics (TA = – 40C to + 85C, VDD = 1.8V to 5.5V) Parameter Symbol Conditions Min. Typ. Max. Unit Interrupt input low width tINTL INT0, INT1 VDD = 5 V  10 % 500 – – ns RESET input low width tRSL Input VDD = 5 V  10 % 10 – – us PS031305-1017 19-3 S3F8S28/S3F8S24 Product Specification tINTL Chapter 19. Electrical Data tINTH 0.8 VDD XIN 0.2 VDD Figure 19-1 Input Timing Measurement Points Table 19-4 Oscillator Characteristics (TA = – 40C to + 85C) Oscillator Clock Circuit XIN Main crystal or ceramic XOUT XIN External clock (Main System) Internal RC oscillator Tolerance of internal RC Internal ring OSC XOUT – – Test Condition Min. Typ. Max. Unit VDD = 2.7 to 5.5V HG oscillator mode 0.4 – 121 MHz VDD 1 = 1.8 to 5.5V HG oscillator mode 0.4 – 4 MHz VDD = 1.8 to 5.5V LG oscillator mode 0.1 – 1 MHz VDD = 2.7 to 5.5V 0.4 – 12 MHz VDD = 1.8 to 5.5V 0.4 – 4 MHz 7.92 8 8.08 3.96 4 4.04 1.98 2 2.02 0.99 1 1.01 495 500 505 kHz VDD = 1.8 to 5.0V TA = 25C – ±0.5 ±1 % VDD = 1.8 to 5.5V TA = – 40C to + 85C – – ±3.5 % 32.768 49.152 VDD = 5V TA =25C, Tolerance:1% – VDD = 5V, TA = 25C, Run Mode (After trimming) 16.384 – VDD = 5V, TA = 25C, Stop Mode (After trimming) – MHz kHz 24 40.2 NOTE: 1. Please refer to the figure of Operating Voltage Range. 2. Ring OSC frequency will decrease in Stop Mode while VDD is not changed. PS031305-1017 19-4 S3F8S28/S3F8S24 Product Specification Table 19-5 Chapter 19. Electrical Data Oscillation Stabilization Time (TA = − 40°C to + 85°C, VDD = 1.8V to 5.5V) Oscillator Main crystal Main ceramic External clock (main system) Oscillator stabilization wait time Test Condition Min. Typ. Max. Unit fOSC  1.0MHz Oscillation stabilization occurs when VDD is equal to the minimum oscillator voltage range. – – 20 ms – – 10 ms XIN input high and low width (tXH, tXL) 25 – 500 ns tWAIT when released by a reset (1) – 219/fOSC – ms tWAIT when released by an interrupt (2) – – – ms NOTE: 1. fOSC is the oscillator frequency. 2. in The duration of the oscillator stabilization wait time, tWAIT, when it is released by an interrupt is determined by the settings the basic timer control register, BTCON. CPU Clock 12 MHz 6 MHz 4 MHz 2 MHz 0.1 MHz 1 2 2.7 3 4 4.5 5 5.5 6 7 Supply Voltage (V) Figure 19-2 PS031305-1017 Operating Voltage Range 19-5 S3F8S28/S3F8S24 Product Specification Chapter 19. Electrical Data VOUT VDD A = 0.2 VDD B = 0.4 VDD C = 0.6 VDD D = 0.8 VDD VSS A B 0.3 VDD Figure 19-3 Table 19-6 C D VIN 0.7 VDD Schmitt Trigger Input Characteristics Diagram Data Retention Supply Voltage in Stop Mode (TA = – 40C to + 85C, VDD = 1.8V to 5.5V) Parameter Symbol Conditions Data retention supply voltage VDDDR Stop mode Data retention supply current IDDDR Stop mode; VDDDR = 2.0V Min. Typ. Max. Unit 2.0 – 5.5 V – 0.1 5 A NOTE: Supply current does not include current drawn through internal pull-up resistors or external output current loads. Figure 19-4 PS031305-1017 Stop Mode Release Timing When Initiated by a RESET 19-6 S3F8S28/S3F8S24 Product Specification Table 19-7 Chapter 19. Electrical Data UART Timing Characteristics in Mode 0 (10MHz) (TA = – 40C to + 85C, VDD = 1.8V to 5.5V, Load capacitance = 80pF) Parameter Symbol Min. Typ. Max. Serial port clock cycle time tSCK 500 tCPU  6 700 Output data setup to clock rising edge tS1 300 tCPU  5 – Clock rising edge to input data valid tS2 – – 300 Output data hold after clock rising edge tH1 tCPU − 50 tCPU – Input data hold after clock rising edge tH2 0 – – Serial port clock High, Low level width tHIGH, tLOW 200 tCPU  3 400 Unit ns NOTE: 1. All timings are in nanoseconds (ns) and assume a 10MHz CPU clock frequency 2. The unit tCPU means one CPU clock period. tSCK tHIGH tLOW 0.8 VDD 0.2 VDD Figure 19-5 PS031305-1017 Waveform for UART Timing Characteristics 19-7 S3F8S28/S3F8S24 Product Specification Table 19-8 Chapter 19. Electrical Data A/D Converter Electrical Characteristics (TA = – 40C to + 85C, VDD = 2.7V to 5.5V, VSS = 0V) Parameter Symbol Test Conditions Min. Typ. Max. Unit Resolution – – – 12 – bit Total accuracy – −3 1 6 Integral linearity error ILE " – 0.8  2 Differential linearity error DLE " – 0.6  1 Offset error of top EOT " –3 1 6 Offset error of bottom EOB " –3 1 6 Conversion time (1) tCON fOSC = 10MHz fADC = fOSC /12 = 10MHz/12 – 20.4 – s Sampling time tSMP fOSC = 10MHz fADC = fOSC /12 = 10MHz/12 – 5 – 1/fADC ADC clock input fADC – – – 850 kHz Analog input voltage VIAN – VSS – VDD V Analog input impedance RAN – 2 – – M Analog input current IADIN VDD = 5V – – 10 A VDD = 5V – 1 3 mA VDD = 3V – 0.5 1.5 – VDD = 5V power down mode – 100 500 nA Analog block current (2) IADC VDD = 5.12V fADC = 850kHz VSS = 0V LSB NOTE: 1. "Conversion time" is the time required from the moment a conversion operation starts until it ends. 2. IADC is operating current during A/D conversion. PS031305-1017 19-8 S3F8S28/S3F8S24 Product Specification Table 19-9 Chapter 19. Electrical Data LVD Circuit Characteristics (TA = – 40 to 85C, VDD = 1.8V to 5.5V) Parameter LVD Detect Voltage Symbol Conditions Min. Typ. Max. VLVD0 – 4.0 4.1 4.2 VLVD1 – 3.1 3.2 3.3 VLVD2 – 2.4 2.5 2.6 VLVD3 – 2.0 2.1 2.2 Table 19-10 Unit V LVR Circuit Characteristics (TA = – 40 to 85C, VDD = 1.8V to 5.5V) Parameter Symbol Low voltage reset VLVR Conditions Min. Typ. Max. Unit – 1.8 2.2 2.9 3.8 1.9 2.3 3.0 3.9 2.0 2.4 3.1 4.0 V VDD VLVR,MAX VLVR VLVR,MIN Figure 19-6 PS031305-1017 LVR Reset Timing 19-9 S3F8S28/S3F8S24 Product Specification Table 19-11 Chapter 19. Electrical Data Flash Memory AC Electrical characteristics (TA = – 40C to + 85C at VDD = 1.8V to 5.5V) Parameter Symbol Conditions Min. Typ. Max. Unit Fewrv VDD 1.8 5.0 5.5 V 20 – 30 S 32 – 70 mS 4 – 12 mS Flash erase/write/read voltage Programming time (1) Chip erasing time Ftp (2) − Ftp1 Sector erasing time (3) Ftp2 Data access time FtRS VDD = 2.0V – 250 – nS Number of writing/erasing FNwe – 10,000 – – Times Ftdr – 10 – – Years Data retention NOTE: 1. The programming time is the time during which one byte (8-bit) is programmed. 2. The chip erasing time is the time during which entire program memory is erased. 3. The sector erasing time is the time during which all 128byte block is erased. 4. The chip erasing is available in tool program mode only. 104 VSS VDD S3F8S28/F8S24 Figure 19-7 The Circuit Diagram to Improve EFT Characteristics NOTE: To improve EFT characteristics, we recommend using power capacitor near S3F8S28/F8S24 like Figure 19-7. PS031305-1017 19-10 S3F8S28/S3F8S24 Product Specification Table 19-12 Parameter Electrostatic discharge PS031305-1017 Symbol VESD Chapter 19. Electrical Data ESD Characteristics Conditions Min. Typ. Max. Unit HBM 2000 – – V MM 200 – – V CDM 500 – – V 19-11 S3F8S28/S3F8S24 Product Specification 20 Chapter 20. Mechanical Data Mechanical Data 20.1 Overview The S3F8S28/S3F8S24 is available in a 24-pin SOP package (Zilog: 24-SOP-375), a 24-pin TSSOP package (Zilog: 24-TSSOP-BD44), a 20-pin DIP package (Zilog: 20-DIP-300A), a 20-pin SOP package (Zilog: 20-SOP375), a 20-pin SSOP package (Zilog: 20-SSOP-225). Package dimensions are shown in Figure 20-1, Figure 20-2, Figure 20-3, and Figure 20-4. 0-8 #24 #12 0.20 2.35  0.10 #1 15.74 MAX 15.34  0.20 + 0.10 - 0.05 0.87  0.20 7.50  0.20 24-SOP-375 2.50 MAX 10.30  0.30 #13 1.27 (0.69) 0.38 NOTE: + 0.10 - 0.05 Dimensions are in millimeters. Figure 20-1 PS031305-1017 0.05 MIN 0.10 MAX 24-SOP-375 Package Dimensions 20-1 S3F8S28/S3F8S24 Product Specification Chapter 20. Mechanical Data 0-8 #13 24-TSSOP-BD44 #12 0.25 1.20 MAX #1 0.62  0.12 4.40  0.10 6.40  0.15 #24 7.80  0.10 0.10 MAX 0.65 0.25 NOTE: + 0.05 - 0.05 Dimensions are in millimeters. Figure 20-2 PS031305-1017 24-TSSOP-BD44 Package Dimensions 20-2 S3F8S28/S3F8S24 Product Specification #11 0-15 0.2 5 20-DIP-300A +0 . - 0 10 .05 7.62 6.40  0.20 #20 Chapter 20. Mechanical Data 0.46  0.10 (1.77) NOTE : 1.52  0.10 Dimensions are in millimeters. Figure 20-3 PS031305-1017 2.54 5.08 MAX 26.40  0.20 3.30  0.30 26.80 MAX 3.25  0.20 #10 0.51 MIN #1 20-DIP-300A Package Dimensions 20-3 S3F8S28/S3F8S24 Product Specification Chapter 20. Mechanical Data 0-8 + 0.10 #10 0.203 - 0.05 2.30  0.10 #1 13.14 MAX 12.74  0.20 0.85  0.20 20-SOP-375 9.53 7.50  0.20 #11 2.50 MAX 10.30  0.30 #20 1.27 (0.66) 0.40 NOTE : + 0.10 - 0.05 Dimensions are in millimeters. Figure 20-4 PS031305-1017 0.05 MIN 0.10 MAX 20-SOP-375 Package Dimensions 20-4 S3F8S28/S3F8S24 Product Specification Chapter 20. Mechanical Data 0-8 #10 6.90 MAX 6.50  0.20 + 0.10 - 0.05 1.85 MAX 0.15 1.50  0.10 #1 0.50  0.20 20-SSOP-225 5.72 4.40  0.10 #11 6.40  0.20 #20 (0.30) 0.65 +0.10 0.22 -0.05 NOTE: Dimensions are in millimeters. Figure 20-5 PS031305-1017 0.05 MIN 0.10 MAX 20-SSOP-225 Package Dimensions 20-5 S3F8S28/S3F8S24 Product Specification 21 Chapter 21. Flash MCU Flash MCU 21.1 Overview The S3F8S28/S3F8S24 single-chip CMOS microcontroller is the Flash MCU. It has an on-chip Flash MCU ROM of 8K/4Kbytes. The Flash ROM is accessed by serial data format. The serial data is transformed by two pins of the chip: SCLK and SDAT, SCLK is the synchronize signal, and the Flash Programmer Tool send data from the SDAT pin. The corresponding ports of SCLK and SDAT in S3F8S28/S3F8S24 are P0.0 and P1.1. And there also need power supply for chip to work and higher power for entering Flash tool mode. So the VDD, VSS of chip must be connected to power and ground. The higher power supply for the Flash operation is named as VPP port, the corresponding pin in S3F8S28/S3F8S24 is nRESET (P1.2) pin. The detail description of the pin functions are listed in the Table 21-1. The pin assignments of the S3F8S28/S3F8S24 package types are shown in below figures. NOTE: 1. This chapter is about the Tool Program Mode of Flash MCU. If you want to know the User Program Mode, refer to the chapter 18 Embedded Flash Memory Interface. 2. In S3F8S28/S3F8S24, there only 5 pins are used as Flash operation pins, the nRESET pin is used as VPP input and without TEST pin that different with other Zilog MCU products. PS031305-1017 21-1 S3F8S28/S3F8S24 Product Specification VSS 1 24 VDD XIN/P1.0 2 23 P0.0/ADC0/INT0/SCLK XOUT/P1.1 3 22 P0.1/ADC1/INT1/SDAT VPP/nRESET/P1.2 4 21 P0.2/ADC2/INT2/SCK T0/P2.0 5 20 P0.3/ADC3/INT3/SDA INT6/P3.2 6 19 P3.0/ADC11/INT4 INT7/P3.3 7 18 P3.1/ADC12/INT5 T1/P2.1 8 17 P0.4/ADC4 RxD/T1CAP/P2.2 9 16 P0.5/ADC5/PWM1 TxD/P2.3 10 15 P0.6/ADC6/PWM0 ADC10/P2.4 11 14 P0.7/ADC7 ADC9/P2.5 12 13 P2.6/ADC8/CLO NOTE: Figure 21-1 S3F8S28/F8S24 (24-SOP-375/ 24-TSSOP-BD44) The bolds indicate MTP pin name. S3F8S28/S3F8S24 Pin Assignments (24-DIP/24-SOP) VSS 1 20 VDD XIN/P1.0 2 19 P0.0/ADC0/INT0/SCLK XOUT/P1.1 3 18 P0.1/ADC1/INT1/SDAT VPP/nRESET/P1.2 4 17 P0.2/ADC2/INT2/SCK T0/P2.0 5 16 P0.3/ADC3/INT3/SDA T1/P2.1 6 15 P0.4/ADC4 RxD/T1CAP/P2.2 7 14 P0.5/ADC5/PWM1 TxD/P2.3 8 13 P0.6/ADC6/PWM0 ADC10/P2.4 9 12 P0.7/ADC7 ADC9/P2.5 10 11 P2.6/ADC8/CLO NOTE: Figure 21-2 PS031305-1017 Chapter 21. Flash MCU S3F8S28/F8S24 (20-DIP-300A/ 20-SOP-375 20-SSOP-225) The bolds indicate MTP pin name. S3F8S28/S3F8S24 Pin Assignments (20-DIP/20-SOP/20-SSOP) 21-2 S3F8S28/S3F8S24 Product Specification Table 21-1 Chapter 21. Flash MCU Descriptions of Pins Used to Read/Write the EPROM Main Chip During Programming Pin Name Pin Name Pin No. I/O Function P0.1 SDAT 22 (24-pin), 18 (20-pin) I/O Serial data pin (output when reading, Input when writing) Input and push-pull output port can be assigned P0.0 SCLK 23 (24-pin), 19 (20-pin) I Serial clock pin (input only pin) RESET/P1.2 VPP 4 I Power supply pin for Tool mode entering (indicates that MTP enters into the Tool mode). When 11V is applied, MTP is in Tool mode. VDD/VSS 24 (24-pin), 20 (20-pin), 1 (24-pin), 1 (20-pin), I Logic power supply pin. VDD/VSS NOTE: Parentheses indicate pin number for 20-DIP-300A package. Table 21-2 Comparison of S3F8S28/S3F8S24 Features Characteristic S3F8S28/S3F8S24 Program memory 8K/4Kbyte Flash ROM Operating voltage (VDD) 2.0V to 5.5V Flash MCU programming mode VDD = 5.0V, VPP (nRESET) = 11V Pin configuration 24-SOP/24-TSSOP/20-DIP/20-SOP/20-SSOP Programmability User program multi time PS031305-1017 21-3 S3F8S28/S3F8S24 Product Specification Chapter 21. Flash MCU 21.2 On Board Writing The S3F8S28/S3F8S24 needs only 5 signal lines including VDD and GND pins for writing internal Flash memory with serial protocol. Therefore the on-board writing is possible if the writing signal lines are considered when the PCB of application board is designed. Circuit Design Guide: At the Flash writing, the writing tool needs 5 signal lines that are GND, VDD, VPP, SDAT and SCLK. When you design the PCB circuits, you should consider the usage of these signal lines for the on-board writing. In case of VPP (nRESET) pin, for the purpose of increase the noise effect, a capacitor should be inserted between the VPP pin and GND. Please be careful to design the related circuit of these signal pins because rising/falling timing of VPP, SCLK and SDAT is very important for proper programming. RSCL To Application circuit SCLK (I/O) RSDA To Application circuit SDAT (I/O) VPP (nRESET) CVpp VDD VPP VSS To Application circuit C RESET VDD SDA SCL CVpp are used to Improve The noise effect GND SPW-uni , GW-uni , AS -pro, US-pro Figure 21-3 PS031305-1017 PCB Design Guide for on Board Programming 21-4 S3F8S28/S3F8S24 Product Specification Table 21-3 Chapter 21. Flash MCU Reference Table for Connection Pin Name I/O Mode in Applications Resistor (Need) VPP (nRESET) Input Yes CVpp is 0.01uF to 0.02uF. Input Yes RSDAT is 2k to 5k. Output No (NOTE) Input Yes SDAT (I/O) SCLK (I/O) Output No Required Value – RSCLK is 2k to 5k. (NOTE) – NOTE: 1. In on-board writing mode, very high-speed signal will be provided to pin SCLK and SDAT. And it will cause some damages to the application circuits connected to SCLK or SDAT port if the application circuit is designed as high speed response such as relay control circuit. If possible, the I/O configuration of SDAT, SCLK pins had better be set to input mode. 2. The value of R, C in this table is recommended value. It varies with circuit of system. PS031305-1017 21-5 S3F8S28/S3F8S24 Product Specification 22 Chapter 22. Development Tools Development Tools 22.1 Overview Zilog offers software and hardware tools for S3 application development. Alternatively, a complete suite of 3rd party tools can be used. Applications targeting S3F8-series microcontrollers can use either the low-cost Zilog librarybased Development Platform toolset or more sophisticated 3rd party emulator-based development tools. Applications targeting S3C8-series microcontrollers typically require the use of 3rd party emulator-based development tools. Section 22.2 describes using 3rd party emulators (such as the OPENice i500 or i2000) to interface with a devicespecific target board for application development on S3C8-series (or S3F8-series) microcontrollers. Section 22.3 describes the Zilog library-based Development Platform for Flash-based S3F8-series microcontrollers. 22.2 Emulator-based Development System Figure 22-1 shows an emulator-based development system utilizing an emulator to interface with an application board through a Zilog-provided Target Board. Figure 22-1 PS031305-1017 Emulator-based Development System Configuration 22-6 S3F8S28/S3F8S24 Product Specification Chapter 22. Development Tools The S3 Emulator Based Development System includes the components listed in the following sections. 22.2.1 Host Software Host software is required to create and debug S3 application programs in C or assembly language. The host software program converts the application source code into an executable format that is downloaded into the evaluation (EVA) chip on the target board for program execution/debugging. Optionally, the probe adapter cable(s) can be connected between the target board and the application board to debug program interaction with components on the application board. Zilog provides the Zilog Developer Studio (ZDS) software suite host software package free of charge for any PC running a supported version of the Windows operating system. Alternatively, 3rd party host software packages (such as the IAR Embedded Workbench host software package) are available for purchase from vendor websites. The ZDS S3 software package is available for free download from the Zilog website. 22.2.2 Target Boards Target boards are available for all S3C8/S3F8-series microcontrollers. Each target board includes the cables and adapters necessary to interface with an application board. The target board can be used with a 3rd party emulator to enable application debugging with or without an application board. Alternatively, the emulator can be used to program the target MCU on the application board using the supplied 10- circuit programming cable. The TB8S19/8S28/8S19 target board can be used with application boards targeting the S3F8S19, S3F8S28, and S3F8S39 MCUs. Figure 22-2 shows how the TB8S19/8S28/8S19 Target Board is configured. The symbol “ ” marks the starting point of the jumper signals. PS031305-1017 22-7 S3F8S28/S3F8S24 Product Specification Chapter 22. Development Tools TB8S19/8S28/8S39 Idle Stop + + VDD On U2 Off CON3 To User_VDD JP5 0 S3F8S19/39 S3F8S28 S3F8S19 S3F8S39 JP4 JP2 Chip Select Jumper 25 32 1 1 100-Pin Connector EVA Mode 8S19 Sub.CLK 38 1 Y2 1 S1 50-Pin Connector 208 QFP S3E8S30 EVA Chip U1 Emulator Interfalce 16 Y1 Main Mode 48 24 1 24-Pin Connector PWM 14 50-Pin Connector Enable Diasble JP13 3F.7 3F.6 3F.5 3F.4 3F.3 3F.2 3F.1 3F.0 3E.7 3E.6 3E.5 3E.4 3E.3 3E.2 3E.1 3E.0 RESET 0 SW2 SW3 ON GND ON SW1 15 S3F8S28 Target System Interface S3 17 S3F8S28 EX.CLK Jumper Board Clock JP10 JP5 SMDS2 JP8 JP11 JP9 S3F8S39 EX.CLK Jumper SMDS2+ JP1 Figure 22-2 JP6 JP7 S3F8S19 EX.CLK Jumper 24 S3F8S39 Target System Interface S4 25 S3F8S19 Target System Interface S2 TB8S19/8S28/8S39 Target Board Configuration NOTE: TB8S19/8S28/8S39 should be supplied 5V normally. Therefore, the power supply from Emulator should be set 5V for the target board operation. PS031305-1017 22-8 S3F8S28/S3F8S24 Product Specification Table 22-1 Symbols Chapter 22. Development Tools Components of TB8S19/8S28/8S39 Usage Description JP3, JP4 Device Selection Selection of device: S3F8S19, S3F8S28, S3F8S39 JP8, JP9 Ex.CLK selection Set external clock connect to S3F8S28/S3F8S24 EVA-chip. JP12 User's Power selection Selection of Power to User. JP2 MODE Selection Selection of Eva/Main-chip mode of S3F8S28/S3F8S24 EVAchip JP1 Emulator selection Selection of SMDS2/SMDS2+ JP5 Clock Source Selection Selection of debug with internal/external clock SW2, SW3 8-pin switch Smart Option setting for S3F8S28/S3F8S24 EVA-chip S1 100-pin connector Connection between emulator and TB8S8S28 target board. S3 24-pin connector Connection between target board and user application system RESET Push button Generation low active reset signal to S3F8S28/S3F8S24 EVAchip VCC, GND POWER connector External power connector for TB8S19/8S28/8S39 IDLE, STOP LED STOP/IDLE Display Indicate the status of STOP or IDLE of S3F8S28/F8S24 EVAchip on TB8S19/8S28/8S39 target board JP3 PWM selection Selection of PWM enable/disable Table 22-2 "Device Selection" Settings Device Selection Settings for TB8S19/8S28/8S39 Operating Mode Device Selection:JP4 8S19/39 8S28 Device Selection JP4 8S19/8S39 8S28 JP3 8S19 Comments TB8S28 Target System Operate with TB8S28 TB8S39 Target System Operate with TB8S39 TB8S19 Target System Operate with TB8S19 8S39 Device Selection JP4 8S19/39 8S28 JP3 8S19 8S39 NOTE: The following symbol in the "8S28" Setting column indicates the electrical short (off) configuration: PS031305-1017 22-9 S3F8S28/S3F8S24 Product Specification Table 22-3 Power Selection Settings for TB8S19/8S28/8S39 "To User_Vcc" Settings Operating Mode TB8S28 Comments External Target System VCC Touser_VDD off Chapter 22. Development Tools The SMDS2/SMDS2+ main board supplies VDD to the target board (evaluation chip) and the target system. V SS on VCC SMDS2/SMDS2+ TB8S28 The SMDS2/SMDS2+ main board supplies VDD only to the target board (evaluation chip). The target system must have its own power supply. Target System VCC Touser_VDD off External V SS on VCC SMDS2/SMDS2+ 22.2.3 SMDS2+ Selection (SAM8) In order to write data into program memory that is available in SMDS2+, the target board should be selected to be for SMDS2+ through a switch as follows. Otherwise, the program memory writing function is not available. Table 22-4 "JP4" Setting The SMDS2+ Tool Selection Setting Operating Mode R/W* SMDS2 PS031305-1017 SMDS2+ SMDS2+ R/W* Target System 22-10 S3F8S28/S3F8S24 Product Specification Table 22-5 Chapter 22. Development Tools Using Single Header Pins to Select Clock Source/PWM/Operation Mode Target Board Part Comments Board CLK JP5 Clock Source Use SMDS2/SMDS2+ internal clock source as the system clock. Default Setting JP5 Clock Source Use external crystal or ceramic oscillator as the system clock. Inner CLK Board CLK Inner CLK JP8 JP9 Connect Clock to S3F8S28. (JP10 to 11, JP6 to 7 off) PWM Enable JP13 PWM function is DISABLED. PWM Disable PWM Enable JP13 PWM function is ENABLED. Default Setting PWM Disable Main Mode JP2 The S3E8S30 run in main mode, just same as S3F8S28/S3F8S24. The debug interface is not available. EVA Mode Main Mode JP2 EVA Mode PS031305-1017 The S3E8S30 run in EVA mode, available. When debug program, please set the jumper in this mode. Default Setting 22-11 S3F8S28/S3F8S24 Product Specification Table 22-6 Chapter 22. Development Tools Using Single Header Pins as the Input Path for External Trigger Sources Target Board Part Comments Connector from External Trigger Sources of the Application System External Triggers Ch1(TP3) Ch2(TP4) You can connect an external trigger source to one of the two external trigger channels (CH1 or CH2) for the SK-1000/SMDS2+ breakpoint and trace functions. SW2 Low OFF High (Default) 3F.0 3F.1 3F.2 3F.7 ON 3F.3 OFF 3F.4 OFF 3F.5 ON 3F.6 ON 3E.0 3E.1 3E.2 0 3E.3 3E.5 3E.6 3E.7 3E.4 SW3 0 NOTE: 1. For EVA chip, smart option is determined by DIP switch not software. 2. Please keep the reserved bits as default value (high). Figure 22-3 DIP Switch for Smart Option • IDLE LED This is LED is ON when the evaluation chip (S3E8S30) is in idle mode. • STOP LED This LED is ON when the evaluation chip (S3E8S30) is in stop mode. PS031305-1017 22-12 S3F8S28/S3F8S24 Product Specification Chapter 22. Development Tools S3 1 24 VDD P1.0 2 23 P0.0/ADC0/INT0 P1.1 3 22 P0.1/ADC1/INT1 RESET/P1.2 4 21 P0.2/ADC2/INT2/SCK T0/P2.0 5 20 P0.3/ADC3/INT3/SDA INT6/P3.2 6 19 P3.0/ADC11/INT4 INT7/P3.3 7 18 P3.1/ADC12/INT5 T1/P2.1 8 17 P0.4/ADC4 RxD/T1CAPP2.2 9 16 P0.5/ADC5/PWM1 TxD/P2.3 10 15 P0.6/ADC6/PWM0 ADC10/P2.4 11 14 P0.7/ADC7 ADC9/P2.5 12 13 P2.6/ADC8/CLO Figure 22-4 24-PIN SOCKET VSS 24-Pin Connector for TB8S19/8S28/8S39 Target Board Target System S3 24 24 12 13 Target Cable for 24-Pin Connector 12 13 Figure 22-5 PS031305-1017 1 24-Pin Connector 24-Pin Connector 1 S3F8S28/S3F8S24 Probe Adapter for 24 Pin Package 22-13 S3F8S28/S3F8S24 Product Specification Chapter 22. Development Tools 22.3 Zilog Library-based Development Platform The Zilog developer platform is a suite of low-cost highly-integrated software and hardware tools for any PC running a supported version of Windows. The developer platform is composed of three components – the host Integrated Development Environment (IDE) software, the S3 Flash In-System Programmer (ISP) II USB interface, and a development board with a standard 10-pin ISP II connector. Together, these tools cost only a fraction of the price of most other 3rd party compilers, programmers/ emulators, or target boards. Features include: • Very low cost development tools • Easy setup • Source-level debugging using the application hardware board 22.3.1 Zilog Developer Platform Components Figure 22-6 shows the simplicity of connecting all of the components of the Zilog developer platform. Figure 22-6 Zilog Development Platform 22.3.1.1 ZDS IDE The Zilog Developer Studio (ZDS) Integrated Development Environment (IDE) is a suite of software tools that run on a Windows-based host PC. These tools include an editor used to create application programs in C or assembly, a compiler, assembler, a linker used to convert the application source code into an executable program image, and a debugger that allows the developer to single-step their application source code while it is executing on the actual target HW platform. ZDS is completely free of charge and available from the Zilog website. For more information about the features of the ZDS IDE, please refer to the Zilog Developer Studio Help file integrated within the ZDS IDE by clicking the Help Topics item available through the IDE’s Help menu, or by pressing F1 on the PC keyboard. 22.3.1.2 S3 Flash ISP II The Zilog S3 Flash ISP II is a low cost hardware interface between the PC and the application board or Zilog development board. The ISP II connects to the Windows PC through a USB cable and connects to the application or development board through a 10-pin ribbon cable. ZDS uses the ISP II to access Flash memory on the S3 target for read, erase, and program operations. Additionally, ZDS can use the S3 Flash ISP II to debug applications built with a Zilog-provided debug library. 22.3.1.3 Application/Development Board The S3 Flash ISP II communicates with the S3 microcontroller on a Zilog development board, or a customer application board, through a 10-pin ribbon cable. This requires the application or development board design to PS031305-1017 22-14 S3F8S28/S3F8S24 Product Specification Chapter 22. Development Tools include the components shown in Figure 22-7. Figure 22-7 PCB Design Guide for In System Programming Some S3 devices have a VPP/Test pin shared with a GPIO pin which can also be configured as the Reset pin. When designing a PCB that requires In-System Programming support for S3 devices with a shared VPP/ Reset pin, do not connect the Reset signal (pin 6) from the 10-pin ISP II connector to the S3 MCU. Instead, connect the MCU VPP/ Reset pin to the Test/ VPP signal (pin 2) of the ISP II connector with RRST and CRST. In this instance, it is not necessary to include RVPP or CVPP. Table 22-7 shows the recommended values for the passive components in the ISP II circuit of Figure 22.6. Table 22-7 ISP II Circuit Recommended Values ISP Signal (Pin Number) VPP/ Test (2) Passive Component CVPP = 0.1 uF RVPP = 10K VDD (4) CVDD = 0.1 uF Reset (6) CRST = 0.1 uF RRST = 40K SDAT (8) SCLK (10) GND (1,3,5,7,9) Notes If the S3 MCU has a shared VPP/Reset pin, connect the ISP II VPP/ Test pin to the MCU VPP/Test pin. The ZDS IDE and S3 Flash ISP II cannot be used to debug applications that use the GPIO pins associated with the SCLK & SDAT signals. In this instance, it is only possible to access Flash Memory in the target S3 MCU. Connect all odd number pins of the ISP connector to GND on the target board and S3 MCU Refer to the schematic diagram in the appropriate Zilog Development Kit User Manual for a complete reference design that includes an ISP II interface circuit applicable to a particular series of S3 devices. Zilog recommends keeping the traces connecting SCLK and SDAT to the ISP II connector as short as possible. PS031305-1017 22-15 S3F8S28/S3F8S24 Product Specification Chapter 22. Development Tools 22.3.2 Compatibility with 3rd Party Tools The Zilog IDE can also be used with 3rd party development tools. For example, the ZDS IDE can program a Hex file generated by a 3rd party compiler such as the IAR Embedded Workbench using the Zilog S3 Flash ISP II or a 3rd party programmer such as the OPENice-i2000 emulator. Information regarding 3rd party development tools can be found in section 22.4. 22.3.3 Benefits and Limitations of Zilog Development Tools Zilog development tools provide a low cost turnkey solution capable of creating and debugging S3 applications on Zilog development boards or customer application boards. Debugging applications on a particular S3 target typically requires the application to be built with a Zilog-provided debug library that is capable of interfacing with the S3 Flash ISP II. The debug library consumes some amount of code space on the S3 target depending on the set of debugging features supported by the particular debug library linked to the application. The ZDS IDE and S3 Flash ISP II can be used to program Flash memory on all Zilog S3 microcontrollers; however, single-step debugging support may not be available for every series of Zilog S3 microcontroller. For more information regarding the debugging features available on a particular S3 microcontroller, refer to the S3 ISP II Interface Debug Library chapter of the Zilog Developer Studio Help file available within the ZDS S3 IDE. 22.3.4 Development Tools Zilog, in conjunction with third parties, provides a complete line of development tools that support the S3 Family of Microcontrollers. With long experience in developing MCU systems, these third party firms are bonafide leaders in MCU development tool technology. In-Circuit Emulators • YIC – OPENice-i500/2000 OPENice-i500 YIC System • • • • OPENice-i2000 YIC System • • • • PS031305-1017 TEL: 82-31-278-0461 FAX: 82-31-278-0463 E-mail: support@yicsystem.com URL: http://www.yicsystem.com TEL: 82-31-278-0461 FAX: 82-31-278-0463 E-mail : support@yicsystem.com URL: http://www.yicsystem.com 22-16 S3F8S28/S3F8S24 Product Specification Chapter 22. Development Tools Zilog Library-based Development Tools • Zilog – S3USBISP000ZACG S3 Flash In-System Programmer (ISP) II • Zilog – S3F8S280100ZCOG S3F8S28/8S24 Development Kit S3USBISP000ZACG Zilog • • • • S3F8S280100ZCOG TEL: (408) 457-9000 FAX: (408) 416-0223 E-mail:s3sales@zilog.com URL: http://www.zilog.com Zilog • • • • TEL: (408) 457-9000 FAX: (408) 416-0223 E-mail:s3sales@zilog.com URL: http://www.zilog.com Programmers (Writer) • Seminix – GW-uni2 • C&A Tech – GW-Pro2 • Elnec – BeeHive series • Zilog – S3 Flash ISP II GW-uni2 Gang Programmer for OTP/MTP/FLASH MCU Seminix • Support all SAMSUNG OTP and MTP devices • • • • • • • • • • • PS031305-1017 with SAMSUNG standard serial protocol format Program up to 8 devices at one time Operation mode: 1.PC base 2.Stand-alone (no PC) Very fast programming speed: OTP(2 Kbps) MTP(10 Kbps) Maximum buffer memory:100 Mbyte Hex data file download via USB port from PC Support simple GUI (Graphical User Interface) Support data format: Intel hex, SAMSUNG hex, Binary Device information can be set by a device part number • TEL: 82-31-703-7891 FAX: 82-31-702-7869 E-mail: sales@seminix.com URL: http://www.seminix.com 22-17 S3F8S28/S3F8S24 Product Specification Chapter 22. Development Tools • LCD Display (Stand-alone mode operation) - Display an operation state • Touch key (Stand-alone mode operation) • System upgradeable - The system firmware can be upgraded simply by user GW-Pro Gang Programmer C & A Technology • Programming of 8 MCUs at a time • • • Fast programming speed (2 Kbyte/sec) • Possible without PC (standalone) • Search operation based on a PC • • Enough features to support Gang Programmer TEL: 02-2612-9027 E-mail : jhc115@cnatech.com URL: http://www.cnatech.com • Off data is also preserved • Key Lock function to prevent malfunction • Good and bad quantity counter • Program completion notification (sound) • Easy-to-use (PC) menu Beehive204 Elnec • Four independent universal programming sites • • • • • Two BeeHive 204 multiprogrammers can be • • • • • • PS031305-1017 attached to one PC to better utilize programming workplace Extremely fast programming, one of the fastest programmers in this category. Sustainable programming speed greater than 5 Mbytes per second Powerful independent pin driver circuit for each and every pin of the programmer In-circuit programming capability through ISP connector Very low voltage support for the latest Flash memory chips ESD protection on each pin of the socket’s USB (up to 480 Mbit/s) interface to PC Comfortable and easy-to-use control program; works with all versions of MS Windows from Windows XP to Windows 10 (32-bit and 64-bit) TEL: +421-51-7734328 FAX: +421-51-7732797 E-mail:tech2@elnec.com URL: http://www.elnec.com 22-18 S3F8S28/S3F8S24 Product Specification S3 Flash In-System Programmer II Zilog’s S3 Flash ISP II provides an interface between any development or application board with an S3 microcontroller device to the high-speed USB port of a PC on which Zilog Developer Studio II for S3 Family devices (ZDS II – S3) is installed. The ISP II allows the Flash memory space on any S3 Family device to be programmed, and also offers limited debugging capabilities when used together with the Zilog Debug Library. The following features are available with the S3 Flash ISP II when using ZDS II for S3 Family devices: • Download code to Flash and begin to program execution • Break program execution arbitrarily • Single-step debugging of the application, view/edit memory and S3 special function registers. Resume normal program operation after a breakpoint • Insert multiple breakpoints in a program at compile/assembly time Chapter 22. Development Tools Zilog • • • • TEL: (408) 457-9000 FAX: (408) 416-0223 E-mail: s3sales@zilog.com URL: http://www.zilog.com To obtain the S3 Family development tools that will satisfy your S3F8S28/S3F8S24 development objectives, contact your local Zilog Sales Office, or visit Zilog’s Third Party Tools page to review our list of third party tool suppliers. PS031305-1017 22-19
S3F8S28XZZ-SK98 价格&库存

很抱歉,暂时无法提供与“S3F8S28XZZ-SK98”相匹配的价格&库存,您可以联系我们找货

免费人工找货