S3P72K8XXX-QWU [SAMSUNG]

Microcontroller, 4-Bit, UVPROM, SAM 48 CPU, 6MHz, CMOS, PQFP80;
S3P72K8XXX-QWU
型号: S3P72K8XXX-QWU
厂家: SAMSUNG    SAMSUNG
描述:

Microcontroller, 4-Bit, UVPROM, SAM 48 CPU, 6MHz, CMOS, PQFP80

可编程只读存储器 时钟 微控制器
文件: 总328页 (文件大小:1166K)
中文:  中文翻译
下载:  下载PDF数据表文档文件
21-S3-C72K8/P72K8-122000  
USER'S MANUAL  
S3C72K8/P72K8  
4-Bit CMOS  
Microcontroller  
Revision 1  
S3C72K8/P72K8  
4-BIT CMOS  
MICROCONTROLLER  
USER'S MANUAL  
Revision 1  
Important Notice  
The information in this publication has been carefully  
checked and is believed to be entirely accurate at the  
time of publication. Samsung assumes no  
responsibility, however, for possible errors or  
omissions, or for any consequences resulting from  
the use of the information contained herein.  
"Typical" parameters can and do vary in different  
applications. All operating parameters, including  
"Typicals" must be validated for each customer  
application by the customer's technical experts.  
Samsung products are not designed, intended, or  
authorized for use as components in systems  
intended for surgical implant into the body, for other  
applications intended to support or sustain life, or for  
any other application in which the failure of the  
Samsung product could create a situation where  
personal injury or death may occur.  
Samsung reserves the right to make changes in its  
products or product specifications with the intent to  
improve function or design at any time and without  
notice and is not required to update this  
documentation to reflect such changes.  
This publication does not convey to a purchaser of  
semiconductor devices described herein any license  
under the patent rights of Samsung or others.  
Should the Buyer purchase or use a Samsung  
product for any such unintended or unauthorized  
application, the Buyer shall indemnify and hold  
Samsung and its officers, employees, subsidiaries,  
affiliates, and distributors harmless against all claims,  
costs, damages, expenses, and reasonable attorney  
fees arising out of, either directly or indirectly, any  
claim of personal injury or death that may be  
associated with such unintended or unauthorized use,  
even if such claim alleges that Samsung was  
negligent regarding the design or manufacture of said  
product.  
Samsung makes no warranty, representation, or  
guarantee regarding the suitability of its products for  
any particular purpose, nor does Samsung assume  
any liability arising out of the application or use of any  
product or circuit and specifically disclaims any and  
all liability, including without limitation any  
consequential or incidental damages.  
S3C72K8/P72K8 4-Bit CMOS Microcontroller  
User's Manual, Revision 1  
Publication Number: 21-S3-C72K8/P72K8-062000  
© 2000 Samsung Electronics  
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any  
form or by any means, electric or mechanical, by photocopying, recording, or otherwise, without the prior written  
consent of Samsung Electronics.  
Samsung Electronics' microcontroller business has been awarded full ISO-14001  
certification (BSI Certificate No. FM24653). All semiconductor products are  
designed and manufactured in accordance with the highest quality standards and  
objectives.  
Samsung Electronics Co., Ltd.  
San #24 Nongseo-Ri, Kiheung-Eup  
Yongin-City Kyunggi-Do, Korea  
C.P.O. Box #37, Suwon 449-900  
TEL: (82)-(331)-209-1907  
FAX: (82)-(331)-209-1889  
Home-Page URL: Http://www.intl.samsungsemi.com/  
Printed in the Republic of Korea  
Preface  
The S3C72K8/P72K8 Microcontroller User's Manual is designed for application designers and programmers who are  
using the S3C72K8/P72K8 microcontroller for application development. It is organized in two parts:  
Part I Programming Model  
Part II Hardware Descriptions  
Part I contains software-related information to familiarize you with the microcontroller's architecture, programming  
model, instruction set, and interrupt structure. It has five chapters:  
Chapter 1  
Chapter 2  
Chapter 3  
Product Overview  
Address Spaces  
Addressing Modes  
Chapter 4  
Chapter 5  
Memory Map  
SAM48 Instruction Set  
Chapter 1, "Product Overview" is a high-level introduction to the S3C72K8/P72K8, ranging from a general product  
description to detailed information about pin characteristics and circuit types.  
Chapter 2, "Address Spaces" introduces you to the S3C72K8/P72K8programming model: the program memory  
(ROM) and data memory (RAM) structures and how to address them. Chapter 2 also includes information about  
stack operations, CPU registers, and the bit sequential carrier (BSC) register.  
Chapter 3, "Addressing Modes" descriptions types of addressing supported by the SAM48 instruction set (direct,  
indirect, and bit manipulation) and the addressing modes which are supported (1-bit, 4-bit, and 8-bit). Numberous  
programming examples make the information practical and usable.  
Chapter 4, "Memory Map" contains a detailed map of the addressable peripheral hardware registers in the memory-  
mapped area of the RAM (bank 15). Chapter 4 also contains detailed descriptions in standard format of the most  
commonly used hardware registers. These easy-to-read register descriptions can be used as a quick-reference  
source when writing programs.  
Chapter 5, " SAM48 Instruction Set," first introduces the basic features and conventions of the SAM48 instruction  
set. Then, two summary tables orient you to the individual instructions: One table is a high-level summary of the  
most important information about each instruction; the other table is designed to give expert programmers a  
summary of binary code and instruction notation information. The final part of Chapter 5 contains detailed  
descriptions of each instruction in a standard format. Each instruction description includes one or more practical  
examples.  
A basic familiarity with the information in Part I will make it easier for you to understand the hardware descriptions in  
Part II. If you are familiar with the SAM48 product family and are reading this user's manual for the first time, we  
recommend that you read chapters 1–3 carefully, and just scan the detailed information in Chapters 4 and 5 very  
briefly. Later, you can refer back to Chapters 4 and 5 as necessary.  
Part II "hardware Descriptions" has detailed information about specific hardware components of the S3C72K8/P72K8  
microcontroller. Also included in Part II are electrical, mechanical, OTP, and development tools data. Part II has 13  
chapters:  
Chapter 6  
Chapter 7  
Chapter 8  
Oscillator Circuit  
Interrupts  
Power-Down  
Chapter 12  
Chapter 13  
Chapter 14  
Chapter 15  
Chapter 16  
Chapter 17  
Chapter 18  
LCD Controller/Driver  
Comparator  
Serial I/O Interface  
Electrical Data  
Mechanical Data  
S3P72K8 OTP  
Development Tools  
Chapter 9  
Chapter 10  
Chapter 11  
RESET  
I/O Ports  
Timers and Timer/Counters  
Two order forms are included at the back of this manual to facilitate customer order for S3C72K8/P72K8  
microcontrollers: the Mask ROM Order Form, and the Mask Option Selection Form. You can photocopy these  
forms, fill them out, and then forward them to your local Samsung Sales Representative.  
S3C72K8/P72K8 MICROCONTROLLER  
iii  
Table of Contents  
Part I — Programming Model  
Chapter 1 Product Overview  
Overview.............................................................................................................................................1-1  
OTP ...................................................................................................................................................1-1  
Features.............................................................................................................................................1-2  
Block Diagram ....................................................................................................................................1-3  
Pin Assignments.................................................................................................................................1-4  
Pin Descriptions..................................................................................................................................1-5  
Pin Circuit Diagrams............................................................................................................................1-7  
Chapter 2 Address Spaces  
Program Memory (ROM)......................................................................................................................2-1  
Overview.....................................................................................................................................2-1  
General-Purpose Memory Areas ...................................................................................................2-2  
Vector Address Area ...................................................................................................................2-2  
Instruction Reference Area ...........................................................................................................2-4  
Data Memory (RAM)............................................................................................................................2-5  
Overview.....................................................................................................................................2-5  
Working Registers.......................................................................................................................2-8  
Stack Operations ................................................................................................................................2-12  
Stack Pointer (SP)......................................................................................................................2-12  
Push Operations .........................................................................................................................2-13  
Pop Operations ...........................................................................................................................2-14  
Bit Sequential Carrier (BSC).................................................................................................................2-15  
Program Counter (PC)..........................................................................................................................2-16  
Program Status Word (PSW)...............................................................................................................2-16  
Interrupt Status Flags (IS0, IS1)....................................................................................................2-17  
Emb Flag (EMB).........................................................................................................................2-18  
Erb Flag (ERB)............................................................................................................................2-19  
Skip Condition Flags (SC2, SC1, SC0)..........................................................................................2-20  
Carry Flag (C) .............................................................................................................................2-20  
S3C72K8/P72K8 MICROCONTROLLER  
v
Table of Contents (Continued)  
Chapter 3 Addressing Modes  
Overview.............................................................................................................................................3-1  
EMB and ERB Initialization Values ...............................................................................................3-3  
Enable Memory Bank Settings .....................................................................................................3-4  
Select Bank Register (SB)...........................................................................................................3-5  
Direct and Indirect Addressing..............................................................................................................3-6  
1-Bit Addressing..........................................................................................................................3-6  
4-Bit Addressing..........................................................................................................................3-8  
8-Bit Addressing..........................................................................................................................3-10  
Chapter 4 Memory Map  
Overview.............................................................................................................................................4-1  
I/O Map for Hardware Registers ....................................................................................................4-1  
Register Descriptions...................................................................................................................4-6  
Chapter 5 SAM48 Instruction Set  
Overview.............................................................................................................................................5-1  
Instruction Set Features.......................................................................................................................5-1  
Instruction Reference Area ...........................................................................................................5-2  
Reducing Instruction Redundancy.................................................................................................5-3  
Flexible Bit Manipulation..............................................................................................................5-4  
Instructions Which Have Skip Conditions.......................................................................................5-4  
Instructions Which Affect The Carry Flag.......................................................................................5-4  
ADC and SBC Instruction Skip Conditions .....................................................................................5-5  
Symbols and Conventions ....................................................................................................................5-6  
Opcode Definitions ..............................................................................................................................5-7  
Calculating Additional Machine Cycles For Skips ...................................................................................5-7  
High-Level Summary............................................................................................................................5-8  
Binary Code Summary.........................................................................................................................5-13  
Instruction Descriptions................................................................................................................5-23  
vi  
S3C72K8/P72K8 MICROCONTROLLER  
Table of Contents (Continued)  
Part II — Hardware Descriptions  
Chapter 6 Oscillator Circuits  
Overview.............................................................................................................................................6-1  
Main System Oscillator Circuits....................................................................................................6-3  
Subsystem Oscillator Circuits ......................................................................................................6-3  
Power Control Register (PCON)....................................................................................................6-4  
Instruction Cycle Times................................................................................................................6-5  
System Clock Mode Register (SCMOD)........................................................................................6-6  
Switching The Cpu Clock .............................................................................................................6-8  
Clock Output Mode Registers (CLMOD) ........................................................................................6-10  
Clock Output Circuit ....................................................................................................................6-11  
Clock Output Procedure...............................................................................................................6-11  
Chapter 7 Interrupts  
Overview.............................................................................................................................................7-1  
Multiple Interrupts........................................................................................................................7-5  
Interrupt Priority Register (IPR) .....................................................................................................7-7  
External Interrupt 0, 1 and 2 Mode Registers (IMOD0, IMOD1 and IMOD2) .......................................7-8  
External Key Interrupt Mode Register (IMODK)...............................................................................7-10  
Interrupt Flags.............................................................................................................................7-12  
Chapter 8 Power-Down  
Overview.............................................................................................................................................8-1  
Idle Mode Timing Diagrams ..........................................................................................................8-3  
Stop Mode Timing Diagrams.........................................................................................................8-4  
Recommended Connections for Unused Pins.................................................................................8-6  
Chapter 9 RES ET  
Overview.............................................................................................................................................9-1  
Hardware Register Values after RESET.........................................................................................9-2  
S3C72K8/P72K8 MICROCONTROLLER  
vii  
Table of Contents (Continued)  
Chapter 10 I/O Ports  
Overview.............................................................................................................................................10-1  
Port Mode Flags (PM FLAGS)......................................................................................................10-3  
Port 1 Mode Register (P1MOD) ....................................................................................................10-3  
Pull-Up Resistor Mode Register (PUMOD).....................................................................................10-4  
N-Channel Open-Drain Mode Register (PNE)..................................................................................10-4  
Port 0 Circuit Diagram..................................................................................................................10-5  
Port 1 Circuit Diagram..................................................................................................................10-6  
Port 2 And 3 Circuit Diagram........................................................................................................10-7  
Port 4 Circuit Diagram..................................................................................................................10-8  
Chapter 11 Timers and Timer/Counters  
Overview.............................................................................................................................................11-1  
Basic Timer (BT) .................................................................................................................................11-2  
Overview.....................................................................................................................................11-2  
Basic Timer Mode Register (BMOD)..............................................................................................11-5  
Basic Timer Counter (BCNT).........................................................................................................11-6  
Basic Timer Operation Sequence..................................................................................................11-6  
Watchdog Timer Mode Register (WDMOD)....................................................................................11-8  
Watchdog Timer Counter (WDCNT)...............................................................................................11-8  
Watchdog Timer Counter Clear Flag (WDTCF) ...............................................................................11-8  
8-Bit Timer/Counter 0 (TC0)..................................................................................................................11-10  
Overview.....................................................................................................................................11-10  
TC0 Function Summary ...............................................................................................................11-10  
TC0 Component Summary ...........................................................................................................11-11  
TC0 Enable/Disable Procedure .....................................................................................................11-12  
TC0 Programmable Timer/Counter Function...................................................................................11-13  
TC0 Operation Sequence.............................................................................................................11-13  
TC0 Event Counter Function.........................................................................................................11-14  
TC0 Clock Frequency Output........................................................................................................11-15  
TC0 Serial I/O Clock Generation ...................................................................................................11-16  
TC0 External Input Signal Divider ..................................................................................................11-16  
TC0 Mode Register (TMOD0)........................................................................................................11-17  
TC0 Counter Register (TCNT0)......................................................................................................11-19  
TC0 Reference Register (TREF0) ..................................................................................................11-20  
TC0 Output Enable Flag (TOE0)....................................................................................................11-20  
TC0 Output Latch (TOL0) .............................................................................................................11-20  
Watch Timer.......................................................................................................................................11-22  
Overview.....................................................................................................................................11-22  
Watch Timer Mode Register (WMOD) ...........................................................................................11-25  
viii  
S3C72K8/P72K8 MICROCONTROLLER  
Table of Contents (Continued)  
Chapter 12 LCD Controller/Driver  
Overview.............................................................................................................................................12-1  
LCD Circuit Diagram....................................................................................................................12-2  
LCD Ram Address Area...............................................................................................................12-3  
LCD Control Register (LCON) .......................................................................................................12-4  
LCD Mode Register (LMOD).........................................................................................................12-5  
LCD Voltage Dividing Method........................................................................................................12-7  
Application Without Contrast Control.............................................................................................12-8  
Application With Contrast Control .................................................................................................12-9  
Common (COM) Signals ..............................................................................................................12-10  
Segment (SEG) Signals...............................................................................................................12-10  
Chapter 13 Comparator  
Overview.............................................................................................................................................13-1  
Comparator Mode Register (CMOD)..............................................................................................13-3  
Port 1 Mode Register (P1MOD) ....................................................................................................13-4  
Comparator Operation..................................................................................................................13-4  
Chapter 14 Serial I/O Interface  
Overview.............................................................................................................................................14-1  
Serial I/O Operation Sequence......................................................................................................14-1  
Serial I/O Mode Register (SMOD) .................................................................................................14-3  
Serial I/O Timing Diagrams...........................................................................................................14-4  
Serial I/O Buffer Register (SBUF)..................................................................................................14-5  
S3C72K8/P72K8 MICROCONTROLLER  
ix  
Table of Contents (Concluded)  
Chapter 15 Electrical Data  
Overview.............................................................................................................................................15-1  
Timing Waveforms...............................................................................................................................15-12  
Chapter 16 Mechanical Data  
Overview.............................................................................................................................................16-1  
Chapter 17 S3P72M9 OTP  
Overview.............................................................................................................................................17-1  
Operating Mode Characteristics....................................................................................................17-3  
Chapter 18 Development Tools  
Overview.............................................................................................................................................18-1  
SHINE........................................................................................................................................18-1  
SAMA Assembler........................................................................................................................18-1  
SASM57.....................................................................................................................................18-1  
HEX2ROM..................................................................................................................................18-1  
Target Boards .............................................................................................................................18-1  
OTPs .........................................................................................................................................18-1  
TB72K8 Target Board...................................................................................................................18-3  
Idle LED.....................................................................................................................................18-5  
Stop LED....................................................................................................................................18-5  
x
S3C72K8/P72K8 MICROCONTROLLER  
List of Figures  
Figure  
Title  
Page  
Number  
Number  
1-1  
1-2  
1-3  
1-4  
1-5  
1-6  
1-7  
1-8  
1-9  
1-10  
1-11  
S3C72K8 Simplified Block Diagram.......................................................................1-3  
S3C72K8 80-QFP Pin Assignment........................................................................1-4  
Pin Circuit Type A ...............................................................................................1-7  
Pin Circuit Type A-3.............................................................................................1-7  
Pin Circuit Type B ...............................................................................................1-7  
Pin Circuit Type 7................................................................................................1-7  
Pin Circuit Type E-2.............................................................................................1-8  
Pin Circuit Type F-4.............................................................................................1-8  
Pin Circuit Type H-5.............................................................................................1-9  
Pin Circuit Type H-6.............................................................................................1-10  
Pin Circuit Type H-11...........................................................................................1-10  
2-1  
2-2  
2-3  
2-4  
2-5  
2-6  
2-7  
2-8  
ROM Address Structure.......................................................................................2-2  
Vector Address Structure.....................................................................................2-2  
Data Memory (RAM) Map.....................................................................................2-5  
Working Register Map .........................................................................................2-8  
Register Pair Configuration...................................................................................2-9  
1-Bit, 4-Bit, and 8-Bit Accumulator........................................................................2-10  
Push-Type Stack Operations................................................................................2-13  
Pop-Type Stack Operations..................................................................................2-14  
3-1  
3-2  
RAM Address Structure.......................................................................................3-2  
SMB and SRB Values in the SB Register..............................................................3-5  
4-1  
Register Description Format .................................................................................4-7  
6-1  
6-2  
6-3  
6-4  
6-5  
6-6  
6-7  
Clock Circuit Diagram..........................................................................................6-2  
Crystal/Ceramic Oscillator (fx)..............................................................................6-3  
External Oscillator (fx).........................................................................................6-3  
RC Oscillator (fx).................................................................................................6-3  
Crystal/Ceramic Oscillator (fxt).............................................................................6-3  
External Oscillator (fxt)........................................................................................6-3  
CLO Output Pin Circuit Diagram ...........................................................................6-11  
7-1  
7-2  
7-3  
7-4  
7-5  
7-6  
Interrupt Execution Flowchart ...............................................................................7-3  
Interrupt Control Circuit Diagram ...........................................................................7-4  
Two-Level Interrupt Handling .................................................................................7-5  
Multi-Level Interrupt Handling................................................................................7-6  
Circuit Diagram for INT0, INT1, and INT2 Pins.........................................................7-9  
Circuit Diagram for INTK.......................................................................................7-11  
S3C72K8/P72K8 MICROCONTROLLER  
xi  
List of Figures (Continued)  
Figure  
Title  
Page  
Number  
Number  
8-1  
8-2  
Timing When Idle Mode is Released by RESET .....................................................8-3  
Timing When Idle Mode is Released by an Interrupt................................................8-3  
8-3  
8-4  
Timing When Stop Mode is Released by RESET ...................................................8-4  
Timing When Stop Mode is Release by an Interrupt................................................8-4  
9-1  
Timing for Oscillation Stabilization After RESET.....................................................9-1  
10-1  
10-2  
10-3  
10-4  
Port 0 Circuit Diagram..........................................................................................10-5  
Port 1 Circuit Diagram..........................................................................................10-6  
Port 2 and 3 Circuit Diagram.................................................................................10-7  
Port 4 Circuit Diagram..........................................................................................10-8  
11-1  
11-2  
11-3  
11-4  
Basic Timer Circuit Diagram.................................................................................11-4  
TC0 Circuit Diagram.............................................................................................11-12  
TC0 Timing Diagram ............................................................................................11-19  
Watch Timer Circuit Diagram................................................................................11-24  
12-1  
12-2  
12-3  
12-4  
12-5  
12-6  
12-7  
12-8  
12-9  
LCD Function Diagram.........................................................................................12-1  
LCD Circuit Diagram............................................................................................12-2  
LCD Display Data RAM Organization ....................................................................12-3  
LCD Bias Circuit Connection ................................................................................12-7  
Connection For LCD On/Off Using Internal Transistor..............................................12-8  
Connection For LCD On/Off Using External Output Pin ...........................................12-9  
LCD Signal Waveforms (1/8 Duty, 1/4 Bias)...........................................................12-11  
LCD Signal Waveforms (1/4 Duty, 1/3 Bias)...........................................................12-13  
LCD Signal Waveforms (1/3 Duty, 1/3 Bias)...........................................................12-14  
13-1  
13-2  
13-3  
Comparator Circuit Diagram..................................................................................13-2  
Comparator Mode Register (CMOD) Organization...................................................13-3  
Conversion Characteristics...................................................................................13-4  
14-1  
14-2  
14-3  
Serial I/O Interface Circuit Diagram........................................................................14-2  
SIO Timing in Transmit/Receive Mode ...................................................................14-4  
SIO Timing in Receive-Only Mode.........................................................................14-4  
xii  
S3C72K8/P72K8 MICROCONTROLLER  
List of Figures (Concluded)  
Figure  
Title  
Page  
Number  
Number  
15-1  
15-2  
15-3  
15-4  
Standard Operating Voltage Range .......................................................................15-10  
Stop Mode Release Timing When Initiated By RESET............................................15-12  
Stop Mode Release Timing When Initiated By Interrupt Request..............................15-12  
A.C. Timing Measurement Points (Except for X and XT )......................................15-13  
IN  
IN  
15-5  
15-6  
15-7  
Clock Timing Measurement at X .........................................................................15-13  
IN  
Clock Timing Measurement at XT ........................................................................15-13  
IN  
TCL Timing .........................................................................................................15-14  
15-8  
15-9  
15-10  
Input Timing for RESET Signal..............................................................................15-14  
Input Timing for External Interrupts and Quasi-Interrupts..........................................15-14  
Serial Data Transfer Timing...................................................................................15-15  
16-1  
17-1  
80-QFP-1420C Package Dimensions ....................................................................16-1  
S3P72K8 Pin Assignments (80-QFP Package)......................................................17-2  
18-1  
18-2  
18-3  
18-4  
SMDS Product Configuration (SMDS2+)................................................................18-2  
TB72K8 Target Board Configuration.......................................................................18-3  
40-Pin Connectors for TB72K8..............................................................................18-6  
TB72K8 Adapter Cable for 80-QFP Package (S3C72K8/P72K8)...............................18-6  
S3C72K8/P72K8 MICROCONTROLLER  
xiii  
List of Tables  
Table  
Title  
Page  
Number  
Number  
1-1  
S3C72K8 Pin Descriptions ...................................................................................1-5  
2-1  
2-2  
2-3  
2-4  
2-5  
2-6  
2-7  
Program Memory Address Ranges........................................................................2-1  
Data Memory Organization and Addressing ...........................................................2-7  
Working Register Organization and Addressing......................................................2-9  
BSC Register Organization...................................................................................2-15  
Program Status Word Bit Descriptions ..................................................................2-16  
Interrupt Status Flag Bit Settings ..........................................................................2-17  
Valid Carry Flag Manipulation Instructions .............................................................2-20  
3-1  
3-2  
3-3  
3-4  
RAM Addressing Not Affected by the EMB Value...................................................3-4  
1-Bit Direct and Indirect RAM Addressing..............................................................3-6  
4-Bit Direct and Indirect RAM Addressing..............................................................3-8  
8-Bit Direct and Indirect RAM Addressing..............................................................3-10  
4-1  
I/O Map for Memory Bank 15................................................................................4-2  
5-1  
5-2  
5-3  
5-4  
5-5  
5-6  
5-7  
5-8  
Valid 1-Byte Instruction Combinations for REF Look-Ups ........................................5-2  
Bit Addressing Modes and Parameters..................................................................5-4  
Skip Conditions for ADC and SBC Instructions.......................................................5-5  
Data Type Symbols.............................................................................................5-6  
Register Identifiers...............................................................................................5-6  
Instruction Operand Notation ................................................................................5-6  
Opcode Definitions (Direct)...................................................................................5-7  
Opcode Definitions (Indirect).................................................................................5-7  
CPU Control Instructions — High-Level Summary...................................................5-9  
Program Control Instructions — High-Level Summary .............................................5-9  
Data Transfer Instructions — High-Level Summary..................................................5-10  
Logic Instructions — High-Level Summary .............................................................5-11  
Arithmetic Instructions — High-Level Summary ......................................................5-11  
Bit Manipulation Instructions — High-Level Summary..............................................5-12  
CPU Control Instructions — Binary Code Summary................................................5-14  
Program Control Instructions — Binary Code Summary ..........................................5-15  
Data Transfer Instructions — Binary Code Summary...............................................5-16  
Logic Instructions — Binary Code Summary ..........................................................5-18  
Arithmetic Instructions — Binary Code Summary ...................................................5-19  
Bit Manipulation Instructions — Binary Code Summary...........................................5-20  
5-9  
5-10  
5-11  
5-12  
5-13  
5-14  
5-15  
5-16  
5-17  
5-18  
5-19  
5-20  
S3C72K8/P72K8 MICROCONTROLLER  
xv  
List of Tables (Continued)  
Table  
Title  
Page  
Number  
Number  
6-1  
6-2  
6-3  
6-4  
6-5  
6-6  
6-7  
Power Control Register (PCON) Organization.........................................................6-4  
Instruction Cycle Times for CPU Clock Rates.........................................................6-5  
System Clock Mode Register (SCMOD) Organization.............................................6-6  
SCMOD.2 for Sub-oscillation On/Off......................................................................6-6  
Main/Sub Oscillation Stop Mode...........................................................................6-7  
Elapsed Machine Cycles During CPU Clock Switch................................................6-8  
Clock Output Mode Register (CLMOD) Organization...............................................6-10  
7-1  
7-2  
7-3  
7-4  
7-5  
7-6  
7-7  
7-8  
Interrupt Types and Corresponding Port Pin(s)........................................................7-1  
IS1 and IS0 Bit Manipulation for Multi-Level Interrupt Handling..................................7-6  
Standard Interrupt Priorities ..................................................................................7-7  
Interrupt Priority Register Settings.........................................................................7-7  
IMOD0, 1 and 2 Register Organization...................................................................7-8  
IMODK Register Bit Settings ................................................................................7-10  
Interrupt Enable and Interrupt Request Flag Addresses ...........................................7-12  
Interrupt Request Flag Conditions and Priorities .....................................................7-13  
8-1  
8-2  
8-3  
Hardware Operation During Power-Down Modes .....................................................8-2  
System Operating Mode Comparison....................................................................8-2  
Unused Pin Connections for Reduced Power Consumption......................................8-6  
9-1  
Hardware Register Values After RESET ................................................................9-2  
10-1  
10-2  
10-3  
10-4  
I/O Port Overview.................................................................................................10-2  
Port Pin Status During Instruction Execution..........................................................10-2  
Port Mode Group Flags........................................................................................10-3  
Pull-Up Resistor Mode Register (PUMOD) Organization..........................................10-4  
11-1  
11-2  
11-3  
11-4  
11-5  
11-6  
11-8  
Basic Timer Register Overview..............................................................................11-3  
Basic Timer Mode Register (BMOD) Organization ..................................................11-5  
Watchdog Timer Interval Time...............................................................................11-8  
TC0 Register Overview .........................................................................................11-11  
TMOD0 Settings for TCL0 Edge Detection .............................................................11-14  
TC0 Mode Register (TMOD0) Organization.............................................................11-17  
Watch Timer Mode Register (WMOD) Organization................................................11-25  
xvi  
S3C72K8/P72K8 MICROCONTROLLER  
List of Tables (Concluded)  
Table  
Title  
Page  
Number  
Number  
12-1  
12-2  
12-3  
12-4  
Common and Segment Pins per Duty Cycle ..........................................................12-4  
LCD Control Register (LCON) Organization............................................................12-4  
LMOD.1–0 Bits Settings ......................................................................................12-4  
LCD Clock Signal (LCDCK) Frame Frequency........................................................12-5  
14-1  
SIO Mode Register (SMOD) Organization..............................................................14-3  
15-1  
15-2  
15-3  
15-4  
15-5  
15-6  
15-7  
15-8  
Absolute Maximum Ratings..................................................................................15-2  
D.C. Electrical Characteristics..............................................................................15-3  
Main System Clock Oscillator Characteristics........................................................15-6  
Subsystem Clock Oscillator Characteristics ..........................................................15-7  
Input/Output Capacitance.....................................................................................15-8  
Comparator Electrical Characteristics....................................................................15-8  
A.C. Electrical Characteristics..............................................................................15-9  
RAM Data Retention Supply Voltage in Stop Mode.................................................15-11  
17-1  
17-2  
17-3  
Descriptions of Pins Used to Read/Write the EPROM.............................................17-3  
Comparison of S3P72K8 and S3C72K8 Features ...................................................17-3  
Operating Mode Selection Criteria.........................................................................17-3  
18-1  
18-2  
18-3  
Power Selection Settings for TB72K8....................................................................18-4  
Main-clock Selection Settings for TB72K8.............................................................18-4  
Sub-clock Selection Settings for TB72K8...............................................................18-5  
S3C72K8/P72K8 MICROCONTROLLER  
xvii  
List of Programming Tips  
Description  
Page  
Number  
Chapter 2 Address Spaces  
Defining Vectored Interrupts..................................................................................................................2-3  
Using the REF Look-Up Table...............................................................................................................2-4  
Clearing Data Memory Banks 0 and 1...................................................................................................2-7  
Selecting the Working Register Area.....................................................................................................2-11  
Initializing the Stack Pointer.................................................................................................................2-12  
Using the BSC Register to Output 16-Bit Data.......................................................................................2-15  
Setting ISx Flags for Interrupt Processing..............................................................................................2-17  
Using the EMB Flag to Select Memory Banks .......................................................................................2-18  
Using the ERB Flag to Select Register Banks........................................................................................2-19  
Using the Carry Flag as a 1-Bit Accumulator..........................................................................................2-21  
Chapter 3 Addressing Modes  
Initializing the EMB and ERB Flags.......................................................................................................3-3  
1-Bit Addressing Modes.......................................................................................................................3-7  
4-Bit Addressing Modes.......................................................................................................................3-8  
4-Bit Addressing Modes.......................................................................................................................3-9  
8-Bit Addressing Modes.......................................................................................................................3-11  
Chapter 5 SAM48 Instruction Set  
Example of the Instruction Redundancy Effect........................................................................................5-3  
Chapter 6 Oscillator Circuits  
Setting the CPU Clock.........................................................................................................................6-4  
Switching Between Main System and Subsystem Clock.........................................................................6-9  
CPU Clock Output to the CLO Pin ........................................................................................................6-11  
Chapter 7  
Interrupts  
Setting the INT Interrupt Priority............................................................................................................7-8  
Using INTK as a Key Input Interrupt.......................................................................................................7-11  
Enabling the INTB and INT4 Interrupts ...................................................................................................7-14  
Chapter 8  
Power-Down  
Reducing Power Consumption for Key Input Interrupt Processing.............................................................8-5  
Chapter 10  
I/O Ports  
Configuring I/O Ports to Input or Output .................................................................................................10-3  
Enabling and Disabling I/O Port Pull-Up Resistors ..................................................................................10-4  
S3C72K8/P72K8 MICROCONTROLLER  
xix  
List of Programming Tips (Continued)  
Description  
Number  
Page  
Chapter 11  
Timers and Timer/Counters  
Using the Basic Timer..........................................................................................................................11-7  
Using the Watchdog Timer...................................................................................................................11-9  
TC0 Signal Output to the TCLO0 Pin.....................................................................................................11-15  
External TCL0 Clock Output to the TCLO0 Pin.......................................................................................11-16  
Restarting TC0 Counting Operation .......................................................................................................11-18  
Setting a TC0 Timer Interval..................................................................................................................11-21  
Using the Watch Timer ........................................................................................................................11-26  
Chapter 13  
Comparator  
Programming the Comparator...............................................................................................................13-5  
Chapter 14  
Serial I/O Interface  
Setting Transmit/Receive Modes for Serial I/O........................................................................................14-5  
xx  
S3C72K8/P72K8 MICROCONTROLLER  
List of Register Descriptions  
Register  
Identifier  
Full Register Name  
Page  
Number  
BMOD  
Basic Timer Mode Register ................................................................................4-8  
Clock Output Mode Register...............................................................................4-9  
Comparator Mode Register.................................................................................4-10  
INT0, 1 Interrupt Enable/Request Flags................................................................4-11  
INT2 Interrupt Enable/Request Flags ...................................................................4-12  
INT4 Interrupt Enable/Request Flags ...................................................................4-13  
INTB Interrupt Enable/Request Flags...................................................................4-13  
INTS Interrupt Enable/Request Flags...................................................................4-14  
INTT0 Interrupt Enable/Request Flags..................................................................4-15  
INTK Interrupt Enable/Request Flags...................................................................4-16  
INTW Interrupt Enable/Request Flags..................................................................4-17  
External Interrupt 0 (INT0) Mode Register.............................................................4-18  
External Interrupt 1 (INT1) Mode Register.............................................................4-19  
External Interrupt 2 (INT2) Mode Register.............................................................4-20  
External Key Interrupt Mode Register..................................................................4-21  
Interrupt Priority Register....................................................................................4-22  
LCD Output Control Register ..............................................................................4-23  
LCD Mode Register ...........................................................................................4-24  
Power Control Register ......................................................................................4-25  
Port I/O Mode Flags (Group 1: Ports 0, 4)............................................................4-26  
Port I/O Mode Flags (Group 2: Ports 2, 3)............................................................4-27  
Port 1 Mode Register.........................................................................................4-28  
N-channel Open-drain Mode Register 1................................................................4-29  
N-channel Open-drain Mode Register 2................................................................4-30  
N-channel Open-drain Mode Register 3................................................................4-31  
Program Status Word........................................................................................4-32  
Pull-Up Resistor Mode Register 1.......................................................................4-33  
Pull-Up Resistor Mode Register 2.......................................................................4-34  
System Clock Mode Control Register..................................................................4-35  
Serial I/O Mode Register....................................................................................4-36  
Timer/Counter 0 Mode Register...........................................................................4-37  
Timer Output Enable Flag...................................................................................4-38  
Watch-Dog Timer Mode Register ........................................................................4-39  
Watch-Dog Timer Flag.......................................................................................4-39  
CLMOD  
CMOD  
IE0, 1, IRQ0,1  
IE2, IRQ2  
IE4, IRQ4  
IEB, IRQB  
IES, IRQS  
IET0, IRQT0  
IEK, IRQK  
IEW, IRQW  
IMOD0  
IMOD1  
IMOD2  
IMODK  
IPR  
LCON  
LMOD  
PCON  
PMG1  
PMG2  
P1MOD  
PNE1  
PNE2  
PNE3  
PSW  
PUMOD1  
PUMOD2  
SCMOD  
SMOD  
TMOD0  
TOE  
WDMOD  
WDTCF  
WMOD  
Watch Timer Mode Register...............................................................................4-40  
S3C72K8/P72K8 MICROCONTROLLER  
xxi  
List of Instruction Descriptions  
Instruction  
Mnemonic  
Full Instruction Name  
Page  
Number  
ADC  
ADS  
AND  
BAND  
BITR  
BITS  
BOR  
BTSF  
BTST  
BTSTZ  
BXOR  
CALL  
CALLS  
CCF  
COM  
CPSE  
DECS  
DI  
Add With Carry .................................................................................................5-24  
Add and Skip on Overflow...................................................................................5-26  
Logical AND......................................................................................................5-28  
Bit Logical AND.................................................................................................5-29  
Bit Reset ..........................................................................................................5-31  
Bit Set..............................................................................................................5-33  
Bit Logical OR...................................................................................................5-35  
Bit Test and Skip on False.................................................................................5-37  
Bit Test and Skip on True...................................................................................5-39  
Bit Test and Skip on True; Clear Bit ....................................................................5-41  
Bit Exclusive OR...............................................................................................5-43  
Call Procedure ..................................................................................................5-45  
Call Procedure (Short)........................................................................................5-46  
Complement Carry Flahg....................................................................................5-47  
Complement Accumulator..................................................................................5-48  
Compare and Skip if Equal.................................................................................5-49  
Decrement and Skip on Borrow...........................................................................5-50  
Disable Interrupts ..............................................................................................5-51  
Enable Interrupts...............................................................................................5-52  
Idle Operation....................................................................................................5-53  
Increment and Skip on Carry ..............................................................................5-54  
Return from Interrupt ..........................................................................................5-55  
Jump................................................................................................................5-56  
Jump (Short).....................................................................................................5-57  
Jump Relative (Very Short).................................................................................5-58  
EI  
IDLE  
INCS  
IRET  
JP  
JPS  
JR  
xxii  
S3C72K8/P72K8 MICROCONTROLLER  
List of Instruction Descriptions (Continued)  
Instruction  
Mnemonic  
Full Instruction Name  
Page  
Number  
LD  
Load.................................................................................................................5-60  
Load Bit............................................................................................................5-64  
Load Code Byte................................................................................................5-66  
Load Data Memory and Decrement .....................................................................5-69  
Load Data Memory and Increment.......................................................................5-69  
No Operation.....................................................................................................5-70  
Logical OR........................................................................................................5-71  
Pop from Stack.................................................................................................5-72  
Push Onto Stack...............................................................................................5-73  
Reset Carry Flag...............................................................................................5-74  
Reference Instruction.........................................................................................5-75  
Return from Subroutine ......................................................................................5-78  
Rotate Accumulator Right Through Carry .............................................................5-79  
Subtract With Carry...........................................................................................5-80  
Subtract ...........................................................................................................5-82  
Set Carry Flag...................................................................................................5-83  
Select Memory Bank .........................................................................................5-84  
Select Register Bank.........................................................................................5-85  
Return from Subroutine and Skip.........................................................................5-86  
Stop Operation..................................................................................................5-87  
Load EMB, ERB, and Vector Address.................................................................5-88  
Exchange A or EA With Nibble or Byte...............................................................5-90  
Exchange and Decrement ..................................................................................5-91  
Exchange and Increment....................................................................................5-92  
Logical Exclusive OR.........................................................................................5-93  
LDB  
LDC  
LDD  
LDI  
NOP  
OR  
POP  
PUSH  
RCF  
REF  
RET  
RRC  
SBC  
SBS  
SCF  
SMB  
SRB  
SRET  
STOP  
VENT  
XCH  
XCHD  
XCHI  
XOR  
S3C72K8/P72K8 MICROCONTROLLER  
xxiii  
S3C72K8/P72K8  
PRODUCT OVERVIEW  
1
PRODUCT OVERVIEW  
OVERVIEW  
The S3C72K8 singl-chip CMOS microcontroller has been designed for high performance using Samsung's newest 4-  
bit CPU core, SAM48 (Samsung Arrageable Microcontrollers). With a two-channel comparator, up-to-320-dot LCD  
direct drive capability, 8-bit timer/counter, watchdog timer and serial I/O, the S3C72K8 offers an excellent design  
solution for a wide variety of applications which require LCD functions.  
Up to 27 pins of the 80-pin QFP package can be dedicated to I/O. Seven vectored interrupts provide fast response to  
internal and external events. In addition, the S3C72K8's advanced CMOS technology provides for low power  
consumption and a wide operating voltage range.  
OTP  
The S3C72K8 microcontroller is also available is OTP (one time programmable) version, S3P72K8.  
S3P72K8 microcontroller has an one-chop 8 Kbyte one time programmable EPROM instead of masked ROM.  
The S3P72K8 is comparable to S3C72K8, both in function and in pin configuration.  
1-1  
PRODUCT OVERVIEW  
S3C72K8/P72K8  
FEATURES  
Memory  
Watch Timer  
— 8 K ´ 8-bit RAM  
— 1,024 ´ 4-bit ROM  
— Timer interval generation:  
0.5 s, 3.9 ms at 32,768 Hz  
— Four frequency outputs to BUZ pin  
— Clock source generation for LCD  
27 I/O Pins  
— Input only: 4 pins  
— I/O: 15 pins  
Interrupts  
— Three internal vectored interrupts:  
INTB, INTT0, INTS  
— Output: maximum 8 pins for 1-bit level output  
(sharing with segment driver outputs)  
— Four external vectored interrupts:  
INT0, INT1, INT4, INTK  
Comparator  
— Two channel mode: internal reference  
(4-bit resolution)  
— Two quasi-interrupts: INT2, INTW  
Memory-Mapped I/O Structure  
— One channel mode: external reference  
— Data memory bank 15  
LCD Controller/Driver  
Two Power-Down Modes  
— 40 segments and 8 common terminals  
— 3, 4 and 8 common selectable  
— Internal resistor circuit for LCD bias  
— All dot can be switched on/off  
— Idle mode (only CPU clock stops)  
— Stop mode (main system oscillation stops)  
— Subsystem clock stop mode  
Oscillation Sources  
8-Bit Basic Timer  
— Crystal, ceramic, or External RC for system clock  
— Main system clock frequency: 0.4 MHz–6 MHz  
— Subsystem clock frequency: 32,768 kHz  
— CPU clock divider circuit (by 4, 8, or 64)  
— 4 interval timer functions  
— Watchdog timer  
8-Bit Timer/Counter  
— Programmable 8-bit timer  
— External event counter  
Instruction Execution Times  
— 0.67 us at 6 MHz (minimum)  
— 0.95 ms at 4.19 MHz (minimum)  
— 122 ms at 32,768 kHz (minimum)  
— Arbitrary clock frequency output  
— External clock signal divider  
— Serial I/O interface clock generator  
Operating Temperature  
8-Bit Serial I/O Interface  
°
°
— – 40 C to 85 C  
— 8-bit transmit/receive mode  
— 8-bit receive only mode  
Operating Voltage Range  
— LSB-first or MSB-first transmission selectable  
— Internal or external clock source  
— 2.0 V to 5.5 V  
Package Type  
Bit Sequential Carrier  
— 80-pin QFP  
— Support 16-bit serial data transfer in arbitrary format  
1-2  
S3C72K8/P72K8  
PRODUCT OVERVIEW  
BLOCK DIAGRAM  
XIN  
XOUT  
RESET  
XTIN XTOUT  
V
LC1-VLC5  
COM0-COM7  
SEG0-SEG31  
P5.0/SEG32-  
P5.7/SEG39  
Watchdog  
Timer  
Basic  
Timer  
LCD Driver/  
Controller  
Interrupt  
Control  
Block  
Stack  
Pointer  
Clock  
Watch  
Timer  
I/O Port 2  
I/O Port 3  
P2.0-P2.3  
Program  
Counter  
P3.0  
P3.1  
P3.2/LCDSY  
P3.3/CLDCK  
Internal  
Interrupts  
SIO  
P0.0/SCK/K0  
P0.1/SO/K1  
P0.2/SI/K2  
Program  
Status Word  
Instruction Decoder  
I/O Port 0  
Comparator  
Input Port 1  
P4.0/CLO  
P4.1/TCL0  
P4.2/TCLO0  
I/O Port 4  
P0.3/BUZ/K3  
Arithmetic  
and  
Logic Unit  
Flags  
8-Bit  
Timer/  
Counter  
P1.0/INT0/CIN0  
P1.1/INT1/CIN1  
P1.2/INT2  
P1.3/INT4  
8 Kbyte  
Program  
Memory  
1024 x 4-Bit  
Data Memory  
Figure 1-1. S3C72K8 Simplified Block Diagram  
1-3  
PRODUCT OVERVIEW  
S3C72K8/P72K8  
PIN ASSIGNMENTS  
P5.6/SEG38  
P5.7/SEG39  
1
2
3
4
5
6
7
8
64  
63  
62  
61  
60  
59  
58  
57  
56  
55  
54  
53  
52  
51  
50  
49  
48  
47  
46  
45  
44  
43  
42  
41  
SEG21  
SEG20  
SEG19  
SEG18  
SEG17  
SEG16  
SEG15  
SEG14  
SEG13  
SEG12  
SEG11  
SEG10  
SEG9  
SEG8  
SEG7  
SEG6  
SEG5  
SEG4  
SEG3  
SEG2  
SEG1  
VLC1  
VLC2  
VLC3  
VLC4  
VLC5  
P0.0/SCK/K0  
P0.1/SO/K1  
P0.2/SI/K2  
9
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
P0.3/BUZ/K3  
S3C72K8  
V
DD  
SS  
OUT  
IN  
V
X
X
(80-QFP-1420C)  
TEST  
XTIN  
XTOUT  
RESET  
P1.0/INT0/CIN0  
P1.1/INT1/CIN1  
P1.2/INT2  
P1.3/INT4  
P2.0  
SEG0  
COM7  
COM6  
Figure 1-2. S3C72K8 80-QFP Pin Assignment  
1-4  
S3C72K8/P72K8  
PRODUCT OVERVIEW  
PIN DESCRIPTIONS  
Table 1-1. S3C72K8 Pin Descriptions  
Description  
Pin Name  
Pin  
Type  
Circuit  
Type  
Pin  
Number  
Share Pin  
P0.0  
P0.1  
P0.2  
P0.3  
I/O 4-bit I/O port.  
E–2  
8
9
10  
11  
K0/SCK  
K1/SO  
K2/SI  
1-bit or 4-bit read/write and test is possible.  
Individual pins are software configurable as input or  
output.  
K3/BUZ  
Individual pins are software configurable as open-drain  
or push-pull output.  
4-bit pull-up resistors are software assignable; pull-up  
resistors are automatically disabled for output pins.  
P1.0  
P1.1  
P1.2  
P1.3  
I
4-bit input port.  
F–4  
F–4  
A–3  
A–3  
20  
21  
22  
23  
INT0/CIN0  
INT1/CIN1  
INT2  
1-bit or 4-bit read and test are possible.  
The 1-bit unit pull-up resistors are assigned to input  
pins by software.  
INT4  
An interrupt is generated by digital input at P1.0, P1.1.  
P2.0–P2.3  
I/O Same as port 0 except that 8-bit read/write and test is  
possible.  
E–2  
24–27  
P3.0  
P3.1  
P3.2  
P3.3  
28  
29  
30  
31  
LCDSY  
LCDCK  
P4.0  
P4.1  
P4.2  
I/O Same as port 0 except that port 4 is 3-bit I/O port.  
E–2  
32  
33  
34  
CLO  
TCL0  
TCLO0  
P5.0–P5.7  
O
Output port for 1-bit data  
H–11  
E–2  
75–  
80,1,2  
SEG32–  
SEG39  
I/O Serial I/O interface clock signal  
8
P0.0/K0  
SCK  
SO  
I/O Serial data output  
I/O Serial data input  
E–2  
E–2  
E–2  
9
P0.1/K1  
P0.2/K2  
P0.3/K3  
SI  
10  
11  
BUZ  
I/O 2 KHz, 4 KHz, 8 KHz or 16 KHz frequency output at  
the watch timer clock frequency of 32.768 kHz.  
K0–K3  
I/O External interrupt. The triggering edge is selectable.  
E–2  
F–4  
8–11  
P0.0–P0.3  
INT0  
INT1  
I
External interrupts. The triggering edge for INT0 and  
INT1 is selectable.  
20  
21  
P1.0/CIN0  
P1.1/CIN1  
INT2  
INT4  
I
I
Quasi-interrupt with detection of rising or falling edges  
A–3  
A–3  
22  
23  
P1.2  
P1.3  
External interrupts with detection of rising and falling  
edges  
1-5  
PRODUCT OVERVIEW  
S3C72K8/P72K8  
Share Pin  
Table 1-1. S3C72K8 Pin Descriptions (Continued)  
Description Circuit  
Pin Name  
Pin  
Pin  
Type  
Type  
Number  
CIN0  
CIN1  
I
2-channel comparator input.  
CIN0: comparator input or external reference input  
CIN1: comparator input only.  
F–4  
20  
21  
P1.0/INT0  
P1.1/INT1  
LCDSY  
I/O LCD synchronization clock output for display  
expansion  
E–2  
30  
P3.2  
LCDCK  
CLO  
I/O LCD clock output for display expansion  
I/O Clock output  
E–2  
E–2  
E–2  
E–2  
H–11  
31  
32  
33  
34  
P3.3  
P4.0  
TCL0  
I/O External clock input for timer/counter 0  
I/O Timer/counter 0 clock output  
P4.1  
TCLO0  
P4.2  
SEG32–  
SEG39  
O
O
O
LCD segment signal output  
LCD segment signal output  
LCD common signal output  
75–  
80,1,2  
P5.0–P5.7  
SEG0–  
SEG31  
H–6  
H–6  
43–74  
35–42  
3–7  
COM0–  
COM7  
V
–V  
LCD power supply. Voltage dividing resistors are  
assignable by mask option.  
LC1 LC5  
X
X
Crystal, ceramic or RC oscillator pins for system  
clock.  
15, 14  
,
IN OUT  
XT XT  
Crystal oscillator pins for subsystem clock.  
Main power supply  
17, 18  
12  
,
IN  
OUT  
DD  
SS  
V
V
Ground  
13  
I
I
Chip reset signal input  
B
19  
16  
RESET  
TEST  
Chip test signal input (must be connected to V  
)
SS  
NOTE: Pull-up resistors for all I/O ports are automatically disabled if they are configured to output mode  
1-6  
S3C72K8/P72K8  
PRODUCT OVERVIEW  
PIN CIRCUIT DIAGRAMS  
VDD  
VDD  
Pull-Up  
Resistor  
P-Channel  
N-Channel  
In  
In  
Schmitt Trigger  
Figure 1-5. Pin Circuit Type B  
Figure 1-3. Pin Circuit Type A  
VDD  
VDD  
Pull-Up  
Resistor  
P-Channel  
Out  
Data  
Pull-Up  
Resistor  
Enable  
P-Channel  
N-Channel  
Output  
Disable  
In  
Schmitt Trigger  
Figure 1-6. Pin Circuit Type 7  
Figure 1-4. Pin Circuit Type A-3  
1-7  
PRODUCT OVERVIEW  
S3C72K8/P72K8  
VDD  
Pull-up  
Resistor  
PNE  
VDD  
Resistor  
Enable  
P-CH  
I/O  
Data  
N-CH  
Output  
Disable  
Schmitt Trigger  
Figure 1-7. Pin Circuit Type E-2  
VDD  
Pull-up  
Resistor  
Resistor Enable  
Schmitt Trigger  
I/O  
Digital In  
EXT-REF  
(P1.0 only)  
+
-
Analog In  
Comparator  
INT-REF  
Digital or Analog Selectable  
by Software (P1MOD)  
Figure 1-8. Pin Circuit Type F-4  
1-8  
S3C72K8/P72K8  
PRODUCT OVERVIEW  
VDD  
V
LC1  
LC2  
V
SEG/COM Data  
Output Disable  
Out  
VLC3  
VLC4  
VLC5  
Figure 1-9. Pin Circuit Type H-5  
1-9  
PRODUCT OVERVIEW  
S3C72K8/P72K8  
VDD  
V
LC1  
LC2  
V
Out  
SEG/COM  
VLC3  
V
LC4  
LC5  
V
Figure 1-10. Pin Circuit Type H-6  
VDD  
P-CH  
N-CH  
Data  
Output Disable 1  
Out  
SEG  
Output Disable 2  
Circuit  
Type H-5  
Figure 1-11. Pin Circuit Type H-11  
1-10  
S3C72K8/P72K8  
ADDRESS SPACES  
2
ADDRESS SPACES  
PROGRAM MEMORY (ROM)  
OVERVIEW  
ROM maps for S3C72K8 devices are mask programmable at the factory. In its standard configuration, the device's  
8,192 ´ 8-bit program memory has three areas that are directly addressable by the program counter (PC):  
— 16-byte area for vector addresses  
— 96-byte instruction reference area  
— 16-byte general-purpose area  
— 8,064-byte general-purpose area  
General-Purpose Program Memory  
Two program memory areas are allocated for general-purpose use: One area is 16 bytes in size and the other is  
8,064 bytes.  
Vector Addresses  
A 16-byte vector address area is used to store the vector addresses required to execute system resets and  
interrupts. Start addresses for interrupt service routines are stored in this area, along with the values of the enable  
memory bank (EMB) and enable register bank (ERB) flags that are used to set their initial value for the corresponding  
service routines. The 16-byte area can be used alternately as general-purpose ROM.  
REF Instructions  
Locations 0020H–007FH are used as a reference area (look-up table) for 1-byte REF instructions. The REF  
instruction reduces the byte size of instruction operands. REF can reference one 2-byte instruction, two 1-byte  
instructions, and 3-byte instructions which are stored in the look-up table. Unused look-up table addresses can be  
used as general-purpose ROM.  
Table 2-1. Program Memory Address Ranges  
ROM Area Function  
Vector address area  
Address Ranges  
0000H–000FH  
0010H–001FH  
0020H–007FH  
0080H–1FFFH  
Area Size (in Bytes)  
16  
16  
General-purpose program memory  
REF instruction look-up table area  
General-purpose program memory  
96  
8,064  
2-1  
ADDRESS SPACES  
S3C72K8/P72K8  
GENERAL-PURPOSE MEMORY AREAS  
The 16-byte area at ROM locations 000CH–001FH and the 8,064-byte area at ROM locations 0080H–1FFFH are  
used as general-purpose program memory. Unused locations in the vector address area and REF instruction look-up  
table areas can be used as general-purpose program memory. However, care must be taken not to overwrite live data  
when writing programs that use special-purpose areas of the ROM.  
VECTOR ADDRESS AREA  
The 16-byte vector address area of the ROM is used to store the vector addresses for executing system resets and  
interrupts. The starting addresses of interrupt service routines are stored in this area, along with the enable memory  
bank (EMB) and enable register bank (ERB) flag values that are needed to initialize the service routines. 16-byte  
vector addresses are organized as follows:  
EMB  
PC7  
ERB  
PC6  
0
PC12  
PC4  
PC11  
PC3  
PC10  
PC2  
PC9  
PC1  
PC8  
PC0  
PC5  
To set up the vector address area for specific programs, use the instruction VENTn. The programming tips on the  
next page explain how to do this.  
0000H  
Vector Address Area  
7
6
5
4
3
2
1
0
(16 Bytes)  
0000H  
0002H  
0004H  
0006H  
0008H  
000AH  
000CH  
RESET  
INTB/INT4  
INT0  
000FH  
0010H  
General- Purpose Area  
(16 Bytes)  
001FH  
0020H  
Instruction  
Reference Area  
(96 Bytes)  
INT1  
007FH  
0080H  
INTS  
INTT0  
INTK  
General-Purpose  
Area  
(8,064 Byte)  
1FFFH  
Figure 2-2. Vector Address Structure  
Figure 2-1. ROM Address Structure  
2-2  
S3C72K8/P72K8  
ADDRESS SPACES  
F
PROGRAMMING TIP — Defining Vectored Interrupts  
The following examples show you several ways you can define the vectored interrupt and instruction reference areas  
in program memory:  
1. When all vector interrupts are used:  
ORG  
0000H  
;
VENT0  
VENT1  
VENT2  
VENT3  
VENT4  
VENT5  
VENT6  
1,0,RESET  
0,0,INTB  
0,0,INT0  
0,0,INT1  
0,0,INTS  
0,0,INTT0  
0,0,INTK  
;
;
;
;
;
;
;
EMB ¬ 1, ERB ¬ 0; Jump to RESET address  
EMB ¬ 0, ERB ¬ 0; Jump to INTB address  
EMB ¬ 0, ERB ¬ 0; Jump to INT0 address  
EMB ¬ 0, ERB ¬ 0; Jump to INT1 address  
EMB ¬ 0, ERB ¬ 0; Jump to INTS address  
EMB ¬ 0, ERB ¬ 0; Jump to INTT0 address  
EMB ¬ 0, ERB ¬ 0; Jump to INTK address  
2. When a specific vectored interrupt such as INT0, and INTT0 is not used, the unused vector interrupt locations  
must be skipped with the assembly instruction ORG so that jumps will address the correct locations:  
ORG  
0000H  
;
VENT0  
VENT1  
ORG  
VENT3  
VENT4  
1,0,RESET  
0,0,INTB  
0006H  
0,0,INT1  
0,0,INTS  
;
;
;
;
;
EMB ¬ 1, ERB ¬ 0; Jump to RESET address  
EMB ¬ 0, ERB ¬ 0; Jump to INTB address  
INT0 interrupt not used  
EMB ¬ 0, ERB ¬ 0; Jump to INT1 address  
EMB ¬ 0, ERB ¬ 0; Jump to INTS address  
;
;
ORG  
000CH  
;
;
INTT0 interrupt not used  
VENT6  
0,0,INTK  
EMB ¬ 0, ERB ¬ 0; Jump to INTK address  
3. If an INT0 interrupt is not used and if its corresponding vector interrupt area is not fully utilized, or if it is not written  
by a ORG instruction as in Example 2, a CPU malfunction will occur:  
ORG  
0000H  
;
VENT0  
VENT1  
VENT3  
VENT4  
VENT5  
VENT6  
1,0,RESET  
0,0,INTB  
0,0,INT1  
0,0,INTS  
0,0,INTT0  
0,0,INTK  
;
;
;
;
;
;
EMB ¬ 1, ERB ¬ 0; Jump to RESET address  
EMB ¬ 0, ERB ¬ 0; Jump to INTB address  
EMB ¬ 0, ERB ¬ 0; Jump to INT0 address  
EMB ¬ 0, ERB ¬ 0; Jump to INT1 address  
EMB ¬ 0, ERB ¬ 0; Jump to INTS address  
EMB ¬ 0, ERB ¬ 0; Jump to INTT0 address  
;
;
ORG  
0010H  
General-purpose ROM area  
In this example, when an INTS interrupt is generated, the corresponding vector area is not VENT4 INTS, but VENT5  
INTT0. This causes an INTS interrupt to jump incorrectly to the INTT0 address and causes a CPU malfunction to  
occur.  
2-3  
ADDRESS SPACES  
S3C72K8/P72K8  
INSTRUCTION REFERENCE AREA  
Using 1-byte REF instructions, you can easily reference instructions with larger byte sizes that are stored in  
addresses 0020H–007FH of program memory. This 96-byte area is called the REF instruction reference area, or  
look-up table. Locations in the REF look-up table may contain two one-byte instructions, a single two-byte  
instruction, or three-byte instruction such as a JP (jump) or CALL. The starting address of the instruction you are  
referencing must always be an even number. To reference a JP or CALL instruction, it must be written to the  
reference area in a two-byte format: for JP, this format is TJP; for CALL, it is TCALL. In summary, there are three  
ways to the REF instruction:  
By using REF instructions to execute instructions larger than one byte, you can improve program execution time  
considerably by reducing the number of program steps. In summary, there are three ways you can use the REF  
instruction:  
— Using the 1-byte REF instruction to execute one 2-byte or two 1-byte instructions,  
— Branching to any location by referencing a branch instruction stored in the look-up table,  
— Calling subroutines at any location by referencing a call instruction stored in the look-up table.  
F
PROGRAMMING TIP — Using the REF Look-Up Table  
Here is one example of how to use the REF instruction look-up table:  
ORG  
0020H  
;
JMAIN  
KEYCK  
WATCH  
INCHL  
TJP  
BTSF  
TCALL  
LD  
INCS  
MAIN  
;
;
;
;
0, MAIN  
1, KEYFG CHECK  
2, CALL CLOCK  
KEYFG  
CLOCK  
@HL,A  
HL  
3, (HL) ¬  
A
ABC  
LD  
ORG  
EA,#00H  
0080H  
;
EA  
¬
#00H  
;
MAIN  
NOP  
NOP  
REF  
REF  
REF  
REF  
KEYCK  
JMAIN  
WATCH  
INCHL  
;
;
;
;
;
;
BTSF KEYFG (1-byte instruction)  
KEYFG = 1, jump to MAIN (1-byte instruction)  
KEYFG = 0, CALL CLOCK (1-byte instruction)  
LD @HL,A  
INCS HL  
LD EA,#00H (1-byte instruction)  
REF  
ABC  
2-4  
S3C72K8/P72K8  
ADDRESS SPACES  
DATA MEMORY (RAM)  
OVERVIEW  
In its standard configuration, the 1,024 x 4-bit data memory has three areas:  
— 32 ´ 4-bit working register area in bank 0  
— 224 ´ 4-bit general-purpose area in bank 0 which is also used as the stack area  
— 176 ´ 4-bit general-purpose area in bank 1  
— 80 ´ 4-bit area for LCD data in bank 1  
— 256 ´ 4-bit general-purpose area in bank 2  
— 256 ´ 4-bit general-purpose area in bank 3  
— 128 ´ 4-bit area in bank 15 for memory-mapped I/O addresses  
To make it easier to reference, the data memory area has five memory banks — bank 0, bank 1, bank 2, babk 3, and  
bank 15. The select memory bank instruction (SMB) is used to select the bank you want to select as working data  
memory. Data stored in RAM locations are 1-, 4-, and 8-bit addressable.  
Initialization values for the data memory area are not defined by hardware and must therefore be initialized by  
program software following power RESET. However, when RESET signal is generated in power-down mode, the data  
memory contents are held.  
000H  
Working Registers  
(32 x 4 Bits)  
01FH  
020H  
General-purpose  
Registers and  
Stack Area  
Bank 0  
Bank 1  
(224 x 4 Bits)  
0FFH  
100H  
General-purpose  
Registers  
(176 x 4 Bits)  
1AFH  
1B0H  
LCD Data Registers  
(80 x 4 Bits)  
1FFH  
200H  
General-purpose  
Registers  
Bank 2  
Bank 3  
Bank 15  
(256 x 4 Bits)  
2FFH  
300H  
General-purpose  
Registers  
(256 x 4 Bits)  
3FFH  
F80H  
Memory-mapped I/O  
Address Registers  
(128 x 4 Bits)  
FFFH  
Figure 2-3. Data Memory (RAM) Map  
2-5  
ADDRESS SPACES  
S3C72K8/P72K8  
Memory Banks 0, 1, and 15  
Bank 0  
(000H–0FFH)  
The lowest 32 nibbles of bank 0 (000H–01FH) are used as working registers; the  
next 224 nibbles (020H–0FFH) can be used both as stack area and as general-  
purpose data memory. Use the stack area for implementing subroutine calls and  
returns, and for interrupt processing.  
Bank 1  
(1E0H–1FFH)  
The lowest 176 nibbles of bank 1 (100H–1AFH) are for general-purpose use;  
use the ramaining of 80 nibbles (1B0H–1FFH) as display registers or as general  
purpose memory.  
Bank 2  
Bank 3  
Bank 15  
(200H–2FFH)  
(300H–3FFH)  
(F80H–FFFH)  
256 nibbles of bank 2 (200H–2FFH) are for general-purpose used  
256 nibbles of bank 3 (300H–3FFH) are for general-purpose used  
The microcontroller uses bank 15 for memory-mapped peripheral I/O. Fixed RAM  
locations for each peripheral hardware address are mapped into this area.  
Data Memory Addressing Modes  
The enable memory bank (EMB) flag controls the addressing mode for data memory banks 0, 1, 2, 3 or 15. When  
the EMB flag is logic zero, the addressable area is restricted to specific locations, depending on whether direct or  
indirect addressing is used. With direct addressing, you can access locations 000H–07FH of bank 0 and bank 15.  
With indirect addressing, only bank 0 (000H–0FFH) can be accessed. When the EMB flag is set to logic one, all  
three data memory banks can be accessed according to the current SMB value.  
For 8-bit addressing, two 4-bit registers are addressed as a register pair. Also, when using 8-bit instructions to  
address RAM locations, remember to use the even-numbered register address as the instruction operand.  
Working Registers  
The RAM working register area in data memory bank 0 is further divided into four register banks (bank 0, 1, 2, and 3).  
Each register bank has eight 4-bit registers and paired 4-bit registers are 8-bit addressable.  
Register A is used as a 4-bit accumulator and register pair EA as an 8-bit extended accumulator. The carry flag bit  
can also be used as a 1-bit accumulator. Register pairs WX, WL, and HL are used as address pointers for indirect  
addressing. To limit the possibility of data corruption due to incorrect register addressing, it is advisable to use  
register bank 0 for the main program and banks 1, 2, and 3 for interrupt service routines.  
LCD Data Register Area  
Bit values for LCD segment data are stored in data memory bank 1. Register locations in this area that are not used  
to store LCD data can be assigned to general-purpose use.  
2-6  
S3C72K8/P72K8  
ADDRESS SPACES  
Table 2-2. Data Memory Organization and Addressing  
Addresses  
000H–01FH  
020H–0FFH  
100H–1AFH  
1B0H–1FFH  
200H–2FFH  
300H–3FFH  
F80H–FFFH  
Register Areas  
Working registers  
Bank  
EMB Value  
SMB Value  
0
0, 1  
0
Stack and general-purpose registers  
General-purpose registers  
LCD Data registers  
1
1
1
General-purpose registers  
General-purpose registers  
I/O- mapped hardware registers  
2
3
1
1
2
3
15  
0, 1  
15  
F
PROGRAMMING TIP — Clearing Data Memory Banks 0 and 1  
Clear banks 0 and 1 of the data memory area:  
RAMCLR  
RMCL1  
;
SMB  
LD  
LD  
LD  
INCS  
JR  
1
;
;
RAM (100H–1FFH) clear  
HL, #00H  
A, #0H  
@HL, A  
HL  
RMCL1  
SMB  
LD  
LD  
INCS  
JR  
0
RAM (020H–0FFH) clear  
HL, #20H  
@HL, A  
HL  
RMCL0  
RMCL0  
2-7  
ADDRESS SPACES  
S3C72K8/P72K8  
WORKING REGISTERS  
Working registers, mapped to RAM address 000H–01FH in data memory bank 0, are used to temporarily store  
intermediate results during program execution, as well as pointer values used for indirect addressing. Unused  
registers may be used as general-purpose memory. Working register data can be manipulated as 1-bit units, 4-bit  
units or, using paired registers, as 8-bit units.  
000H  
001H  
002H  
A
E
L
003H  
H
X
Working  
Register  
Bank 0  
004H  
005H  
006H  
007H  
008H  
W
Z
Data  
Memory  
Bank 0  
Y
Register  
Bank 1  
A ...Y  
A ...Y  
A ...Y  
00FH  
010H  
Register  
Bank 2  
017H  
018H  
Register  
Bank 3  
01FH  
Figure 2-4. Working Register Map  
2-8  
S3C72K8/P72K8  
ADDRESS SPACES  
Working Register Banks  
For addressing purposes, the working register area is divided into four register banks — bank 0, bank 1, bank 2, and  
bank 3. Any one of these banks can be selected as the working register bank by the register bank selection  
instruction (SRB n) and by setting the status of the register bank enable flag (ERB).  
Generally, working register bank 0 is used for the main program, and banks 1, 2, and 3 for interrupt service routines.  
Following this convention helps to prevent possible data corruption during program execution due to contention in  
register bank addressing.  
Table 2-3. Working Register Organization and Addressing  
SRB Settings  
Selected Register Bank  
ERB  
Setting  
3
2
1
0
0
1
1
0
0
1
0
1
0
1
0
0
Always set to bank 0  
Bank 0  
0
0
Bank 1  
Bank 2  
Bank 3  
NOTE: 'x' means don't care.  
Paired Working Registers  
Each of the register banks is subdivided into eight 4-bit registers. These registers, named Y, Z, W, X, H, L, E, and A,  
can either be manipulated individually using 4-bit instructions, or together as register pairs for 8-bit data manipulation.  
The names of the 8-bit register pairs in each register bank are EA, HL, WX, YZ, and WL. Registers A, L, X, and Z  
always become the lower nibble when registers are addressed as 8-bit pairs. This makes a total of eight 4-bit  
registers or four 8-bit double registers in each of the four working register banks.  
(MSB)  
(LSB)  
(MSB)  
(LSB)  
Y
W
H
E
Z
X
L
A
Figure 2-5. Register Pair Configuration  
2-9  
ADDRESS SPACES  
S3C72K8/P72K8  
Special-Purpose Working Registers  
Register A is used as a 4-bit accumulator and double register EA as an 8-bit accumulator. The carry flag can also be  
used as a 1-bit accumulator.  
8-bit double registers WX, WL, and HL are used as data pointers for indirect addressing. When the HL register  
serves as a data pointer, the instructions LDI, LDD, XCHI, and XCHD can make very efficient use of working registers  
as program loop counters by letting you transfer a value to the L register and increment or decrement it using a  
single instruction.  
C
1-Bit Accumulator  
4-Bit Accumulator  
8-Bit Accumulator  
A
EA  
Figure 2-6. 1-Bit, 4-Bit, and 8-Bit Accumulator  
Recommendation for Multiple Interrupt Processing  
If more than four interrupts are being processed at one time, you can avoid possible loss of working register data by  
using the PUSH RR instruction to save register contents to the stack before the service routines are executed in the  
same register bank. When the routines have executed successfully, you can restore the register contents from the  
stack to working memory using the POP instruction.  
2-10  
S3C72K8/P72K8  
ADDRESS SPACES  
F
PROGRAMMING TIP — Selecting the Working Register Area  
The following examples show the correct programming method for selecting working register area:  
1. When ERB = "0":  
VENT2  
;
1,0,INT0  
;
EMB ¬ 1, ERB ¬ 0, Jump to INT0 address  
INT0  
PUSH  
SRB  
PUSH  
PUSH  
PUSH  
PUSH  
SMB  
LD  
LD  
LD  
INCS  
LD  
LD  
POP  
POP  
POP  
POP  
POP  
IRET  
SB  
2
HL  
WX  
YZ  
EA  
0
EA,#00H  
80H,EA  
HL,#40H  
HL  
WX,EA  
YZ,EA  
EA  
YZ  
WX  
HL  
SB  
;
;
;
;
;
;
PUSH current SMB, SRB  
Instruction does not execute because ERB = "0"  
PUSH HL register contents to stack  
PUSH WX register contents to stack  
PUSH YZ register contents to stack  
PUSH EA register contents to stack  
;
;
;
;
;
POP EA register contents from stack  
POP YZ register contents from stack  
POP WX register contents from stack  
POP HL register contents from stack  
POP current SMB, SRB  
The POP instructions execute alternately with the PUSH instructions. If an SMB n instruction is used in an  
interrupt service routine, a PUSH and POP SB instruction must be used to store and restore the current SMB and  
SRB values, as shown in Example 2 below.  
2. When ERB = "1":  
VENT2  
;
1,1,INT0  
;
EMB ¬ 1, ERB ¬ 1, Jump to INT0 address  
INT0  
PUSH  
SRB  
SMB  
LD  
LD  
LD  
INCS  
LD  
LD  
POP  
IRET  
SB  
2
0
EA,#00H  
80H,EA  
HL,#40H  
HL  
WX,EA  
YZ,EA  
SB  
;
;
Store current SMB, SRB  
Select register bank 2 because of ERB = "1"  
;
Restore SMB, SRB  
2-11  
ADDRESS SPACES  
S3C72K8/P72K8  
STACK OPERATIONS  
STACK POINTER (SP)  
The stack pointer (SP) is an 8-bit register that stores the address used to access the stack, an area of data memory  
set aside for temporary storage of data and addresses. The SP can be read or written by 8-bit control instructions.  
When addressing the SP, bit 0 must always remain cleared to logic zero.  
F80H  
F81H  
SP3  
SP7  
SP2  
SP6  
SP1  
SP5  
"0"  
SP4  
There are two basic stack operations: writing to the top of the stack (push), and reading from the top of the stack  
(pop). A push decrements the SP and a pop increments it so that the SP always points to the top address of the  
last data to be written to the stack.  
The program counter contents and program status word (PSW) are stored in the stack area prior to the execution of  
a CALL or a PUSH instruction, or during interrupt service routines. Stack operation is a LIFO (Last In-First Out) type.  
The stack area is located in general-purpose data memory bank 0.  
During an interrupt or a subroutine, the PC value and the PSW are saved to the stack area. When the routine has  
completed, the stack pointer is referenced to restore the PC and PSW, and the next instruction is executed.  
The SP can address stack registers in bank 0 (addresses 000H–0FFH) regardless of the current value of the enable  
memory bank (EMB) flag and the select memory bank (SMB) flag. Although general-purpose register areas can be  
used for stack operations, be careful to avoid data loss due to simultaneous use of the same register(s).  
Since the RESET value of the stack pointer is not defined in firmware, we recommend that you initialize the stack  
pointer by program code to location 00H. This sets the first register of the stack area to 0FFH.  
NOTE  
A subroutine call occupies six nibbles in the stack; an interrupt requires six. When subroutine nesting or  
interrupt routines are used continuously, the stack area should be set in accordance with the maximum  
number of subroutine levels. To do this, estimate the number of nibbles that will be used for the subroutines  
or interrupts and set the stack area correspondingly.  
+
PROGRAMMING TIP — Initializing the Stack Pointer  
To initialize the stack pointer (SP):  
1. When EMB = "1":  
SMB  
LD  
LD  
15  
EA,#00H  
SP,EA  
;
;
;
Select memory bank 15  
Bit 0 of SP is always cleared to "0"  
Stack area initial address (0FFH) ¬ (SP) – 1  
2. When EMB = "0":  
LD  
LD  
EA,#00H  
SP,EA  
;
Memory addressing area (00H–7FH, F80H–FFFH)  
2-12  
S3C72K8/P72K8  
ADDRESS SPACES  
PUSH OPERATIONS  
Three kinds of push operations reference the stack pointer (SP) to write data from the source register to the stack:  
PUSH instructions, CALL instructions, and interrupts. In each case, the SP is decreased by a number determined  
by the type of push operation and then points to the next available stack location.  
PUSH Instructions  
A PUSH instruction references the SP to write two 4-bit data nibbles to the stack. Two 4-bit stack addresses are  
referenced by the stack pointer: one for the upper register value and another for the lower register. After the PUSH  
has executed, the SP is decreased by two and points to the next available stack location.  
CALL Instructions  
When a subroutine call is issued, the CALL instruction references the SP to write the PC's contents to six 4-bit  
stack locations. Current values for the enable memory bank (EMB) flag and the enable register bank (ERB) flag are  
also pushed to the stack. Since six 4-bit stack locations are used per CALL, you may nest subroutine calls up to  
the number of levels permitted in the stack.  
Interrupt Routines  
An interrupt routine references the SP to push the contents of the PC and the program status word (PSW) to the  
stack. Six 4-bit stack locations are used to store this data. After the interrupt has executed, the SP is decreased by  
six and points to the next available stack location. During an interrupt sequence, subroutines may be nested up to  
the number of levels which are permitted in the stack area.  
INTERRUPT  
PUSH  
CALL  
(When INT is acknowledged,  
SP SP-6)  
(After PUSH, SP SP-2)  
(After CALL , SP SP-6)  
SP-6  
SP-5  
SP-4  
SP-3  
SP-2  
SP-1  
SP  
PC11-PC8  
SP-6  
SP-5  
SP-4  
SP-3  
SP-2  
SP-1  
SP  
PC11-PC8  
0
0
0
0
0
0
0
0
PC3-PC0  
PC7-PC4  
PC3-PC0  
PC7-PC4  
SP-2  
SP-1  
SP  
Lower Register  
Upper Register  
0
0
0
0
EMB ERB  
PSW  
IS1 IS0 EMB ERB  
PSW  
0
0
C
SC2 SC1 SC0  
Figure 2-7. Push-Type Stack Operations  
2-13  
ADDRESS SPACES  
S3C72K8/P72K8  
POP OPERATIONS  
For each push operation there is a corresponding pop operation to write data from the stack back to the source  
register or registers: for the PUSH instruction it is the POP instruction; for CALL, the instruction RET or SRET; for  
interrupts, the instruction IRET. When a pop operation occurs, the SP is incremented by a number determined by  
the type of operation and points to the next free stack location.  
POP Instructions  
A POP instruction references the SP to write data stored in two 4-bit stack locations back to the register pairs and  
SB register. The value of the lower 4-bit register is popped first, followed by the value of the upper 4-bit register. After  
the POP has executed, the SP is incremented by two and points to the next free stack location.  
RET and SRET Instructions  
The end of a subroutine call is signaled by the return instruction, RET or SRET. The RET or SRET uses the SP to  
reference the six 4-bit stack locations used for the CALL and to write this data back to the PC, the EMB, and the  
ERB. After the RET or SRET has executed, the SP is incremented by six and points to the next free stack location.  
IRET Instructions  
The end of an interrupt sequence is signaled by the instruction IRET. IRET references the SP to locate the six 4-bit  
stack addresses used for the interrupt and to write this data back to the PC and the PSW. After the IRET has  
executed, the SP is incremented by six and points to the next free stack location.  
POP  
SP+2)  
RET or SRET  
(SP SP+6)  
IRET  
(SP SP+6)  
(SP  
SP  
Lower Register  
Upper Register  
SP  
PC11-PC8  
SP  
PC11-PC8  
SP+1  
SP+2  
SP+1  
SP+2  
SP+3  
SP+4  
SP+5  
SP+6  
0
0
0
SP+1  
SP+2  
SP+3  
SP+4  
SP+5  
SP+6  
0
0
0
0
0
PC3-PC0  
PC7-PC4  
PC3-PC0  
PC7-PC4  
0
0
0
0
EMB ERB  
PSW  
IS1 IS0 EMB ERB  
PSW  
0
0
C
SC2 SC1 SC0  
Figure 2-8. Pop-Type Stack Operations  
2-14  
S3C72K8/P72K8  
ADDRESS SPACES  
BIT SEQUENTIAL CARRIER (BSC)  
The bit sequential carrier (BSC) is a 16-bit general register that can be manipulated using 1-, 4-, and 8-bit RAM  
control instructions. RESET clears all BSC bit values to logic zero.  
Using the BSC, you can specify sequential addresses and bit locations using 1-bit indirect addressing (memb.@L).  
(Bit addressing is independent of the current EMB value.) In this way, programs can process 16-bit data by moving  
the bit location sequentially and then incrementing or decreasing the value of the L register.  
BSC data can also be manipulated using direct addressing. For 8-bit manipulations, the 4-bit register names BSC0  
and BSC2 must be specified and the upper and lower 8 bits manipulated separately.  
If the values of the L register are 0H at BSC0.@L, the address and bit location assignment is FC0H.0. If the L  
register content is FH at BSC0.@L, the address and bit location assignment is FC3H.3.  
Table 2-4. BSC Register Organization  
Name  
BSC0  
BSC1  
BSC2  
BSC3  
Address  
FC0H  
Bit 3  
Bit 2  
Bit 1  
Bit 0  
BSC0.3  
BSC1.3  
BSC2.3  
BSC3.3  
BSC0.2  
BSC1.2  
BSC2.2  
BSC3.2  
BSC0.1  
BSC1.1  
BSC2.1  
BSC3.1  
BSC0.0  
BSC1.0  
BSC2.0  
BSC3.0  
FC1H  
FC2H  
FC3H  
F
PROGRAMMING TIP — Using the BSC Register to Output 16-Bit Data  
To use the bit sequential carrier (BSC) register to output 16-bit data (5937H) to the P3.0 pin:  
BITS  
SMB  
LD  
LD  
LD  
LD  
SMB  
LD  
LDB  
LDB  
INCS  
JR  
EMB  
15  
EA,#37H  
BSC0,EA  
EA,#59H  
BSC2,EA  
0
L,#0H  
C,BSC0.@L  
P3.0,C  
L
;
;
;
;
BSC0 ¬ A, BSC1 ¬  
BSC2 ¬ A, BSC3 ¬  
E
E
;
;
;
AGN  
P3.0 ¬  
C
AGN  
RET  
2-15  
ADDRESS SPACES  
S3C72K8/P72K8  
PROGRAM COUNTER (PC)  
A 12-bit program counter (PC) stores addresses for instruction fetches during program execution. Whenever a reset  
operation or an interrupt occurs, bits PC11 through PC0 are set to the vector address.  
Usually, the PC is incremented by the number of bytes of the instruction being fetched. One exception is the 1-byte  
REF instruction which is used to reference instructions stored in the ROM.  
PROGRAM STATUS WORD (PSW)  
The program status word (PSW) is an 8-bit word that defines system status and program execution status and which  
permits an interrupted process to resume operation after an interrupt request has been serviced. PSW values are  
mapped as follows:  
(MSB)  
IS1  
(LSB)  
ERB  
SC0  
FB0H  
FB1H  
IS0  
EMB  
SC1  
C
SC2  
The PSW can be manipulated by 1-bit or 4-bit read/write and by 8-bit read instructions, depending on the specific bit  
or bits being addressed. The PSW can be addressed during program execution regardless of the current value of the  
enable memory bank (EMB) flag.  
Part or all of the PSW is saved to stack prior to execution of a subroutine call or hardware interrupt. After the  
interrupt has been processed, the PSW values are popped from the stack back to the PSW address.  
When a RESET is generated, the EMB and ERB values are set according to the RESET vector address, and the  
carry flag is left undefined (or the current value is retained). PSW bits IS0, IS1, SC0, SC1, and SC2 are all cleared to  
logical zero.  
Table 2-5. Program Status Word Bit Descriptions  
PSW Bit Identifier  
IS1, IS0  
Description  
Interrupt status flags  
Enable memory bank flag  
Enable register bank flag  
Carry flag  
Bit Addressing  
Read/Write  
R/W  
1, 4  
1
EMB  
R/W  
ERB  
1
R/W  
C
1
R/W  
SC2, SC1, SC0  
Program skip flags  
8
R
2-16  
S3C72K8/P72K8  
ADDRESS SPACES  
INTERRUPT STATUS FLAGS (IS0, IS1)  
PSW bits IS0 and IS1 contain the current interrupt execution status values. You can manipulate IS0 and IS1 flags  
directly using 1-bit RAM control instructions  
By manipulating interrupt status flags in conjunction with the interrupt priority register (IPR), you can process  
multiple interrupts by anticipating the next interrupt in an execution sequence. The interrupt priority control circuit  
determines the IS0 and IS1 settings in order to control multiple interrupt processing. When both interrupt status flags  
are set to "0", all interrupts are allowed. The priority with which interrupts are processed is then determined by the  
IPR.  
When an interrupt occurs, IS0 and IS1 are pushed to the stack as part of the PSW and are automatically  
incremented to the next higher priority level. Then, when the interrupt service routine ends with an IRET instruction,  
IS0 and IS1 values are restored to the PSW. Table 2-6 shows the effects of IS0 and IS1 flag settings.  
Table 2-6. Interrupt Status Flag Bit Settings  
IS1  
Value  
IS0  
Value  
Status of Currently  
Executing Process  
Effect of IS0 and IS1 Settings  
on Interrupt Request Control  
0
0
0
1
0
1
All interrupt requests are serviced  
Only high-priority interrupt(s) as determined in the interrupt  
priority register (IPR) are serviced  
1
1
0
1
2
No more interrupt requests are serviced  
Not applicable; these bit settings are undefined  
Since interrupt status flags can be addressed by write instructions, programs can exert direct control over interrupt  
processing status. Before interrupt status flags can be addressed, however, you must first execute a DI instruction to  
inhibit additional interrupt routines. When the bit manipulation has been completed, execute an EI instruction to re-  
enable interrupt processing.  
+
PROGRAMMING TIP — Setting ISx Flags for Interrupt Processing  
The following instruction sequence shows how to use the IS0 and IS1 flags to control interrupt processing:  
INTB  
DI  
BITR  
BITS  
EI  
;
;
;
;
Disable interrupt  
IS1 ¬ 0  
Allow interrupts according to IPR priority level  
Enable interrupt  
IS1  
IS0  
.
.
.
IRET  
2-17  
ADDRESS SPACES  
EMB FLAG (EMB)  
S3C72K8/P72K8  
The EMB flag is used to allocate specific address locations in the RAM by modifying the upper 4 bits of 12-bit data  
memory addresses. In this way, it controls the addressing mode for data memory banks 0, 1, or 15.  
When the EMB flag is "0", the data memory address space is restricted to bank 15 and addresses 000H–07FH of  
memory bank 0, regardless of the SMB register contents. When the EMB flag is set to "1", the general-purpose  
areas of bank 0, 1, and 15 can be accessed by using the appropriate SMB value.  
F
PROGRAMMING TIP — Using the EMB Flag to Select Memory Banks  
EMB flag settings for memory bank selection:  
1. When EMB = "0":  
SMB  
LD  
LD  
LD  
SMB  
LD  
LD  
SMB  
LD  
1
;
Non-essential instruction since EMB = "0"  
A,#9H  
90H,A  
34H,A  
0
90H,A  
34H,A  
15  
;
;
;
;
;
;
;
;
(F90H) ¬ A, bank 15 is selected  
(034H) ¬ A, bank 0 is selected  
Non-essential instruction since EMB = "0"  
(F90H) ¬ A, bank 15 is selected  
(034H) ¬ A, bank 0 is selected  
Non-essential instruction, since EMB = "0"  
(020H) ¬ A, bank 0 is selected  
(F90H) ¬ A, bank 15 is selected  
20H,A  
90H,A  
LD  
2. When EMB = "1":  
SMB  
LD  
LD  
LD  
SMB  
LD  
LD  
SMB  
LD  
1
;
Select memory bank 1  
A,#9H  
90H,A  
34H,A  
0
90H,A  
34H,A  
15  
;
;
;
;
;
;
;
;
(190H) ¬ A, bank 1 is selected  
(1340H) ¬ A, bank 1 is selected  
Select memory bank 0  
(090H) ¬ A, bank 0 is selected  
(034H) ¬ A, bank 0 is selected  
Select memory bank 15  
20H,A  
90H,A  
Program error, but assembler does not detect it  
(F90H) ¬ A, bank 15 is selected  
LD  
2-18  
S3C72K8/P72K8  
ADDRESS SPACES  
ERB FLAG (ERB)  
The 1-bit register bank enable flag (ERB) determines the range of addressable working register area. When the ERB  
flag is "1", the working register area from register banks 0 to 3 is selected according to the register bank selection  
register (SRB). When the ERB flag is "0", register bank 0 is the selected working register area, regardless of the  
current value of the register bank selection register (SRB).  
When an internal RESET is generated, bit 6 of program memory address 0000H is written to the ERB flag. This  
automatically initializes the flag. When a vectored interrupt is generated, bit 6 of the respective address table in  
program memory is written to the ERB flag, setting the correct flag status before the interrupt service routine is  
executed.  
During the interrupt routine, the ERB value is automatically pushed to the stack area along with the other PSW bits.  
Afterwards, it is popped back to the FB0H.0 bit location. The initial ERB flag settings for each vectored interrupt are  
defined using VENTn instructions.  
F
PROGRAMMING TIP — Using the ERB Flag to Select Register Banks  
ERB flag settings for register bank selection:  
1. When ERB = "0":  
SRB  
1
;
;
;
;
;
;
;
;
Register bank 0 is selected (since ERB = "0", the  
SRB is configured to bank 0)  
Bank 0 EA ¬ #34H  
Bank 0 HL ¬ EA  
Register bank 0 is selected  
Bank 0 YZ ¬ EA  
LD  
LD  
SRB  
LD  
SRB  
LD  
EA,#34H  
HL,EA  
2
YZ,EA  
3
Register bank 0 is selected  
Bank 0 WX ¬ EA  
WX,EA  
2. When ERB = "1":  
SRB  
LD  
LD  
SRB  
LD  
SRB  
LD  
1
;
;
;
;
;
;
;
Register bank 1 is selected  
Bank 1 EA ¬ #34H  
EA,#34H  
HL,EA  
2
YZ,EA  
3
Bank 1 HL ¬ Bank 1 EA  
Register bank 2 is selected  
Bank 2 YZ ¬ Bank 2 EA  
Register bank 3 is selected  
Bank 3 WX ¬ Bank 3 EA  
WX,EA  
2-19  
ADDRESS SPACES  
S3C72K8/P72K8  
SKIP CONDITION FLAGS (SC2, SC1, SC0)  
The skip condition flags SC2, SC1, and SC0 in the PSW indicate the current program skip conditions and are set  
and reset automatically during program execution. Skip condition flags can only be addressed by 8-bit read  
instructions. Direct manipulation of the SC2, SC1, and SC0 bits is not allowed.  
CARRY FLAG (C)  
The carry flag is used to save the result of an overflow or borrow when executing arithmetic instructions involving a  
carry (ADC, SBC). The carry flag can also be used as a 1-bit accumulator for performing Boolean operations involving  
bit-addressed data memory.  
If an overflow or borrow condition occurs when executing arithmetic instructions with carry (ADC, SBC), the carry flag  
is set to "1". Otherwise, its value is "0". When a RESET occurs, the current value of the carry flag is retained during  
power-down mode, but when normal operating mode resumes, its value is undefined.  
The carry flag can be directly manipulated by predefined set of 1-bit read/write instructions, independent of other bits  
in the PSW. Only the ADC and SBC instructions, and the instructions listed in Table 2-7, affect the carry flag.  
Table 2-7. Valid Carry Flag Manipulation Instructions  
Operation Type  
Instructions  
Carry Flag Manipulation  
Set carry flag to "1"  
Direct manipulation  
SCF  
RCF  
CCF  
Clear carry flag to "0" (reset carry flag)  
Invert carry flag value (complement carry flag)  
Test carry and skip if C = "1"  
BTST C  
(1)  
Bit transfer  
Load carry flag value to the specified bit  
LDB (operand)  
,C  
(1)  
Load contents of the specified bit to carry flag  
LDB C,(operand)  
BAND C,(operand)  
(1)  
Boolean manipulation  
AND the specified bit with contents of carry flag and save  
the result to the carry flag  
(1)  
OR the specified bit with contents of carry flag and save  
the result to the carry flag  
BOR C,(operand)  
(1)  
XOR the specified bit with contents of carry flag and save  
the result to the carry flag  
BXOR C,(operand)  
(2)  
Interrupt routine  
Save carry flag to stack with other PSW bits  
INTn  
Return from interrupt  
IRET  
Restore carry flag from stack with other PSW bits  
NOTES:  
1. The operand has three bit addressing formats: mema.a, memb.@L, and @H + DA.b.  
2. 'INTn' refers to the specific interrupt being executed and is not an instruction.  
2-20  
S3C72K8/P72K8  
ADDRESS SPACES  
F
PROGRAMMING TIP — Using the Carry Flag as a 1-Bit Accumulator  
1. Set the carry flag to logic one:  
SCF  
LD  
LD  
ADC  
;
;
;
;
C ¬  
EA ¬ #0C3H  
HL ¬ #0AAH  
EA ¬ #0C3H + #0AAH + #1H, C ¬  
1
EA,#0C3H  
HL,#0AAH  
EA,HL  
1
2. Logical-AND bit 3 of address 3FH with P3.3 and output the result to P5.0:  
LD  
H,#3H  
;
;
;
;
;
Set the upper four bits of the address to the H register  
value  
C ¬ bit 3 of 3FH  
C ¬ C AND P3.3  
Output result from carry flag to P4.0  
LDB  
BAND  
LDB  
C,@H+0FH.3  
C,P3.3  
P4.0,C  
2-21  
ADDRESS SPACES  
S3C72K8/P72K8  
NOTES  
2-22  
S3C72K8/P72K8  
ADDRESSING MODES  
3
ADDRESSING MODES  
OVERVIEW  
The enable memory bank flag, EMB, controls the two addressing modes for data memory. When the EMB flag is set  
to logic one, you can address the entire RAM area; when the EMB flag is cleared to logic zero, the addressable area  
in the RAM is restricted to specific locations.  
The EMB flag works in connection with the select memory bank instruction, SMBn. You will recall that the SMBn  
instruction is used to select RAM bank 0, 1, 2, 3 or 15. The SMB setting is always contained in the upper four bits  
of a 12-bit RAM address. For this reason, both addressing modes (EMB = "0" and EMB = "1") apply specifically to  
the memory bank indicated by the SMB instruction, and any restrictions to the addressable area within banks 0, 1,  
2, 3 or 15. Direct and indirect 1-bit, 4-bit, and 8-bit addressing methods can be used. Several RAM locations are  
addressable at all times, regardless of the current EMB flag setting.  
Here are a few guidelines to keep in mind regarding data memory addressing:  
— When you address peripheral hardware locations in bank 15, the mnemonic for the memory-mapped hardware  
component can be used as the operand in place of the actual address location.  
— Always use an even-numbered RAM address as the operand in 8-bit direct and indirect addressing.  
— With direct addressing, use the RAM address as the instruction operand; with indirect addressing, the  
instruction specifies a register which contains the operand's address.  
3-1  
ADDRESSING MODES  
S3C72K8/P72K8  
Addressing  
Mode  
DA  
DA.b  
@HL  
@H+DA.b  
@WX  
@WL  
mema.b memb.@L  
RAM  
Areas  
EMB = 0  
EMB = 1  
EMB = 0  
EMB = 1  
X
X
X
000H  
Working  
Registers  
01FH  
020H  
07FH  
080H  
SMB = 0  
SMB = 0  
Bank 0  
(General  
Registers  
and Stack)  
0FFH  
100H  
Bank 1  
(General  
Registers)  
SMB = 1  
SMB = 1  
SMB = 2  
SMB = 3  
SMB = 1  
SMB = 1  
SMB = 2  
SMB = 3  
1AFH  
1B0H  
Bank 1  
(Display  
Registers)  
1FFH  
200H  
Bank 2  
(General  
Registers)  
2FFH  
300H  
Bank 3  
(General  
Registers)  
3FFH  
F80H  
FB0H  
Bank 15  
(Peripheral  
Hardware  
Registers)  
FBFH  
FC0H  
SMB = 15  
SMB = 15  
FF0H  
FFFH  
NOTES:  
1. 'X' means don't care.  
2. Blank columns indicate RAM areas that are not addressable, given the addressing method and  
enable memory bank (EMB) flag setting shown in the column headers.  
Figure 3-1. RAM Address Structure  
3-2  
S3C72K8/P72K8  
ADDRESSING MODES  
EMB AND ERB INITIALIZATION VALUES  
The EMB and ERB flag bits are set automatically by the values of the RESET vector address and the interrupt vector  
address. When a RESET is generated internally, bit 7 of program memory address 0000H is written to the EMB flag,  
initializing it automatically. When a vectored interrupt is generated, bit 7 of the respective vector address table is  
written to the EMB. This automatically sets the EMB flag status for the interrupt service routine. When the interrupt  
is serviced, the EMB value is automatically saved to stack and then restored when the interrupt routine has  
completed.  
At the beginning of a program, the initial EMB and ERB flag values for each vectored interrupt must be set by using  
VENT instruction. The EMB and ERB can be set or reset by bit manipulation instructions (BITS, BITR) despite the  
current SMB setting.  
F
PROGRAMMING TIP — Initializing the EMB and ERB Flags  
The following assembly instructions show how to initialize the EMB and ERB flag settings:  
ORG  
0000H  
;
ROM address assignment  
VENT0  
VENT1  
VENT2  
VENT3  
VENT4  
VENT5  
VENT6  
1,0,RESET  
0,1,INTB  
0,1,INT0  
0,1,INT1  
0,1,INTS  
0,1,INTT0  
0,1,INTK  
;
;
;
;
;
;
;
EMB ¬ 1, ERB ¬ 0, branch RESET  
EMB ¬ 0, ERB ¬ 1, branch INTB  
EMB ¬ 0, ERB ¬ 1, branch INT0  
EMB ¬ 0, ERB ¬ 1, branch INT1  
EMB ¬ 0, ERB ¬ 1, branch INTS  
EMB ¬ 0, ERB ¬ 1, branch INTT0  
EMB ¬ 0, ERB ¬ 1, branch INTK  
RESET  
BITR  
EMB  
3-3  
ADDRESSING MODES  
S3C72K8/P72K8  
ENABLE MEMORY BANK SETTINGS  
EMB = "1"  
When the enable memory bank flag EMB is set to logic one, you can address the data memory bank specified by  
the select memory bank (SMB) value (0, 1, 2, 3 or 15) using 1-, 4-, or 8-bit instructions. You can use both direct and  
indirect addressing modes. The addressable RAM areas when EMB = "1" are as follows:  
If SMB = 0,  
If SMB = 1,  
If SMB = 2,  
If SMB = 3,  
If SMB = 15,  
000H–0FFH  
100H–1FFH  
200H–2FFH  
300H–3FFH  
F80H–FFFH  
EMB = "0"  
When the enable memory bank flag EMB is set to logic zero, the addressable area is defined independently of the  
SMB value, and is restricted to specific locations depending on whether a direct or indirect address mode is used.  
If EMB = "0", the addressable area is restricted to locations 000H–07FH in bank 0 and to locations F80H–FFFH in  
bank 15 for direct addressing. For indirect addressing, only locations 000H–0FFH in bank 0 are addressable,  
regardless of SMB value.  
To address the peripheral hardware register (bank 15) using indirect addressing, the EMB flag must first be set to "1"  
and the SMB value to "15". When a RESET occurs, the EMB flag is set to the value contained in bit 7 of ROM  
address 0000H.  
EMB-Independent Addressing  
At any time, several areas of the data memory can be addressed independent of the current status of the EMB flag.  
These exceptions are described in Table 3-1.  
Table 3-1. RAM Addressing Not Affected by the EMB Value  
Address  
000H–0FFH  
Addressing Method  
Affected Hardware  
Program Examples  
4-bit indirect addressing using WX  
and WL register pairs;  
Not applicable  
LD  
A,@WX  
8-bit indirect addressing using SP  
PUSH EA  
POP  
EA  
FB0H–FBFH  
FF0H–FFFH  
1-bit direct addressing  
PSW, SCMOD,  
IEx, IRQx, I/O  
BITS  
BITR  
EMB  
IE4  
FC0H–FFFH  
1-bit indirect addressing using the  
L register  
BSC, I/O  
BTST FC3H.@L  
BAND C,P3.@L  
3-4  
S3C72K8/P72K8  
ADDRESSING MODES  
SELECT BANK REGISTER (SB)  
The select bank register (SB) is used to assign the memory bank and register bank. The 8-bit SB register consists  
of the 4-bit select register bank register (SRB) and the 4-bit select memory bank register (SMB), as shown in Figure  
3-2.  
During interrupts and subroutine calls, SB register contents can be saved to stack in 8-bit units by the PUSH SB  
instruction. You later restore the value to the SB using the POP SB instruction.  
SMB (F83H)  
SMB 2 SMB 1  
SRB (F82H)  
SRB 1  
SB  
Register  
SMB 3  
SMB 0  
0
0
SRB 0  
Figure 3-2. SMB and SRB Values in the SB Register  
Select Register Bank (SRB) Instruction  
The select register bank (SRB) value specifies which register bank is to be used as a working register bank. The  
SRB value is set by the 'SRB n' instruction, where n = 0, 1, 2, 3.  
One of the four register banks is selected by the combination of ERB flag status and the SRB value that is set using  
the 'SRB n' instruction. The current SRB value is retained until another register is requested by program software.  
PUSH SB and POP SB instructions are used to save and restore the contents of SRB during interrupts and  
subroutine calls. RESET clears the 4-bit SRB value to logic zero.  
Select Memory Bank (SMB) Instruction  
To select one of the four available data memory banks, you must execute an SMB n instruction specifying the  
number of the memory bank you want (0, 1, 2, 3 or 15). For example, the instruction 'SMB 1' selects bank 1 and  
'SMB 15' selects bank 15. (And remember to enable the selected memory bank by making the appropriate EMB flag  
setting.)  
The upper four bits of the 12-bit data memory address are stored in the SMB register. If the SMB value is not  
specified by software (or if a RESET does not occur) the current value is retained. RESET clears the 4-bit SMB value  
to logic zero.  
The PUSH SB and POP SB instructions save and restore the contents of the SMB register to and from the stack  
area during interrupts and subroutine calls.  
3-5  
ADDRESSING MODES  
S3C72K8/P72K8  
DIRECT AND INDIRECT ADDRESSING  
1-bit, 4-bit, and 8-bit data stored in data memory locations can be addressed directly using a specific register or bit  
address as the instruction operand.  
Indirect addressing specifies a memory location that contains the required direct address. The S3C7 instruction set  
supports 1-bit, 4-bit, and 8-bit indirect addressing. For 8-bit indirect addressing, an even-numbered RAM address  
must always be used as the instruction operand.  
1-BIT ADDRESSING  
Table 3-2. 1-Bit Direct and Indirect RAM Addressing  
Operand  
Notation  
Addressing Mode  
Description  
EMB Flag Addressable  
Memory  
Bank  
Hardware I/O  
Mapping  
Setting  
Area  
000H–07FH  
F80H–FFFH  
Bank 0  
DA.b  
Direct: bit is indicated by the  
RAM address (DA), memory  
bank selection, and specified  
bit number (b).  
0
Bank 15  
All 1-bit  
addressable  
peripherals  
(SMB = 15)  
1
x
000H–FFFH  
SMB = 0-3,15  
Bank 15  
mema.b  
Direct: bit is indicated by ad-  
dressable area (mema) and bit  
number (b).  
FB0H–FBFH  
FF0H–FFFH  
IS0, IS1, EMB,  
ERB, IEx, IRQx,  
Pn.n  
memb.@L  
Indirect: lower two bits of reg-  
ister L as indicated by the up-  
per 10 bits of RAM area  
(memb) and the upper two bits  
of register L.  
x
FC0H–FFFH  
Bank 15  
BSCn.x  
Pn.n  
@H + DA.b Indirect: bit indicated by the  
lower four bits of the address  
0
1
000H–0FFH  
000H–FFFH  
Bank 0  
(DA), memory bank selection,  
and the H register identifier.  
SMB = 0-3,15  
All 1-bit  
addressable  
peripherals  
(SMB = 15)  
NOTE: 'x' means don't care.  
3-6  
S3C72K8/P72K8  
ADDRESSING MODES  
F
PROGRAMMING TIP — 1-Bit Addressing Modes  
1-Bit Direct Addressing  
1. If EMB = "0":  
AFLAG  
BFLAG  
CFLAG  
EQU  
EQU  
EQU  
SMB  
BITS  
BITS  
BTST  
BITS  
BITS  
34H.3  
85H.3  
0BAH.0  
0
AFLAG  
BFLAG  
CFLAG  
BFLAG  
P3.0  
;
;
;
;
;
34H.3 ¬  
F85H.3 ¬  
1
1
If FBAH.0 = 1, skip  
Else if, FBAH.0 = 0, F85H.3 (BMOD.3) ¬  
FF3H.0 (P3.0) ¬  
1
1
2. If EMB = "1":  
AFLAG  
BFLAG  
CFLAG  
EQU  
34H.3  
85H.3  
0BAH.0  
0
AFLAG  
BFLAG  
CFLAG  
BFLAG  
P3.0  
EQU  
EQU  
SMB  
BITS  
BITS  
BTST  
BITS  
BITS  
;
;
;
;
;
34H.3 ¬  
85H.3 ¬  
If 0BAH.0 = 1, skip  
Else if 0BAH.0 = 0, 085H.3 ¬  
FF3H.0 (P3.0) ¬  
1
1
1
1
1-Bit Indirect Addressing  
1. If EMB = "0":  
AFLAG  
BFLAG  
CFLAG  
EQU  
EQU  
EQU  
SMB  
LD  
34H.3  
85H.3  
0BAH.0  
0
H,#0BH  
@H+CFLAG  
CFLAG  
;
;
;
H ¬ #0BH  
If 0BAH.0 = 1, 0BAH.0 ¬ 0 and skip  
BTSTZ  
BITS  
Else if 0BAH.0 = 0, FBAH.0  
¬
1
2. If EMB = "1":  
AFLAG  
BFLAG  
CFLAG  
EQU  
34H.3  
85H.3  
EQU  
EQU  
SMB  
LD  
BTSTZ  
BITS  
0BAH.0  
0
H,#0BH  
@H+CFLAG  
CFLAG  
;
;
;
H ¬ #0BH  
If 0BAH.0 = 1, 0BAH.0 ¬ 0 and skip  
Else if 0BAH.0 = 0, 0BAH.0 ¬  
1
3-7  
ADDRESSING MODES  
4-BIT ADDRESSING  
S3C72K8/P72K8  
Table 3-3. 4-Bit Direct and Indirect RAM Addressing  
Addressing Mode EMB Flag Addressable Memory  
Operand  
Notation  
Hardware I/O  
Mapping  
Description  
Setting  
Area  
Bank  
000H–07FH  
F80H–FFFH  
Bank 0  
DA  
0
Bank 15  
All 4-bit  
addressable pe-  
ripherals  
Direct: 4-bit address indicated  
by the RAM address (DA) and  
the memory bank selection  
1
0
000H–FFFH  
000H–0FFH  
SMB = 0-3,15  
Bank 0  
(SMB = 15)  
@HL  
Indirect: 4-bit address indicated  
by the memory bank selection  
and register HL  
1
000H–FFFH  
SMB = 0-3,15  
All 4-bit  
addressable pe-  
ripherals  
(SMB = 15)  
@WX  
@WL  
x
x
000H–0FFH  
000H–0FFH  
Bank 0  
Bank 0  
Indirect: 4-bit address indicated  
by register WX  
Indirect: 4-bit address indicated  
by register WL  
NOTE: 'x' means don't care.  
F
PROGRAMMING TIP — 4-Bit Addressing Modes  
4-Bit Direct Addressing  
1. If EMB = "0":  
ADATA  
BDATA  
EQU  
EQU  
SMB  
LD  
SMB  
LD  
46H  
8EH  
15  
A,P3  
0
;
;
;
;
;
Non-essential instruction, since EMB = "0"  
A ¬ (P3)  
Non-essential instruction, since EMB = "0"  
ADATA,A  
BDATA,A  
(046H) ¬  
A
LD  
(F8EH (LCON)) ¬  
A
2. If EMB = "1":  
]
ADATA  
BDATA  
EQU  
EQU  
SMB  
LD  
SMB  
LD  
46H  
8EH  
15  
A,P3  
0
;
A ¬ (P3)  
ADATA,A ;  
BDATA,A ;  
(046H) ¬  
(08EH) ¬  
A
A
LD  
3-8  
S3C72K8/P72K8  
ADDRESSING MODES  
F
PROGRAMMING TIP — 4-Bit Addressing Modes  
4-Bit Indirect Addressing (Example 1)  
1. If EMB = "0", compare bank 0 locations 040H–046H with bank 0 locations 060H–066H:  
ADATA  
BDATA  
EQU  
EQU  
SMB  
LD  
LD  
LD  
CPSE  
SRET  
DECS  
JR  
46H  
66H  
1
HL,#BDATA  
WX,#ADATA  
A,@WL  
A,@HL  
;
Non-essential instruction, since EMB = "0"  
COMP  
;
;
A ¬ bank 0 (040H–046H)  
If bank 0 (060H–066H) = A, skip  
L
COMP  
RET  
2. If EMB = "1", compare bank 0 locations 040H–046H with bank 1 locations 160H–166H:  
ADATA  
BDATA  
EQU  
EQU  
SMB  
LD  
LD  
LD  
CPSE  
SRET  
DECS  
JR  
46H  
66H  
1
HL,#BDATA  
WX,#ADATA  
A,@WL  
A,@HL  
COMP  
;
;
A ¬ bank 0 (040H–046H)  
If bank 1 (160H–166H) = A, skip  
L
COMP  
RET  
4-Bit Indirect Addressing (Example 2)  
1. If EMB = "0", exchange bank 0 locations 040H–046H with bank 0 locations 060H–066H:  
ADATA  
BDATA  
EQU  
EQU  
SMB  
LD  
LD  
LD  
46H  
66H  
1
HL,#BDATA  
WX,#ADATA  
A,@WL  
A,@HL  
TRANS  
;
Non-essential instruction, since EMB = "0"  
TRANS  
;
;
A ¬ bank 0 (040H–046H)  
If bank 0 (060H–066H) « A, skip  
XCHD  
JR  
2. If EMB = "1", exchange bank 0 locations 040H–046H with bank 1 locations 160H–166H:  
ADATA  
BDATA  
EQU  
EQU  
SMB  
LD  
LD  
LD  
46H  
66H  
1
HL,#BDATA  
WX,#ADATA  
A,@WL  
A,@HL  
TRANS  
TRANS  
;
;
A ¬ bank 0 (040H–046H)  
If bank 1 (160H–166H) « A, skip  
XCHD  
JR  
3-9  
ADDRESSING MODES  
8-BIT ADDRESSING  
S3C72K8/P72K8  
Table 3-4. 8-Bit Direct and Indirect RAM Addressing  
Instruction  
Notation  
Addressing Mode  
Description  
EMB Flag  
Setting  
Addressable  
Area  
Memory  
Bank  
Hardware I/O  
Mapping  
000H–07FH  
F80H–FFFH  
Bank 0  
DA  
Direct: 8-bit address indicated  
by the RAM address (DA =  
even number) and memory  
bank selection  
0
Bank 15  
All 8-bit  
addressable pe-  
ripherals  
1
0
000H–FFFH  
000H–0FFH  
SMB = 0-3,15  
Bank 0  
(SMB = 15)  
@HL  
Indirect: the 8-bit address indi-  
cated by the memory bank  
selection and register HL; (the  
4-bit L register value must be  
an even number)  
1
000H–FFFH  
SMB = 0-3,15  
All 8-bit  
addressable pe-  
ripherals  
(SMB = 15)  
3-10  
S3C72K8/P72K8  
ADDRESSING MODES  
F
PROGRAMMING TIP — 8-Bit Addressing Modes  
8-Bit Direct Addressing  
1. If EMB = "0":  
ADATA  
BDATA  
EQU  
EQU  
SMB  
LD  
SMB  
LD  
46H  
8EH  
15  
EA, P4  
0
;
;
Non-essential instruction, since EMB = "0"  
E ¬ (P5), A ¬ (P4)  
ADATA,EA  
BDATA,EA  
;
;
(046H) ¬ A, (047H) ¬  
(F8EH) ¬ A, (F8FH) ¬  
E
E
LD  
2. If EMB = "1":  
ADATA  
BDATA  
EQU  
46H  
8EH  
15  
EA,P4  
0
EQU  
SMB  
LD  
SMB  
LD  
;
E ¬ (P5), A ¬ (P4)  
ADATA,EA  
BDATA,EA  
;
;
(046H) ¬ A, (047H) ¬  
(08EH) ¬ A, (08FH) ¬  
E
E
LD  
8-Bit Indirect Addressing  
1. If EMB = "0":  
ADATA  
EQU  
SMB  
LD  
46H  
1
HL,#ADATA  
EA,@HL  
;
;
Non-essential instruction, since EMB = "0"  
LD  
A ¬ (046H), E ¬ (047H)  
2. If EMB = "1":  
ADATA EQU  
46H  
SMB  
LD  
LD  
1
HL,#ADATA  
EA,@HL  
;
A ¬ (146H), E ¬ (147H)  
3-11  
ADDRESSING MODES  
S3C72K8/P72K8  
NOTES  
3-12  
S3C72K8/P72K8  
MEMORY MAP  
4
MEMORY MAP  
OVERVIEW  
To support program control of peripheral hardware, I/O addresses for peripherals are memory-mapped to bank 15 of  
the RAM. Memory mapping lets you use a mnemonic as the operand of an instruction in place of the specific  
memory location.  
Access to bank 15 is controlled by the select memory bank (SMB) instruction and by the enable memory bank flag  
(EMB) setting. If the EMB flag is "0", bank 15 can be addressed using direct addressing, regardless of the current  
SMB value. 1-bit direct and indirect addressing can be used for specific locations in bank 15, regardless of the  
current EMB value.  
I/O MAP FOR HARDWARE REGISTERS  
Table 4-1 contains detailed information about I/O mapping for peripheral hardware in bank 15 (register locations  
F80H–FFFH). Use the I/O map as a quick-reference source when writing application programs. The I/O map gives  
you the following information:  
— Register address  
— Register name (mnemonic for program addressing)  
— Bit values (both addressable and non-manipulable)  
— Read-only, write-only, or read and write addressability  
— 1-bit, 4-bit, or 8-bit data manipulation characteristics  
4-1  
MEMORY MAP  
Addressing  
S3C72K8/P72K8  
Table 4-1. I/O Map for Memory Bank 15  
Description  
Symbol  
Affected Memory mapped I/O  
1-bit direct  
addressing  
DA.b  
The bit indicated by memory bank, DA  
and bit.  
All peripheral hardware that can be  
manipulated in 1 bit.  
(EMB=0, or EMB=1 and SMB 15)  
4-bit direct  
addressing  
DA  
DA  
The address indicated by memory bank  
and DA.  
(EMB=0, or EMB=1 and SMB 15)  
All peripheral hardware that can be  
manipulated in 4 bits.  
8-bit direct  
addressing  
The address (DA specifies an even  
address) indicated by memory bank and  
DA. (EMB=0, or EMB=1 and SMB 15)  
All peripheral hardware that can be  
manipulated in 8 bits.  
4-bit indirect  
addressing  
@HL  
@HL  
The address indicated by memory bank  
and HL register.  
(EMB=1 and SMB 15)  
All peripheral hardware that can be  
manipulated in 4 bits.  
8-bit indirect  
addressing  
The address indicated by memory bank  
and HL (the contents of the L register are manipulated in 8 bit.  
All peripheral hardware that can be  
even).  
(EMB=1 and SMB 15)  
1-bit  
manipulating  
addressing  
mema.b The bit indicated by mema and bit.  
(regardless of the status of EMB and  
SMB)  
IS0, IS1, EMB, ERB, IEx, IRQx, Pn.m  
memb.@L The bit indicated by the lower 2 bits of the Pn.m  
L register of the address indicated by the  
upper 10 bits of memb and the upper 2  
bits of the L reigster.  
(regardless of the status of EMB and  
SMB)  
@H+DA.b The bit of the address indicated by  
memory bank, H register and the lower 4  
bits of DA.  
All peripheral hardware that can be  
manipulated in 1 bit.  
(EMB=1 and SMB=15)  
4-2  
S3C72K8/P72K8  
MEMORY MAP  
Table 4-1. I/O Map for Memory Bank 15 (Continued)  
Memory Bank 15  
Addressing Mode  
Address  
F80H  
F81H  
F82H  
F83H  
F84H  
F85H  
F86H  
F87H  
F88H  
F89H  
F8AH  
F8BH  
F8CH  
F8DH  
F8EH  
F8FH  
F90H  
F91H  
F92H  
F93H  
F94H  
F95H  
F96H  
F97H  
F98H  
F99H  
F9AH  
FA6H  
FA7H  
FA8H  
FA9H  
FAAH  
Register  
Bit 3  
.3  
.7  
Bit 2  
.2  
.6  
Bit 1  
.1  
.5  
Bit 0  
"0"  
.4  
R/W  
R/W  
1-Bit  
No  
4-Bit  
No  
8-Bit  
Yes  
SP  
BMOD  
BCNT  
.3  
.2  
.1  
.0  
W
R
.3  
No  
Yes  
No  
No  
Yes  
WMOD  
.3  
.7  
.2  
"0"  
.1  
.5  
.0  
.4  
W
.3  
No  
Yes  
LMOD  
LCON  
.3  
.7  
"0"  
.2  
.6  
.2  
.1  
.5  
.1  
.0  
.4  
.0  
W
W
No  
No  
.3  
No  
Yes  
No  
Yes  
No  
TMOD0  
.3  
"0"  
"0"  
.2  
.6  
TOE0  
"0"  
.5  
"0"  
"0"  
.4  
"0"  
W
Yes  
No  
R/W  
R
Yes  
No  
No  
No  
Yes  
No  
TCNT0  
TREF0  
Yes  
Yes  
Yes  
W
No  
WDMOD  
.3  
.7  
.2  
.6  
"0"  
.2  
.1  
.5  
"0"  
.1  
.0  
.4  
"0"  
.0  
W
No  
WDFLAG  
PNE1  
WDTCF  
.3  
W
W
.3  
No  
Yes  
Yes  
No  
Yes  
PNE2  
PNE3  
.3  
.7  
"0"  
.2  
.6  
.2  
.1  
.5  
.1  
.0  
.4  
.0  
W
No  
No  
Yes  
No  
Yes  
4-3  
MEMORY MAP  
S3C72K8/P72K8  
Table 4-1. I/O Map for Memory Bank 15 (Continued)  
Memory Bank 15  
Addressing Mode  
Address  
FB0H  
Register  
Bit 3  
Bit 2  
IS0  
Bit 1  
EMB  
SC1  
Bit 0  
ERB  
SC0  
R/W  
R/W  
R
1-Bit  
Yes  
No  
4-Bit  
Yes  
No  
8-Bit  
PSW  
IS1  
Yes  
(1)  
FB1H  
SC2  
C
FB2H  
FB3H  
FB4H  
FB5H  
FB6H  
FB7H  
FB8H  
FB9H  
FBAH  
FBBH  
FBCH  
FBDH  
FBEH  
FBFH  
FC0H  
FC1H  
FC2H  
FC3H  
IPR  
PCON  
IMOD0  
IMOD1  
IMODK  
SCMOD  
IT0  
IME  
.3  
.2  
.2  
.1  
.1  
.0  
.0  
W
W
IME  
No  
Yes  
Yes  
Yes  
Yes  
Yes  
No  
No  
No  
No  
No  
No  
No  
No  
"0"  
"0"  
"0"  
.3  
"0"  
"0"  
.2  
.1  
.0  
W
No  
"0"  
.1  
.0  
W
No  
.0  
W
No  
.2  
"0"  
IEB  
.0  
W
Yes  
Yes  
IE4  
IRQ4  
IRQB  
R/W  
Yes  
IT1  
IT2  
"0"  
"0"  
"0"  
"0"  
IE1  
"0"  
"0"  
"0"  
IEW  
IEK  
IET0  
IES  
IE0  
IRQW  
IRQK  
IRQT0  
IRQS  
IRQ0  
IRQ2  
R/W  
Yes  
Yes  
No  
IT3  
"0"  
IT4  
"0"  
IT5  
IRQ1  
"0"  
IT6  
IE2  
BSC0  
BSC1  
BSC2  
BSC3  
R/W  
Yes  
Yes  
Yes  
Yes  
FD0H  
FD1H  
FD2H  
FD3H  
FD4H  
FD5H  
FD6H  
FD7H  
FD8H  
FD9H  
CLMOD  
.3  
.3  
"0"  
.2  
.1  
.1  
.0  
.0  
W
No  
Yes  
No  
CMPREG  
CMOD  
R
No  
No  
Yes  
No  
No  
.3  
.7  
.2  
.6  
.1  
.5  
.0  
R/W  
Yes  
"0"  
4-4  
S3C72K8/P72K8  
MEMORY MAP  
Table 4-1. I/O Map for Memory Bank 15 (Continued)  
Memory Bank 15  
Addressing Mode  
Address  
FDAH  
FDBH  
FDCH  
FDDH  
FDEH  
FDFH  
FE0H  
FE1H  
FE2H  
FE3H  
FE4H  
FE5H  
FE6H  
FE7H  
FE8H  
FE9H  
Register  
Bit 3  
Bit 2  
Bit 1  
Bit 0  
R/W  
1-Bit  
4-Bit  
8-Bit  
IMOD2  
.3  
"0"  
.1  
.0  
W
No  
Yes  
No  
PUMOD1  
PUMOD2  
SMOD  
.3  
"0"  
.3  
.2  
"0"  
.2  
"0"  
"0"  
.1  
.0  
.4  
.0  
W
W
No  
No  
.3  
No  
Yes  
No  
Yes  
No  
.3  
.7  
.2  
.6  
.1  
.5  
.1  
.0  
"0"  
.0  
W
Yes  
No  
P1MOD  
SBUF  
"0"  
"0"  
W
No  
No  
No  
No  
Yes  
No  
R/W  
W
Yes  
Yes  
Yes  
PMG1  
.3  
"0"  
.3  
.2  
.6  
.2  
.6  
.1  
.5  
.1  
.5  
.0  
.4  
.0  
.4  
No  
PMG2  
W
No  
.7  
FF0H  
FF1H  
FF2H  
FF3H  
FF4H  
Port 0  
Port 1  
Port 2  
Port 3  
Port 4  
.3  
.3  
.2  
.2  
.1  
.1  
.0  
.0  
R/W  
R
Yes  
Yes  
Yes  
Yes  
Yes  
Yes  
No  
No  
.3  
.2  
.1  
.0  
R/W  
Yes  
.3/.7  
"0"  
.2/.6  
.2  
.1/.5  
.1  
.0/.4  
.0  
R/W  
Yes  
Yes  
No  
FFFH  
NOTES:  
1. The carry flag can be read or written by specific bit manipulation instructions only.  
2. P5 is mapped at RAM locations 1F0H-1FFH. (Refer to 12-13 page)  
4-5  
MEMORY MAP  
S3C72K8/P72K8  
REGISTER DESCRIPTIONS  
In this section, register descriptions are presented in a consistent format to familiarize you with the memory-mapped  
I/O locations in bank 15 of the RAM. Figure 4-1 describes features of the register description format. Register  
descriptions are arranged in alphabetical order. Programmers can use this section as a quick-reference source when  
writing application programs.  
Counter registers, buffer registers, and reference registers, as well as the stack pointer and port I/O latches, are not  
included in these descriptions. More detailed information about how these registers are used is included in Part II of  
this manual, "Hardware Descriptions", in the context of the corresponding peripheral hardware module descriptions.  
4-6  
S3C72K8/P72K8  
MEMORY MAP  
Register and bit IDs  
used for bit addressing  
Name of individual  
bit or related bits  
Associated  
Register location  
Register ID  
Register name  
hardware module  
in RAM bank 15  
CLMOD - Clock Output Mode Control Register  
CPU  
FD0H  
Bit  
3
.3  
0
2
.2  
0
1
.1  
0
0
.0  
0
Identifier  
RES ETValue  
Read/Write  
Bit Addressing  
W
4
W
4
W
4
W
4
CLMOD.3  
Enable/Disable Clock Output Control bit  
Disable clock output at the CLO pin  
Enable clock output at the CLO pin  
0
0
CLMOD.2  
Bit 2  
Always logic zero  
0
CLMOD.1 -.0  
Clock Source and Frequency Selection Control Bits  
0
0
1
1
0
1
0
1
Select CPU clock souce fx/4, fx/8, fx/64 (1.05 MHz, 524kHz, or 65.5 kHz), or fxt/4  
Select system clock fxx/8 (524 kHz at 4.19 MHz)  
Select system clock fxx/16 (262 kHz at 4.19 MHz)  
Select system clock fxx/64 (65.5 kHz at 4.19 MHz)  
R = Read-only  
Bit value immediately  
Bit number in  
W = Write-only  
R/W = Read/write  
after a RESET  
MSB to LSB order  
Type of addressing  
that must be used to  
address the bit  
Description of the  
effect of specific  
bit settings  
Bit identifier used  
for bit addressing  
(1-bit, 4-bit, or 8-bit)  
Figure 4-1. Register Description Format  
4-7  
MEMORY MAP  
S3C72K8/P72K8  
BMOD— Basic Timer Mode Register  
BT  
F85H  
Bit  
3
.3  
0
2
.2  
0
1
.1  
0
0
.0  
0
Identifier  
RES ET Value  
Read/Write  
W
W
4
W
4
W
4
Bit Addressing  
1/4  
BMOD.3  
Basic Timer Restart Bit  
Restart basic timer, then clear IRQB flag, BCNT and BMOD.3 to logic zero  
1
BMOD.2–.0  
Input Clock Frequency and Signal Stabilization Interval Control Bits  
12  
0
0
1
1
0
1
0
1
0
1
1
1
Input clock frequency:  
Interrupt interval time (wait time):  
fxx/2 (1.02 kHz)  
20  
2 /fxx (250 ms)  
9
Input clock frequency:  
Interrupt interval time (wait time):  
fxx/2 (8.18 kHz)  
17  
2 /fxx (31.3 ms)  
7
Input clock frequency:  
Interrupt interval time (wait time):  
fxx/2 (32.7 kHz)  
15/  
2
fxx (7.82 ms)  
5
Input clock frequency:  
fxx/2 (131 kHz)  
Interrupt interval time (wait time):  
13  
2 /fxx (1.95 ms)  
NOTES:  
17  
1. When a RESET occurs, the oscillation stabilization time is 31.3 ms (2 /fxx) at 4.19 MHz..  
2. 'fxx' is the system clock rate given a clock frequency of 4.19 MHz.  
4-8  
S3C72K8/P72K8  
MEMORY MAP  
CLMOD — Clock Output Mode Register  
CPU  
FD0H  
Bit  
3
.3  
0
2
"0"  
0
1
.1  
0
0
.0  
0
Identifier  
RES ET Value  
Read/Write  
W
4
W
4
W
4
W
4
Bit Addressing  
CLMOD.3  
Enable/Disable Clock Output Control Bit  
0
1
Disable clock output at the CLO pin  
Enable clock output at the CLO pin  
CLMOD.2  
Bit 2  
0
Always logic zero  
CLMOD.1–.0  
Clock Source and Frequency Selection Control Bits  
0
0
Select CPU clock source fxx/4, fxx/8 or fxx/64 (1.05 MHz, 524 kHz or 65.5  
kHz); Refer to PCON  
0
1
1
1
0
1
Select clock fxx/8 (524 kHz)  
Select clock fxx/16 (262 kHz)  
Select clock fxx/64 (65.5 kHz)  
NOTE: "fx" is the main clock, given a clock frequency of 4.19 MHz.  
4-9  
MEMORY MAP  
S3C72K8/P72K8  
CMOD — Comparator Mode Register  
COMPARATOR  
FD7H, FD6H  
Bit  
7
.7  
0
6
.6  
0
5
.5  
0
4
"0"  
0
3
.3  
0
2
.2  
0
1
.1  
0
0
.0  
0
Identifier  
RES ET Value  
Read/Write  
R/W  
8
R/W  
8
R/W  
8
R/W  
8
R/W  
8
R/W  
8
R/W  
8
R/W  
8
Bit Addressing  
.7  
.6  
Comparator Enable/Disable Bit  
0
1
Comparator operation disable  
Comparator operation enable  
Conversion Timer Control Bit  
8
0
1
4 ´ 2 /fx, 244.4 ms at 4.19 MHz  
5
4 ´ 2 /fx, 30.5 ms at 4.19 MHz  
.5  
External/Internal Reference Selection Bit  
0
1
Internal reference, CIN0–1; analog input  
External reference at CIN0, CIN1; analog input  
.4  
Bit 4  
0
Always logic zero  
.3–.0  
Reference Voltage Selection Bits  
Selected V = V  
(N+0.5)  
16  
´
DD  
, N = 0 to 15  
REF  
4-10  
S3C72K8/P72K8  
MEMORY MAP  
IE0, IRQ0— INT0 Interrupt Enable/Request Flags  
IE1, IRQ1— INT1 Interrupt Enable/Request Flags  
CPU  
CPU  
FBEH  
FBEH  
Bit  
3
IE1  
0
2
IRQ1  
0
1
IE0  
0
0
IRQ0  
0
Identifier  
RES ET Value  
Read/Write  
R/W  
1/4  
R/W  
1/4  
R/W  
1/4  
R/W  
1/4  
Bit Addressing  
IE1  
INT1 Interrupt Enable Flag  
0
1
Disable interrupt requests at the INT1 pin  
Enable interrupt requests at the INT1 pin  
IRQ1  
IE0  
INT1 Interrupt Request Flag  
Generate INT1 interrupt (This bit is set and cleared by hardware when rising or  
falling edge detected at INT1 pin.)  
INT0 Interrupt Enable Flag  
0
1
Disable interrupt requests at the INT0 pin  
Enable interrupt requests at the INT0 pin  
IRQ0  
INT0 Interrupt Request Flag  
Generate INT0 interrupt (This bit is set and cleared automatically by hardware  
when rising or falling edge detected at INT0 pin.)  
4-11  
MEMORY MAP  
S3C72K8/P72K8  
IE2, IRQ2— INT2 Interrupt Enable/Request Flags  
CPU  
FBFH  
Bit  
3
"0"  
0
2
"0"  
0
1
IE2  
0
0
IRQ2  
0
Identifier  
RES ET Value  
Read/Write  
R/W  
1/4  
R/W  
1/4  
R/W  
1/4  
R/W  
1/4  
Bit Addressing  
.3–.2  
IE2  
Bits 3–2  
0
Always logic zero  
INT2 Interrupt Enable Flag  
0
1
Disable INT2 interrupt requests at the INT2 pin  
Enable INT2 interrupt requests at the INT2 pin  
IRQ2  
INT2 Interrupt Request Flag  
Generate INT2 quasi-interrupt (This bit is set and is not cleared automatically by  
hardware when a rising or falling edge is detected at INT2. Since INT2 is a quasi-  
interrupt, IRQ2 flag must be cleared by software.)  
4-12  
S3C72K8/P72K8  
MEMORY MAP  
IE4, IRQ4— INT4 Interrupt Enable/Request Flags  
IEB, IRQB— INTB Interrupt Enable/Request Flags  
CPU  
CPU  
FB8H  
FB8H  
Bit  
3
IE4  
0
2
IRQ4  
0
1
IEB  
0
0
IRQB  
0
Identifier  
RES ET Value  
Read/Write  
R/W  
1/4  
R/W  
1/4  
R/W  
1/4  
R/W  
1/4  
Bit Addressing  
IE4  
INT4 Interrupt Enable Flag  
0
1
Disable interrupt requests at the INT4 pin  
Enable interrupt requests at the INT4 pin  
IRQ4  
IEB  
INT4 Interrupt Request Flag  
Generate INT4 interrupt (This bit is set and cleared automatically by hardware  
when rising and falling signal edge detected at INT4 pin.)  
INTB Interrupt Enable Flag  
0
1
Disable INTB interrupt requests  
Enable INTB interrupt requests  
IRQB  
INTB Interrupt Request Flag  
Generate INTB interrupt (This bit is set and cleared automatically by hardware  
when reference interval signal received from basic timer.)  
4-13  
MEMORY MAP  
S3C72K8/P72K8  
IES, IRQS — INTS Interrupt Enable/Request Flags  
CPU  
FBDH  
Bit  
3
"0"  
0
2
"0"  
0
1
IES  
0
0
IRQS  
0
Identifier  
RES ET Value  
Read/Write  
R/W  
1/4  
R/W  
1/4  
R/W  
1/4  
R/W  
1/4  
Bit Addressing  
.3–.2  
IES  
Bits 3–2  
0
Always logic zero  
INTS Interrupt Enable Flag  
0
1
Disable INTS interrupt requests  
Enable INTS interrupt requests  
IRQS  
INTS Interrupt Request Flag  
Generate INTS interrupt (This bit is set and cleared automatically by hardware  
when serial data transfer completion signal received from serial I/O interface.)  
4-14  
S3C72K8/P72K8  
MEMORY MAP  
IET0, IRQT0— INTT0 Interrupt Enable/Request Flags  
CPU  
FBCH  
Bit  
3
"0"  
0
2
"0"  
0
1
IET0  
0
0
IRQT0  
0
Identifier  
RES ET Value  
Read/Write  
R/W  
1/4  
R/W  
¼
R/W  
1/4  
R/W  
1/4  
Bit Addressing  
.3–.2  
IET0  
Bits 3–2  
0
Always logic zero  
INTT0 Interrupt Enable Flag  
0
1
Disable INTT0 interrupt requests  
Enable INTT0 interrupt requests  
IRQT0  
INTT0 Interrupt Request Flag  
Generate INTT0 interrupt (This bit is set and cleared automatically by hardware  
when contents of TCNT0 and TREF0 registers match.)  
4-15  
MEMORY MAP  
S3C72K8/P72K8  
IEK, IRQK— INTK Interrupt Enable/Request Flags  
CPU  
FBBH  
Bit  
3
"0"  
0
2
"0"  
0
1
IEK  
0
0
IRQK  
0
Identifier  
RES ET Value  
Read/Write  
R/W  
1/4  
R/W  
1/4  
R/W  
1/4  
R/W  
1/4  
Bit Addressing  
IEK  
INTK Interrupt Enable Flag  
0
1
Disable interrupt requests at the K0–K3 pins  
Enable interrupt requests at the K0–K3 pins  
IRQK  
INTK Interrupt Request Flag  
Generate INTK interrupt (This bit is set and cleared automatically by hardware  
when rising or falling edge detected at K0–K3 pins.)  
4-16  
S3C72K8/P72K8  
MEMORY MAP  
IEW, IRQW — INTW Interrupt Enable/Request Flags  
CPU  
FBAH  
Bit  
3
"0"  
0
2
"0"  
0
1
IEW  
0
0
IRQW  
0
Identifier  
RES ET Value  
Read/Write  
R/W  
1/4  
R/W  
1/4  
R/W  
1/4  
R/W  
¼
Bit Addressing  
.3–.2  
IEW  
Bits 3–2  
0
Always logic zero  
INTW Interrupt Enable Flag  
0
1
Disable INTW interrupt requests  
Enable INTW interrupt requests  
IRQW  
INTW Interrupt Request Flag  
Generate INTW interrupt (This bit is set when the timer interval is set to 0.5  
seconds or 3.91 milliseconds.)  
NOTE: Since INTW is a quasi-interrupt, the IRQW flag must be cleared by software.  
4-17  
MEMORY MAP  
S3C72K8/P72K8  
IMOD0— External Interrupt 0 (INT0) Mode Register  
CPU  
FB4H  
Bit  
3
3
0
2
"0"  
0
1
.1  
0
0
.0  
0
Identifier  
RES ET Value  
Read/Write  
W
4
W
4
W
4
W
4
Bit Addressing  
IMOD0.3  
Interrupt Sampling Clock Selection Bit  
0
1
Select CPU clock as a sampling clock  
Select sampling clock frequency of the selected system clock (fxx/64)  
IMOD0.2  
Bit 2  
0
Always logic zero  
IMOD0.1–.0  
External Interrupt Mode Control Bits  
0
0
1
1
0
1
0
1
Interrupt requests are triggered by a rising signal edge  
Interrupt requests are triggered by a falling signal edge  
Interrupt requests are triggered by both rising and falling signal edges  
Interrupt request flag (IRQx) cannot be set to logic one  
4-18  
S3C72K8/P72K8  
MEMORY MAP  
IMOD1— External Interrupt 1 (INT1) Mode Register  
CPU  
FB5H  
Bit  
3
"0"  
0
2
"0"  
0
1
"0"  
0
0
IMOD1.0  
0
Identifier  
RES ET Value  
Read/Write  
W
4
W
4
W
4
W
4
Bit Addressing  
IMOD1.3–.1  
IMOD1.0  
Bits 3–1  
0
Always logic zero  
External Interrupt 1 Edge Detection Control Bit  
0
1
Rising edge detection  
Falling edge detection  
4-19  
MEMORY MAP  
S3C72K8/P72K8  
IMOD2— External Interrupt 2 (INT2) Mode Register  
CPU  
FDAH  
Bit  
3
"0"  
0
2
"0"  
0
1
"0"  
0
0
IMOD2.0  
0
Identifier  
RES ET Value  
Read/Write  
W
4
W
4
W
4
W
4
Bit Addressing  
IMOD2.3–.1  
IMOD2.0  
Bits 3–1  
0
Always logic zero  
External Interrupt 2 Edge Detection Selection Bit  
0
1
Interrupt request at INT2 pin trigged by rising edge  
Interrupt request at INT2 pin trigged by falling edge  
4-20  
S3C72K8/P72K8  
MEMORY MAP  
IMODK— External Key Interrupt Mode Register  
CPU  
FB6H  
Bit  
3
2
1
0
"0"  
IMODK.2 IMODK.1 IMODK.0  
Identifier  
0
0
0
0
RES ET Value  
Read/Write  
W
4
W
4
W
4
W
4
Bit Addressing  
IMODK.3  
IMODK.2  
Bit 3  
0
Always logic zero  
External Key Interrupt Edge Detection Selection Bit  
0
1
Falling edge detection  
Rising edge detection  
IMODK.1–.0  
External Key Interrupt Mode Control Bits  
0
0
1
1
0
1
0
1
Disable key interrupt  
Enable edge detection at K0–K1 pins  
Enable edge detection at K0–K2 pins  
Enable edge detection at K0–K3 pins  
NOTES:  
1. To generate a key interrupt, the selected pins must be configured to input mode.  
2. If any one of key interrupt pins selected by IMODK register is configured as output mode, only falling edge can be  
detected.  
3. To generate a key interrupt, first, configure pull-up resistors or external pull-down resistors. And then, select edge  
detection and pins by setting IMODK register.  
4-21  
MEMORY MAP  
S3C72K8/P72K8  
IPR— Interrupt Priority Register  
CPU  
FB2H  
Bit  
3
IME  
0
2
.2  
0
1
.1  
0
0
.0  
0
Identifier  
RES ET Value  
Read/Write  
W
W
4
W
4
W
4
Bit Addressing  
1/4  
IME  
Interrupt Master Enable Bit  
0
1
Disable all interrupt processing  
Enable processing for all interrupt service requests  
IPR.2–.0  
Interrupt Priority Assignment Bits  
0
0
0
0
1
1
1
0
0
1
1
0
0
1
0
1
0
1
0
1
0
Process all interrupt requests at low priority  
Process INTB and INT4 interrupts only  
Process INT0 interrupts only  
Process INT1 interrupts only  
Process INTS interrupts only  
Process INTT0 interrupts only  
Process INTK interrupts only  
4-22  
S3C72K8/P72K8  
MEMORY MAP  
LCON— LCD Output Control Register  
LCD  
F8EH  
Bit  
3
.3  
0
2
.2  
0
1
.1  
0
0
.0  
0
Identifier  
RES ET Value  
Read/Write  
W
4
W
4
W
4
W
4
Bit Addressing  
LCON.3  
LCON.2  
LCON.1  
LCD Bais Selection Bit  
0
1
1/4 bias select  
1/3 bias select  
LCD Clock Output Disable/Enable Bit  
0
1
Disable LCDCK and LCDSY signal outputs  
Enable LCDCK and LCDSY signal outputs  
Bit 1  
0
1
LCD display off ( All COM/SEG pins are high output)  
LCD display on  
LCON.0  
NOTES:  
Bit 0  
0
1
Turn off the internal LCD bias TR  
Turn on the internal LCD bias TR  
1. In case of LCON.0, you can turn on/off internal LCD bias TR.  
2. In case of internal LCD bias  
When LCON.1–.0 = #00B, LCD display is turned off. When LCON.1–.0 = #11B, LCD display is turned on.  
3. In case of external LCD bias  
When LCON.1–.0 = #00B and V  
= "High", LCD display is turned off.  
LC5  
LC5  
When LCON.1–.0 = #10B and V  
= "Low", LCD display is turned on.  
4. To select LCD bias, you must use both the LCON.3 setting and an external LCD bias circuit connection.  
4-23  
MEMORY MAP  
S3C72K8/P72K8  
LMOD — LCD Mode Register  
LCD  
F8DH, F8CH  
Bit  
7
.7  
0
6
.6  
0
5
.5  
0
4
.4  
0
3
.3  
0
2
.2  
0
1
.1  
0
0
.0  
0
Identifier  
RES ET Value  
Read/Write  
W
8
W
8
W
8
W
8
W
8
W
8
W
8
W
8
Bit Addressing  
LMOD.7–.6  
LCD Output Segment and Pin Configuration Bits  
0
0
1
1
0
1
0
1
Segments 32–35 and 36–39  
Segment 36–39; 1-bit output at P5.0–P5.3  
Segment 32–35; 1-bit output at P5.4–P5.7  
1-bit output only at P5.0–P5.7  
LMOD.5–.4  
LCD Clock (LCDCK) Frequency Selection Bits  
8
7
0
0
1
1
0
1
0
1
When 1/3 duty: fw/2 (128 Hz); when 1/4 duty: fw/2 (256 Hz);  
6
When 1/8 duty: fw/2 (512 Hz)  
7
6
When 1/3 duty: fw/2 (256 Hz); when 1/4 duty: fw/2 (512 Hz);  
5
When 1/8 duty: fw/2 (1024 Hz)  
6
5
When 1/3 duty: fw/2 (512 Hz); when 1/4 duty: fw/2 (1024 Hz);  
4
When 1/8 duty: fw/2 (2048 Hz)  
5
4
When 1/3 duty: fw/2 (1024 Hz); when 1/4 duty: fw/2 (2048 Hz);  
3
When 1/8 duty: fw/2 (4096 Hz)  
LMOD.3–.2  
LCD Output Segment and Pin Configuration Bits  
0
1
1
0
0
1
1/8 duty (COM0–COM7 select)  
1/4duty (COM0–COM3 select)  
1/3duty (COM0–COM2 select)  
LMOD.1–.0  
LCD Display Mode Selection Bits  
0
0
1
0
1
1
All LCD dots off  
All LCD dots on  
Normal display  
NOTE: fw = 32,768 kHz  
4-24  
S3C72K8/P72K8  
MEMORY MAP  
PCON— Power Control Register  
CPU  
FB3H  
Bit  
3
.3  
0
2
.2  
0
1
.1  
0
0
.0  
0
Identifier  
RES ET Value  
Read/Write  
W
4
W
4
W
4
W
4
Bit Addressing  
PCON.3–.2  
PCON.1–.0  
CPU Operating Mode Control Bits  
0
0
1
0
1
0
Enable normal CPU operating mode  
Initiate idle power-down mode  
Initiate stop power-down mode  
CPU Clock Frequency Selection Bits  
0
1
1
0
0
1
If SCMOD.0 = "0", fx/64; if SCMOD.0 = "1", fxt/4  
If SCMOD.0 = "0", fx/8; if SCMOD.0 = "1", fxt/4  
If SCMOD.0 = "0", fx/4; if SCMOD.0 = "1", fxt/4  
NOTE: 'fx' is the main system clock; 'fxt' is the subsystem clock.  
4-25  
MEMORY MAP  
S3C72K8/P72K8  
PMG1 — Port I/O Mode Flags (Group 1: Ports 0, 4)  
I/O  
FE7H, FE6H  
Bit  
7
"0"  
0
6
PM4.2  
0
5
PM4.1  
0
4
PM4.0  
0
3
PM0.3  
0
2
1
0
Identifier  
PM0.2  
PM0.1  
PM0.0  
0
0
0
RES ET Value  
Read/Write  
W
8
W
8
W
8
W
8
W
8
W
8
W
8
W
8
Bit Addressing  
.7  
Bit 7  
0
Always logic zero  
PM4.2  
P4.2 I/O Mode Selection Flag  
0
1
Set P4.2 to input mode  
Set P4.2 to output mode  
PM4.1  
PM4.0  
P4.1 I/O Mode Selection Flag  
0
1
Set P4.1 to input mode  
Set P4.1 to output mode  
P4.0 I/O Mode Selection Flag  
0
1
Set P4.0 to input mode  
Set P4.0 to output mode  
PM0.3  
PM0.2  
P0.3 I/O Mode Selection Flag  
0
1
Set P0.3 to input mode  
Set P0.3 to output mode  
P0.2 I/O Mode Selection Flag  
0
1
Set P0.2 to input mode  
Set P0.2 to output mode  
PM0.1  
PM0.0  
P0.1 I/O Mode Selection Flag  
0
1
Set P0.1 to input mode  
Set P0.1 to output mode  
P0.0 I/O Mode Selection Flag  
0
1
Set P0.0 to input mode  
Set P0.0 to output mode  
4-26  
S3C72K8/P72K8  
MEMORY MAP  
PMG2 — Port I/O Mode Flags (Group 2: Ports 2, 3)  
I/O  
FE9H, FE8H  
Bit  
7
PM3.3  
0
6
PM3.2  
0
5
PM3.1  
0
4
PM3.0  
0
3
PM2.3  
0
2
1
0
Identifier  
PM2.2  
PM2.1  
PM2.0  
0
0
0
RES ET Value  
Read/Write  
W
8
W
8
W
8
W
8
W
8
W
8
W
8
W
8
Bit Addressing  
PM3.3  
PM3.2  
PM3.1  
PM3.0  
PM2.3  
P3.3 I/O Mode Selection Flag  
0
1
Set P3.3 to input mode  
Set P3.3 to output mode  
P3.2 I/O Mode Selection Flag  
0
1
Set P3.2 to input mode  
Set P3.2 to output mode  
P3.1 I/O Mode Selection Flag  
0
1
Set P3.1 to input mode  
Set P3.1 to output mode  
P3.0 I/O Mode Selection Flag  
0
1
Set P3.0 to input mode  
Set P3.0 to output mode  
P2.3 I/O Mode Selection Flag  
0
1
Set P2.3 to input mode  
Set P2.3 to output mode  
PM2.2  
PM2.1  
PM2.0  
P2.2 I/O Mode Selection Flag  
0
1
Set P2.2 to input mode  
Set P2.2 to output mode  
P2.1 I/O Mode Selection Flag  
0
1
Set P2.1 to input mode  
Set P2.1 to output mode  
P2.0 I/O Mode Selection Flag  
0
1
Set P2.0 to input mode  
Set P2.0 to output mode  
4-27  
MEMORY MAP  
S3C72K8/P72K8  
P1MOD — Port 1 Mode Register  
I/O  
FE2H  
Bit  
3
"0"  
0
2
"0"  
0
1
.1  
0
0
.0  
0
Identifier  
RES ET Value  
Read/Write  
W
4
W
4
W
4
W
4
Bit Addressing  
.3 and .2  
P1MOD.1  
Bits 3–2  
0
Always logic zero  
P1.1 Analog/digital Selection Bit  
0
1
Configure P1.1 as an analog input pin  
Configure p1.1 as a digital input pin (interrupt may be occurred)  
P1MOD.0  
P1.0 Analog/digital Selection Bit  
0
1
Configure P1.0 as an analog input pin  
Configure p1.0 as a digital input pin (interrupt may be occurred)  
NOTE: If analog input is selected in state if digital input, the IRQ0 and IRQ1 flags are set automatically.  
4-28  
S3C72K8/P72K8  
MEMORY MAP  
PNE1 — N-Channel Open-Drain Mode Register 1  
I/O  
FA6H  
Bit  
3
.3  
0
2
.2  
0
1
.1  
0
0
.0  
0
Identifier  
RES ET Value  
Read/Write  
W
4
W
4
W
4
W
4
Bit Addressing  
PNE0.3  
PNE0.2  
PNE0.1  
PNE0.0  
P0.3 N-Channel Open-Drain Configurable Bit  
0
1
Configure P0.3 as a push-pull  
Configure P0.3 as a n-channel open-drain  
P0.2 N-Channel Open-Drain Configurable Bit  
0
1
Configure P0.2 as a push-pull  
Configure P0.2 as a n-channel open-drain  
P0.1 N-Channel Open-Drain Configurable Bit  
0
1
Configure P0.1 as a push-pull  
Configure P0.1 as a n-channel open-drain  
P0.0 N-Channel Open-Drain Configurable Bit  
0
1
Configure P0.0 as a push-pull  
Configure P0.0 as a n-channel open-drain  
4-29  
MEMORY MAP  
S3C72K8/P72K8  
PNE2 — N-Channel Open-Drain Mode Register 2  
I/O  
FA9H, FA8H  
Bit  
Identifier  
7
.7  
0
6
.6  
0
5
.5  
0
4
.4  
0
3
.3  
0
2
.2  
0
1
.1  
0
0
.0  
0
RES ET Value  
Read/Write  
Bit Addressing  
W
8
W
8
W
8
W
8
W
8
W
8
W
8
W
8
PNE2.7  
PNE2.6  
PNE2.5  
PNE2.4  
PNE2.3  
PNE2.2  
PNE2.1  
PNE2.0  
P3.3 N-Channel Open-Drain Configurable Bit  
0
1
Configure P3.3 as a push-pull  
Configure P3.3 as a n-channel open-drain  
P3.2 N-Channel Open-Drain Configurable Bit  
0
1
Configure P3.2 as a push-pull  
Configure P3.2 as a n-channel open-drain  
P3.1 N-Channel Open-Drain Configurable Bit  
0
1
Configure P3.1 as a push-pull  
Configure P3.1 as a n-channel open-drain  
P3.0 N-Channel Open-Drain Configurable Bit  
0
1
Configure P3.0 as a push-pull  
Configure P3.0 as a n-channel open-drain  
P2.3 N-Channel Open-Drain Configurable Bit  
0
1
Configure P2.3 as a push-pull  
Configure P2.3 as a n-channel open-drain  
P2.2 N-Channel Open-Drain Configurable Bit  
0
1
Configure P2.2 as a push-pull  
Configure P2.2 as a n-channel open-drain  
P2.1 N-Channel Open-Drain Configurable Bit  
0
1
Configure P2.1 as a push-pull  
Configure P2.1 as a n-channel open-drain  
P2.0 N-Channel Open-Drain Configurable Bit  
0
1
Configure P2.0 as a push-pull  
Configure P2.0 as a n-channel open-drain  
4-30  
S3C72K8/P72K8  
MEMORY MAP  
PNE3 — N-Channel Open-Drain Mode Register 3  
I/O  
FAAH  
Bit  
3
"0"  
0
2
.2  
0
1
.1  
0
0
.0  
0
Identifier  
RES ET Value  
Read/Write  
W
4
W
4
W
4
W
4
Bit Addressing  
.3  
Bit 3  
0
Always logic zero  
PNE3.2  
P4.2 N-Channel Open-Drain Configurable Bit  
0
1
Configure P4.2 as a push-pull  
Configure P4.2 as a n-channel open-drain  
PNE3.1  
PNE3.0  
P4.1 N-Channel Open-Drain Configurable Bit  
0
1
Configure P4.1 as a push-pull  
Configure P4.1 as a n-channel open-drain  
P4.0 N-Channel Open-Drain Configurable Bit  
0
1
Configure P4.0 as a push-pull  
Configure P4.0 as a n-channel open-drain  
4-31  
MEMORY MAP  
S3C72K8/P72K8  
PSW — Program Status Word  
CPU  
FB1H, FB0H  
Bit  
7
6
SC2  
0
5
SC1  
0
4
SC0  
0
3
IS1  
0
2
IS0  
0
1
0
Identifier  
C
EMB  
ERB  
(1)  
0
0
RES ET Value  
Read/Write  
R/W  
R
8
R
8
R
8
R/W  
R/W  
R/W  
R/W  
(2)  
Bit Addressing  
1/4/8  
1/4/8  
1/4/8  
1/4/8  
C
Carry Flag  
0
1
No overflow or borrow condition exists  
An overflow or borrow condition does exist  
SC2–SC0  
IS1, IS0  
Skip Condition Flags  
0
1
No skip condition exists; no direct manipulation of these bits is allowed  
A skip condition exists; no direct manipulation of these bits is allowed  
Interrupt Status Flags  
0
0
0
1
Service all interrupt requests  
Service only the high-priority interrupt(s) as determined in the interrupt  
priority register (IPR)  
1
1
0
1
Do not service any more interrupt requests  
Undefined  
EMB  
Enable Data Memory Bank Flag  
0
Restrict program access to data memory to bank 15 (F80H–FFFH) and to  
the locations 000H–07FH in the bank 0 only  
1
Enable full access to data memory banks 0, 1, 2 and 15  
ERB  
Enable Register Bank Flag  
0
1
Select register bank 0 as working register area  
Select register banks 0, 1, 2 or 3 as working register area in accordance with the  
select register bank (SRB) instruction operand  
NOTES:  
1. The value of the carry flag after a RESET occurs during normal operation is undefined. If a RESET occurs during  
power-down mode (IDLE or STOP), the current value of the carry flag is retained.  
2. The carry flag can only be addressed by a specific set of 1-bit manipulation instructions. See Section 2 for  
detailed information.  
4-32  
S3C72K8/P72K8  
MEMORY MAP  
PUMOD1 — Pull-up Resistor Mode Register 1  
I/O  
FDDH, FDCH  
Bit  
7
"0"  
0
6
"0"  
0
5
"0"  
0
4
PUR4  
0
3
PUR3  
0
2
1
0
PUR0  
0
Identifier  
PUR2  
"0"  
0
0
RES ET Value  
Read/Write  
W
8
W
8
W
8
W
8
W
8
W
8
W
8
W
8
Bit Addressing  
.7–.5  
Bits 7–5  
0
Always logic zero  
PUR4  
Connect/Disconnect Port 4 Pull-up Resistor Control Bit  
0
1
Disconnect port 4 pull-up resistor  
Connect port 4 pull-up resistor  
PUR3  
PUR2  
Connect/Disconnect Port 3 Pull-up Resistor Control Bit  
0
1
Disconnect port 3 pull-up resistor  
Connect port 3 pull-up resistor  
Connect/Disconnect Port 2 Pull-up Resistor Control Bit  
0
1
Disconnect port 2 pull-up resistor  
Connect port 2 pull-up resistor  
.1  
Bit 1  
0
Always logic zero  
PUR0  
Connect/Disconnect Port 0 Pull-up Resistor Control Bit  
0
1
Disconnect port 0 pull-up resistor  
Connect port 0 pull-up resistor  
4-33  
MEMORY MAP  
S3C72K8/P72K8  
PUMOD2 — Pull-up Resistor Mode Register 2  
I/O  
FDEH  
Bit  
3
.3  
0
2
.2  
0
1
.1  
0
0
.0  
0
Identifier  
RES ET Value  
Read/Write  
W
4
W
4
W
4
W
4
Bit Addressing  
PUMOD2.3  
PUMOD2.2  
PUMOD2.1  
PUMOD2.0  
Connect/Disconnect P1.3 Pull-up Resistor Control Bit  
0
1
Disconnect P1.3 pull-up resistor  
Connect P1.3 pull-up resistor  
Connect/Disconnect P1.2 Pull-up Resistor Control Bit  
0
1
Disconnect P1.2 pull-up resistor  
Connect P1.2 pull-up resistor  
Connect/Disconnect P1.1 Pull-up Resistor Control Bit  
0
1
Disconnect P1.1 pull-up resistor  
Connect P1.1 pull-up resistor  
Connect/Disconnect P1.0 Pull-up Resistor Control Bit  
0
1
Disconnect P1.0 pull-up resistor  
Connect P1.0 pull-up resistor  
4-34  
S3C72K8/P72K8  
MEMORY MAP  
SCMOD— System Clock Mode Control Register  
CPU  
FB7H  
Bit  
3
.3  
0
2
.2  
0
1
"0"  
0
0
.0  
0
Identifier  
RES ET Value  
Read/Write  
W
1
W
1
W
1
W
1
Bit Addressing  
SCMOD.3  
SCMOD.2  
Bit 3  
0
1
Enable main system clock  
Disable main system clock  
Bit 2  
0
1
Enable sub system clock  
Disable sub system clock  
SCMOD.1  
SCMOD.0  
Bit 1  
0
Always logic zero  
Bit 0  
0
1
Select main system clock  
Select sub system clock  
NOTES:  
1. Sub-oscillation goes into stop mode only by SCMOD.2. PCON which revokes stop mode cannot stop the sub-  
oscillation.  
2. You can use SCMOD.2 as follows (ex; after data bank was used, a few minutes have passed):  
Main operation ® sub-operation ® sub-idle (LCD on, after a few minutes later without any external input) ® sub-  
operation ® main operation ® SCMOD.2 = 1 ® main stop mode (LCD off).  
3. SCMOD bits 3–0 cannot be modified simultaneously by a 4-bit instruction; they can only be modified by  
separate 1-bit instructions.  
4-35  
MEMORY MAP  
S3C72K8/P72K8  
SMOD — Serial I/O Mode Register  
SIO  
FE1H, FE0H  
Bit  
7
.7  
0
6
.6  
0
5
.5  
0
4
"0"  
0
3
.3  
0
2
.2  
0
1
.1  
0
0
.0  
0
Identifier  
RES ET Value  
Read/Write  
W
8
W
8
W
8
W
8
W
W
8
W
8
W
8
Bit Addressing  
1/8  
SMOD.7–.5  
Serial I/O Clock Selection and SBUF R/W Status Control Bits  
0
0
0
Use an external clock at the SCK pin;  
Enable SBUF when SIO operation is halted or when SCK goes high  
Use the TOL0 clock from timer/counter 0;  
0
0
0
1
1
x
Enable SBUF when SIO operation is halted or when SCK goes high  
Use the selected CPU clock (fx/4, fx/8, fx/64, or fxt/4) then, enable  
SBUF read/write operation. 'x' means 'don't care.'  
10  
1
1
0
1
0
1
4.09 kHz clock (fxx/2 )  
4
262 kHz clock (fxx/2 );  
4
NOTE: You cannot select a fx/2 clock frequency if you have selected a  
CPU clock of fxx/64  
NOTE: All kHz frequency ratings assume a system clock of 4.19 MHz.  
SMOD.4  
SMOD.3  
Bit 4  
0
Always logic zero  
Initiate Serial I/O Operation Bit  
1
Clear IRQS flag and 3-bit clock counter to logic zero; then initiate serial trans-  
mission. When SIO transmission starts, this bit is cleared by hardware to logic  
zero  
SMOD.2  
Enable/Disable SIO Data Shifter and Clock Counter Bit  
0
Disable the data shifter and clock counter; the contents of IRQS flag is retained  
when serial transmission is completed  
1
Enable the data shifter and clock counter; The IRQS flag is set to logic one when  
serial transmission is completed  
SMOD.1  
SMOD.0  
Serial I/O Transmission Mode Selection Bit  
0
1
Receive-only mode  
Transmit-and-receive mode  
LSB/MSB Transmission Mode Selection Bit  
0
1
Transmit the most significant bit (MSB) first  
Transmit the least significant bit (LSB) first  
4-36  
S3C72K8/P72K8  
MEMORY MAP  
TMOD0— Timer/Counter 0 Mode Register  
T/C0  
F91H, F90H  
Bit  
7
"0"  
0
6
.6  
0
5
.5  
0
4
.4  
0
3
.3  
0
2
.2  
0
1
"0"  
0
0
"0"  
0
Identifier  
RES ET Value  
Read/Write  
W
8
W
8
W
8
W
8
W
W
8
W
8
W
8
Bit Addressing  
1/8  
TMOD0.7  
Bit 7  
0
Always logic zero  
TMOD0.6–.4  
Timer/Counter 0 Input Clock Selection Bits  
0
0
1
0
0
0
0
1
0
External clock input at TCL0 pin on rising edge  
External clock input at TCL0 pin on falling edge  
10  
fxx/2 (4.09 kHz)  
6
1
1
1
0
1
1
1
0
1
fxx/2 (65.5 kHz)  
4
fxx/2 (262 kHz)  
fxx (4.19 MHz)  
TMOD0.3  
TMOD0.2  
Clear Counter and Resume Counting Control Bit  
Clear TCNT0, IRQT0, and TOL0 and resume counting immediately  
(This bit is cleared automatically when counting starts.)  
1
Enable/Disable Timer/Counter 0 Bit  
0
1
Disable timer/counter 0; retain TCNT0 contents  
Enable timer/counter 0  
TMOD0.1  
TMOD0.0  
Bit 1  
0
Always logic zero  
Always logic zero  
Bit 0  
0
4-37  
MEMORY MAP  
S3C72K8/P72K8  
TOE— Timer Output Enable Flag Register  
T/C0  
F92H  
Bit  
3
"0"  
0
2
TOE0  
0
1
"0"  
0
0
"0"  
0
Identifier  
RES ET Value  
Read/Write  
R/W  
1/4  
R/W  
1/4  
R/W  
1/4  
R/W  
1/4  
Bit Addressing  
.3  
Bit 3  
0
Always logic zero  
TOE0  
Timer/Counter 0 Output Enable Flag  
0
1
Disable timer/counter 0 output at the TCLO0 pin  
Enable timer/counter 0 output at the TCLO0 pin  
.1–.0  
Bit 1–0  
Always logic zero  
0
4-38  
S3C72K8/P72K8  
MEMORY MAP  
WDMOD— Watch-Dog Timer Mode Register  
F98H, F99H  
Bit  
7
.7  
1
6
.6  
0
5
.5  
1
4
.4  
0
3
.3  
0
2
.2  
1
1
.1  
0
0
.0  
1
Identifier  
RES ET Value  
Read/Write  
W
8
W
8
W
8
W
8
W
8
W
8
W
8
W
8
Bit Addressing  
.7 - .0  
Watch-Dog Timer Enable/Disable Control  
5AH  
Disable watch-dog timer function  
Enable watch-dog timer function  
Any other value  
WDTCF — Watch-Dog Timer Flag  
F9AH  
Bit  
3
WDTCF  
0
2
“0”  
0
1
“0”  
0
0
“0”  
0
Identifier  
RES ET Value  
Read/Write  
W
1
¾
¾
¾
¾
¾
¾
Bit Addressing  
.3  
Watch-dog timer's counter clear bit  
Clear and restart the watch-dog timer's counter  
1
NOTE: Instruction that clear the watch-dog timer (“BITS WDTCF”) should be executed at proper points in a program within  
a given period. If not executed within a given period and watch-dog timer overflows, RESET signal is generated  
and  
system is restarted with reset status.  
4-39  
MEMORY MAP  
S3C72K8/P72K8  
WMOD — Watch Timer Mode Register  
WT  
F89H, F88H  
Bit  
7
.7  
0
6
"0"  
0
5
.5  
0
4
.4  
0
3
2
.2  
0
1
.1  
0
0
.0  
0
Identifier  
.3  
(note)  
RES ET Value  
Read/Write  
W
8
W
8
W
8
W
8
R
1
W
8
W
8
W
8
Bit Addressing  
WMOD.7  
Enable/Disable Buzzer Output Bit  
0
1
Disable buzzer (BUZ) signal output at the BUZ pin  
Enable buzzer (BUZ) signal output at the BUZ pin  
WMOD.6  
Bit 6  
0
Always logic zero  
WMOD.5–.4  
Output Buzzer Frequency Selection Bits  
0
0
1
1
0
1
0
1
2 kHz buzzer (BUZ) signal output  
4 kHz buzzer (BUZ) signal output  
8 kHz buzzer (BUZ) signal output  
16 kHz buzzer (BUZ) signal output  
WMOD.3  
XT Input Level Control Bit  
IN  
0
1
Input level to XT pin is low; 1-bit read-only addressable for tests  
IN  
Input level to XT pin is high; 1-bit read-only addressable for tests  
IN  
WMOD.2  
WMOD.1  
WMOD.0  
Enable/Disable Watch Timer Bit  
0
1
Disable watch timer and clear frequency dividing circuits  
Enable watch timer  
Watch Timer Speed Control Bit  
0
1
Normal speed; set IRQW to 0.5 seconds  
High-speed operation; set IRQW to 3.91 ms  
Watch Timer Clock Selection Bit  
0
Select main system clock (fx)/128 as the watch timer clock  
Select main system clock (fx) as a LCD clock source  
1
Select subsystem clock as the watch timer clock  
Select subsystem clock as the LCD clock source  
NOTE: RESET sets WMOD.3 to the current input level of the subsystem clock, XT . If the input level is high, WMOD.3  
IN  
is set to logic one; if low, WMOD.3 is cleared to zero along with all the other bits in the WMOD register.  
4-40  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
5
SAM48 INSTRUCTION SET  
OVERVIEW  
The SAM48 instruction set is specifically designed to support the large register files typically founded in most S3C7-  
series microcontrollers. The SAM48 instruction set includes 1-bit, 4-bit, and 8-bit instructions for data manipulation,  
logical and arithmetic operations, program control, and CPU control. I/O instructions for peripheral hardware devices  
are flexible and easy to use. Symbolic hardware names can be substituted as the instruction operand in place of the  
actual address. Other important features of the SAM48 instruction set include:  
— 1-byte referencing of long instructions (REF instruction)  
— Redundant instruction reduction (string effect)  
— Skip feature for ADC and SBC instructions  
Instruction operands conform to the operand format defined for each instruction. Several instructions have multiple  
operand formats.  
Predefined values or labels can be used as instruction operands when addressing immediate data. Many of the  
symbols for specific registers and flags may also be substituted as labels for operations such DA, mema, memb, b,  
and so on. Using instruction labels can greatly simplify programming and debugging tasks.  
INSTRUCTION SET FEATURES  
In this section, the following SAM48 instruction set features are described in detail:  
— Instruction reference area  
— Instruction redundancy reduction  
— Flexible bit manipulation  
— ADC and SBC instruction skip condition  
NOTES:  
1. The ROM size accessed by instruction may change for different devices in the SAM48 product family (JP, JPS, CALL,  
and CALLS).  
2. The number of memory bank selected by SMB may change for different devices in the SAM48 product family.  
3. The port names used in the instruction set may change for different devices in the SAM48 product family.  
4. The interrupt names and the interrupt numbers used in the instruction set may change for different devices in the SAM  
47 product family.  
5-1  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
INSTRUCTION REFERENCE AREA  
Using the 1-byte REF (Reference) instruction, you can reference instructions stored in addresses 0020H-007FH of  
program memory (the REF instruction look-up table). The location referenced by REF may contain either two 1-byte  
instructions or a single 2-byte instruction. The starting address of the instruction being referenced must always be an  
even number.  
3-byte instructions such as JP or CALL may also be referenced using REF. To reference these 3-byte instructions,  
the 2-byte pseudo commands TJP and TCALL must be written in the reference.  
The PC is not incremented when a REF instruction is executed. After it executes, the program's instruction  
execution sequence resumes at the address immediately following the REF instruction. By using REF instructions  
to execute instructions larger than one byte, as well as branches and subroutines, you can reduce the program size.  
To summarize, the REF instruction can be used in three ways:  
— Using the 1-byte REF instruction to execute one 2-byte or two 1-byte instructions;  
— Branching to any location by referencing a branch address that is stored in the look-up table;  
— Calling subroutines at any location by referencing a call address that is stored in the look-up table.  
If necessary, a REF instruction can be circumvented by means of a skip operation prior to the REF in the execution  
sequence. In addition, the instruction immediately following a REF can also be skipped by using an appropriate  
reference instruction or instructions.  
Two-byte instruction can be referenced by using a REF instruction (An exception is XCH A, DA). If the MSB value of  
the first one-byte instruction in the reference area is “0”, the instruction cannot be referenced by a REF instruction.  
Therefore, if you use REF to reference two 1-byte instruction stored in the reference area, specific combinations  
must be used for the first and second 1-byte instruction.  
These combination examples are described in Table 5-1.  
Table 5-1. Valid 1-Byte Instruction Combinations for REF Look-Ups  
First 1-Byte Instruction  
Instruction Operand  
Second 1-Byte Instruction  
Instruction Operand  
(note)  
LD  
LD  
LD  
A, #im  
R
INCS  
INCS  
RRb  
R
(note)  
DECS  
(note)  
A, @RRa  
@HL, A  
R
INCS  
INCS  
RRb  
R
(note)  
DECS  
(note)  
R
INCS  
INCS  
RRb  
R
(note)  
DECS  
NOTE: The MSB value of the instruction is “0”.  
5-2  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
REDUCING INSTRUCTION REDUNDANCY  
When redundant instructions such as LD A,#im and LD EA,#imm are used consecutively in a program sequence,  
only the first instruction is executed. The redundant instructions which follow are ignored, that is, they are handled  
like a NOP instruction. When LD HL,#imm instructions are used consecutively, redundant instructions are also  
ignored.  
In the following example, only the 'LD A, #im' instruction will be executed. The 8-bit load instruction which follows it is  
interpreted as redundant and is ignored:  
LD  
LD  
A,#im  
EA,#imm  
;
;
Load 4-bit immediate data (#im) to accumulator  
Load 8-bit immediate data (#imm) to extended accumulator  
In this example, the statements 'LD A,#2H' and 'LD A,#3H' are ignored:  
BITR  
LD  
LD  
LD  
LD  
EMB  
A,#1H  
A,#2H  
A,#3H  
23H,A  
;
;
;
;
Execute instruction  
Ignore, redundant instruction  
Ignore, redundant instruction  
Execute instruction, 023H ¬ #1H  
If consecutive LD HL, #imm instructions (load 8-bit immediate data to the 8-bit memory pointer pair, HL) are  
detected, only the first LD is executed and the LDs which immediately follow are ignored. For example,  
LD  
LD  
LD  
LD  
LD  
HL,#10H  
HL,#20H  
A,#3H  
EA,#35H  
@HL,A  
;
;
;
;
;
HL ¬ 10H  
Ignore, redundant instruction  
A ¬ 3H  
Ignore, redundant instruction  
(10H) ¬ 3H  
If an instruction reference with a REF instruction has a redundancy effect, the following conditions apply:  
— If the instruction preceding the REF has a redundancy effect, this effect is cancelled and the referenced  
instruction is not skipped.  
— If the instruction following the REF has a redundancy effect, the instruction following the REF is skipped.  
F
PROGRAMMING TIP — Example of the Instruction Redundancy Effect  
ORG  
0020H  
ABC  
LD  
ORG  
EA,#30H  
0080H  
;
Stored in REF instruction reference area  
LD  
REF  
EA,#40H  
ABC  
;
;
Redundancy effect is encountered  
No skip (EA ¬ #30H)  
REF  
LD  
ABC  
EA,#50H  
;
;
EA ¬ #30H  
Skip  
5-3  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
FLEXIBLE BIT MANIPULATION  
In addition to normal bit manipulation instructions like set and clear, the SAM48 instruction set can also perform bit  
tests, bit transfers, and bit Boolean operations. Bits can also be addressed and manipulated by special bit  
addressing modes. Three types of bit addressing are supported:  
— mema.b  
— memb.@L  
— @H+DA.b  
The parameters of these bit addressing modes are described in more detail in Table 5-2.  
Table 5-2. Bit Addressing Modes and Parameters  
Addressing Mode  
Addressable Peripherals  
ERB, EMB, IS1, IS0, IEx, IRQx  
Ports  
Address Range  
mema.b  
FB0H-FBFH  
FF0H-FFFH  
FC0H-FFFH  
memb.@L  
@H+DA.b  
Ports, and BSC  
All bit-manipulatable peripheral hardware  
All bits of the memory bank specified by  
EMB and SMB that are bit-manipulatable  
NOTE: Some device in the SAM48 product family don’t have BSC.  
INSTRUCTIONS WHICH HAVE SKIP CONDITIONS  
The following instructions have a skip function when an overflow or borrow occurs:  
XCHI  
XCHD  
LDI  
INCS  
DECS  
ADS  
LDD  
SBS  
If there is an overflow or borrow from the result of an increment or decrement, a skip signal is generated and a skip is  
executed. However, the carry flag value is unaffected.  
The instructions BTST, BTSF, and CPSE also generate a skip signal and execute a skip when they meet a skip  
condition, and the carry flag value is also unaffected.  
INSTRUCTIONS WHICH AFFECT THE CARRY FLAG  
The only instructions which do not generate a skip signal, but which do affect the carry flag are as follows:  
ADC  
SBC  
SCF  
RCF  
CCF  
RRC  
LDB  
C,(operand)  
C,(operand)  
C,(operand)  
C,(operand)  
BAND  
BOR  
BXOR  
IRET  
5-4  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
ADC AND SBC INSTRUCTION SKIP CONDITIONS  
The instructions 'ADC A,@HL' and 'SBC A,@HL' can generate a skip signal, and set or clear the carry flag, when  
they are executed in combination with the instruction 'ADS A,#im'.  
If an 'ADS A,#im' instruction immediately follows an 'ADC A,@HL' or 'SBC A,@HL' instruction in a program  
sequence, the ADS instruction does not skip the instruction following it, even if it has a skip function. If, however, an  
'ADC A,@HL' or 'SBC A,@HL' instruction is immediately followed by an 'ADS A,#im' instruction, the ADC (or SBC)  
skips on overflow (or if there is no borrow) to the instruction immediately following the ADS, and program execution  
continues. Table 5-3 contains additional information and examples of the 'ADC A,@HL' and 'SBC A,@HL' skip  
feature.  
Table 5-3. Skip Conditions for ADC and SBC Instructions  
Sample  
Instruction Sequences  
If the result of  
instruction 1 is:  
Then, the execution  
sequence is:  
Reason  
ADC A,@HL  
ADS A,#im  
xxx  
1
2
3
4
Overflow  
1, 3, 4  
ADS cannot skip instruc-  
tion 3, even if it has a  
skip function.  
No overflow  
1, 2, 3, 4  
xxx  
SBC A,@HL  
ADS A,#im  
xxx  
1
2
3
4
Borrow  
1, 2, 3, 4  
1, 3, 4  
ADS cannot skip instruc-  
tion 3, even if it has a  
skip function.  
No borrow  
xxx  
5-5  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
SYMBOLS AND CONVENTIONS  
Table 5-4. Data Type Symbols  
Table 5-6. Instruction Operand Notation  
Symbol Definition  
Direct address  
Symbol  
Data Type  
Immediate data  
d
a
b
r
DA  
@
Indirect address prefix  
Source operand  
Address data  
src  
dst  
(R)  
.b  
Bit data  
Destination operand  
Contents of register R  
Bit location  
Register data  
f
Flag data  
i
Indirect addressing data  
memc ´ 0.5 immediate data  
im  
4-bit immediate data (number)  
8-bit immediate data (number)  
Immediate data prefix  
000H-3FFFH immediate address  
'n' bit address  
t
imm  
#
Table 5-5. Register Identifiers  
Full Register Name  
ID  
ADR  
ADRn  
R
4-bit accumulator  
A
A, E, L, H, X, W, Z, Y  
E, L, H, X, W, Z, Y  
EA, HL, WX, YZ  
4-bit working registers  
E, L, H, X, W,  
Z, Y  
Ra  
8-bit extended accumulator  
8-bit memory pointer  
8-bit working registers  
Select register bank 'n'  
Select memory bank 'n'  
Carry flag  
EA  
RR  
HL  
RRa  
RRb  
RRc  
mema  
memb  
memc  
HL, WX, WL  
WX, YZ, WL  
SRB n  
SMB n  
C
HL, WX, YZ  
WX, WL  
FB0H-FBFH, FF0H-FFFH  
FC0H-FFFH  
Program status word  
Port 'n'  
PSW  
Pn  
Code direct addressing:  
0020H-007FH  
SB  
Select bank register (8 bits)  
Logical exclusive-OR  
Logical OR  
'm'-th bit of port 'n'  
Pn.m  
IPR  
XOR  
OR  
Interrupt priority register  
Enable memory bank flag  
Enable register bank flag  
EMB  
ERB  
AND  
[(RR)]  
Logical AND  
Contents addressed by RR  
5-6  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
OPCODE DEFINITIONS  
Table 5-7. Opcode Definitions (Direct)  
Table 5-8. Opcode Definitions (Indirect)  
Register  
r2  
0
0
0
0
1
1
1
1
0
0
1
1
r1  
0
0
1
1
0
0
1
1
0
1
0
1
r0  
0
1
0
1
0
1
0
1
0
0
0
0
Register  
@HL  
i2  
1
i1  
0
i0  
1
A
E
@WX  
@WL  
1
1
0
L
1
1
1
H
i = Immediate data for indirect addressing  
X
W
Z
Y
EA  
HL  
WX  
YZ  
r = Immediate data for register  
CALCULATING ADDITIONAL MACHINE CYCLES FOR SKIPS  
A machine cycle is defined as one cycle of the selected CPU clock. Three different clock rates can be selected  
using the PCON register.  
In this document, the letter 'S' is used in tables when describing the number of additional machine cycles required for  
an instruction to execute, given that the instruction has a skip function ('S' = skip). The addition number of machine  
cycles that will be required to perform the skip usually depends on the size of the instruction being skipped —  
whether it is a 1-byte, 2-byte, or 3-byte instruction. A skip is also executed for SMB and SRB instructions.  
The values in additional machine cycles for 'S' for the three cases in which skip conditions occur are as follows:  
Case 1: No skip  
S = 0 cycles  
S = 1 cycle  
S = 2 cycles  
Case 2: Skip is 1-byte or 2-byte instruction  
Case 3: Skip is 3-byte instruction  
NOTE: REF instructions are skipped in one machine cycle.  
5-7  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
HIGH-LEVEL SUMMARY  
This section contains a high-level summary of the SAM48 instruction set in table format. The tables are designed to  
familiarize you with the range of instructions that are available in each instruction category.  
These tables are a useful quick-reference resource when writing application programs.  
If you are reading this user's manual for the first time, however, you may want to scan this detailed information  
briefly, and then return to it later on. The following information is provided for each instruction:  
— Instruction name  
— Operand(s)  
— Brief operation description  
— Number of bytes of the instruction and operand(s)  
— Number of machine cycles required to execute the instruction  
The tables in this section are arranged according to the following instruction categories:  
— CPU control instructions  
— Program control instructions  
— Data transfer instructions  
— Logic instructions  
— Arithmetic instructions  
— Bit manipulation instructions  
5-8  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
Table 5-9. CPU Control Instructions — High-Level Summary  
Operand Operation Description  
Set carry flag to logic one  
Name  
SCF  
Bytes  
Cycles  
1
1
1
2
2
2
2
1
2
2
1
2
1
1
1
2
2
2
2
1
2
2
1
2
RCF  
Reset carry flag to logic zero  
Complement carry flag  
Enable all interrupts  
Disable all interrupts  
Engage CPU idle mode  
Engage CPU stop mode  
No operation  
CCF  
EI  
DI  
IDLE  
STOP  
NOP  
SMB  
SRB  
REF  
n
Select memory bank  
Select register bank  
Reference code  
n
memc  
VENTn  
EMB (0,1)  
ERB (0,1)  
ADR  
Load enable memory bank flag (EMB) and the enable  
register bank flag (ERB) and program counter to vector  
address, then branch to the corresponding location  
Table 5-10. Program Control Instructions — High-Level Summary  
Name  
Operand  
Operation Description  
Compare and skip if register equals #im  
Compare and skip if indirect data memory equals #im  
Compare and skip if A equals R  
Compare and skip if A equals indirect data memory  
Compare and skip if EA equals indirect data memory  
Compare and skip if EA equals RR  
Jump to direct address (14 bits)  
Jump direct in page (12 bits)  
Bytes  
Cycles  
CPSE  
R,#im  
@HL,#im  
A,R  
2
2
2
1
2
2
3
2
1
2
2
3
2
1
1
1
2 + S  
2 + S  
2 + S  
A,@HL  
EA,@HL  
EA,RR  
ADR  
ADR  
#im  
1 + S  
2 + S  
2 + S  
JP  
3
JPS  
JR  
2
Jump to immediate address  
2
@WX  
@EA  
ADR  
ADR  
Branch relative to WX register  
3
Branch relative to EA  
3
CALL  
CALLS  
RET  
Call direct in page (14 bits)  
4
Call direct in page (11 bits)  
3
3
Return from subroutine  
IRET  
Return from interrupt  
3
SRET  
Return from subroutine and skip  
3 + S  
5-9  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
Table 5-11. Data Transfer Instructions — High-Level Summary  
Name  
XCH  
Operand  
Operation Description  
Exchange A and direct data memory contents  
Exchange A and register (Ra) contents  
Bytes  
Cycles  
A,DA  
A,Ra  
2
1
1
2
2
2
1
2
1
A,@RRa  
EA,DA  
Exchange A and indirect data memory  
1
Exchange EA and direct data memory contents  
Exchange EA and register pair (RRb) contents  
Exchange EA and indirect data memory contents  
2
2
EA,RRb  
EA,@HL  
A,@HL  
2
XCHI  
XCHD  
LD  
Exchange A and indirect data memory contents;  
increment contents of register L and skip on carry  
2 + S  
A,@HL  
Exchange A and indirect data memory contents;  
decrement contents of register L and skip on carry  
1
2 + S  
A,#im  
Load 4-bit immediate data to A  
1
1
2
2
2
2
2
2
2
2
2
1
2
2
2
1
1
A,@RRa  
A,DA  
Load indirect data memory contents to A  
Load direct data memory contents to A  
Load register contents to A  
1
2
A,Ra  
2
Ra,#im  
RR,#imm  
DA,A  
Load 4-bit immediate data to register  
Load 8-bit immediate data to register  
Load contents of A to direct data memory  
Load contents of A to register  
2
2
2
Ra,A  
2
EA,@HL  
EA,DA  
EA,RRb  
@HL,A  
DA,EA  
RRb,EA  
@HL,EA  
A,@HL  
Load indirect data memory contents to EA  
Load direct data memory contents to EA  
Load register contents to EA  
2
2
2
Load contents of A to indirect data memory  
Load contents of EA to data memory  
Load contents of EA to register  
1
2
2
Load contents of EA to indirect data memory  
2
LDI  
Load indirect data memory to A; increment register L  
contents and skip on carry  
2 + S  
LDD  
LDC  
A,@HL  
Load indirect data memory contents to A; decrement  
register L contents and skip on carry  
1
2 + S  
EA,@WX  
Load code byte from WX to EA  
Load code byte from EA to EA  
Rotate right through carry bit  
1
1
1
1
2
1
2
3
3
1
1
2
1
2
EA,@EA  
A
RRC  
PUSH  
RR  
Push register pair onto stack  
SB  
Push SMB and SRB values onto stack  
Pop to register pair from stack  
Pop SMB and SRB values from stack  
POP  
RR  
SB  
5-10  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
Table 5-12. Logic Instructions — High-Level Summary  
Name  
Operand  
Operation Description  
Logical-AND A immediate data to A  
Logical-AND A indirect data memory to A  
Logical-AND register pair (RR) to EA  
Logical-AND EA to register pair (RRb)  
Logical-OR immediate data to A  
Bytes  
Cycles  
AND  
A,#im  
2
1
2
2
2
1
2
2
2
1
2
2
2
2
1
2
2
2
1
2
2
2
1
2
2
2
A,@HL  
EA,RR  
RRb,EA  
A, #im  
A, @HL  
EA,RR  
RRb,EA  
A,#im  
OR  
Logical-OR indirect data memory contents to A  
Logical-OR double register to EA  
Logical-OR EA to double register  
XOR  
COM  
Exclusive-OR immediate data to A  
Exclusive-OR indirect data memory to A  
Exclusive-OR register pair (RR) to EA  
Exclusive-OR register pair (RRb) to EA  
Complement accumulator (A)  
A,@HL  
EA,RR  
RRb,EA  
A
Table 5-13. Arithmetic Instructions — High-Level Summary  
Name  
Operand  
Operation Description  
Bytes  
Cycles  
1
ADC  
A,@HL  
EA,RR  
RRb,EA  
A, #im  
EA,#imm  
A,@HL  
EA,RR  
RRb,EA  
A,@HL  
EA,RR  
RRb,EA  
A,@HL  
EA,RR  
RRb,EA  
R
Add indirect data memory to A with carry  
1
2
2
1
2
1
2
2
1
2
2
1
2
2
1
2
1
2
2
1
Add register pair (RR) to EA with carry  
2
Add EA to register pair (RRb) with carry  
2
ADS  
Add 4-bit immediate data to A and skip on carry  
Add 8-bit immediate data to EA and skip on carry  
Add indirect data memory to A and skip on carry  
Add register pair (RR) contents to EA and skip on carry  
Add EA to register pair (RRb) and skip on carry  
Subtract indirect data memory from A with carry  
Subtract register pair (RR) from EA with carry  
Subtract EA from register pair (RRb) with carry  
Subtract indirect data memory from A; skip on borrow  
Subtract register pair (RR) from EA; skip on borrow  
Subtract EA from register pair (RRb); skip on borrow  
Decrement register (R); skip on borrow  
1 + S  
2 + S  
1 + S  
2 + S  
2 + S  
1
SBC  
SBS  
2
2
1 + S  
2 + S  
2 + S  
1 + S  
2 + S  
1 + S  
2 + S  
2 + S  
1 + S  
DECS  
INCS  
RR  
Decrement register pair (RR); skip on borrow  
Increment register (R); skip on carry  
R
DA  
Increment direct data memory; skip on carry  
Increment indirect data memory; skip on carry  
Increment register pair (RRb); skip on carry  
@HL  
RRb  
5-11  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
Table 5-14. Bit Manipulation Instructions — High-Level Summary  
Name  
BTST  
Operand  
Operation Description  
Test specified bit and skip if carry flag is set  
Test specified bit and skip if memory bit is set  
Bytes  
Cycles  
1 + S  
C
1
2
DA.b  
2 + S  
mema.b  
memb.@L  
@H+DA.b  
DA.b  
BTSF  
Test specified memory bit and skip if bit equals "0"  
mema.b  
memb.@L  
@H+DA.b  
mema.b  
BTSTZ  
BITS  
Test specified bit; skip and clear if memory bit is set  
Set specified memory bit  
memb.@L  
@H+DA.b  
DA.b  
2
2
mema.b  
memb.@L  
@H+DA.b  
DA.b  
BITR  
Clear specified memory bit to logic zero  
mema.b  
memb.@L  
@H+DA.b  
C,mema.b  
C,memb.@L  
C,@H+DA.b  
C,mema.b  
C,memb.@L  
C,@H+DA.b  
C,mema.b  
C,memb.@L  
C,@H+DA.b  
mema.b,C  
memb.@L,C  
@H+DA.b,C  
C,mema.b  
C,memb.@L  
C,@H+DA.b  
BAND  
BOR  
Logical-AND carry flag with specified memory bit  
Logical-OR carry with specified memory bit  
Exclusive-OR carry with specified memory bit  
BXOR  
LDB  
Load carry bit to a specified memory bit  
Load carry bit to a specified indirect memory bit  
Load specified memory bit to carry bit  
Load specified indirect memory bit to carry bit  
5-12  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
BINARY CODE SUMMARY  
This section contains binary code values and operation notation for each instruction in the SAM48 instruction set in  
an easy-to-read, tabular format. It is intended to be used as a quick-reference source for programmers who are  
experienced with the SAM48 instruction set. The same binary values and notation are also included in the detailed  
descriptions of individual instructions later in Section 5.  
If you are reading this user's manual for the first time, please just scan this very detailed information briefly. Most of  
the general information you will need to write application programs can be found in the high-level summary tables in  
the previous section. The following information is provided for each instruction:  
— Instruction name  
— Operand(s)  
— Binary values  
— Operation notation  
The tables in this section are arranged according to the following instruction categories:  
— CPU control instructions  
— Program control instructions  
— Data transfer instructions  
— Logic instructions  
— Arithmetic instructions  
— Bit manipulation instructions  
5-13  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
Table 5-15. CPU Control Instructions — Binary Code Summary  
Operand Binary Code Operation Notation  
Name  
SCF  
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
t7  
1
1
1
1
0
1
0
1
0
1
0
0
1
1
1
1
t6  
1
1
0
1
1
1
1
1
1
1
1
1
0
0
0
0
t5  
0
0
1
1
1
1
1
1
0
1
1
0
1
0
1
1
t4  
0
0
1
1
1
1
1
0
C ¬ 1  
RCF  
CCF  
EI  
C ¬ 0  
0
1
1
0
C ¬ C  
IME ¬ 1  
1
1
1
1
0
0
1
0
DI  
1
1
1
0
IME ¬ 0  
0
0
1
0
IDLE  
STOP  
1
1
1
1
PCON.2 ¬ 1  
PCON.3 ¬ 1  
0
0
1
1
1
1
1
1
0
0
1
1
NOP  
SMB  
0
0
0
0
No operation  
n
n
1
1
0
1
SMB ¬ n  
d3  
1
d2  
1
d1  
0
d0  
1
SRB  
SRB ¬ n (n = 0, 1, 2, 3)  
0
0
d1  
t1  
d0  
REF  
memc  
t3  
t2  
t0 PC13-0¬ memc.5-0+ (memc+1).7-0  
VENTn  
EMB (0,1)  
ERB (0,1)  
ADR  
E
M
B
E
R
B
a13 a12 a11 a10 a9 a8 ROM (2 x n) 7-6 ® EMB, ERB  
ROM (2 x n) 5-4 ® PC12,PC13  
ROM (2 x n) 3-0 ® PC11-8  
ROM (2 x n + 1) 7-0 ® PC7-0  
(n = 0, 1, 2, 3, 4, 5, 6, 7)  
a7  
a6  
a5  
a4  
a3  
a2  
a1  
a0  
5-14  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
Table 5-16. Program Control Instructions — Binary Code Summary  
Name  
CPSE  
Operand  
Binary Code  
Operation Notation  
Skip if R = im  
R,#im  
1
d3  
1
1
d2  
1
0
d1  
0
1
d0  
1
1
0
0
r2  
1
0
r1  
0
1
r0  
1
@HL,#im  
A,R  
1
Skip if (HL) = im  
Skip if A = R  
0
1
1
1
d3  
1
d2  
1
d1  
0
d0  
1
1
1
0
1
0
1
1
0
1
r2  
0
r1  
0
r0  
0
A,@HL  
0
0
1
1
1
Skip if A = (HL)  
EA,@HL  
1
1
0
1
1
1
0
0
Skip if A = (HL), E = (HL+1)  
0
0
0
0
1
0
0
1
EA,RR  
ADR  
1
1
0
1
1
1
0
0
Skip if EA = RR  
1
1
1
0
1
r2  
0
r1  
1
0
JP  
1
1
0
1
1
1
PC13-0 ¬ ADR13-0  
0
0
a13 a12 a11 a10 a9  
a8  
a0  
a7  
1
a6  
0
a5  
0
a4  
1
a3  
a2  
a1  
JPS  
JR  
ADR  
a11 a10 a9 a8 PC13-0 ¬ PC13-12 + ADR11-0  
a7  
a6  
a5  
a4  
a3  
a2  
a1  
a0  
PC13-0 ¬ ADR (PC-15 to PC+16)  
PC13-0 ¬ PC13-8 + (WX)  
#im *  
@WX  
1
0
1
0
1
0
1
1
1
1
1
1
0
1
0
1
0
1
0
1
0
1
1
0
1
0
1
1
1
1
0
0
0
0
0
0
1
1
0
1
0
1
@EA  
ADR  
PC13-0 ¬ PC13-8 + (EA)  
CALL  
[(SP-1) (SP-2)] ¬ EMB, ERB  
a13 a12 a11 a10 a9 a8 [(SP-3) (SP-4)] ¬ PC7-0  
a7 a6 a5 a4 a3 a2 a1 a0 [(SP-5) (SP-6)] ¬ PC13-8  
a10 a9 a8 [(SP-1) (SP-2)] ¬ EMB, ERB  
CALLS  
ADR  
1
1
1
0
1
a7 a6 a5 a4 a3 a2 a1 a0 [(SP-3) (SP-4)] ¬ PC7-0  
[(SP-5) (SP-6)] ¬ PC14-8  
First Byte  
Condition  
0
0
0
0
0
0
1
0
a3  
a3  
a2  
a2  
a1  
a1  
a0  
a0  
PC ¬ PC+2 to PC+16  
* JR #im  
PC ¬ PC-1 to PC-15  
5-15  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
Table 5-16. Program Control Instructions — Binary Code Summary (Continued)  
Name  
RET  
Operand  
Binary Code  
Operation Notation  
PC13-8 ¬ (SP + 1) (SP)  
PC7-0¬ (SP + 3) (SP + 2)  
EMB,ERB ¬ (SP + 4)  
SP ¬ SP + 6  
1
1
1
1
1
1
0
0
1
0
1
0
0
0
0
1
1
1
0
0
0
1
1
1
IRET  
PC13-8 ¬ (SP + 1) (SP)  
PC7-0 ¬ (SP + 3) (SP + 2)  
PSW ¬ (SP + 5) (SP + 4)  
SP ¬ SP + 6  
SRET  
PC13-8 ¬ (SP + 1) (SP)  
PC7-0 ¬ (SP + 3) (SP + 2)  
EMB,ERB ¬ (SP + 4)  
SP ¬ SP + 6  
Table 5-17. Data Transfer Instructions — Binary Code Summary  
Operand Binary Code Operation Notation  
Name  
XCH  
A,DA  
0
a7  
0
1
a6  
1
1
a5  
1
1
a4  
0
1
a3  
1
0
a2  
r2  
i2  
1
0
a1  
r1  
i1  
1
1
A « DA  
a0  
A,Ra  
r0 A « Ra  
A,@RRa  
EA,DA  
0
1
1
1
1
i0 A « (RRa)  
1
1
0
0
1
1
a0  
0
A « DA,E « DA + 1  
a7  
1
a6  
1
a5  
0
a4  
1
a3  
1
a2  
1
a1  
0
EA,RRb  
EA,@HL  
EA « RRb  
1
1
1
0
0
r2  
1
r1  
0
0
1
1
0
1
1
0
A « (HL), E « (HL + 1)  
0
0
0
0
0
0
0
1
XCHI  
XCHD  
LD  
A,@HL  
A,@HL  
0
1
1
1
1
0
1
0
A « (HL), then L ¬ L+1;  
skip if L = 0H  
0
1
1
1
1
0
1
1
A « (HL), then L ¬ L-1;  
skip if L = 0FH  
A,#im  
1
1
0
0
1
0
1
0
d3  
1
d2 d1 d0 A ¬ im  
A,@RRa  
A,DA  
i2  
1
i1  
0
i0 A ¬ (RRa)  
1
0
0
0
1
0
a0  
1
A ¬ DA  
a7  
1
a6  
1
a5  
0
a4  
1
a3  
1
a2  
1
a1  
0
A,Ra  
A ¬ Ra  
0
0
0
0
1
r2  
r1  
r0  
5-16  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
Table 5-17. Data Transfer Instructions — Binary Code Summary (Continued)  
Name  
Operand  
Binary Code  
Operation Notation  
LD  
Ra,#im  
1
d3  
1
1
d2  
0
0
d1  
0
1
d0  
0
1
1
0
r2  
r2  
d2  
0
0
r1  
r1  
d1  
0
1
r0  
1
Ra ¬ im  
RR,#imm  
DA,A  
0
RR ¬ imm  
DA ¬ A  
d7  
1
d6  
0
d5  
0
d4  
0
d3  
1
d0  
1
a7  
1
a6  
1
a5  
0
a4  
1
a3  
1
a2  
1
a1  
0
a0  
1
Ra,A  
Ra ¬ A  
0
0
0
0
0
r2  
1
r1  
0
r0  
0
EA,@HL  
EA,DA  
EA,RRb  
1
1
0
1
1
A ¬ (HL), E ¬ (HL + 1)  
A ¬ DA, E ¬ DA + 1  
EA ¬ RRb  
0
0
0
0
1
0
0
0
1
1
0
0
1
1
1
0
a7  
1
a6  
1
a5  
0
a4  
1
a3  
1
a2  
1
a1  
0
a0  
0
1
1
1
1
1
r2  
1
r1  
0
0
@HL,A  
DA,EA  
1
1
0
0
0
0
(HL) ¬ A  
1
1
0
0
1
1
0
1
DA ¬ A, DA + 1 ¬ E  
a7  
1
a6  
1
a5  
0
a4  
1
a3  
1
a2  
1
a1  
0
a0  
0
RRb,EA  
@HL,EA  
RRb ¬ EA  
1
1
1
1
0
r2  
1
r1  
0
0
1
1
0
1
1
0
(HL) ¬ A, (HL + 1) ¬ E  
0
0
0
0
0
0
0
0
LDI  
A,@HL  
A,@HL  
1
0
0
0
1
0
1
0
A ¬ (HL), then L ¬ L+1;  
skip if L = 0H  
LDD  
LDC  
1
0
0
0
1
0
1
1
A ¬ (HL), then L ¬ L-1;  
skip if L = 0FH  
EA,@WX  
EA,@EA  
A
1
1
1
1
1
0
0
0
0
0
0
0
1
1
1
1
0
0
0
0
0
0
0
0
EA ¬ [PC13-8 + (WX)]  
EA ¬ [PC13-8 + (EA)]  
RRC  
C ¬ A.0, A3 ¬ C  
A.n-1 ¬ A.n (n = 1, 2, 3)  
PUSH  
RR  
SB  
0
1
0
0
1
1
1
0
1
0
1
0
1
1
0
r2  
1
r1  
0
1
1
1
((SP-1)) ((SP-2)) ¬ (RR),  
(SP) ¬ (SP)-2  
((SP-1)) ¬ (SMB), ((SP-2)) ¬ (SRB),  
(SP) ¬ (SP)-2  
1
1
5-17  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
Table 5-17. Data Transfer Instructions — Binary Code Summary (Concluded)  
Operand Binary Code Operation Notation  
RR  
Name  
POP  
0
0
1
0
1
r2  
r1  
0
RR ¬ (SP), RR ¬ (SP + 1)  
L
H
SP ¬ SP + 2  
SB  
1
0
1
1
0
1
1
0
1
0
1
1
0
1
1
0
(SRB) ¬ (SP), SMB ¬ (SP + 1),  
SP ¬ SP + 2  
Table 5-18. Logic Instructions — Binary Code Summary  
Binary Code Operation Notation  
Name  
AND  
Operand  
A,#im  
1
0
0
1
0
1
0
1
0
0
1
0
1
0
1
0
0
1
0
1
0
1
0
1
0
0
1
0
1
0
1
0
0
1
0
1
0
1
0
0
1
0
1
0
1
0
0
0
1
0
0
0
0
0
1
1
0
1
0
1
0
1
1
0
1
0
1
0
1
1
1
1
1
1
1
1
1
0
1
1
0
1
0
1
1
1
1
1
1
1
1
1
1
d3  
1
1
d2  
0
0
d1  
0
1
d0  
1
A ¬ A AND im  
A,@HL  
EA,RR  
A ¬ A AND (HL)  
EA ¬ EA AND RR  
1
1
0
0
1
r2  
1
r1  
0
0
RRb,EA  
A, #im  
1
0
RRb ¬ RRb AND EA  
A ¬ A OR im  
0
r2  
1
r1  
0
0
OR  
1
1
d3  
1
d2  
0
d1  
1
d0  
0
A, @HL  
EA,RR  
A ¬ A OR (HL)  
1
1
0
0
EA ¬ EA OR RR  
1
r2  
1
r1  
0
0
RRb,EA  
A,#im  
1
0
RRb ¬ RRb OR EA  
A ¬ A XOR im  
0
r2  
1
r1  
0
0
XOR  
1
1
d3  
1
d2  
0
d1  
1
d0  
1
A,@HL  
EA,RR  
A ¬ A XOR (HL)  
1
1
0
0
EA ¬ EA XOR (RR)  
0
r2  
1
r1  
0
0
RRb,EA  
A
1
0
RRb ¬ RRb XOR EA  
A ¬ A  
0
r2  
1
r1  
0
0
COM  
1
1
1
1
1
1
5-18  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
Table 5-19. Arithmetic Instructions — Binary Code Summary  
Binary Code Operation Notation  
C, A ¬ A + (HL) + C  
Name  
Operand  
A,@HL  
EA,RR  
ADC  
ADS  
0
1
1
1
1
1
1
d7  
0
1
1
1
1
0
1
1
1
1
0
1
1
1
1
0
1
1
0
1
a7  
1
0
1
0
1
0
1
0
0
1
d6  
0
1
0
1
0
0
1
1
1
1
0
1
0
1
0
1
1
1
1
1
a6  
1
1
0
1
0
1
0
1
1
0
d5  
1
0
0
0
0
1
0
0
0
0
1
0
1
0
1
0
0
0
0
0
a5  
0
1
0
1
1
0
1
0
0
0
d4  
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
0
1
1
1
0
a4  
1
0
0
1
1
1
1
0
1
1
1
0
0
0
0
0
0
C, EA ¬ EA + RR + C  
r2  
1
r1  
0
RRb,EA  
C, RRb ¬ RRb + EA + C  
r2  
r1  
A, #im  
d3 d2 d1 d0 A ¬ A + im; skip on carry  
EA,#imm  
1
d3  
1
0
d2  
1
0
d1  
1
1
d0  
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
EA ¬ EA + imm; skip on carry  
A,@HL  
EA,RR  
A ¬ A+ (HL); skip on carry  
EA ¬ EA + RR; skip on carry  
1
1
0
1
r2  
1
r1  
0
RRb,EA  
1
RRb ¬ RRb + EA; skip on carry  
0
r2  
1
r1  
0
SBC  
SBS  
A,@HL  
EA,RR  
1
C,A ¬ A - (HL) - C  
1
1
0
C, EA ¬ EA -RR - C  
1
r2  
1
r1  
0
RRb,EA  
1
C,RRb ¬ RRb - EA - C  
0
r2  
1
r1  
0
A,@HL  
EA,RR  
1
A ¬ A - (HL); skip on borrow  
EA ¬ EA - RR; skip on borrow  
1
1
0
1
r2  
1
r1  
0
RRb,EA  
1
RRb ¬ RRb - EA; skip on borrow  
0
r2  
r2  
1
r1  
r1  
0
DECS  
INCS  
R
1
r0 R ¬ R-1; skip on borrow  
RR  
1
0
0
RR ¬ RR-1; skip on borrow  
1
r2  
r2  
0
r1  
r1  
1
R
1
r0 R ¬ R + 1; skip on carry  
DA  
1
0
a0  
1
DA ¬ DA + 1; skip on carry  
(HL) ¬ (HL) + 1; skip on carry  
RRb ¬ RRb + 1; skip on carry  
a3  
1
a2  
1
a1  
0
@HL  
RRb  
0
0
1
0
0
r2  
r1  
0
5-19  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
Table 5-20. Bit Manipulation Instructions — Binary Code Summary  
Operand Binary Code Operation Notation  
Skip if C = 1  
Name  
BTST  
C
1
1
1
1
0
b1  
a5  
1
1
b0  
a4  
1
0
0
1
0
1
1
1
1
DA.b  
Skip if DA.b = 1  
a7  
1
a6  
1
a3  
1
a2  
0
a1  
0
a0  
1
Skip if mema.b = 1  
mema.b *  
memb.@L  
1
1
1
1
1
0
0
1
Skip if [memb.7-2 + L.3-2].  
[L.1-0] = 1  
0
1
1
1
0
1
0
1
a5  
1
a4  
0
a3  
0
a2  
1
@H+DA.b  
DA.b  
Skip if [H + DA.3-0].b = 1  
Skip if DA.b = 0  
0
0
b1  
b1  
a5  
1
b0  
b0  
a4  
1
a3  
0
a2  
0
a1  
1
a0  
0
BTSF  
1
1
a7  
1
a6  
1
a3  
1
a2  
0
a1  
0
a0  
0
Skip if mema.b = 0  
mema.b *  
memb.@L  
1
1
1
1
1
0
0
0
Skip if [memb.7-2 + L.3-2].  
[L.1-0] = 0  
0
1
0
1
1
1
0
1
0
1
0
1
a5  
1
a4  
0
a3  
0
a2  
0
@H DA.b  
Skip if [H + DA.3-0].b = 0  
b1  
1
b0  
1
a3  
1
a2  
1
a1  
0
a0  
1
BTSTZ  
Skip if mema.b = 1 and clear  
mema.b *  
memb.@L  
1
1
1
1
1
1
0
1
Skip if [memb.7-2 + L.3-2].  
[L.1-0] = 1 and clear  
0
1
1
1
0
1
0
1
a5  
1
a4  
1
a3  
0
a2  
1
@H+DA.b  
DA.b  
Skip if [H + DA.3-0].b =1 and clear  
DA.b ¬ 1  
0
0
b1  
b1  
a5  
1
b0  
b0  
a4  
1
a3  
0
a2  
0
a1  
0
a0  
1
BITS  
1
1
a7  
1
a6  
1
a3  
1
a2  
1
a1  
1
a0  
1
mema.b ¬ 1  
mema.b *  
memb.@L  
@H+DA.b  
1
0
1
0
1
1
1
0
1
0
1
0
1
a5  
1
1
a4  
1
1
a3  
1
1
a2  
1
[memb.7-2 + L.3-2].[L.1-0] ¬ 1  
[H + DA.3-0].b ¬ 1  
1
1
b1  
b0  
a3  
a2  
a1  
a0  
5-20  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
Table 5-20. Bit Manipulation Instructions — Binary Code Summary (Continued)  
Name  
Operand  
Binary Code  
Operation Notation  
BITR  
DA.b  
1
a7  
1
1
a6  
1
b1  
a5  
1
b0  
a4  
1
0
a3  
1
0
a2  
1
0
a1  
1
0
a0  
0
DA.b ¬ 0  
mema.b ¬ 0  
mema.b *  
memb.@L  
@H+DA.b  
1
0
1
0
1
1
1
1
0
1
1
0
1
0
1
a5  
1
1
a4  
1
1
a3  
1
0
a2  
0
[memb.7-2 + L3-2].[L.1-0] ¬ 0  
[H + DA.3-0].b ¬ 0  
1
1
b1  
1
b0  
1
a3  
0
a2  
1
a1  
0
a0  
1
BAND  
C ¬ C AND mema.b  
C,mema.b *  
C,memb.@L  
1
1
1
1
0
1
0
1
C ¬ C AND [memb.7-2 + L.3-2].  
[L.1-0]  
0
1
0
1
1
1
0
1
0
1
0
1
a5  
0
a4  
1
a3  
0
a2  
1
C,@H+DA.b  
C ¬ C AND [H + DA.3-0].b  
C ¬ C OR mema.b  
b1  
1
b0  
1
a3  
0
a2  
1
a1  
1
a0  
0
BOR  
C,mema.b *  
C,memb.@L  
1
1
1
1
0
1
1
0
C ¬ C OR [memb.7-2 + L.3-2].  
[L.1-0]  
0
1
0
1
1
1
0
1
0
1
0
1
a5  
0
a4  
1
a3  
1
a2  
0
C,@H+DA.b  
C ¬ C OR [H + DA.3-0].b  
C ¬ C XOR mema.b  
b1  
1
b0  
1
a3  
0
a2  
1
a1  
1
a0  
1
BXOR  
C,mema.b *  
C,memb.@L  
1
1
1
1
0
1
1
1
C ¬ C XOR [memb.7-2 + L.3-2].  
[L.1-0]  
0
1
0
1
1
0
0
1
0
1
a5  
0
a4  
1
a3  
1
a2  
1
C,@H+DA.b  
C ¬ C XOR [H + DA.3-0].b  
b1  
b0  
a3  
a2  
a1  
a0  
Second Byte  
Bit Addresses  
1
1
0
1
b1 b0 a3 a2 a1 a0 FB0H-FBFH  
b1 b0 a3 a2 a1 a0 FF0H-FFFH  
* mema.b  
5-21  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
Table 5-20. Bit Manipulation Instructions — Binary Code Summary (Concluded)  
Name  
LDB  
Operand  
Binary Code  
Operation Notation  
mema.b ¬ C  
1
1
1
1
1
1
0
0
mema.b,C *  
memb.@L,C  
@H+DA.b,C  
1
0
1
0
1
1
1
1
0
1
1
0
1
0
1
a5  
1
1
a4  
1
0
a3  
0
0
a2  
0
memb.7-2 + [L.3-2]. [L.1-0] ¬ C  
H + [DA.3-0].b ¬ (C)  
C ¬ mema.b  
1
1
b1  
1
b0  
1
a3  
0
a2  
1
a1  
0
a0  
0
C,mema.b *  
C,memb.@L  
C,@H+DA.b  
1
0
1
0
1
1
1
0
1
0
1
0
0
a5  
0
1
a4  
1
0
a3  
0
0
a2  
0
C ¬ memb.7-2 + [L.3-2] . [L.1-0]  
C ¬ [H + DA.3-0].b  
1
1
b1  
b0  
a3  
a2  
a1  
a0  
Second Byte  
Bit Addresses  
1
1
0
1
b1 b0 a3 a2 a1 a0 FB0H-FBFH  
b1 b0 a3 a2 a1 a0 FFF0H-FFFH  
* mema.b  
5-22  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
INSTRUCTION DESCRIPTIONS  
This section contains detailed information and programming examples for each instruction of the SAM48 instruction  
set. Information is arranged in a consistent format to improve readability and for use as a quick-reference resource for  
application programmers.  
If you are reading this user's manual for the first time, please just scan this very detailed information briefly in order to  
acquaint yourself with the basic features of the instruction set. The information elements of the instruction description  
format are as follows:  
— Instruction name (mnemonic)  
— Full instruction name  
— Source/destination format of the instruction operand  
— Operation overview (from the "High-Level Summary" table)  
— Textual description of the instruction's effect  
— Binary code overview (from the "Binary Code Summary" table)  
— Programming example(s) to show how the instruction is used  
5-23  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
ADC— ADD With Carry  
ADC  
dst,src  
Operation:  
Operand  
Operation Summary  
Add indirect data memory to A with carry  
Add register pair (RR) to EA with carry  
Add EA to register pair (RRb) with carry  
Bytes  
Cycles  
A,@HL  
EA,RR  
RRb,EA  
1
2
2
1
2
2
Description:  
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. If there is an  
overflow from the most significant bit of the result, the carry flag is set; otherwise, the carry flag is  
cleared.  
If 'ADC A,@HL' is followed by an 'ADS A,#im' instruction in a program, ADC skips the ADS  
instruction if an overflow occurs. If there is no overflow, the ADS instruction is executed normally.  
(This condition is valid only for 'ADC A,@HL' instructions. If an overflow occurs following an 'ADS  
A,#im' instruction, the next instruction will not be skipped.)  
Operand  
A,@HL  
EA,RR  
Binary Code  
Operation Notation  
C, A ¬ A + (HL) + C  
0
1
1
1
1
0
1
0
1
0
1
0
1
0
1
1
1
0
1
0
1
1
1
1
0
1
1
1
0
0
0
0
0
0
C, EA ¬ EA + RR + C  
r2  
1
r1  
0
RRb,EA  
C, RRb ¬ RRb + EA + C  
r2  
r1  
Examples:  
1. The extended accumulator contains the value 0C3H, register pair HL the value 0AAH, and  
the carry flag is set to "1":  
SCF  
ADC  
JPS  
;
;
;
C ¬ "1"  
EA,HL  
XXX  
EA ¬ 0C3H + 0AAH + 1H = 6EH, C ¬ "1"  
Jump to XXX; no skip after ADC  
2. If the extended accumulator contains the value 0C3H, register pair HL the value 0AAH, and  
the carry flag is cleared to "0":  
RCF  
ADC  
JPS  
;
;
;
C ¬ "0"  
EA,HL  
XXX  
EA ¬ 0C3H + 0AAH + 0H = 6DH, C ¬ "1"  
Jump to XXX; no skip after ADC  
5-24  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
ADCAdd with Carry  
ADC  
(Continued)  
Examples:  
3. If ADC A,@HL is followed by an ADS A,#im, the ADC skips on carry to the instruction  
immediately after the ADS. An ADS instruction immediately after the ADC does not skip  
even if an overflow occurs. This function is useful for decimal adjustment operations.  
a. 8 + 9 decimal addition (the contents of the address specified by the HL register is 9H):  
RCF  
LD  
ADS  
ADC  
ADS  
JPS  
;
;
;
;
;
C ¬ "0"  
A ¬ 8H  
A,#8H  
A,#6H  
A,@HL  
A,#0AH  
XXX  
A ¬ 8H + 6H = 0EH  
A ¬ OEH + 9H + C(0) = 7H, C ¬ "1"  
Skip this instruction because C = "1" after ADC result  
b. 3 + 4 decimal addition (the contents of the address specified by the HL register is 4H):  
RCF  
LD  
ADS  
ADC  
ADS  
;
;
;
;
;
;
;
C ¬ "0"  
A ¬ 3H  
A ¬ 3H + 6H = 9H  
A ¬ 9H + 4H + C(0) = 0DH  
No skip. A ¬ 0DH + 0AH = 7H  
(The skip function for 'ADS A,#im' is inhibited after an  
'ADC A,@HL' instruction even if an overflow occurs.)  
A,#3H  
A,#6H  
A,@HL  
A,#0AH  
JPS  
XXX  
5-25  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
ADS— Add and Skip on Overflow  
ADS  
dst,src  
Operation:  
Operand  
Operation Summary  
Bytes  
Cycles  
1 + S  
2 + S  
1 + S  
2 + S  
A, #im  
Add 4-bit immediate data to A and skip on overflow  
Add 8-bit immediate data to EA and skip on overflow  
Add indirect data memory to A and skip on overflow  
1
2
1
2
EA,#imm  
A,@HL  
EA,RR  
Add register pair (RR) contents to EA and skip on  
overflow  
RRb,EA  
Add EA to register pair (RRb) and skip on overflow  
2
2 + S  
Description:  
The source operand is added to the destination operand and the sum is stored in the destination.  
The contents of the source are unaffected. If there is an overflow from the most significant bit of the  
result, the skip signal is generated and a skip is executed, but the carry flag value is unaffected.  
If 'ADS A,#im' follows an 'ADC A,@HL' instruction in a program, ADC skips the ADS instruction if  
an overflow occurs. If there is no overflow, the ADS instruction is executed normally. This skip  
condition is valid only for 'ADC A,@HL' instructions, however. If an overflow occurs following an ADS  
instruction, the next instruction is not skipped.  
Operand  
A, #im  
Binary Code  
Operation Notation  
1
1
0
1
1
0
0
0
d3 d2 d1 d0 A ¬ A + im; skip on overflow  
EA,#imm  
1
0
0
1
EA ¬ EA + imm; skip on overflow  
d7 d6 d5 d4 d3 d2 d1 d0  
A,@HL  
EA,RR  
0
1
1
1
1
0
1
0
1
0
1
0
0
0
0
1
1
1
1
1
1
1
1
1
0
1
1
1
0
1
0
0
0
0
A ¬ A + (HL); skip on overflow  
EA ¬ EA + RR; skip on overflow  
r2  
1
r1  
0
RRb,EA  
RRb ¬ RRb + EA; skip on overflow  
r2  
r1  
Examples:  
1. The extended accumulator contains the value 0C3H, register pair HL the value 0AAH, and  
the carry flag = "0":  
ADS  
EA,HL  
;
;
;
;
EA ¬ 0C3H + 0AAH = 6DH  
ADS skips on overflow, but carry flag value is not affected.  
This instruction is skipped since ADS had an overflow.  
Jump to YYY.  
JPS  
JPS  
XXX  
YYY  
5-26  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
ADS— Add and Skip on Overflow  
ADS  
(Continued)  
Examples:  
2. If the extended accumulator contains the value 0C3H, register pair HL the value 12H, and  
the carry flag = "0":  
ADS  
JPS  
EA,HL  
XXX  
;
;
EA ¬ 0C3H + 12H = 0D5H  
Jump to XXX; no skip after ADS.  
3. If 'ADC A,@HL' is followed by an 'ADS A,#im', the ADC skips on overflow to the instruction  
immediately after the ADS. An 'ADS A,#im' instruction immediately after the 'ADC A,@HL' does  
not skip even if overflow occurs. This function is useful for decimal adjustment operations.  
a. 8 + 9 decimal addition (the contents of the address specified by the HL register is 9H):  
RCF  
LD  
ADS  
ADC  
ADS  
JPS  
;
;
;
;
;
C ¬ "0"  
A ¬ 8H  
A,#8H  
A,#6H  
A,@HL  
A,#0AH  
XXX  
A ¬ 8H + 6H = 0EH  
A ¬ OEH + 9H + C(0) = 7H, C ¬ "1"  
Skip this instruction because C = "1" after ADC result.  
b. 3 + 4 decimal addition (the contents of the address specified by the HL register is 4H):  
RCF  
LD  
ADS  
ADC  
ADS  
;
;
;
;
;
;
;
C ¬ "0"  
A ¬ 3H  
A ¬ 3H + 6H = 9H  
A ¬ 9H + 4H + C(0) = 0DH, C ¬ "0"  
No skip. A ¬ 0DH + 0AH = 7H  
(The skip function for 'ADS A,#im' is inhibited after an  
'ADC A,@HL' instruction even if an overflow occurs.)  
A,#3H  
A,#6H  
A,@HL  
A,#0AH  
JPS  
XXX  
5-27  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
AND— Logical AND  
AND  
dst,src  
Operation:  
Operand  
Operation Summary  
Logical-AND A immediate data to A  
Logical-AND A indirect data memory to A  
Logical-AND register pair (RR) to EA  
Logical-AND EA to register pair (RRb)  
Bytes  
Cycles  
A,#im  
2
1
2
2
2
1
2
2
A,@HL  
EA,RR  
RRb,EA  
Description:  
The source operand is logically ANDed with the destination operand. The result is stored in the  
destination. The logical AND operation results in a "1" whenever the corresponding bits in the two  
operands are both "1"; otherwise a "0" is stored in the corresponding destination bit. The contents of  
the source are unaffected.  
Operand  
A,#im  
Binary Code  
Operation Notation  
A ¬ A AND im  
1
0
0
1
0
1
0
1
0
0
1
0
1
0
0
0
1
0
0
0
0
1
1
1
1
1
1
1
1
1
0
1
d3 d2 d1 d0  
A,@HL  
EA,RR  
1
1
1
1
0
0
1
0
0
1
0
0
0
0
A ¬ A AND (HL)  
EA ¬ EA AND RR  
r2  
1
r1  
0
RRb,EA  
RRb ¬ RRb AND EA  
r2  
r1  
Example:  
If the extended accumulator contains the value 0C3H (11000011B) and register pair HL the value  
55H (01010101B), the instruction  
AND  
EA,HL  
leaves the value 41H (01000001B) in the extended accumulator EA .  
5-28  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
BAND— Bit Logical AND  
BAND  
C,src.b  
Operation:  
Operand  
Operation Summary  
Bytes  
Cycles  
C,mema.b  
Logical-AND carry flag with memory bit  
2
2
2
2
2
2
C,memb.@L  
C,@H+DA.b  
Description:  
The specified bit of the source is logically ANDed with the carry flag bit value. If the Boolean value of  
the source bit is a logic zero, the carry flag is cleared to "0"; otherwise, the current carry flag setting  
is left unaltered. The bit value of the source operand is not affected.  
Operand  
Binary Code  
Operation Notation  
C ¬ C AND mema.b  
1
1
1
1
1
1
1
0
1
1
0
0
1
1
C,mema.b *  
C,memb.@L  
C,@H+DA.b  
1
0
C ¬ C AND [memb.7-2 + L.3-2].  
[L.1-0]  
0
1
0
1
1
0
0
1
0
1
a5 a4 a3 a2  
0
1
0
1
C ¬ C AND [H + DA.3-0].b  
b1 b0 a3 a2 a1 a0  
Second Byte  
Bit Addresses  
1
1
0
1
b1 b0 a3 a2 a1 a0 FB0H-FBFH  
b1 b0 a3 a2 a1 a0 FF0H-FFFH  
* mema.b  
Examples:  
1. The following instructions set the carry flag if P1.0 (port 1.0) is equal to "1" (and assuming  
the carry flag is already set to "1"):  
SMB  
BAND  
15  
C,P1.0  
;
;
;
C ¬ "1"  
If P1.0 = "1", C ¬ "1"  
If P1.0 = "0", C ¬ "0"  
2. Assume the P1 address is FF1H and the value for register L is 5H (0101B). The address  
(memb.7-2) is 111100B; (L.3-2) is 01B. The resulting address is 11110001B or FF1H,  
specifying P1. The bit value for the BAND instruction, (L.1-0) is 01B which specifies bit 1.  
Therefore, P1.@L = P1.1:  
LD  
L,#5H  
BAND  
C,P1.@L  
;
;
P1.@L is specified as P1.1  
C AND P1.1  
5-29  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
BAND— Bit Logical AND  
BAND  
(Continued)  
Examples:  
3. Register H contains the value 2H and FLAG = 20H.3. The address of H is 0010B and  
FLAG(3-0) is 0000B. The resulting address is 00100000B or 20H. The bit value for the  
BAND instruction is 3. Therefore, @H+FLAG = 20H.3:  
FLAG  
LD  
EQU  
H,#2H  
20H.3  
BAND  
C,@H+FLAG  
; C AND FLAG (20H.3)  
5-30  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
BITR — Bit Reset  
BITR  
dst.b  
Operation:  
Operand  
Operation Summary  
Bytes  
Cycles  
DA.b  
Clear specified memory bit to logic zero  
2
2
2
2
2
2
2
2
mema.b  
memb.@L  
@H+DA.b  
Description:  
A BITR instruction clears to logic zero (resets) the specified bit within the destination operand. No  
other bits in the destination are affected.  
Operand  
DA.b  
Binary Code  
b1 b0  
a7 a6 a5 a4 a3 a2 a1 a0  
Operation Notation  
DA.b ¬ 0  
1
1
0
0
0
0
1
1
1
1
1
1
1
1
1
1
0
0
mema.b ¬ 0  
mema.b *  
memb.@L  
@H+DA.b  
1
0
1
0
1
1
1
0
1
0
1
1
0
1
[memb.7-2 + L3-2].[L.1-0] ¬ 0  
[H + DA.3-0].b ¬ 0  
a5 a4 a3 a2  
1
1
1
0
b1 b0 a3 a2 a1 a0  
Second Byte  
Bit Addresses  
1
1
0
1
b1 b0 a3 a2 a1 a0 FB0H-FBFH  
b1 b0 a3 a2 a1 a0 FF0H-FFFH  
* mema.b  
Examples:  
1. If the bit location 30H.2 in the RAM has a current value of "1". The following instruction  
clears the third bit of location 30H to"0":  
BITR  
2. You can use BITR in the same way to manipulate a port address bit:  
BITR P0.0 P0.0 ¬ "0"  
30H.2  
; 30H.2 ¬ "0"  
;
5-31  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
BITR— Bit Reset  
BITR  
(Continued)  
Examples:  
3. For clearing P0.2, P0.3, and P1.0-P1.3 to "0":  
LD  
L,#2H  
BP2  
BITR  
P0.@L  
;
;
First, P0.@2H = P0.2  
(111100B) + 00B.10B = 0F0H.2  
INCS  
CPSE  
JR  
L
L,#8H  
BP2  
4. If bank 0, location 0A0H.0 is cleared (and regardless of whether the EMB value is logic zero),  
BITR has the following effect:  
FLAG  
EQU  
0A0H.0  
BITR  
EMB  
LD  
BITR  
H,#0AH  
@H+FLAG; Bank 0 (AH + 0H).0 = 0A0H.0 ¬ "0”  
NOTE: Since the BITR instruction is used for output functions, the pin names used in the examples above may change for  
different devices in the SAM48 product family.  
5-32  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
BITS — Bit Set  
BITS  
dst.b  
Operation:  
Operand  
Operation Summary  
Set specified memory bit  
Bytes  
Cycles  
DA.b  
2
2
2
2
2
2
2
2
mema.b  
memb.@L  
@H+DA.b  
Description:  
This instruction sets the specified bit within the destination without affecting any other bits in the  
destination. BITS can manipulate any bit that is addressable using direct or indirect addressing  
modes.  
Operand  
DA.b  
Binary Code  
b1 b0  
a7 a6 a5 a4 a3 a2 a1 a0  
Operation Notation  
DA.b ¬ 1  
1
1
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
mema.b ¬ 1  
mema.b *  
memb.@L  
@H+DA.b  
1
0
1
0
1
1
1
0
1
0
1
1
0
1
[memb.7-2 + L.3-2].[L.1-0] ¬ 1  
[H + DA.3-0] ¬ 1  
a5 a4 a3 a2  
1
1
1
1
b1 b0 a3 a2 a1 a0  
Second Byte  
Bit Addresses  
1
1
0
1
b1 b0 a3 a2 a1 a0 FB0H-FBFH  
b1 b0 a3 a2 a1 a0 FF0H-FFFH  
* mema.b  
Examples:  
1. If the bit location 30H.2 in the RAM has a current value of "0", the following instruction sets  
the second bit of location 30H to "1".  
BITS  
2. You can use BITS in the same way to manipulate a port address bit:  
BITS P0.0 P0.0 ¬ "1"  
30H.2  
; 30H.2 ¬ "1"  
;
5-33  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
BITS — Bit Set  
BITS  
(Continued)  
Examples:  
3. For setting P0.2, P0.3, and P1.0-P1.3 to "1":  
LD  
L,#2H  
BP2  
BITS  
P0.@L  
;
;
First, P0.@2H = P0.2  
(111100B) + 00B.10B = 0F0H.2  
INCS  
CPSE  
JR  
L
L,#8H  
BP2  
4. If bank 0, location 0A0H.0, is set to "1" and the EMB = "0", BITS has the following effect:  
FLAG EQU  
0A0H.0  
EMB  
BITR  
LD  
BITS  
H,#0AH  
@H+FLAG; Bank 0 (AH + 0H).0 = 0A0H.0 ¬ "1"  
NOTE: Since the BITS instruction is used for output functions, pin names used in the examples above may change for  
different devices in the SAM48 product family.  
5-34  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
BOR— Bit Logical OR  
BOR  
C,src.b  
Operation:  
Operand  
Operation Summary  
Bytes  
Cycles  
C,mema.b  
Logical-OR carry with specified memory bit  
2
2
2
2
2
2
C,memb.@L  
C,@H+DA.b  
Description:  
The specified bit of the source is logically ORed with the carry flag bit value. The value of the source  
is unaffected.  
Operand  
Binary Code  
Operation Notation  
C ¬ C OR mema.b  
1
1
1
1
1
1
1
0
1
1
1
1
0
0
C,mema.b *  
C,memb.@L  
C,@H+DA.b  
1
0
C ¬ C OR [memb.7-2 + L.3-2].  
[L.1-0]  
0
1
0
1
1
0
0
1
0
1
a5 a4 a3 a2  
0
1
1
0
C ¬ C OR [H + DA.3-0].b  
b1 b0 a3 a2 a1 a0  
Second Byte  
Bit Addresses  
1
1
0
1
b1 b0 a3 a2 a1 a0 FB0H-FBFH  
b1 b0 a3 a2 a1 a0 FF0H-FFFH  
* mema.b  
Examples:  
1. The carry flag is logically ORed with the P1.0 value:  
RCF  
BOR  
;
;
C ¬ "0"  
C,P1.0  
If P1.0 = "1", then C ¬ "1"; if P1.0 = "0", then C ¬ "0"  
2. The P1 address is FF1H and register L contains the value 1H (0001B). The address (memb.7-2)  
is 111100B and (L.3-2) = 00B. The resulting address is 11110000B or FF0H, specifying P0. The  
bit value for the BOR instruction, (L.1-0) is 01B which specifies bit 1. Therefore, P1.@L = P0.1:  
LD  
L,#1H  
BOR  
C,P1.@L  
; P1.@L is specified as P0.1; C OR P0.1  
5-35  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
BOR— Bit Logical OR  
BOR  
(Continued)  
Examples:  
3. Register H contains the value 2H and FLAG = 20H.3. The address of H is 0010B and FLAG(3-0)  
is 0000B. The resulting address is 00100000B or 20H. The bit value for the BOR  
instruction is 3. Therefore, @H+FLAG = 20H.3:  
FLAG  
LD  
EQU  
H,#2H  
20H.3  
BOR  
C,@H+FLAG  
; C OR FLAG (20H.3)  
5-36  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
BTSF Bit Test and Skip on False  
BTSF  
dst.b  
Operation:  
Operand  
Operation Summary  
Bytes  
Cycles  
2 + S  
2 + S  
2 + S  
2 + S  
DA.b  
Test specified memory bit and skip if bit equals "0"  
2
2
2
2
mema.b  
memb.@L  
@H+DA.b  
Description:  
The specified bit within the destination operand is tested. If it is a "0", the BTSF instruction skips  
the instruction which immediately follows it; otherwise the instruction following the BTSF is  
executed. The destination bit value is not affected.  
Operand  
DA.b  
Binary Code  
b1 b0  
a7 a6 a5 a4 a3 a2 a1 a0  
Operation Notation  
Skip if DA.b = 0  
1
1
0
0
1
0
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
Skip if mema.b = 0  
mema.b *  
memb.@L  
Skip if [memb.7-2 + L.3-2].  
[L.1-0] = 0  
0
1
0
1
1
0
0
1
0
1
a5 a4 a3 a2  
@H + DA.b  
1
0
0
0
Skip if [H + DA.3-0].b = 0  
b1 b0 a3 a2 a1 a0  
Second Byte  
Bit Addresses  
1
1
0
1
b1 b0 a3 a2 a1 a0 FB0H-FBFH  
b1 b0 a3 a2 a1 a0 FF0H-FFFH  
* mema.b  
Examples:  
1. If RAM bit location 30H.2 is set to "0", the following instruction sequence will cause the program  
to continue execution from the instruction identifed as LABEL2:  
BTSF  
RET  
JP  
30H.2  
;
;
If 30H.2 = "0", then skip  
If 30H.2 = "1", return  
LABEL2  
2. You can use BTSF in the same way to test a port pin address bit:  
BTSF  
RET  
JP  
P1.0  
;
;
If P1.0 = "0", then skip  
If P1.0 = "1", then return  
LABEL3  
5-37  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
BTSF — Bit Test and Skip on False  
BTSF  
(Continued)  
Examples:  
3. P0.2, P0.3 and P1.0-P1.3 are tested:  
LD  
L,#2H  
BP2  
BTSF  
P0.@L  
;
;
First, P1.@2H = P0.2  
(111100B) + 00B.10B = 0F0H.2  
RET  
INCS  
CPSE  
JR  
L
L,#8H  
BP2  
4. Bank 0, location 0A0H.0, is tested and (regardless of the current EMB value) BTSF has the  
following effect:  
FLAG  
EQU  
0A0H.0  
BITR  
EMB  
LD  
H,#0AH  
BTSF  
@H+FLAG; If bank 0 (AH + 0H).0 = 0A0H.0 = "0", then skip  
RET  
5-38  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
BTST — Bit Test and Skip on True  
BTST  
dst.b  
Operation:  
Operand  
Operation Summary  
Bytes  
Cycles  
1 + S  
2 + S  
2 + S  
2 + S  
2 + S  
C
Test carry bit and skip if set (= "1")  
Test specified bit and skip if memory bit is set  
1
2
2
2
2
DA.b  
mema.b  
memb.@L  
@H+DA.b  
Description:  
The specified bit within the destination operand is tested. If it is "1", the instruction that immediately  
follows the BTST instruction is skipped; otherwise the instruction following the BTST instruction is  
executed. The destination bit value is not affected.  
Operand  
Binary Code  
Operation Notation  
Skip if C = 1  
C
1
1
1
1
0
1
0
0
1
0
1
1
1
1
DA.b  
b1 b0  
Skip if DA.b = 1  
a7 a6 a5 a4 a3 a2 a1 a0  
1
1
1
1
1
1
1
1
1
1
0
0
0
0
1
1
Skip if mema.b = 1  
mema.b *  
memb.@L  
Skip if [memb.7-2 + L.3-2].  
[L.1-0] = 1  
0
1
0
1
1
0
0
1
0
1
a5 a4 a3 a2  
@H+DA.b  
1
0
0
1
Skip if [H + DA.3-0].b = 1  
b1 b0 a3 a2 a1 a0  
Second Byte  
Bit Addresses  
1
1
0
1
b1 b0 a3 a2 a1 a0 FB0H-FBFH  
b1 b0 a3 a2 a1 a0 FF0H-FFFH  
* mema.b  
Examples:  
1. If RAM bit location 30H.2 is set to "0", the following instruction sequence will execute the RET  
instruction:  
BTST  
RET  
JP  
30H.2  
;
;
If 30H.2 = "1", then skip  
If 30H.2 = "0", return  
LABEL2  
5-39  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
BTST — Bit Test and Skip on True  
BTST  
(Continued)  
Examples:  
2. You can use BTST in the same way to test a port pin address bit:  
BTST  
RET  
JP  
P1.0  
;
;
If P1.0 = "1", then skip  
If P1.0 = "0", then return  
LABEL3  
3. P0.2, P0.3 and P1.0-P1.3 are tested :  
LD  
L,#2H  
BP2  
BTST  
P0.@L  
;
;
First, P0.@2H = P0.2  
(111100B) + 00B.10B = 0F0H.2  
RET  
INCS  
CPSE  
JR  
L
L,#8H  
BP2  
4. Bank 0, location 0A0H.0, is tested and (regardless of the current EMB value) BTST has the  
following effect:  
FLAG  
EQU  
0A0H.0  
BITR  
EMB  
LD  
H,#0AH  
BTST  
@H+FLAG; If bank 0 (AH + 0H).0 = 0A0H.0 = "1", then skip  
RET  
5-40  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
BTSTZ— Bit Test and Skip on True; Clear Bit  
BTSTZ  
dst.b  
Operation:  
Operand  
Operation Summary  
Bytes  
Cycles  
2 + S  
2 + S  
2 + S  
mema.b  
Test specified bit; skip and clear if memory bit is set  
2
2
2
memb.@L  
@H+DA.b  
Description:  
The specified bit within the destination operand is tested. If it is a "1", the instruction immediately  
following the BTSTZ instruction is skipped; otherwise the instruction following the BTSTZ is  
executed. The destination bit value is cleared.  
Operand  
Binary Code  
Operation Notation  
1
1
1
1
1
1
1
1
1
1
0
0
1
1
Skip if mema.b = 1 and clear  
mema.b *  
memb.@L  
@H+DA.b  
1
1
Skip if [memb.7-2 + L.3-2].  
[L.1-0] = 1 and clear  
0
1
0
1
1
0
0
1
0
1
a5 a4 a3 a2  
1
1
0
1
Skip if [H + DA.3-0].b =1 and clear  
b1 b0 a3 a2 a1 a0  
Second Byte  
Bit Addresses  
1
1
0
1
b1 b0 a3 a2 a1 a0 FB0H-FBFH  
b1 b0 a3 a2 a1 a0 FF0H-FFFH  
* mema.b  
Examples:  
1. Port pin P0.0 is toggled by checking the P0.0 value (level):  
BTSTZ  
BITS  
JP  
P0.0  
P0.0  
LABEL3  
;
;
If P0.0 = "1", then P0.0 ¬ "0" and skip  
If P0.0 = "0", then P0.0 ¬ "1"  
2. For toggling P2.2, P2.3 and P3.0-P3.3:  
LD  
BTSTZ  
L,#0AH  
P2.@L  
BP2  
;
;
First, P2.@0AH = P2.2  
(111100B) + 10B.10B = 0F2H.2  
BITS  
INCS  
JR  
P2.@L  
L
BP2  
5-41  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
BTSTZ— Bit Test and Skip on True; Clear Bit  
BTSTZ  
(Continued)  
Examples:  
3. Bank 0, location 0A0H.0, is tested and EMB = "0":  
FLAG  
EQU  
0A0H.0  
BITR  
EMB  
LD  
H,#0AH  
BTSTZ  
BITS  
@H+FLAG; If bank 0 (AH + 0H).0 = 0A0H.0 = "1", clear and skip  
@H+FLAG; If 0A0H.0 = "0", then 0A0H.0 ¬ "1"  
5-42  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
BXOR— Bit Exclusive OR  
BXOR  
C,src.b  
Operation:  
Operand  
Operation Summary  
Bytes  
Cycles  
C,mema.b  
Exclusive-OR carry with memory bit  
2
2
2
2
2
2
C,memb.@L  
C,@H+DA.b  
Description:  
The specified bit of the source is logically XORed with the carry bit value. The resultant bit is written  
to the carry flag. The source value is unaffected.  
Operand  
Binary Code  
Operation Notation  
C ¬ C XOR mema.b  
1
1
1
1
1
1
1
0
1
1
1
1
1
1
C,mema.b *  
C,memb.@L  
C,@H+DA.b  
1
0
C ¬ C XOR [memb.7-2 + L.3-2].  
[L.1-0]  
0
1
0
1
1
0
0
1
0
1
a5 a4 a3 a2  
0
1
1
1
C ¬ C XOR [H + DA.3-0].b  
b1 b0 a3 a2 a1 a0  
Second Byte  
Bit Addresses  
1
1
0
1
b1 b0 a3 a2 a1 a0 FB0H-FBFH  
b1 b0 a3 a2 a1 a0 FF0H-FFFH  
* mema.b  
Examples:  
1. The carry flag is logically XORed with the P1.0 value:  
RCF  
BXOR  
;
;
C ¬ "0"  
C,P1.0  
If P1.0 = "1", then C ¬ "1"; if P1.0 = "0", then C ¬ "0"  
2. The P1 address is FF1H and register L contains the value 1H (0001B). The address (memb.7-2)  
is 111100B and (L.3-2) = 00B. The resulting address is 11110000B or FF0H, specifying P0. The  
bit value for the BXOR instruction, (L.1-0) is 01B which specifies bit 1. Therefore, P1.@L = P0.1:  
LD  
L,#1H  
BXOR  
C,P0.@L  
; P1.@L is specified as P0.1; C XOR P0.1  
5-43  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
BXOR— Bit Exclusive OR  
BXOR  
(Continued)  
Examples:  
3. Register H contains the value 2H and FLAG = 20H.3. The address of H is 0010B and FLAG(3-0)  
is 0000B. The resulting address is 00100000B or 20H. The bit value for the BOR  
instruction is 3. Therefore, @H+FLAG = 20H.3:  
FLAG  
LD  
EQU  
H,#2H  
20H.3  
BXOR  
C,@H+FLAG  
; C XOR FLAG (20H.3)  
5-44  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
CALL — Call Procedure  
CALL  
dst  
Operation:  
Operand  
ADR  
Operation Summary  
Call direct in page (14 bits)  
Bytes  
Cycles  
3
4
Description:  
CALL calls a subroutine located at the destination address. The instruction adds three to the  
program counter to generate the return address and then pushes the result onto the stack,  
decreasing the stack pointer by six. The EMB and ERB are also pushed to the stack. Program  
execution continues with the instruction at this address. The subroutine may therefore begin  
anywhere in the full 16 K byte program memory address space.  
Operand  
ADR  
Binary Code  
Operation Notation  
1
0
1
1
0
1
1
0
1
1
[(SP-1) (SP-2)] ¬ EMB, ERB  
a13 a12 a11 a10 a9  
a5 a4 a3 a2 a1  
a8 [(SP-3) (SP-4)] ¬ PC7-0  
a0 [(SP-5) (SP-6)] ¬ PC13-8  
a7  
a6  
Example:  
The stack pointer value is 00H and the label 'PLAY' is assigned to program memory location 0E3FH.  
Executing the instruction  
CALL PLAY  
at location 0123H will generate the following values:  
SP  
=
=
=
=
=
=
=
=
0FAH  
0H  
EMB, ERB  
2H  
3H  
0H  
0FFH  
0FEH  
0FDH  
0FCH  
0FBH  
0FAH  
PC  
1H  
0E3FH  
Data is written to stack locations 0FFH - 0FAH as follows:  
SP - 6  
SP - 5  
SP - 4  
SP - 3  
SP - 2  
SP - 1  
SP ®  
(0FAH)  
(0FBH)  
(0FCH)  
(0FDH)  
(0FEH)  
(0FFH)  
(00H)  
PC11 – PC8  
0
0
PC13 PC12  
PC3 – PC0  
PC7 – PC4  
0
0
0
0
EMB  
0
ERB  
0
5-45  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
CALLS Call Procedure (Short)  
CALLS  
dst  
Operation:  
Operand  
ADR  
Operation Summary  
Call direct in page (11 bits)  
Bytes  
Cycles  
2
3
Description:  
The CALLS instruction unconditionally calls a subroutine located at the indicated address. The  
instruction increments the PC twice to obtain the address of the following instruction. Then, it  
pushes the result onto the stack, decreasing the stack pointer six times. The higher bits of the PC,  
with the exception of the lower 11 bits, are cleared. The CALLS instruction can be used in the all  
range (0000H-3FFFH), but the subroutine must therefore be located within the 2 K byte block  
(0000H-07FFH) of program memory.  
Operand  
ADR  
Binary Code  
Operation Notation  
1
1
1
0
1
a10 a9  
a2 a1  
a8 [(SP-1) (SP-2)] ¬ EMB, ERB  
a7  
a6  
a5  
a4  
a3  
a0 [(SP-3) (SP-4)] ¬ PC7-0  
[(SP-5) (SP-6)] ¬ PC14-8  
Example:  
The stack pointer value is 00H and the label 'PLAY' is assigned to program memory location 0345H.  
Executing the instruction  
CALLS  
PLAY  
at location 0123H will generate the following values:  
SP  
=
=
=
=
=
=
=
=
0FAH  
0H  
EMB, ERB  
2H  
3H  
0H  
0FFH  
0FEH  
0FDH  
0FCH  
0FBH  
0FAH  
PC  
1H  
0345H  
Data is written to stack locations 0FFH - 0FAH as follows:  
SP - 6  
SP - 5  
SP - 4  
SP - 3  
SP - 2  
SP - 1  
SP ®  
(0FAH)  
(0FBH)  
(0FCH)  
(0FDH)  
(0FEH)  
(0FFH)  
(00H)  
PC11 – PC8  
PC14 PC13 PC12  
PC3 – PC0  
0
PC7 – PC4  
0
0
0
0
EMB  
0
ERB  
0
5-46  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
CCF — Complement Carry Flag  
CCF  
Operation:  
Operand  
Operation Summary  
Complement carry flag  
Bytes  
Cycles  
1
1
Description:  
The carry flag is complemented; if C = "1" it is changed to C = "0" and vice-versa.  
Operand  
Binary Code  
Operation Notation  
1
1
0
1
0
1
1
0
C ¬ C  
Example:  
If the carry flag is logic zero, the instruction  
CCF  
changes the value to logic one.  
5-47  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
COM — Complement Accumulator  
COM  
A
Operation:  
Operand  
Operation Summary  
Complement accumulator (A)  
Bytes  
Cycles  
A
2
2
Description:  
The accumulator value is complemented; if the bit value of A is "1", it is changed to "0" and vice  
versa.  
Operand  
Binary Code  
Operation Notation  
A
1
0
1
0
0
1
1
1
1
1
1
1
0
1
1
1
A ¬ A  
Example:  
If the accumulator contains the value 4H (0100B), the instruction  
COM  
leaves the value 0BH (1011B) in the accumulator.  
A
5-48  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
CPSECompare and Skip If Equal  
CPSE  
dst,src  
Operation:  
Operand  
Operation Summary  
Bytes  
Cycles  
2 + S  
2 + S  
2 + S  
1 + S  
2 + S  
2 + S  
R,#im  
Compare and skip if register equals #im  
Compare and skip if indirect data memory equals #im  
Compare and skip if A equals R  
2
2
2
1
2
2
@HL,#im  
A,R  
A,@HL  
EA,@HL  
EA,RR  
Compare and skip if A equals indirect data memory  
Compare and skip if EA equals indirect data memory  
Compare and skip if EA equals RR  
Description:  
CPSE compares the source operand (subtracts it from) the destination operand, and skips the next  
instruction if the values are equal. Neither operand is affected by the comparison.  
Operand  
R,#im  
Binary Code  
Operation Notation  
Skip if R = im  
1
1
0
1
1
0
1
0
r2  
1
0
r1  
0
1
r0  
1
d3 d2 d1 d0  
@HL,#im  
A,R  
1
0
1
0
0
1
0
1
1
1
1
1
1
0
1
0
1
1
0
1
0
1
1
0
0
0
1
1
1
1
0
1
1
0
1
0
Skip if (HL) = im  
Skip if A = R  
d3 d2 d1 d0  
1
1
1
1
1
1
1
1
r2  
0
0
r1  
0
1
r0  
0
A,@HL  
Skip if A = (HL)  
EA,@HL  
1
0
0
Skip if A = (HL), E = (HL+1)  
0
0
1
EA,RR  
1
0
0
Skip if EA = RR  
r2  
r1  
0
Example:  
The extended accumulator contains the value 34H and register pair HL contains 56H. The second  
instruction (RET) in the instruction sequence  
CPSE  
RET  
EA,HL  
is not skipped. That is, the subroutine returns since the result of the comparison is 'not equal.'  
5-49  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
DECS— Decrement and Skip on Borrow  
DECS  
dst  
Operation:  
Operand  
Operation Summary  
Decrement register (R); skip on borrow  
Decrement register pair (RR); skip on borrow  
Bytes  
Cycles  
1 + S  
R
1
2
RR  
2 + S  
Description:  
The destination is decremented by one. An original value of 00H will underflow to 0FFH. If a borrow  
occurs, a skip is executed. The carry flag value is unaffected.  
Operand  
Binary Code  
Operation Notation  
R
0
1
1
1
1
1
0
0
0
0
1
1
1
1
1
r2  
1
r1  
0
r0 R ¬ R-1; skip on borrow  
RR  
0
0
RR ¬ RR-1; skip on borrow  
r2  
r1  
Examples:  
1. Register pair HL contains the value 7FH (01111111B). The following instruction leaves the  
value 7EH in register pair HL:  
DECS  
HL  
2. Register A contains the value 0H. The following instruction sequence leaves the value 0FFH in  
register A. Since a "borrow" occurs, the 'CALL PLAY1' instruction is skipped and the 'CALL  
PLAY2' instruction is executed:  
DECS  
CALL  
CALL  
A
;
;
;
"Borrow" occurs  
Skipped  
Executed  
PLAY1  
PLAY2  
5-50  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
DI — Disable Interrupts  
DI  
Operation:  
Operand  
Operation Summary  
Disable all interrupts  
Bytes  
Cycles  
2
2
Description:  
Bit 3 of the interrupt priority register IPR, IME, is cleared to logic zero, disabling all interrupts.  
Interrupts can still set their respective interrupt status latches, but the CPU will not directly service  
them.  
Operand  
Binary Code  
Operation Notation  
IME ¬ 0  
1
1
1
0
1
1
1
1
1
0
1
0
1
1
0
0
Example:  
If the IME bit (bit 3 of the IPR) is logic one (e.g., all instructions are enabled), the instruction  
DI  
sets the IME bit to logic zero, disabling all interrupts.  
5-51  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
EI — Enable Interrupts  
EI  
Operation:  
Operand  
Operation Summary  
Enable all interrupts  
Bytes  
Cycles  
2
2
Description:  
Bit 3 of the interrupt priority register IPR (IME) is set to logic one. This allows all interrupts to be  
serviced when they occur, assuming they are enabled. If an interrupt's status latch was previously  
enabled by an interrupt, this interrupt can also be serviced.  
Operand  
Binary Code  
Operation Notation  
IME ¬ 1  
1
1
1
0
1
1
1
1
1
0
1
0
1
1
1
0
Example:  
If the IME bit (bit 3 of the IPR) is logic zero (e.g., all instructions are disabled), the instruction  
EI  
sets the IME bit to logic one, enabling all interrupts.  
5-52  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
IDLE — Idle Operation  
IDLE  
Operation:  
Operand  
Operation Summary  
Engage CPU idle mode  
Bytes  
Cycles  
2
2
Description:  
IDLE causes the CPU clock to stop while the system clock continues oscillating by setting bit 2 of  
the power control register (PCON). After an IDLE instruction has been executed, peripheral hardware  
remains operative.  
In application programs, an IDLE instruction must be immediately followed by at least three NOP  
instructions. This ensures an adequate time interval for the clock to stabilize before the next  
instruction is executed. If three or more NOP instructions are not used after IDLE instruction,  
leakage current could be flown because of the floating state in the internal bus.  
Operand  
Binary Code  
Operation Notation  
PCON.2 ¬ 1  
1
1
1
0
1
1
1
0
1
0
1
0
1
1
1
1
Example:  
The instruction sequence  
IDLE  
NOP  
NOP  
NOP  
sets bit 2 of the PCON register to logic one, stopping the CPU clock. The three NOP instructions  
provide the necessary timing delay for clock stabilization before the next instruction in the program  
sequence is executed.  
5-53  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
INCS— Increment and Skip on Carry  
INCS  
dst  
Operation:  
Operand  
Operation Summary  
Increment register (R); skip on carry  
Bytes  
Cycles  
1 + S  
2 + S  
2 + S  
1 + S  
R
1
2
2
1
DA  
Increment direct data memory; skip on carry  
Increment indirect data memory; skip on carry  
Increment register pair (RRb); skip on carry  
@HL  
RRb  
Description:  
The instruction INCS increments the value of the destination operand by one. An original value of  
0FH will, for example, overflow to 00H. If a carry occurs, the next instruction is skipped. The carry  
flag value is unaffected.  
Operand  
Binary Code  
Operation Notation  
R
0
1
1
1
0
0
1
0
1
1
r2  
0
r1  
1
r0 R ¬ R + 1; skip on carry  
DA  
0
DA ¬ DA + 1; skip on carry  
(HL) ¬ (HL) + 1; skip on carry  
RRb ¬ RRb + 1; skip on carry  
a7 a6 a5 a4 a3 a2 a1 a0  
@HL  
RRb  
1
0
1
1
1
0
0
1
0
1
0
0
1
0
0
1
0
0
1
1
0
0
r2  
r1  
Example:  
Register pair HL contains the value 7EH (01111110B). RAM location 7EH contains 0FH. The  
instruction sequence  
INCS  
INCS  
INCS  
@HL  
HL  
@HL  
;
;
;
7EH ¬ "0"  
Skip  
7EH ¬ "1"  
leaves the register pair HL with the value 7EH and RAM location 7EH with the value 1H. Since a  
carry occurred, the second instruction is skipped. The carry flag value remains unchanged.  
5-54  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
IRET — Return From Interrupt  
IRET  
Operation:  
Operand  
Operation Summary  
Return from interrupt  
Bytes  
Cycles  
1
3
Description:  
IRET is used at the end of an interrupt service routine. It pops the PC values successively from the  
stack and restores them to the program counter. The stack pointer is incremented by six and the  
PSW, enable memory bank (EMB) bit, and enable register bank (ERB) bit are also automatically  
restored to their pre-interrupt values. Program execution continues from the resulting address, which  
is generally the instruction immediately after the point at which the interrupt request was detected. If  
a lower-level or same-level interrupt was pending when the IRET was executed, IRET will be  
executed before the pending interrupt is processed.  
Since the 'a14' bit of an interrupt return address is not stored in the stack, this bit location is always  
interpreted as a logic zero. The starting address in the ROM must for this reason be located in  
0000H-3FFFH.  
Operand  
Binary Code  
Operation Notation  
1
1
0
1
0
1
0
1
PC13-8 ¬ (SP + 1) (SP)  
PC7-0 ¬ SP + 3) (SP + 2)  
PSW ¬ (SP + 5) (SP + 4)  
SP ¬ SP + 6  
Example:  
The stack pointer contains the value 0FAH. An interrupt is detected in the instruction at location  
0123H. RAM locations 0FDH, 0FCH, and 0FAH contain the values 2H, 3H, and 1H, respectively.  
The instruction  
IRET  
leaves the stack pointer with the value 00H and the program returns to continue execution at  
location 0123H.  
During a return from interrupt, data is popped from the stack to the program counter. The data in  
stack locations 0FFH-0FAH is organized as follows:  
SP ®  
(0FAH)  
(0FBH)  
(0FCH)  
(0FDH)  
(0FEH)  
(0FFH)  
(00H)  
PC11 – PC8  
SP + 1  
SP + 2  
SP + 3  
SP + 4  
SP + 5  
SP + 6  
0
0
PC13 PC12  
PC3 – PC0  
PC7 – PC4  
IS1  
C
IS0  
EMB  
SC1  
ERB  
SC0  
SC2  
5-55  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
JP — Jump  
JP  
dst  
Operation:  
Operand  
ADR  
Operation Summary  
Jump to direct address (14 bits)  
Bytes  
Cycles  
3
3
Description:  
JP causes an unconditional branch to the indicated address by replacing the contents of the  
program counter with the address specified in the destination operand. The destination can be  
anywhere in the 16 K byte program memory address space.  
Operand  
ADR  
Binary Code  
Operation Notation  
PC13-0 ¬ ADR13-0  
1
0
1
0
0
1
1
0
1
1
a13 a12 a11 a10 a9  
a5 a4 a3 a2 a1  
a8  
a0  
a7  
a6  
Example:  
The label 'SYSCON' is assigned to the instruction at program location 07FFH. The instruction  
JP SYSCON  
at location 0123H will load the program counter with the value 07FFH.  
5-56  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
JPSJump (Short)  
JPS  
dst  
Operation:  
Operand  
ADR  
Operation Summary  
Jump direct in page (12 bits)  
Bytes  
Cycles  
2
2
Description:  
JPS causes an unconditional branch to the indicated address with the 4 K byte program memory  
address space. Bits 0-11 of the program counter are replaced with the directly specified address.  
The destination address for this jump is specified to the assembler by a label or by an actual  
address in program memory.  
Operand  
ADR  
Binary Code  
Operation Notation  
a8 PC13-0 ¬ PC13-12 + ADR11-0  
a0  
1
0
0
1
a11 a10 a9  
a3 a2 a1  
a7  
a6  
a5  
a4  
Example:  
The label 'SUB' is assigned to the instruction at program memory location 00FFH. The instruction  
JPS SUB  
at location 0EABH will load the program counter with the value 00FFH. Normally, the JPS  
instruction jumps to the address in the block in which the instruction is located. If the first byte of  
the instruction code is located at address xFFEH or xFFFH, the instruction will jump to the next  
block. If the instruction 'JPS SUB' were located instead at program memory address 0FFEH or  
0FFFH, the instruction 'JPS SUB' would load the PC with the value 10FFH, causing a program  
malfunction.  
5-57  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
JR— Jump Relative (Very Short)  
JR  
dst  
Operation:  
Operand  
Operation Summary  
Branch to relative immediate address  
Branch relative to contents of WX register  
Branch relative to contents of EA  
Bytes  
Cycles  
#im  
1
2
2
2
3
3
@WX  
@EA  
Description:  
JR causes the relative address to be added to the program counter and passes control to the  
instruction whose address is now in the PC. The range of the relative address is current PC - 15 to  
current PC + 16. The destination address for this jump is specified to the assembler by a label, an  
actual address, or by immediate data using a plus sign (+) or a minus sign (-).  
For immediate addressing, the (+) range is from 2 to 16 and the (-) range is from -1 to -15. If a 0, 1,  
or any other number that is outside these ranges are used, the assembler interprets it as an error.  
For JR @WX and JR @EA branch relative instructions, the valid range for the relative address is 0H-  
0FFH. The destination address for these jumps can be specified to the assembler by a label that  
lies anywhere within the current 256-byte block.  
Normally, the 'JR @WX' and 'JR @EA' instructions jump to the address in the page in which the  
instruction is located. However, if the first byte of the instruction code is located at address xxFEH  
or xxFFH, the instruction will jump to the next page.  
Operand  
#im *  
Binary Code  
Operation Notation  
PC13-0 ¬ ADR (PC-15 to PC+16)  
@WX  
1
0
1
0
1
1
1
1
0
1
0
1
1
0
1
0
1
0
1
0
1
1
1
0
0
0
0
0
1
0
1
0
PC13-0 ¬ PC13-8 + (WX)  
@EA  
PC13-0 ¬ PC13-8 + (EA)  
First Byte  
Condition  
0
0
0
0
0
0
1
0
a3 a2 a1 a0 PC ¬ PC+2 to PC+16  
a3 a2 a1 a0 PC ¬ PC-1 to PC-15  
* JR #im  
5-58  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
JRJump Relative (Very Short)  
JR  
(Continued)  
Examples:  
1. A short form for a relative jump to label 'KK' is the instruction  
JR  
KK  
where 'KK' must be within the allowed range of current PC-15 to current PC+16. The JR  
instruction has in this case the effect of an unconditional JP instruction.  
2. In the following instruction sequence, if the instruction 'LD WX, #02H' were to be executed in  
place of 'LD WX,#00H', the program would jump to 1004H and 'JPS CCC' would be executed. If  
'LD WX,#03H' were to be executed, the jump would be to1006H and 'JPS DDD' would be  
executed.  
ORG  
JPS  
JPS  
JPS  
JPS  
LD  
1000H  
AAA  
BBB  
CCC  
DDD  
XXX  
WX,#00H ; WX ¬ 00H  
LD  
EA,WX  
ADS  
JR  
WX,EA  
@WX  
;
;
;
WX ¬ (WX) + (EA)  
Current PC12-8 (10H) + WX (00H) = 1000H  
Jump to address 1000H and execute JPS AAA  
3. Here is another example:  
ORG  
1100H  
LD  
LD  
LD  
LD  
A,#0H  
A,#1H  
A,#2H  
A,#3H  
30H,A  
YYY  
LD  
;
Address 30H ¬ A  
JPS  
XXX  
JR  
LD  
@EA  
EA,#00H  
;
;
;
EA ¬ 00H  
Jump to address 1100H  
Address 30H ¬ 00H  
If 'LD EA,#01H' were to be executed in place of 'LD EA,#00H', the program would jump to  
1101H and address 30H would contain the value 1H. If 'LD EA,#02H' were to be executed, the  
jump would be to 1102H and address 30H would contain the value 2H.  
5-59  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
LDLoad  
LD  
dst,src  
Operation:  
Operand  
Operation Summary  
Load 4-bit immediate data to A  
Bytes  
Cycles  
A,#im  
1
1
2
2
2
2
2
2
2
2
2
1
2
2
2
1
1
2
2
2
2
2
2
2
2
2
1
2
2
2
A,@RRa  
A,DA  
Load indirect data memory contents to A  
Load direct data memory contents to A  
Load register contents to A  
A,Ra  
Ra,#im  
RR,#imm  
DA,A  
Load 4-bit immediate data to register  
Load 8-bit immediate data to register  
Load contents of A to direct data memory  
Load contents of A to register  
Ra,A  
EA,@HL  
EA,DA  
EA,RRb  
@HL,A  
DA,EA  
RRb,EA  
@HL,EA  
Load indirect data memory contents to EA  
Load direct data memory contents to EA  
Load register contents to EA  
Load contents of A to indirect data memory  
Load contents of EA to data memory  
Load contents of EA to register  
Load contents of EA to indirect data memory  
Description:  
The contents of the source are loaded into the destination. The source's contents are unaffected.  
If an instruction such as 'LD A,#im' (LD EA,#imm) or 'LD HL,#imm' is written more than two times  
in succession, only the first LD will be executed; the other similar instructions that immediately  
follow the first LD will be treated like a NOP. This is called the 'redundancy effect' (see examples  
below).  
Operand  
A,#im  
Binary Code  
Operation Notation  
1
1
1
0
0
0
1
0
0
1
0
0
d3 d2 d1 d0 A ¬ im  
A,@RRa  
A,DA  
1
1
i2  
1
i1  
0
i0 A ¬ (RRa)  
0
A ¬ DA  
a7 a6 a5 a4 a3 a2 a1 a0  
A,Ra  
1
0
1
1
0
1
0
0
0
1
0
1
1
1
1
1
1
r2  
0
0
r1  
0
1
r0  
1
A ¬ Ra  
Ra,#im  
Ra ¬ im  
d3 d2 d1 d0  
r2  
r1  
r0  
5-60  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
LDLoad  
LD  
(Continued)  
Description:  
Operand  
Binary Code  
Operation Notation  
RR ¬ imm  
RR,#imm  
1
0
0
0
0
r2  
r1  
1
d7 d6 d5 d4 d3 d2 d1 d0  
DA,A  
1
0
0
0
1
0
0
1
DA ¬ A  
Ra ¬ A  
a7 a6 a5 a4 a3 a2 a1 a0  
Ra,A  
1
0
1
0
1
1
0
1
0
1
0
0
0
0
0
1
0
1
0
0
1
0
1
1
1
1
r2  
1
0
r1  
0
1
r0  
0
EA,@HL  
EA,DA  
EA,RRb  
A ¬ (HL), E ¬ (HL + 1)  
A ¬ DA, E ¬ DA + 1  
EA ¬ RRb  
0
0
0
1
1
0
a7 a6 a5 a4 a3 a2 a1 a0  
1
1
1
1
1
1
1
1
0
1
0
0
1
1
0
0
1
1
0
1
1
r2  
1
0
r1  
0
0
0
0
1
@HL,A  
DA,EA  
(HL) ¬ A  
1
0
DA ¬ A, DA + 1 ¬ E  
a7 a6 a5 a4 a3 a2 a1 a0  
RRb,EA  
@HL,EA  
1
1
1
0
1
1
1
0
0
1
0
0
1
1
1
0
1
0
1
0
1
r2  
1
0
r1  
0
0
0
0
0
RRb ¬ EA  
(HL) ¬ A, (HL + 1) ¬ E  
0
0
Examples:  
1. RAM location 30H contains the value 4H. The RAM location values are 40H, 41H and 0AH,  
3H respectively. The following instruction sequence leaves the value 40H in point pair HL,  
0AH in the accumulator and in RAM location 40H, and 3H in register E.  
LD  
LD  
LD  
LD  
LD  
HL,#30H  
A,@HL  
HL,#40H  
EA,@HL  
@HL,A  
;
;
;
;
;
HL ¬ 30H  
A ¬ 4H  
HL ¬ 40H  
A ¬ 0AH, E ¬ 3H  
RAM (40H) ¬ 0AH  
5-61  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
LD— Load  
LD  
(Continued)  
2. If an instruction such as LD A,#im (LD EA,#imm) or LD HL,#imm is written more than two  
Examples:  
times in succession, only the first LD is executed; the next instructions are treated as NOPs.  
Here are two examples of this 'redundancy effect':  
LD  
LD  
LD  
LD  
A,#1H  
EA,#2H  
A,#3H  
23H,A  
;
;
;
;
A ¬ 1H  
NOP  
NOP  
(23H) ¬ 1H  
LD  
LD  
LD  
LD  
LD  
HL,#10H  
HL,#20H  
A,#3H  
EA,#35  
@HL,A  
;
;
;
;
;
HL ¬ 10H  
NOP  
A ¬ 3H  
NOP  
(10H) ¬ 3H  
The following table contains descriptions of special characteristics of the LD instruction when used  
in different addressing modes:  
Instruction  
Operation Description and Guidelines  
LD A,#im  
Since the 'redundancy effect' occurs with instructions like LD EA,#imm, if this  
instruction is used consecutively, the second and additional instructions of the  
same type will be treated like NOPs.  
LD A,@RRa Load the data memory contents pointed to by 8-bit RRa register pairs (HL, WX,  
WL) to the A register.  
LD A,DA  
LD A,Ra  
LD Ra,#im  
Load direct data memory contents to the A register.  
Load 4-bit register Ra (E, L, H, X, W, Z, Y) to the A register.  
Load 4-bit immediate data into the Ra register (E, L, H, X, W, Y, Z).  
LD RR,#imm Load 8-bit immediate data into the Ra register (EA, HL, WX, YZ). There is a  
redundancy effect if the operation addresses the HL or EA registers.  
LD DA,A  
LD Ra,A  
Load contents of register A to direct data memory address.  
Load contents of register A to 4-bit Ra register (E, L, H, X, W, Z, Y).  
5-62  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
LD— Load  
LD  
(Concluded)  
Examples:  
Instruction  
Operation Description and Guidelines  
LD EA,@HL Load data memory contents pointed to by 8-bit register HL to the A register, and  
the contents of HL+1 to the E register. The contents of register L must be an  
even number. If the number is odd, the LSB of register L is recognized as a logic  
zero (an even number), and it is not replaced with the true value. For example,  
'LD HL,#36H' loads immediate 36H to HL and the next instruction 'LD EA,@HL'  
loads the contents of 36H to register A and the contents of 37H to register E.  
LD EA,DA  
Load direct data memory contents of DA to the A register, and the next direct  
data memory contents of DA + 1 to the E register. The DA value must be an even  
number. If it is an odd number, the LSB of DA is recognized as a logic zero (an  
even number), and it is not replaced with the true value. For example, 'LD  
EA,37H' loads the contents of 36H to the A register and the contents of 37H to  
the E register.  
LD EA,RRb  
Load 8-bit RRb register (HL, WX, YZ) to the EA register. H, W, and Y register  
values are loaded into the E register, and the L, X, and Z values into the A  
register.  
LD @HL,A  
LD DA,EA  
Load A register contents to data memory location pointed to by the 8-bit HL  
register value.  
Load the A register contents to direct data memory and the E register contents  
to the next direct data memory location. The DA value must be an even number.  
If it is an odd number, the LSB of the DA value is recognized as logic zero (an  
even number), and is not replaced with the true value.  
LD RRb,EA  
Load contents of EA to the 8-bit RRb register (HL, WX, YZ). The E register is  
loaded into the H, W, and Y register and the A register into the L, X, and Z  
register.  
LD @HL,EA Load the A register to data memory location pointed to by the 8-bit HL register,  
and the E register contents to the next location, HL + 1. The contents of the L  
register must be an even number. If the number is odd, the LSB of the L register  
is recognized as logic zero (an even number), and is not replaced with the true  
value. For example, 'LD HL,#36H' loads immediate 36H to register HL; the  
instruction 'LD @HL,EA' loads the contents of A into address 36H and the  
contents of E into address 37H.  
5-63  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
LDB— Load Bit  
LDB  
LDB  
dst,src.b  
dst.b,src  
Operation:  
Operand  
Operation Summary  
Load carry bit to a specified memory bit  
Load carry bit to a specified indirect memory bit  
Bytes  
Cycles  
mema.b,C  
2
2
2
2
2
2
2
2
2
2
2
2
memb.@L,C  
@H+DA.b,C  
C,mema.b  
Load memory bit to a specified carry bit  
C,memb.@L  
C,@H+DA.b  
Load indirect memory bit to a specified carry bit  
Description:  
The Boolean variable indicated by the first or second operand is copied into the location specified by  
the second or first operand. One of the operands must be the carry flag; the other may be any  
directly or indirectly addressable bit. The source is unaffected.  
Operand  
Binary Code  
Operation Notation  
mema.b ¬ C  
1
1
1
1
1
1
1
0
0
0
0
mema.b,C *  
memb.@L,C  
@H+DA.b,C  
C,mema.b*  
1
0
1
0
1
1
1
1
0
1
1
0
1
1
0
1
1
memb.7-2 + [L.3-2]. [L.1-0] ¬ C  
H + [DA.3-0].b ¬ (C)  
a5 a4 a3 a2  
1
1
0
0
b1 b0 a3 a2 a1 a0  
1
1
0
1
0
0
C ¬ mema.b  
C,memb.@L  
C,@H+DA.b  
1
0
1
0
1
1
1
0
1
0
1
1
0
1
0
1
0
0
C ¬ memb.7-2 + [L.3-2] . [L.1-0]  
C ¬ [H + DA.3-0].b  
a5 a4 a3 a2  
0
1
0
0
b1 b0 a3 a2 a1 a0  
Second Byte  
Bit Addresses  
1
1
0
1
b1 b0 a3 a2 a1 a0 FB0H-FBFH  
b1 b0 a3 a2 a1 a0 FF0H-FFFH  
* mema.b  
5-64  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
LDBLoad Bit  
LDB  
(Continued)  
Examples:  
1. The carry flag is set and the data value at input pin P1.0 is logic zero. The following instruction  
clears the carry flag to logic zero.  
LDB  
C,P1.0  
2. The P1 address is FF1H and the L register contains the value 9H (1001B). The address  
(memb.7-2) is 111100B and (L.3-2) is 10B. The resulting address is 11110010B or FF2H and P2  
is addressed. The bit value (L.1-0) is specified as 01B (bit 1).  
LD  
L,#9H  
LDB  
CO,P1.@L  
; P1.@L specifies P2.1 and C ¬ P2.1  
3. The H register contains the value 2H and FLAG = 20H.3. The address for H is 0010B and for  
FLAG(3-0) the address is 0000B. The resulting address is 00100000B or 20H. The bit value is 3.  
Therefore, @H+FLAG = 20H.3.  
FLAG  
LD  
EQU  
H,#2H  
20H.3  
LDB  
C,@H+FLAG  
; C ¬ FLAG (20H.3)  
4. The following instruction sequence sets the carry flag and the loads the "1" data value to the  
output pin P2.0, setting it to output mode:  
SCF  
LDB  
;
;
C ¬ "1"  
P2.0 ¬ "1"  
P2.0,C  
5. The P1 address is FF1H and L = 9H (1001B). The address (memb.7-2) is 111100B and (L.3-2)  
is 10B. The resulting address, 11110010B specifies P2. The bit value (L.1-0) is specified as 01B  
(bit 1). Therefore, P1.@L = P2.1.  
SCF  
LD  
;
C ¬ "1"  
L,#9H  
LDB  
P1.@L,C  
;
;
P1.@L specifies P2.1  
P2.1 ¬ "1"  
6. In this example, H = 2H and FLAG = 20H.3 and the address 20H is specified. Since the bit  
value is 3, @H+FLAG = 20H.3:  
FLAG  
RCF  
LD  
EQU  
20H.3  
;
;
C ¬ "0"  
H,#2H  
@H+FLAG,C  
LDB  
FLAG(20H.3) ¬ "0"  
NOTE: Port pin names used in examples 4 and 5 may vary with different SAM48 devices.  
5-65  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
LDCLoad Code Byte  
LDC  
dst,src  
Operation:  
Operand  
Operation Summary  
Load code byte from WX to EA  
Load code byte from EA to EA  
Bytes  
Cycles  
EA,@WX  
EA,@EA  
1
1
3
3
Description:  
This instruction is used to load a byte from program memory into an extended accumulator. The  
address of the byte fetched is the six highest bit values in the program counter and the contents of  
an 8-bit working register (either WX or EA). The contents of the source are unaffected.  
Operand  
EA,@WX  
EA,@EA  
Binary Code  
Operation Notation  
EA ¬ [PC13-8 + (WX)]  
EA ¬ [PC13-8 + (EA)]  
1
1
1
1
0
0
0
0
1
1
1
0
0
0
0
0
Examples:  
1. The following instructions will load one of four values defined by the define byte (DB)  
to the extended accumulator:  
directive  
LD  
CALL  
JPS  
EA,#00H  
DISPLAY  
MAIN  
ORG  
0500H  
DB  
DB  
DB  
DB  
66H  
77H  
88H  
99H  
DISPLAY LDC  
RET  
EA,@EA ; EA ¬ address 0500H = 66H  
If the instruction 'LD EA,#01H' is executed in place of 'LD EA,#00H', The content of 0501H (77H)  
is loaded to the EA register. If 'LD EA,#02H' is executed, the content of address 0502H (88H) is  
loaded to EA.  
5-66  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
LDC— Load Code Byte  
LDC  
(Continued)  
Examples:  
2. The following instructions will load one of four values defined by the define byte (DB)  
to the extended accumulator:  
directive  
ORG  
0500H  
DB  
DB  
DB  
DB  
66H  
77H  
88H  
99H  
DISPLAY LD  
WX,#00H  
LDC  
RET  
EA,@WX  
; EA ¬ address 0500H = 66H  
If the instruction 'LD WX,#01H' is executed in place of 'LD WX,#00H', then  
EA ¬ address 0501H = 77H.  
If the instruction 'LD WX,#02H' is executed in place of 'LD WX,#00H', then  
EA ¬ address 0502H = 88H.  
3. Normally, the LDC EA, @EA and the LDC EA, @WX instructions reference the table data  
on the page on which the instruction is located. If, however, the instruction is located at  
address xxFFH, it will reference table data on the next page. In this example, the upper 4 bits  
of the address at location 0200H is loaded into register E and the lower 4 bits into register A:  
ORG  
01FDH  
01FDH  
01FFH  
LD  
LDC  
WX,#00H  
EA,@WX ; E ¬ upper 4 bits of 0200H address  
;
A ¬ lower 4 bits of 0200H address  
4. Here is another example of page referencing with the LDC instruction:  
ORG  
0100H  
DB  
67H  
SMB  
LD  
LD  
0
HL,#30H  
WX,#00H  
EA,@WX  
;
Even number  
LDC  
;
;
;
E ¬ upper 4 bits of 0100H address  
A ¬ lower 4 bits of 0100H address  
RAM (30H) ¬ 7, RAM (31H) ¬ 6  
LD  
@HL,EA  
5-67  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
LDD— Load Data Memory and Decrement  
LDD  
dst  
Operation:  
Operand  
A,@HL  
Operation Summary  
Bytes  
Cycles  
Load indirect data memory contents to A; decrement  
register L contents and skip on borrow  
1
2 + S  
Description:  
The contents of a data memory location are loaded into the accumulator, and the contents of the  
register L are decreased by one. If a "borrow" occurs (e.g., if the resulting value in register L is 0FH),  
the next instruction is skipped. The contents of data memory and the carry flag value are not  
affected.  
Operand  
A,@HL  
Binary Code  
Operation Notation  
1
0
0
0
1
0
1
1
A ¬ (HL), then L ¬ L-1;  
skip if L = 0FH  
Example:  
In this example, assume that register pair HL contains 20H and internal RAM location 20H contains  
the value 0FH:  
LD  
HL,#20H  
A,@HL  
XXX  
LDD  
JPS  
JPS  
;
A ¬ (HL) and L ¬ L-1  
Skip  
; H ¬ 2H and L ¬ 0FH  
;
YYY  
The instruction 'JPS XXX' is skipped since a "borrow" occurred after the 'LDD A,@HL' and  
instruction 'JPS YYY' is executed.  
5-68  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
LDI — Load Data Memory and Increment  
LDI  
dst,src  
Operation:  
Operand  
A,@HL  
Operation Summary  
Bytes  
Cycles  
Load indirect data memory to A; increment register L  
contents and skip on overflow  
1
2 + S  
Description:  
The contents of a data memory location are loaded into the accumulator, and the contents of the  
register L are incremented by one. If an overflow occurs (e.g., if the resulting value in register L is  
0H), the next instruction is skipped. The contents of data memory and the carry flag value are not  
affected.  
Operand  
A,@HL  
Binary Code  
Operation Notation  
1
0
0
0
1
0
1
0
A ¬ (HL), then L ¬ L+1;  
skip if L = 0H  
Example:  
Assume that register pair HL contains the address 2FH and internal RAM location 2FH contains the  
value 0FH:  
LD  
HL,#2FH  
A,@HL  
XXX  
LDI  
JPS  
JPS  
;
A ¬ (HL) and L ¬ L+1  
Skip  
; H ¬ 2H and L ¬ 0H  
;
YYY  
The instruction 'JPS XXX' is skipped since an overflow occurred after the 'LDI A,@HL' and the  
instruction 'JPS YYY' is executed.  
5-69  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
NOP — No Operation  
NOP  
Operation:  
Operand  
Operation Summary  
Bytes  
Cycles  
No operation  
1
1
Description:  
No operation is performed by a NOP instruction. It is typically used for timing delays.  
One NOP causes a 1-cycle delay: with a 1 µs cycle time, five NOPs would therefore cause a 5 µs  
delay. Program execution continues with the instruction immediately following the NOP. Only the  
PC is affected. At least three NOP instructions should follow a STOP or IDLE instruction.  
Operand  
Binary Code  
Operation Notation  
No operation  
1
0
1
0
0
0
0
0
Example:  
Three NOP instructions follow the STOP instruction to provide a short interval for clock stabilization  
before power-down mode is initiated:  
STOP  
NOP  
NOP  
NOP  
5-70  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
OR— Logical OR  
OR  
dst,src  
Operation:  
Operand  
Operation Summary  
Logical-OR immediate data to A  
Bytes  
Cycles  
A, #im  
2
1
2
2
2
1
2
2
A, @HL  
EA,RR  
RRb,EA  
Logical-OR indirect data memory contents to A  
Logical-OR double register to EA  
Logical-OR EA to double register  
Description:  
The source operand is logically ORed with the destination operand. The result is stored in the  
destination. The contents of the source are unaffected.  
Operand  
A, #im  
Binary Code  
Operation Notation  
A ¬ A OR im  
1
0
0
1
0
1
0
1
0
0
1
0
1
0
0
1
1
0
1
0
1
1
0
1
1
0
1
0
1
1
0
1
d3 d2 d1 d0  
A, @HL  
EA,RR  
1
1
1
1
0
0
1
1
0
0
0
0
0
0
A ¬ A OR (HL)  
EA ¬ EA OR RR  
r2  
1
r1  
0
RRb,EA  
RRb ¬ RRb OR EA  
r2  
r1  
Example:  
If the accumulator contains the value 0C3H (11000011B) and register pair HL the value 55H  
(01010101B), the instruction  
OR  
EA,@HL  
leaves the value 0D7H (11010111B) in the accumulator .  
5-71  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
POP — POP From Stack  
POP  
dst  
Operation:  
Operand  
Operation Summary  
Pop to register pair from stack  
Pop SMB and SRB values from stack  
Bytes  
Cycles  
RR  
SB  
1
2
1
2
Description:  
The contents of the RAM location addressed by the stack pointer is read, and the SP is  
incremented by two. The value read is then transferred to the variable indicated by the destination  
operand.  
Operand  
RR  
Binary Code  
Operation Notation  
0
0
1
0
1
r2  
r1  
0
RR ¬ (SP), RR ¬ (SP+1)  
L
H
SP ¬ SP+2  
SB  
1
0
1
1
0
1
1
0
1
0
1
1
0
1
1
0
(SRB) ¬ (SP), SMB ¬ (SP+1),  
SP ¬ SP+2  
Example:  
The SP value is equal to 0EDH, and RAM locations 0EFH through 0EDH contain the values 2H, 3H,  
and 4H, respectively. The instruction  
POP  
HL  
leaves the stack pointer set to 0EFH and the data pointer pair HL set to 34H.  
5-72  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
PUSH— PUSH onto Stack  
PUSH  
src  
Operation:  
Operand  
Operation Summary  
Push register pair onto stack  
Push SMB and SRB values onto stack  
Bytes  
Cycles  
RR  
SB  
1
2
1
2
Description:  
The SP is then decreased by two and the contents of the source operand are copied into the RAM  
location addressed by the stack pointer, thereby adding a new element to the top of the stack.  
Operand  
RR  
Binary Code  
Operation Notation  
(SP-1) ¬ RR , (SP-2) ¬ RR  
0
0
1
0
1
r2  
r1  
1
H
L
SP ¬ SP-2  
SB  
1
0
1
1
0
1
1
0
1
0
1
1
0
1
1
1
(SP-1) ¬ SMB, (SP-2) ¬ SRB;  
(SP) ¬ SP-2  
Example:  
As an interrupt service routine begins, the stack pointer contains the value 0FAH and the data  
pointer register pair HL contains the value 20H. The instruction  
PUSH  
HL  
leaves the stack pointer set to 0F8H and stores the values 2H and 0H in RAM locations 0F9H and  
0F8H, respectively.  
5-73  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
RCF — Reset Carry Flag  
RCF  
Operation:  
Operand  
Operation Summary  
Reset carry flag to logic zero  
Bytes  
Cycles  
1
1
Description:  
The carry flag is cleared to logic zero, regardless of its previous value.  
Operand  
Binary Code  
Operation Notation  
1
1
1
0
0
1
1
0
C ¬ 0  
Example:  
Assuming the carry flag is set to logic one, the instruction  
RCF  
resets (clears) the carry flag to logic zero.  
5-74  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
REF — Reference Instruction  
REF  
dst  
Operation:  
Operand  
memc  
Operation Summary  
Reference code  
Bytes  
Cycles  
(note)  
1
1
NOTE: The instruction referenced by REF determines instruction cycles.  
Description:  
The REF instruction is used to rewrite into 1-byte form, arbitrary 2-byte or 3-byte instructions (or two  
1-byte instructions) stored in the REF instruction reference area in program memory. REF reduces  
the number of program memory accesses for a program.  
Operand  
Binary Code  
t4 t3  
Operation Notation  
memc  
t7  
t6  
t5  
t2  
t1  
t0 PC13-0 ¬ memc5-0 + (memc+1).7-0  
TJP and TCALL are 2-byte pseudo-instructions that are used only to specify the reference area:  
1. When the reference area is specified by the TJP instruction,  
memc.7-6 = 00  
PC13-0 ¬ memc.5-0 + (memc+1).7-0  
2. When the reference area is specified by the TCALL instruction,  
memc.7-6 = 01  
[(SP-1) (SP-2)] ¬ EMB, ERB  
[(SP-3) (SP-4)] ¬ PC7-0  
[(SP-5) (SP-6)] ¬ PC13-8  
SP ¬ SP-6  
PC-0 ¬ memc.5-0 + (memc+1).7-0  
When the reference area is specified by any other instruction, the 'memc' and 'memc + 1'  
instructions are executed.  
Instructions referenced by REF occupy 2 bytes of memory space (for two 1-byte instructions or one  
2-byte instruction) and must be written as an even number from 0020H to 007FH in ROM. In  
addition, the destination address of the TJP and TCALL instructions must be located with the  
3FFFH address. TJP and TCALL are reference instructions for JP/JPS and CALL/CALLS.  
If the instruction following a REF is subject to the 'redundancy effect', the redundant instruction is  
skipped. If, however, the REF follows a redundant instruction, it is executed.  
On the other hand, the binary code of a REF instruction is 1 byte. The upper 4 bits become the  
higher address bits of the referenced instruction, and the lower 4 bits of the referenced instruction  
becomes the lower address, producing a total of 8 bits or 1 byte (see Example 3 below).  
NOTE: If the MSB value of the first one-byte binary code in instruction is “0”, the instruction cannot be referenced by a REF  
instruction.  
5-75  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
REF — Reference Instruction  
REF  
(Continued)  
Examples:  
1. Instructions can be executed efficiently using REF, as shown in the following example:  
ORG  
0020H  
AAA  
BBB  
CCC  
DDD  
LD  
LD  
TCALL  
TJP  
HL,#00H  
EA,#FFH  
SUB1  
SUB2  
ORG 0080H  
REF  
REF  
REF  
REF  
AAA  
;
;
;
;
LD  
LD  
HL,#00H  
EA,#FFH  
BBB  
CCC  
DDD  
CALL SUB1  
JP SUB2  
2. The following example shows how the REF instruction is executed in relation to LD  
instructions that have a 'redundancy effect':  
ORG  
0020H  
AAA  
LD  
EA,#40H  
ORG  
LD  
REF  
REF  
LD  
SRB  
0100H  
EA,#30H  
AAA  
;
;
Not skipped  
Skipped  
AAA  
EA,#50H  
2
5-76  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
REF — Reference Instruction  
REF  
(Concluded)  
Examples:  
3. In this example the binary code of 'REF A1' at locations 20H-21H is 20H, for 'REF A2' at  
locations 22H-23H, it is 21H, and for 'REF A3' at 24H-25H, the binary code is 22H :  
Opcode Symbol Instruction  
ORG  
0020H  
83 00  
83 03  
83 05  
83 10  
83 26  
83 08  
83 0F  
83 F0  
83 67  
41 0B  
01 0D  
A1  
A2  
A3  
A4  
A5  
A6  
A7  
A8  
A9  
A10  
A11  
LD  
LD  
LD  
LD  
LD  
LD  
LD  
LD  
LD  
TCALL  
TJP  
HL,#00H  
HL,#03H  
HL,#05H  
HL,#10H  
HL,#26H  
HL,#08H  
HL,#0FH  
HL,#0F0H  
HL,#067H  
SUB1  
SUB2  
ORG  
0100H  
20  
21  
22  
23  
24  
25  
26  
27  
30  
31  
32  
REF  
REF  
REF  
REF  
REF  
REF  
REF  
REF  
REF  
REF  
REF  
A1  
A2  
A3  
A4  
A5  
A6  
A7  
A8  
A9  
A10  
A11  
;
;
;
;
;
;
;
;
;
;
;
LD  
LD  
LD  
LD  
LD  
LD  
LD  
LD  
LD  
CALL  
JP  
HL,#00H  
HL,#03H  
HL,#05H  
HL,#10H  
HL,#26H  
HL,#08H  
HL,#0FH  
HL,#0F0H  
HL,#067H  
SUB1  
SUB2  
5-77  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
RET — Return From Subroutine  
RET  
Operation:  
Operand  
Operation Summary  
Return from subroutine  
Bytes  
Cycles  
1
3
Description:  
RET pops the PC values successively from the stack, incrementing the stack pointer by six.  
Program execution continues from the resulting address, generally the instruction immediately  
following a CALL or CALLS.  
Operand  
Binary Code  
Operation Notation  
1
1
0
0
0
1
0
1
PC13-8 ¬ (SP + 1) (SP)  
PC7-0 ¬ (SP + 3) (SP + 2)  
EMB,ERB ¬ (SP + 4)  
SP ¬ SP + 6  
Example:  
The stack pointer contains the value 0FAH. RAM locations 0FAH, 0FBH, 0FCH, and 0FDH contain  
1H, 0H, 5H, and 2H, respectively. The instruction  
RET  
leaves the stack pointer with the new value of 00H and program execution continues from location  
0125H.  
During a return from subroutine, PC values are popped from stack locations as follows:  
SP ®  
(0FAH)  
(0FBH)  
(0FCH)  
(0FDH)  
(0FEH)  
(0FFH)  
(000H)  
PC11 – PC8  
SP + 1  
SP + 2  
SP + 3  
SP + 4  
SP + 5  
SP + 6  
0
0
PC13 PC12  
PC3 – PC0  
PC7 – PC4  
0
0
0
0
EMB  
0
ERB  
0
5-78  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
RRC— Rotate Accumulator Right through Carry  
RRC  
A
Operation:  
Operand  
Operation Summary  
Rotate right through carry bit  
Bytes  
Cycles  
A
1
1
Description:  
The four bits in the accumulator and the carry flag are together rotated one bit to the right. Bit 0  
moves into the carry flag and the original carry value moves into the bit 3 accumulator position.  
3
0
C
Operand  
Binary Code  
Operation Notation  
C ¬ A.0, A3 ¬ C  
A.n-1 ¬ A.n (n = 1, 2, 3)  
A
1
0
0
0
1
0
0
0
Example:  
The accumulator contains the value 5H (0101B) and the carry flag is cleared to logic zero. The  
instruction  
RRC  
A
leaves the accumulator with the value 2H (0010B) and the carry flag set to logic one.  
NOTE  
The number of memory bank selected by SMB may change for different devices in the SAM48 product  
family.  
5-79  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
SBC— Subtract With Carry  
SBC  
dst,src  
Operation:  
Operand  
Operation Summary  
Bytes  
Cycles  
A,@HL  
EA,RR  
RRb,EA  
Subtract indirect data memory from A with carry  
Subtract register pair (RR) from EA with carry  
Subtract EA from register pair (RRb) with carry  
1
2
2
1
2
2
Description:  
SBC subtracts the source and carry flag value from the destination operand, leaving the result in the  
destination. SBC sets the carry flag if a borrow is needed for the most significant bit; otherwise it  
clears the carry flag. The contents of the source are unaffected.  
If the carry flag was set before the SBC instruction was executed, a borrow was needed for the  
previous step in multiple precision subtraction. In this case, the carry bit is subtracted from the  
destination along with the source operand.  
Operand  
A,@HL  
Binary Code  
Operation Notation  
C,A ¬ A - (HL) - C  
0
1
1
1
1
0
1
1
1
1
1
0
0
0
0
1
1
0
1
0
1
1
1
1
0
1
1
0
0
0
0
0
0
0
EA,RR  
C, EA ¬ EA -RR - C  
r2  
1
r1  
0
RRb,EA  
C,RRb ¬ RRb - EA - C  
r2  
r1  
Examples:  
1. The extended accumulator contains the value 0C3H, register pair HL the value 0AAH, and  
the carry flag is set to "1":  
SCF  
SBC  
JPS  
;
;
;
C ¬ "1"  
EA,HL  
XXX  
EA ¬ 0C3H - 0AAH - 1H, C ¬ "0"  
Jump to XXX; no skip after SBC  
2. If the extended accumulator contains the value 0C3H, register pair HL the value 0AAH, and  
the carry flag is cleared to "0":  
RCF  
SBC  
JPS  
;
;
;
C ¬ "0"  
EA,HL  
XXX  
EA ¬ 0C3H - 0AAH - 0H = 19H, C ¬ "0"  
Jump to XXX; no skip after SBC  
5-80  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
SBC— Subtract with Carry  
SBC  
(Continued)  
Examples:  
3. If SBC A,@HL is followed by an ADS A,#im, the SBC skips on 'no borrow' to the instruction  
immediately after the ADS. An 'ADS A,#im' instruction immediately after the 'SBC A,@HL'  
instruction does not skip even if an overflow occurs. This function is useful for decimal  
adjustment operations.  
a. 8 - 6 decimal addition (the contents of the address specified by the HL register is 6H):  
RCF  
LD  
SBC  
ADS  
JPS  
;
;
;
;
C ¬ "0"  
A ¬ 8H  
A,#8H  
A,@HL  
A,#0AH  
XXX  
A ¬ 8H - 6H - C(0) = 2H, C ¬ "0"  
Skip this instruction because no borrow after SBC result  
b. 3 - 4 decimal addition (the contents of the address specified by the HL register is 4H):  
RCF  
LD  
SBC  
ADS  
;
;
;
;
;
;
C ¬ "0"  
A ¬ 3H  
A,#3H  
A,@HL  
A,#0AH  
A ¬ 3H - 4H - C(0) = 0FH, C ¬ "1"  
No skip. A ¬ 0FH + 0AH = 9H  
(The skip function of 'ADS A,#im' is inhibited after a  
'SBC A,@HL' instruction even if an overflow occurs.)  
JPS  
XXX  
5-81  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
SBS— Subtract  
SBS  
dst,src  
Operation:  
Operand  
Operation Summary  
Bytes  
Cycles  
1 + S  
2 + S  
2 + S  
A,@HL  
EA,RR  
RRb,EA  
Subtract indirect data memory from A; skip on borrow  
Subtract register pair (RR) from EA; skip on borrow  
Subtract EA from register pair (RRb); skip on borrow  
1
2
2
Description:  
The source operand is subtracted from the destination operand and the result is stored in the  
destination. The contents of the source are unaffected. A skip is executed if a borrow occurs. The  
value of the carry flag is not affected.  
Operand  
A,@HL  
Binary Code  
Operation Notation  
A ¬ A - (HL); skip on borrow  
EA ¬ EA - RR; skip on borrow  
0
1
1
1
1
0
1
0
1
0
1
0
1
0
1
1
1
1
1
1
1
1
1
1
0
1
1
0
0
1
0
0
0
0
EA,RR  
r2  
1
r1  
0
RRb,EA  
RRb ¬ RRb - EA; skip on borrow  
r2  
r1  
Examples:  
1. The accumulator contains the value 0C3H, register pair HL contains the value 0C7H, and the  
carry flag is cleared to logic zero:  
RCF  
SBS  
;
;
;
;
;
;
C ¬ "0"  
EA ¬ 0C3H - 0C7H  
SBS instruction skips on borrow,  
but carry flag value is not affected  
Skip because a borrow occurred  
Jump to YYY is executed  
EA,HL  
JPS  
JPS  
XXX  
YYY  
2. The accumulator contains the value 0AFH, register pair HL contains the value 0AAH, and the  
carry flag is set to logic one:  
SCF  
SBS  
JPS  
;
;
;
;
C ¬ "1"  
EA ¬ 0AFH - 0AAH  
Jump to XXX  
JPS was not skipped since no "borrow" occurred after  
SBS  
EA,HL  
XXX  
5-82  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
SCF — Set Carry Flag  
SCF  
Operation:  
Operand  
Operation Summary  
Set carry flag to logic one  
Bytes  
Cycles  
1
1
Description:  
The SCF instruction sets the carry flag to logic one, regardless of its previous value.  
Operand  
Binary Code  
Operation Notation  
1
1
1
0
0
1
1
1
C ¬ 1  
Example:  
If the carry flag is cleared to logic zero, the instruction  
SCF  
sets the carry flag to logic one.  
5-83  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
SMB— Select Memory Bank  
SMB  
n
Operation:  
Operand  
Operation Summary  
Select memory bank  
Bytes  
Cycles  
n
2
2
Description:  
The SMB instruction sets the upper four bits of a 12-bit data memory address to select a specific  
memory bank. The constants 0, n, and 15 are usually used as the SMB operand to select the  
corresponding memory bank. All references to data memory addresses fall within the following  
address ranges:  
Please note that since data memory spaces differ for various devices in the SAM4 product family,  
the 'n' value of the SMB instruction will also vary.  
Addresses  
000H-01FH  
Register Areas  
Working registers  
Bank  
SMB  
0
0
020H-0FFH  
N00H-NFFH  
Stack and general-purpose registers  
General-purpose registers  
Display registers  
n
n
(n = 1-14) (n = 1-14)  
15 15  
F80H-FFFH  
I/O-mapped hardware registers  
The enable memory bank (EMB) flag must always be set to "1" in order for the SMB instruction to  
execute successfully for memory bank 0 - 15.  
Format  
Binary Code  
Operation Notation  
SMB ¬ n  
n
1
0
1
1
0
0
1
0
1
1
0
1
d3 d2 d1 d0  
Example:  
NOTE:  
If the EMB flag is set, the instruction  
SMB  
0
selects the data memory address range for bank 0 (000H-0FFH) as the working memory bank.  
Number of memory bank selected by SMB may change for different device in the SAM48 product family.  
5-84  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
SRB— Select Register Bank  
SRB  
n
Operation:  
Operand  
Operation Summary  
Select register bank  
Bytes  
Cycles  
n
2
2
Description:  
The SRB instruction selects one of four register banks in the working register memory area. The  
constant value used with SRB is 0, 1, 2, or 3. The following table shows the effect of SRB settings:  
ERB Setting  
SRB Settings  
Selected Register Bank  
3
2
1
x
0
0
1
1
0
x
0
1
0
1
0
1
0
0
Always set to bank 0  
Bank 0  
0
0
Bank 1  
Bank 2  
Bank 3  
NOTE: 'x' = not applicable.  
The enable register bank flag (ERB) must always be set for the SRB instruction to execute  
successfully for register banks 0, 1, 2, and 3. In addition, if the ERB value is logic zero, register  
bank 0 is always selected, regardless of the SRB value.  
Operand  
Binary Code  
Operation Notation  
n
1
0
1
1
0
0
1
1
1
0
1
0
0
1
SRB ¬ n (n = 0, 1, 2, 3)  
d1 d0  
Example:  
If the ERB flag is set, the instruction  
SRB  
selects register bank 3 (018H-01FH) as the working memory register bank.  
3
5-85  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
SRET — Return from Subroutine and Skip  
SRET  
Operation:  
Operand  
Operation Summary  
Return from subroutine and skip  
Bytes  
Cycles  
1
3 + S  
Description:  
SRET is normally used to return to the previously executing procedure at the end of a subroutine  
that was initiated by a CALL or CALLS instruction. SRET skips the resulting address, which is  
generally the instruction immediately after the point at which the subroutine was called. Then,  
program execution continues from the resulting address and the contents of the location addressed  
by the stack pointer are popped into the program counter.  
Operand  
Binary Code  
Operation Notation  
1
1
1
0
0
1
0
1
PC13-8 ¬ (SP + 1) (SP)  
PC7-0 ¬ (SP + 3) (SP + 2)  
EMB,ERB ¬ (SP + 4)  
SP ¬ SP + 6  
Example:  
If the stack pointer contains the value 0FAH and RAM locations 0FAH, 0FBH, 0FCH, and 0FDH  
contain the values 1H, 0H, 5H, and 2H, respectively, the instruction  
SRET  
leaves the stack pointer with the value 00H and the program returns to continue execution at  
location 0125H, then skips unconditionally.  
During a return from subroutine, data is popped from the stack to the PC as follows:  
SP ®  
(0FAH)  
(0FBH)  
(0FCH)  
(0FDH)  
(0FEH)  
(0FFH)  
(000H)  
PC11 – PC8  
SP + 1  
SP + 2  
SP + 3  
SP + 4  
SP + 5  
SP + 6  
0
0
PC13 PC12  
PC3 – PC0  
PC7 – PC4  
0
0
0
0
EMB  
0
ERB  
0
5-86  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
STOP — Stop Operation  
STOP  
Operation:  
Operand  
Operation Summary  
Engage CPU stop mode  
Bytes  
Cycles  
-
2
2
Description:  
The STOP instruction stops the system clock by setting bit 3 of the power control register (PCON)  
to logic one. When STOP executes, all system operations are halted with the exception of some  
peripheral hardware with special power-down mode operating conditions.  
In application programs, a STOP instruction must be immediately followed by at least three NOP  
instructions. This ensures an adequate time interval for the clock to stabilize before the next  
instruction is executed. If three or more NOP instructions are not used after STOP instruction,  
leakage current could be flown because of the floating state in the internal bus.  
Operand  
Binary Code  
Operation Notation  
PCON.3 ¬ 1  
1
1
1
0
1
1
1
1
1
0
1
0
1
1
1
1
Example:  
Given that bit 3 of the PCON register is cleared to logic zero, and all systems are operational, the  
instruction sequence  
STOP  
NOP  
NOP  
NOP  
sets bit 3 of the PCON register to logic one, stopping all controller operations (with the exception of  
some peripheral hardware). The three NOP instructions provide the necessary timing delay for clock  
stabilization before the next instruction in the program sequence is executed.  
5-87  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
VENT — Load EMB, ERB, and Vector Address  
VENTn  
dst  
Operation:  
Operand  
Operation Summary  
Bytes  
Cycles  
EMB (0,1)  
ERB (0,1)  
ADR  
Load enable memory bank flag (EMB) and the enable  
register bank flag (ERB) and program counter to vector  
address, then branch to the corresponding location.  
2
2
Description:  
The VENT instruction loads the contents of the enable memory bank flag (EMB) and enable register  
bank flag (ERB) into the respective vector addresses. It then points the interrupt service routine to  
the corresponding branching locations. The program counter is loaded automatically with the  
respective vector addresses which indicate the starting address of the respective vector interrupt  
service routines.  
The EMB and ERB flags should be modified using VENT before the vector interrupts are  
acknowledged. Then, when an interrupt is generated, the EMB and ERB values of the previous  
routine are automatically pushed onto the stack and then popped back when the routine is  
completed.  
After the return from interrupt (IRET) you do not need to set the EMB and ERB values again.  
Instead, use BITR and BITS to clear these values in your program routine.  
The starting addresses for vector interrupts and reset operations are pointed to by the VENTn  
instruction. These starting addresses must be located in ROM ranges 0000H-3FFFH. Generally, the  
VENTn instructions are coded starting at location 0000H.  
The format for VENT instructions is as follows:  
VENTn  
d1,d2,ADDR  
EMB ¬ d1 ("0" or "1")  
ERB ¬ d2 ("0" or "1")  
PC ¬ ADDR (address to branch  
n = device-specific module address code (n = 0-n)  
Operand  
Binary Code  
Operation Notation  
EMB (0,1)  
ERB (0,1)  
ADR  
E
M
B
E
R
B
a13 a12 a11 a10 a9  
a8 ROM (2 x n) 7-6 ® EMB, ERB  
ROM (2 x n) 5-4 ® PC13, PC12  
ROM (2 x n) 3-0 ® PC12-8  
ROM (2 x n + 1) 7-0 ® PC7-0  
(n = 0, 1, 2, 3, 4, 5, 6, 7)  
a7  
a6  
a5  
a4  
a3  
a2  
a1  
a0  
5-88  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
VENT — Load EMB, ERB, and Vector Address  
VENTn  
(Continued)  
Example:  
The instruction sequence  
ORG  
0000H  
VENT0  
VENT1  
VENT2  
VENT3  
VENT4  
VENT5  
VENT6  
VENT7  
1,0,RESET  
0,1,INTA  
0,1,INTB  
0,1,INTC  
0,1,INTD  
0,1,INTE  
0,1,INTF  
0,1,INTG  
causes the program sequence to branch to the RESET routine labeled RESET, setting EMB to "1"  
and ERB to "0" when RESET is activated. When a basic timer interrupt is generated, VENT1 causes  
the program to branch to the basic timer's interrupt service routine, INTA, and to set the EMB value  
to "0" and the ERB value to "1". VENT2 then branches to INTB, VENT3 to INTC, and so on, setting  
the appropriate EMB and ERB values.  
NOTE:  
the  
The number of VENTn interrupt names used in the examples above may change for different devices in  
SAM48 product family.  
5-89  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
XCH— Exchange A or EA with Nibble or Byte  
XCH  
dst,src  
Operation:  
Operand  
Operation Summary  
Exchange A and data memory contents  
Exchange A and register (Ra) contents  
Exchange A and indirect data memory  
Bytes  
Cycles  
A,DA  
2
1
1
2
2
2
2
1
1
2
2
2
A,Ra  
A,@RRa  
EA,DA  
EA,RRb  
EA,@HL  
Exchange EA and direct data memory contents  
Exchange EA and register pair (RRb) contents  
Exchange EA and indirect data memory contents  
Description:  
The instruction XCH loads the accumulator with the contents of the indicated destination variable  
and writes the original contents of the accumulator to the source.  
Operand  
A,DA  
Binary Code  
Operation Notation  
A « DA  
0
1
1
1
1
0
0
1
a7 a6 a5 a4 a3 a2 a1 a0  
A,Ra  
0
0
1
1
1
1
1
1
0
0
1
0
1
1
1
r2  
i2  
1
r1  
i1  
1
r0 A « Ra  
i0 A « (RRa)  
A « DA,E « DA + 1  
A,@RRa  
EA,DA  
1
a7 a6 a5 a4 a3 a2 a1 a0  
EA,RRb  
EA,@HL  
1
1
1
0
1
1
1
0
0
1
0
0
1
0
1
0
1
0
1
0
1
r2  
1
0
r1  
0
0
0
0
1
EA « RRb  
A « (HL), E « (HL + 1)  
0
0
Example:  
Double register HL contains the address 20H. The accumulator contains the value 3FH (00111111B)  
and internal RAM location 20H the value 75H (01110101B). The instruction  
XCH  
EA,@HL  
leaves RAM location 20H with the value 3FH (00111111B) and the extended accumulator with the  
value 75H (01110101B).  
5-90  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
XCHD— Exchange and Decrement  
XCHD  
dst,src  
Operation:  
Operand  
A,@HL  
Operation Summary  
Bytes  
Cycles  
Exchange A and data memory contents; decrement  
contents of register L and skip on borrow  
1
2 + S  
Description:  
The instruction XCHD exchanges the contents of the accumulator with the RAM location addressed  
by register pair HL and then decrements the contents of register L. If the content of register L is  
0FH, the next instruction is skipped. The value of the carry flag is not affected.  
Operand  
A,@HL  
Binary Code  
Operation Notation  
0
1
1
1
1
0
1
1
A « (HL), then L ¬ L-1;  
skip if L = 0FH  
Example:  
Register pair HL contains the address 20H and internal RAM location 20H contains the value 0FH:  
LD HL,#20H  
LD A,#0H  
XCHD  
JPS  
JPS  
A,@HL  
XXX  
YYY  
;
;
;
A ¬ 0FH and L ¬ L - 1, (HL) ¬ "0"  
Skipped since a borrow occurred  
H ¬ 2H, L ¬ 0FH  
YYY  
XCHD  
A,@HL  
;
(2FH) ¬ 0FH, A ¬ (2FH), L ¬ L - 1 = 0EH  
The 'JPS YYY' instruction is executed since a skip occurs after the XCHD instruction.  
5-91  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
XCHI — Exchange and Increment  
XCHI  
dst,src  
Operation:  
Operand  
A,@HL  
Operation Summary  
Bytes  
Cycles  
Exchange A and data memory contents; increment  
contents of register L and skip on overflow  
1
2 + S  
Description:  
The instruction XCHI exchanges the contents of the accumulator with the RAM location addressed  
by register pair HL and then increments the contents of register L. If the content of register L is 0H,  
a skip is executed. The value of the carry flag is not affected.  
Operand  
A,@HL  
Binary Code  
Operation Notation  
0
1
1
1
1
0
1
0
A « (HL), then L ¬ L+1;  
skip if L = 0H  
Example:  
Register pair HL contains the address 2FH and internal RAM location 2FH contains 0FH:  
LD  
LD  
HL,#2FH  
A,#0H  
XCHI A,@HL  
;
A ¬ 0FH and L ¬ L + 1 = 0, (HL) ¬ "0"  
JPS  
JPS  
XXX ;  
YYY  
Skipped since an overflow occurred  
;
H ¬ 2H, L ¬ 0H  
; (20H) ¬ 0FH, A ¬ (20H), L ¬ L + 1 = 1H  
YYY  
XCHI  
A,@HL  
The 'JPS YYY' instruction is executed since a skip occurs after the XCHI instruction.  
5-92  
S3C72K8/P72K8  
SAM48 INSTRUCTION SET  
XOR— Logical Exclusive OR  
XOR  
dst,src  
Operation:  
Operand  
Operation Summary  
Exclusive-OR immediate data to A  
Bytes  
Cycles  
A,#im  
2
1
2
2
2
1
2
2
A,@HL  
EA,RR  
RRb,EA  
Exclusive-OR indirect data memory to A  
Exclusive-OR register pair (RR) to EA  
Exclusive-OR register pair (RRb) to EA  
Description:  
XOR performs a bitwise logical XOR operation between the source and destination variables and  
stores the result in the destination. The source contents are unaffected.  
Operand  
A,#im  
Binary Code  
Operation Notation  
A ¬ A XOR im  
1
0
0
1
0
1
0
1
0
0
1
0
1
0
0
1
1
0
1
0
1
1
1
1
1
1
1
1
1
1
0
1
d3 d2 d1 d0  
A,@HL  
EA,RR  
1
1
0
1
0
0
1
1
0
1
0
0
0
0
A ¬ A XOR (HL)  
EA ¬ EA XOR (RR)  
r2  
1
r1  
0
RRb,EA  
RRb ¬ RRb XOR EA  
r2  
r1  
Example:  
If the extended accumulator contains 0C3H (11000011B) and register pair HL contains 55H  
(01010101B), the instruction  
XOR  
EA,HL  
leaves the value 96H (10010110B) in the extended accumulator.  
5-93  
SAM48 INSTRUCTION SET  
S3C72K8/P72K8  
NOTES  
5-94  
S3C72K8/P72K8  
OSCILLATOR CIRCUITS  
6
OSCILLATOR CIRCUITS  
OVERVIEW  
The S3C72K8 microcontroller have two oscillator circuits: a main system clock circuit, and a subsystem clock  
circuit. The CPU and peripheral hardware operate on the system clock frequency supplied through these circuits.  
Specifically, a clock pulse is required by the following peripheral modules:  
— LCD controller  
— Basic timer  
— Timer/counter 0  
— Watch timer  
— Serial I/O interface  
— Clock output circuit  
CPU Clock Notation  
In this document, the following notation is used for descriptions of the CPU clock:  
fx Main-system clock  
fxt Sub-system clock  
fxx Selected system clock  
Clock Control Registers  
When the system clock mode register, SCMOD, and the power control register, PCON, are both cleared to zero  
after RESET, the normal CPU operating mode is enabled, a main system clock is selected as fx/64, and main  
system clock oscillation is initiated.  
The PCON is used to select normal CPU operating mode or one of two power down mode-stop or idle. Bits 3 and 2  
of the PCON register can be manipulated by STOP or IDLE instruction to engage stop or idle power down mode.  
The SCMOD, lets you select the main system clock (fx) or a subsystem clock (fxt) as the CPU clock and start (or  
stop) main/sub system clock oscillation. The resulting clock source, either main system clock or subsystem clock,  
is referred to the selected system clock (fxx).  
The main system clock is selected and oscillation started when all SCMOD bits are cleared to "0". By setting  
SCMOD.3, SCMOD.2 and SCMOD.0 to different values, you can select a subsystem clock source and start or stop  
main/sub system clock oscillation. To stop main system clock oscillation, you must use the STOP instruction  
(assuming the main system clock is selected) or manipulate SCMOD.3 to (assuming the sub system clock is  
selected).  
The main system clock frequencies can be divided by 4, 8, or 64 and a subsystem clock frequencies can only be  
divided by 4. By manipulating PCON bits 1 and 0, you select one of the following frequencies as the CPU clock.  
fx/4, fxt/4, fx/8, fx/64  
6-1  
OSCILLATOR CIRCUITS  
S3C72K8/P72K8  
Using a Subsystem Clock  
If a subsystem clock is being used as the selected system clock, the idle power-down mode can be initiated by  
executing an IDLE instruction.  
The watch timer, buzzer and LCD display operate normally with a subsystem clock source, since they operate at  
very low speed (as low as 122 ms at 32.768 kHz) and with very low power consumption. Other hardware such as the  
basic timer, timer/counter 0 and the serial I/O interface should not be driven using the subsystem clock, since they  
require higher operating speeds for normal performance.  
Watch  
Timer  
fx  
fxt  
Main-system  
Oscillator  
Circuit  
Sub-system  
Oscillator  
Circuit  
LCD  
Controller  
Selector  
Oscillator  
Stop  
XIN  
XOUT  
XTIN  
XTOUT  
fxx  
Oscillator  
Stop  
1/1-1/4096  
Basic Timer  
Timer/Counter0  
Watch Timer  
LCD Controller  
Clock Output Circuit  
Serial I/O Interface  
Frequency  
Dividing  
Circuit  
1/2  
1/16  
SCMOD.3  
SCMOD.0  
Selector  
1/4  
CPU Clock  
fx/1, 2, 16  
fxt  
CPU stop signal  
(IDLE mode)  
PCON.0  
PCON.1  
PCON.2  
PCON.3  
Wait release signal  
Oscillator  
Control  
Circuit  
Idle  
Internal RESET signal  
Stop  
Power down release signal  
fx: Main-system clock  
fxt: Sub-system clock  
fxx: Selected system clock  
PCON.3, .2 clear  
Figure 6-1. Clock Circuit Diagram  
6-2  
S3C72K8/P72K8  
OSCILLATOR CIRCUITS  
MAIN SYSTEM OSCILLATOR CIRCUITS  
SUBSYSTEM OSCILLATOR CIRCUITS  
XTIN  
XIN  
XTOUT  
XOUT  
32.768 kHz  
Figure 6-5. Crystal/Ceramic Oscillator (fxt)  
Figure 6-2. Crystal/Ceramic Oscillator (fx)  
XIN  
XTIN  
External  
Clock  
External  
Clock  
XOUT  
XTOUT  
Figure 6-3. External Oscillator (fx)  
Figure 6-6. External Oscillator (fxt)  
XIN  
R
XOUT  
Figure 6-4. RC Oscillator (fx)  
6-3  
OSCILLATOR CIRCUITS  
S3C72K8/P72K8  
POWER CONTROL REGISTER (PCON)  
The power control register, PCON, is a 4-bit register that is used to select the CPU clock frequency and to control  
CPU operating and power-down modes. PCON can be addressed directly by 4-bit write instructions or indirectly by  
the instructions IDLE and STOP.  
FB3H  
PCON.3  
PCON.2  
PCON.1  
PCON.0  
PCON bits 3 and 2 are addressed by the STOP and IDLE instructions, respectively, to engage the idle and stop  
power-down modes. Idle and stop modes can be initiated by these instruction despite the current value of the enable  
memory bank flag (EMB). PCON bits 1 and 0 are used to select a specific system clock frequency. There are two  
basic choices:  
— Main system clock (fx) or subsystem clock (fxt);  
— Divided fx/4, 8, 64 or fxt/4 clock frequency.  
PCON.1 and PCON.0 settings are also connected with the system clock mode control register, SCMOD. If  
SCMOD.0 = "0" the main system clock is always selected by the PCON.1 and PCON.0 setting; if SCMOD.0 =  
"1" the subsystem clock is selected.  
RESET sets PCON register values (and SCMOD) to logic zero: SCMOD.3 and SCMOD.0 select the main system  
clock (fx) and start clock oscillation; PCON.1 and PCON.0 divide the selected fx frequency by 64, and PCON.3 and  
PCON.2 enable normal CPU operating mode.  
Table 6-1. Power Control Register (PCON) Organization  
PCON Bit Settings  
Resulting CPU Operating Mode  
PCON.3  
PCON.2  
0
0
1
0
1
0
Normal CPU operating mode  
Idle power-down mode  
Stop power-down mode  
PCON Bit Settings  
Resulting CPU Clock Frequency  
PCON.1  
PCON.0  
If SCMOD.0 = "0"  
If SCMOD.0 = "1"  
0
1
1
0
0
1
fx/64  
fx/8  
fx/4  
fxt/4  
+
PROGRAMMING TIP — Setting the CPU Clock  
To set the CPU clock to 0.95 ms at 4.19 MHz:  
BITS  
SMB  
LD  
EMB  
15  
A,#3H  
PCON,A  
LD  
6-4  
S3C72K8/P72K8  
OSCILLATOR CIRCUITS  
INSTRUCTION CYCLE TIMES  
The unit of time that equals one machine cycle varies depending on whether the main system clock (fx) or a  
subsystem clock (fxt) is used, and on how the oscillator clock signal is divided (by 4, 8, or 64). Table 6-2 shows  
corresponding cycle times in microseconds.  
Table 6-2. Instruction Cycle Times for CPU Clock Rates  
Selected  
CPU Clock  
Resulting Frequency  
Oscillation  
Source  
Cycle Time (msec)  
fx/64  
fx/8  
fx/4  
65.5 kHz  
524.0 kHz  
1.05 MHz  
fx = 4.19 MHz  
15.3  
1.91  
0.95  
fxt/4  
8.19 kHz  
fxt = 32,768 kHz  
122.0  
6-5  
OSCILLATOR CIRCUITS  
S3C72K8/P72K8  
SYSTEM CLOCK MODE REGISTER (SCMOD)  
The system clock mode register, SCMOD, is a 4-bit register that is used to select the CPU clock and to control  
main and sub-system clock oscillation. The SCMOD is mapped to the RAM address FB7H.  
The main clock oscillation is stopped by setting SCMOD.3 when the clock source is subsystem clock and  
subsystem clock can be stopped by setting SCMOD.2 when the clock source is main system clock. SCMOD.0,  
SCMOD.3 cannot be simultaneously modified.  
The subsystem clock is stopped only by setting SCMOD.2, and PCON which revokes stop mode cannot stop the  
subsystem clock. The stop of subsystem clock is released by RESET when the selected system clock is main  
system clock or subsystem clock and is released by setting SCMOD.2 when the selected system clock is main  
system clock.  
RESET clears all SCMOD values to logic zero, selecting the main system clock (fx) as the CPU clock and starting  
clock oscillation. The reset value of the SCMOD is "0".  
SCMOD.0, SCMOD.2, and SCMOD.3 bits can be manipulated by 1-bit write instructions (In other words, SCMOD.0,  
SCMOD.2, and SCMOD.3 cannot be modified simultaneously by a 4-bit write).  
Bit 1 is always logic zero.  
FB7H  
SCMOD.3  
SCMOD.2  
"0"  
SCMOD.0  
A subsystem clock (fxt) can be selected as the system clock by manipulating the SCMOD.3 and SCMOD.0 bit  
settings. If SCMOD.3 = "0" and SCMOD.0 = "1", the subsystem clock is selected and main system clock  
oscillation continues. If SCMOD.3 = "1" and SCMOD.0 = "1", fxt is selected, but main system clock oscillation  
stops.  
Even if you have selected fx as the CPU clock, setting SCMOD.3 to "1" will stop main system clock oscillation, and  
malfunction may be occurred. To operate safely, main system clock should be stopped by a stop instruction is main  
system clock mode.  
Table 6-3. System Clock Mode Register (SCMOD) Organization  
SCMOD Register Bit Settings  
Resulting Clock Selection  
CPU Clock fx Oscillation  
fx On  
SCMOD.3  
SCMOD.0  
0
0
1
0
1
1
fxt  
fxt  
On  
Off  
Table 6-4. SCMOD.2 for Sub-oscillation On/Off  
SCMOD.2  
Sub-oscillation on/off  
Enable sub system clock  
Disable sub system clock  
0
1
NOTE: You can use SCMOD.2 as follows (ex; after data bank was used, a few minutes have passed):  
Main operation ® sub-operation ® sub-idle (LCD on, after a few minutes later without any  
external input) ® sub-operation ® main operation ® SCMOD.2 = 1 ® main stop mode (LCD off).  
6-6  
S3C72K8/P72K8  
OSCILLATOR CIRCUITS  
Table 6-5. Main/Sub Oscillation Stop Mode  
Condition Method to issue OSC Stop  
(2)  
Mode  
OSC Stop Release Source  
Main  
Oscillation  
STOP Mode  
Main oscillator runs.  
Sub oscillator runs  
(stops).  
System clock is the  
main oscillation  
clock.  
STOP instruction:  
Main oscillator stops.  
CPU is in idle mode.  
Interrupt and RESET:  
After releasing stop mode, main  
oscillation starts and oscillation  
stabilization time is elapsed. And  
then the CPU operates.  
Oscillation stabilization time is  
1/[256 x BT clock (fx)]  
Sub oscillator still runs (stops).  
(1),  
When SCMOD.3 is set to "1”  
main oscillator stops, halting the  
CPU operation.  
RESET:  
Interrupt can't start the main  
oscillation. Therefore, the CPU  
operation can never be restarted.  
Sub oscillator still runs (stops).  
(1)  
Main oscillator runs.  
Sub oscillator runs.  
System clock is the  
sub oscillation clock.  
STOP instruction  
:
BT overflow, interrupt, and RESET:  
After the overflow of basic timer  
[1/(256 x BT clock (fxt))], CPU  
operation and main oscillation  
automatically start.  
Main oscillator stops.  
CPU is in idle mode.  
Sub oscillator still runs (stops).  
Sub oscillator still runs.  
When SCMOD.3 is set to "1",  
main oscillator stops.  
The CPU, however, would still  
operate.  
Set SCMOD.3 to "0" or RESET  
Set SCMOD.2 to "0" or RESET  
RESET  
Sub oscillator still runs.  
Sub  
Oscillation  
STOP Mode  
Main oscillator runs.  
Sub oscillator runs.  
System clock is the  
main oscillation  
clock.  
When SCMOD.2 to "1", sub  
oscillator stops, while main  
oscillator and the CPU would still  
operate.  
Main oscillator runs  
(stops).  
When SCMOD.2 to "1", sub  
oscillator stops, halting the CPU  
operation.  
Sub oscillator runs.  
System clock is the  
sub oscillation clock.  
Main oscillator still runs (stops).  
NOTES:  
1. This mode must not be used.  
2. Oscillation stabilization time by interrupt is 1/(256 x BT clocks). Oscillation stabilization time by a reset is  
31.3 ms at 4.19 MHz, main oscillation clock.  
6-7  
OSCILLATOR CIRCUITS  
S3C72K8/P72K8  
SWITCHING THE CPU CLOCK  
Together, bit settings in the power control register, PCON, and the system clock mode register, SCMOD, determine  
whether a main system or a subsystem clock is selected as the CPU clock, and also how this frequency is to be  
divided. This makes it possible to switch dynamically between main and subsystem clocks and to modify operating  
frequencies.  
SCMOD.3, SCMOD.2, and SCMOD.0 select the main system clock (fx) or a subsystem clock (fxt) and start or stop  
main system clock oscillation. PCON.1 and PCON.0 control the frequency divider circuit, and divide the selected fx  
clock by 4, 8, or 64,or fxt clock by 4.  
NOTE  
A clock switch operation does not go into effect immediately when you make the SCMOD and PCON  
register modifications — the previously selected clock continues to run for a certain number of machine  
cycles.  
For example, you are using the default CPU clock (normal operating mode and a main system clock of fx/64) and  
you want to switch from the fx clock to a subsystem clock and to stop the main system clock. To do this, you first  
need to set SCMOD.0 to "1". This switches the clock from fx to fxt but allows main system clock oscillation to  
continue. Before the switch actually goes into effect, a certain number of machine cycles must elapse. After this  
time interval, you can then disable main system clock oscillation by setting SCMOD.3 to "1".  
This same 'stepped' approach must be taken to switch from a subsystem clock to the main system clock: first,  
clear SCMOD.3 to "0" to enable main system clock oscillation. Then, after a certain number of machine cycles has  
elapsed, select the main system clock by clearing all SCMOD values to logic zero.  
Following a RESET, CPU operation starts with the lowest main system clock frequency of 15.3 ms at 4.19 MHz after  
the standard oscillation stabilization interval of 31.3 ms has elapsed. Table 6-4 details the number of machine cycles  
that must elapse before a CPU clock switch modification goes into effect.  
Table 6-6. Elapsed Machine Cycles During CPU Clock Switch  
AFTER  
SCMOD.0 = 0  
SCMOD.0 = 1  
N/A  
BEFORE  
PCON.1 = 0 PCON.0 = 0 PCON.1 = 1 PCON.0 = 0 PCON.1 = 1 PCON.0 = 1  
PCON.1 = 0  
PCON.0 = 0  
PCON.1 = 1  
PCON.0 = 0  
PCON.1 = 1  
PCON.0 = 1  
N/A  
1 Machine Cycle  
1 Machine Cycle  
1 Machine Cycle  
N/A  
SCMOD.0 = 0  
8 Machine Cycles  
16 Machine Cycles  
N/A  
N/A  
N/A  
1 Machine Cycle  
N/A  
fx / 4fxt  
N/A  
SCMOD.0 = 1  
1 Machine Cycle  
NOTES:  
1. Even if oscillation is stopped by setting SCMOD.3 during main system clock operation, the stop mode is not entered.  
2. Since the X input is connected internally to V to avoid current leakage due to the crystal oscillator in stop mode, do  
IN  
SS  
not set SCMOD.3 to "1" or do not use stop instruction when an external clock is used as the main system clock.  
3. When the system clock is switched to the subsystem clock, it is necessary to disable any interrupts which may occur  
during the time intervals shown in Table 6-6.  
4. 'N/A' means 'not available'.  
5. fx: Main-system clock, fxt: Sub-system clock. When fx is 4.19 MHz, and fxt is 32.768 kHz.  
6-8  
S3C72K8/P72K8  
OSCILLATOR CIRCUITS  
F
PROGRAMMING TIP — Switching Between Main System and Subsystem Clock  
1. Switch from the main system clock to the subsystem clock:  
MA2SUB BITS  
CALL  
SCMOD.0  
DLY80  
SCMOD.3  
;
;
;
Switches to subsystem clock  
Delay 80 machine cycles  
Stop the main system clock  
BITS  
RET  
DLY80  
DEL1  
LD  
A,#0FH  
NOP  
NOP  
DECS  
JR  
A
DEL1  
RET  
2. Switch from the subsystem clock to the main system clock:  
SUB2MA BITR  
CALL  
SCMOD.3  
DLY80  
;
;
Start main system clock oscillation  
Delay 80 machine cycles  
CALL  
DLY80  
BITR  
SCMOD.0  
;
Switch to main system clock  
RET  
6-9  
OSCILLATOR CIRCUITS  
S3C72K8/P72K8  
CLOCK OUTPUT MODE REGISTERS (CLMOD)  
The clock output mode register, CLMOD, is a 4-bit register that is used to enable or disable clock output to the CLO  
pin and to select the CPU clock source and frequency. CLMOD is addressable by 4-bit write instructions only.  
FD0H  
CLMOD.3  
"0"  
CLMOD.1  
CLMOD.0  
RESET clears CLMOD to logic zero, which automatically selects the CPU clock as the clock source (without  
initiating clock oscillation), and disables clock output.  
CLMOD.3 is the enable/disable clock output control bit; CLMOD.1 and CLMOD.0 are used to select one of four  
possible clock sources and frequencies: normal CPU clock, fxx/8, fxx/16, or fxx/64.  
Table 6-7. Clock Output Mode Register (CLMOD) Organization  
CLMOD Bit Settings  
CLMOD.1 CLMOD.0  
Resulting Clock Output  
Clock Source  
Frequency  
0
0
CPU clock (fx/4, fx/8, fx/64, fxt/4)  
1.05 MHz, 524 kHz, 65.5 kHz, 8.2 kHz  
0
1
1
1
0
1
fxx/8  
fxx/16  
fxx/64  
524 kHz  
262 kHz  
65.5 kHz  
CLMOD1.3  
Result of CLMOD1.3 Setting  
0
1
Clock output is disabled (CLO1, CLO2)  
Clock output is enabled (CLO1, CLO2)  
NOTE: Frequencies assume that fxx, fx= 4.19 MHzand fxt is 32,768 kHz.  
6-10  
S3C72K8/P72K8  
OSCILLATOR CIRCUITS  
CLOCK OUTPUT CIRCUIT  
The clock output circuit, used to output clock pulses to the CLO pin, has the following components:  
— 4-bit clock output mode register (CLMOD)  
— Clock selector  
— Output latch  
— Port mode flag  
— CLO output pin (P4.0)  
CLMOD.3  
CLO  
CLMOD.2  
4
CLMOD.1  
Clock  
P4.0 Output Latch  
PM4.0  
Selector  
CLMOD.0  
CLOCKS  
(CPU clock, fxx/8, fxx/16, fxx/64)  
Figure 6-7. CLO Output Pin Circuit Diagram  
CLOCK OUTPUT PROCEDURE  
The procedure for outputting clock pulses to the CLO pin may be summarized as follows:  
1. Disable clock output by clearing CLMOD.3 to logic zero.  
2. Set the clock output frequency (CLMOD.1, CLMOD.0).  
3. Load a "0" to the output latch of the CLO pin (P4.0).  
4. Set the P4.0 mode flag (PM4.0) to output mode.  
5. Enable clock output by setting CLMOD.3 to logic one.  
F
PROGRAMMING TIP — CPU Clock Output to the CLO Pin  
To output the CPU clock to the CLO pin:  
BITS  
SMB  
LD  
LD  
BITR  
LD  
EMB  
15  
EA,#10H  
PMG1,EA  
P4.0  
A,#9H  
CLMOD,A  
;
;
P4.0 ¬ Output mode  
Clear P4.0 output latch  
LD  
6-11  
OSCILLATOR CIRCUITS  
S3C72K8/P72K8  
NOTES  
6-12  
S3C72K9/P72K8  
INTERRUPTS  
7
INTERRUPTS  
OVERVIEW  
The S3C72K8 interrupt control circuit has five functional components:  
— Interrupt enable flags (IEx)  
— Interrupt request flags (IRQx)  
— Interrupt master enable register (IME)  
— Interrupt priority register (IPR)  
— Power-down release signal circuit  
Three kinds of interrupts are supported:  
— Internal interrupts generated by on-chip processes  
— External interrupts generated by external peripheral devices  
— Quasi-interrupts used for edge detection and as clock sources  
Table 7-1. Interrupt Types and Corresponding Port Pin(s)  
Interrupt Name Corresponding Port Pins  
P1.0, P1.1, P1.3, K0–K3  
Interrupt Type  
External interrupts  
Internal interrupts  
Quasi-interrupts  
INT0, INT1, INT4, INTK  
INTB, INTT0, INTS  
INT2  
Not applicable  
P1.2  
INTW  
Not applicable  
7-1  
INTERRUPTS  
S3C72K9/P72K8  
Vectored Interrupts  
Interrupt requests may be processed as vectored interrupts in hardware, or they can be generated by program  
software. A vectored interrupt is generated when the following flags and register settings, corresponding to the  
specific interrupt (INTn) are set to logic one:  
— Interrupt enable flag (IEx)  
— Interrupt master enable flag (IME)  
— Interrupt request flag (IRQx)  
— Interrupt status flags (IS0, IS1)  
— Interrupt priority register (IPR)  
If all conditions are satisfied for the execution of a requested service routine, the start address of the interrupt is  
loaded into the program counter and the program starts executing the service routine from this address.  
EMB and ERB flags for RAM memory banks and registers are stored in the vector address area of the ROM during  
interrupt service routines. The flags are stored at the beginning of the program with the VENT instruction. The initial  
flag values determine the vectors for resets and interrupts. Enable flag values are saved during the main routine, as  
well as during service routines. Any changes that are made to enable flag values during a service routine are not  
stored in the vector address.  
When an interrupt occurs, the enable flag values before the interrupt is initiated are saved along with the program  
status word (PSW), and the enable flag values for the interrupt is fetched from the respective vector address. Then, if  
necessary, you can modify the enable flags during the interrupt service routine. When the interrupt service routine is  
returned to the main routine by the IRET instruction, the original values saved in the stack are restored and the main  
program continues program execution with these values.  
Software-Generated Interrupts  
To generate an interrupt request from software, the program manipulates the appropriate IRQx flag. When the  
interrupt request flag value is set, it is retained until all other conditions for the vectored interrupt have been met, and  
the service routine can be initiated.  
Multiple Interrupts  
By manipulating the two interrupt status flags (IS0 and IS1), you can control service routine initialization and thereby  
process multiple interrupts simultaneously.  
If more than four interrupts are being processed at one time, you can avoid possible loss of working register data by  
using the PUSH RR instruction to save register contents to the stack before the service routines are executed in the  
same register bank. When the routines have executed successfully, you can restore the register contents from the  
stack to working memory using the POP instruction.  
Power-Down Mode Release  
An interrupt (with the exception of INT0) can be used to release power-down mode (stop or idle). Interrupts for power-  
down mode release are initiated by setting the corresponding interrupt enable flag. Even if the IME flag is cleared to  
zero, power-down mode will be released by an interrupt request signal when the interrupt enable flag has been set. In  
such cases, the interrupt routine will not be executed since IME = "0".  
7-2  
S3C72K9/P72K8  
INTERRUPTS  
Interrupt is generated (INT xx)  
Request flag (IRQx)  
1
No  
IEx = 1?  
Yes  
Retain value until IEx = 1  
Generate corresponding vector interrupt  
and release power-down mode  
No  
IME = 1?  
Retain value until IME= 1  
Yes  
Yes  
Retain value until interrupt  
IS1, 0 = 0, 0?  
service routine is completed  
No  
No  
IS1, 0 = 0, 1?  
Yes  
No  
High-priority interrupt?  
Yes  
IS1, 0 = 0, 1  
IS1, 0 = 1, 0  
Store contents of PC and PSW in the stack area;  
set PC contents to corresponding vector address  
Yes  
Are both interrupt sources  
of shared vector address used?  
IRQx flag value remains 1  
No  
Reset corresponding IRQx flag  
Jump to interrupt start address  
Jump to interrupt start address  
Verify interrupt source and clear  
IRQx with a BTSTZ instruction  
Figure 7-1. Interrupt Execution Flowchart  
7-3  
INTERRUPTS  
S3C72K9/P72K8  
IMOD1  
IMOD0  
IE2 IEW IEK IET0 IES IE1 IE0 IE4 IEB  
INTB  
IRQB  
IRQ4  
IRQ0  
IRQ1  
IRQS  
IRQT0  
IRQK  
IRQW  
IRQ2  
INT4  
INT0  
INT1  
@
@
INTS  
INTT0  
@
K0-K3  
INT2  
INTW  
IMODK  
@
IMOD2  
(note)  
Power-Down  
Mode  
Release Signal  
IME  
IPR  
IS1 IS0  
Interrupt Control Unit  
Vector Interrupt Generator  
@ = Edge Detection Circuit  
NOTE: Stop and Idle mode can be released by INT0.  
Figure 7-2. Interrupt Control Circuit Diagram  
7-4  
S3C72K9/P72K8  
INTERRUPTS  
MULTIPLE INTERRUPTS  
The interrupt controller can service multiple interrupts in two ways: as two-level interrupts, where either all interrupt  
requests or only those of highest priority are serviced, or as multi-level interrupts, when the interrupt service routine  
for a lower-priority request is accepted during the execution of a higher priority routine.  
Two-Level Interrupt Handling  
Two-level interrupt handling is the standard method for processing multiple interrupts. When the IS1 and IS0 bits of  
the PSW (FB0H.3 and FB0H.2, respectively) are both logic zero, program execution mode is normal and all interrupt  
requests are serviced (see Figure 7-3).  
Whenever an interrupt request is accepted, IS1 and IS0 are incremented by one ("0" ® "1" or "1" ® "0"), and the  
values are stored in the stack along with the other PSW bits. After the interrupt routine has been serviced, the  
modified IS1 and IS0 values are automatically restored from the stack by an IRET instruction.  
IS0 and IS1 can be manipulated directly by 1-bit write instructions, regardless of the current value of the enable  
memory bank flag (EMB). Before you can modify an interrupt service flag, however, you must first disable interrupt  
processing with a DI instruction.  
When IS1 = "0" and IS0 = "1", all interrupt service routines are inhibited except for the highest priority interrupt  
currently defined by the interrupt priority register (IPR).  
Normal Program  
Processing  
(Status 0)  
High or Low Level  
Interrupt Processing  
(Status 1)  
High Level Interrupt  
Processing  
INT Disable  
(Status 2)  
Set IPR  
INT Enable  
Low or  
High Level  
Interrupt  
High Level  
Interrupt  
Generated  
Generated  
Figure 7-3. Two-Level Interrupt Handling  
7-5  
INTERRUPTS  
S3C72K9/P72K8  
Multi-Level Interrupt Handling  
With multi-level interrupt handling, a lower-priority interrupt request can be executed while a high-priority interrupt is  
being serviced. This is done by manipulating the interrupt status flags, IS0 and IS1 (see Table 7-2).  
When an interrupt is requested during normal program execution, interrupt status flags IS0 and IS1 are set to "1" and  
"0", respectively. This setting allows only highest-priority interrupts to be serviced. When a high-priority request is  
accepted, both interrupt status flags are then cleared to "0" by software so that a request of any priority level can be  
serviced. In this way, the high- and low-priority requests can be serviced in parallel (see Figure 7-4).  
Table 7-2. IS1 and IS0 Bit Manipulation for Multi-Level Interrupt Handling  
Process Status  
Before INT  
Effect of ISx Bit Setting  
After INT ACK  
IS1  
IS0  
0
IS1  
0
IS0  
1
0
1
0
0
All interrupt requests are serviced.  
1
Only high-priority interrupts as determined by the  
current settings in the IPR register are serviced.  
1
0
2
1
1
0
1
No additional interrupt requests will be serviced.  
Value undefined  
Normal Program  
Processing  
(Status 0)  
Single  
Interrupt  
2-Level  
Interrupt  
INT Disable  
Set IPR  
Status 1  
3-Level  
INT Disable  
Interrupt  
INT Enable  
Modify Status  
INT Enable  
Status 0  
Low or  
High Level  
Interrupt  
High Level  
Low or  
High Level  
Interrupt  
Interrupt Status 1  
Generated  
Status 2  
Generated  
Generated  
Status 0  
Figure 7-4. Multi-Level Interrupt Handling  
7-6  
S3C72K9/P72K8  
INTERRUPTS  
INTERRUPT PRIORITY REGISTER (IPR)  
The 4-bit interrupt priority register (IPR) is used to control multi-level interrupt handling. Its reset value is logic zero.  
Before the IPR can be modified by 4-bit write instructions, all interrupts must first be disabled by a DI instruction.  
FB2H  
IME  
IPR.2  
IPR.1  
IPR.0  
By manipulating the IPR settings, you can choose to process all interrupt requests with the same priority level, or  
you can select one type of interrupt for high-priority processing. A low-priority interrupt can itself be interrupted by a  
high-priority interrupt, but not by another low-priority interrupt. A high-priority interrupt cannot be interrupted by any  
other interrupt source.  
Table 7-3. Standard Interrupt Priorities  
Interrupt  
INTB, INT4  
INT0  
Default Priority  
1
2
3
4
5
6
INT1  
INTS  
INTT0  
INTK  
The MSB of the IPR, the interrupt master enable flag (IME), enables and disables all interrupt processing. Even if an  
interrupt request flag and its corresponding enable flag are set, a service routine cannot be executed until the IME  
flag is set to logic one. The IME flag can be directly manipulated by EI and DI instructions, regardless of the current  
enable memory bank (EMB) value.  
Table 7-4. Interrupt Priority Register Settings  
IPR.2  
IPR.1  
IPR.0  
Result of IPR Bit Setting  
(note)  
0
0
0
Process all interrupt requests at low priority  
Process INTB and INT4 interrupts only  
Process INT0 interrupts only  
0
0
0
1
1
1
0
1
1
0
0
1
1
0
1
0
1
0
Process INT1 interrupts only  
Process INTS interrupts only  
Process INTT0 interrupts only  
Process INTK interrupts only  
NOTE: When all interrupts are low priority (the lower three bits of the IPR register are logic zero), the interrupt requested  
first will have high priority. Therefore, the first-request interrupt cannot be superceded by any other interrupt.  
7-7  
INTERRUPTS  
S3C72K9/P72K8  
F
Programming Tip — Setting the INT Interrupt Priority  
The following instruction sequence sets the INT1 interrupt to high priority:  
BITS  
SMB  
DI  
LD  
LD  
EMB  
15  
;
;
IPR.3 (IME) ¬  
IPR.3 (IME) ¬  
0
1
A,#3H  
IPR,A  
EI  
EXTERNAL INTERRUPT 0, 1 AND 2 MODE REGISTERS (IMOD0, IMOD1 AND IMOD2)  
The following components are used to process external interrupts at the INT0, INT1 and INT2 pins:  
— Edge detection circuit  
— Three mode registers, IMOD0, IMOD1 and IMOD2  
The mode registers are used to control the triggering edge of the input signal. IMOD0, IMOD1 and IMOD2 settings let  
you choose either the rising or falling edge of the incoming signal as the interrupt request trigger. The INT4 interrupt  
is an exception since its input signal generates an interrupt request on both rising and falling edges. Since INT2 is a  
quasi-interrupt, the interrupt request flag (IRQ2) must be cleared by software.  
FB4H  
FB5H  
"0"  
"0"  
"0"  
"0"  
IMOD0.1  
"0"  
IMOD0.0  
IMOD1.0  
FDAH  
"0"  
"0"  
"0"  
IMOD2.0  
IMOD0, IMOD1 and IMOD2 are addressable by 4-bit write instructions. RESET clears all IMOD values to logic zero,  
selecting rising edges as the trigger for incoming interrupt requests.  
Table 7-5. IMOD0, 1 and 2 Register Organization  
IMOD0  
IMOD0.3  
0
IMOD0.1  
IMOD0.0  
Effect of IMOD0 Settings  
Rising edge detection  
0
0
1
1
0
1
0
1
Falling edge detection  
Both rising and falling edge detection  
IRQ0 flag cannot be set to "1"  
IMOD1  
IMOD2  
0
0
0
IMOD1.0  
IMOD2.0  
Effect of IMOD1 and IMOD2 Settings  
0
1
Rising edge detection  
Falling edge detection  
7-8  
S3C72K9/P72K8  
INTERRUPTS  
EXTERNAL INTERRUPT 0, 1, and 2 MODE REGISTERS (Continued)  
IMOD0  
2
Edge Detection  
IRQ0  
IRQ1  
IRQ2  
INT0  
INT1  
Edge Detection  
Edge Detection  
IMOD2  
INT2  
IMOD1  
P1.2  
P1.1  
P1.0  
Figure 7-5. Circuit Diagram for INT0, INT1, and INT2 Pins  
When modifying the IMOD registers, it is possible to accidentally set an interrupt request flag. To avoid unwanted  
interrupts, take these precautions when writing your programs:  
1. Disable all interrupts with a DI instruction.  
2. Modify the IMOD register.  
3. Clear all relevant interrupt request flags.  
4. Enable the interrupt by setting the appropriate IEx flag.  
5. Enable all interrupts with an EI instructions.  
7-9  
INTERRUPTS  
S3C72K9/P72K8  
EXTERNAL KEY INTERRUPT MODE REGISTER (IMODK)  
The mode register for external key interrupts at the K0–K3 pins, IMODK, is addressable only by 4-bit write  
instructions. RESET clears all IMODK bits to logic zero.  
FB6H  
"0"  
IMODK.2  
IMODK.1  
IMODK.0  
Rising or falling edge can be detected by bit IMODK.2 settings. If a rising or falling edge is detected at any one of the  
selected K pin by the IMODK register, the IRQK flag is set to logic one and a release signal for power-down mode is  
generated.  
Table 7-6. IMODK Register Bit Settings  
IMODK  
0
IMODK.2  
IMODK.1  
IMODK.0  
Effect of IMODK Settings  
Disable key interrupt  
0, 1  
0
0
1
1
0
1
0
1
Enable edge detection at the K0–K1 pins  
Enable edge detection at the K0–K2 pins  
Enable edge detection at the K0–K3 pins  
IMODK.2  
NOTES:  
0
1
Falling edge detection  
Rising edge detection  
1. To generate a key interrupt, the selected pins must be configured to input mode. If any one pin of the selected pins is  
configured to output mode, only falling edge can be detected.  
2. To generate a key interrupt, first, configure pull-up resistors or external pull-down resistors. And then, select  
edge detection and pins by setting IMODK register.  
7-10  
S3C72K9/P72K8  
INTERRUPTS  
P0.3/K3  
Rising/  
Falling  
Edge  
P0.2/K2  
P0.1/K1  
P0.0/K0  
Pin  
Selector  
IRQK  
Selector  
IMODK  
Figure 7-6. Circuit Diagram for INTK  
F
PROGRAMMING TIP — Using INTK as a Key Input Interrupt  
When the key interrupt is used, the selected key interrupt source pin must be set to input:  
1. When K0–K3 are selected (four pins):  
BITS  
SMB  
LD  
LD  
LD  
EMB  
15  
EA,#00H  
PMG1,EA  
EA,#01H  
PUMOD1,EA  
A,#3H  
;
;
;
P0, P4 ¬ input mode  
LD  
LD  
Enable P0 pull-up resistors  
LD  
IMODK,A  
(IMODK) ¬ #3H, K0–K3 falling edge select  
7-11  
INTERRUPTS  
S3C72K9/P72K8  
INTERRUPT FLAGS  
There are three types of interrupt flags: interrupt request and interrupt enable flags that correspond to each interrupt,  
the interrupt master enable flag, which enables or disables all interrupt processing.  
Interrupt Master Enable Flag (IME)  
The interrupt master enable flag, IME, enables or disables all interrupt processing. Therefore, even when an IRQx flag  
is set and its corresponding IEx flag is enabled, the interrupt service routine is not executed until the IME flag is set  
to logic one.  
The IME flag is located in the IPR register (IPR.3). It can be directly be manipulated by EI and DI instructions,  
regardless of the current value of the enable memory bank flag (EMB).  
IME  
0
IPR.2  
IPR.1  
IPR.0  
Effect of Bit Settings  
Inhibit all interrupts  
Enable all interrupts  
1
Interrupt Enable Flags (IEx)  
IEx flags, when set to logical one, enable specific interrupt requests to be serviced. When the interrupt request flag is  
set to logical one, an interrupt will not be serviced until its corresponding IEx flag is also enabled.  
Interrupt enable flags can be read, written, or tested directly by 1-bit instructions. IEx flags can be addressed directly  
at their specific RAM addresses, despite the current value of the enable memory bank (EMB) flag.  
Table 7-7. Interrupt Enable and Interrupt Request Flag Addresses  
Address  
FB8H  
Bit 3  
IE4  
"0"  
Bit 2  
IRQ4  
"0"  
Bit 1  
IEB  
IEW  
IEK  
IET0  
IES  
IE0  
Bit 0  
IRQB  
IRQW  
IRQK  
IRQT0  
IRQS  
IRQ0  
IRQ2  
FBAH  
FBBH  
FBCH  
FBDH  
FBEH  
FBFH  
"0"  
"0"  
"0"  
"0"  
"0"  
"0"  
IE1  
"0"  
IRQ1  
"0"  
IE2  
NOTES:  
1. IEx refers generically to all interrupt enable flags.  
2. IRQx refers generically to all interrupt request flags.  
3. IEx = 0 is interrupt disable mode.  
4. IEx = 1 is interrupt enable mode.  
7-12  
S3C72K9/P72K8  
INTERRUPTS  
Interrupt Request Flags (IRQx)  
Interrupt request flags are read/write addressable by 1-bit or 4-bit instructions. IRQx flags can be addressed directly  
at their specific RAM addresses, regardless of the current value of the enable memory bank (EMB) flag.  
When a specific IRQx flag is set to logic one, the corresponding interrupt request is generated. The flag is then  
automatically cleared to logic zero when the interrupt has been serviced. Exceptions are the watch timer interrupt  
request flags, IRQW, and the external interrupt 2 flag IRQ2, which must be cleared by software after the interrupt  
service routine has executed. IRQx flags are also used to execute interrupt requests from software. In summary,  
follow these guidelines for using IRQx flags:  
1. IRQx is set to request an interrupt when an interrupt meets the set condition for interrupt generation.  
2. IRQx is set to "1" by hardware and then cleared by hardware when the interrupt has been serviced (with the  
exception of IRQW and IRQ2).  
3. When IRQx is set to "1" by software, an interrupt is generated.  
When two interrupts share the same service routine start address, interrupt processing may occur in one of two  
ways:  
— When only one interrupt is enabled, the IRQx flag is cleared automatically when the interrupt has been serviced.  
— When two interrupts are enabled, the request flag is not automatically cleared so that the user has an  
opportunity to locate the source of the interrupt request. In this case, the IRQx setting must be cleared manually  
using a BTSTZ instruction.  
Table 7-8. Interrupt Request Flag Conditions and Priorities  
Interrupt  
Source  
Internal /  
External  
Pre-condition for IRQx Flag Setting  
Interrupt  
Priority  
IRQ Flag  
Name  
INTB  
INT4  
INT0  
INT1  
INTS  
I
E
E
E
I
Reference time interval signal from basic timer  
Both rising and falling edges detected at INT4  
Rising or falling edge detected at INT0 pin  
Rising or falling edge detected at INT1 pin  
1
1
2
3
4
IRQB  
IRQ4  
IRQ0  
IRQ1  
IRQS  
Completion signal for serial transmit-and-receive  
or receive-only operation  
INTT0  
INTK  
I
Signals for TCNT0 and TREF0 registers match  
5
6
IRQT0  
IRQK  
E
When a rising or falling edge detected at any  
one of the K0–K3 pins  
(note)  
E
I
Rising or falling edge detected at INT2  
Time interval of 0.5 secs or 3.19 msecs  
IRQ2  
INT2  
INTW  
IRQW  
NOTE: The quasi-interrupt INT2 is only used for testing incoming signals.  
7-13  
INTERRUPTS  
S3C72K9/P72K8  
F
PROGRAMMING TIP — Enabling the INTB and INT4 Interrupts  
To simultaneously enable INTB and INT4 interrupts:  
INTB  
DI  
BTSTZ  
JR  
IRQB  
INT4  
;
;
IRQB = 1 ?  
If no, INT4 interrupt; if yes, INTB interrupt is processed  
EI  
IRET  
;
INT4  
BITR  
IRQ4  
;
INT4 is processed  
EI  
IRET  
7-14  
S3C72K9/P72K8  
POWER-DOWN  
8
POWER-DOWN  
OVERVIEW  
The S3C72K8 microcontroller has two power-down modes to reduce power consumption: idle and stop. Idle mode is  
initiated by the IDLE instruction and stop mode by the instruction STOP. (Several NOP instructions must always  
follow an IDLE or STOP instruction in a program.) In idle mode, the CPU clock stops while peripherals and the  
oscillation source continue to operate normally.  
When RESET occurs during normal operation or during a power-down mode, a reset operation is initiated and the  
CPU enters idle mode. When the standard oscillation stabilization time interval (31.3 ms at 4.19 MHz) has elapsed,  
normal CPU operation resumes.  
In stop mode, main system clock oscillation is halted (assuming it is currently operating), and peripheral hardware  
components are powered-down. The effect of stop mode on specific peripheral hardware components — CPU, basic  
timer, serial I/O, timer/ counters 0, watch timer, and LCD controller — and on external interrupt requests, is detailed  
in Table 8-1.  
NOTE  
Do not use stop mode if you are using an external clock source because X input must be restricted  
IN  
internally to V to reduce current leakage.  
SS  
Idle or stop modes are terminated either by a RESET, or by an interrupt which is enabled by the corresponding  
interrupt enable flag, IEx. When power-down mode is terminated by RESET, a normal reset operation is executed.  
Assuming that both the interrupt enable flag and the interrupt request flag are set to "1", power-down mode is  
released immediately upon entering power-down mode.  
When an interrupt is used to release power-down mode, the operation differs depending on the value of the interrupt  
master enable flag (IME):  
— If the IME flag = "0", program execution starts immediately after the instruction which issues the request to  
enter power-down mode is executed. The interrupt request flag remains set to logical one.  
— If the IME flag = "1", two instructions are executed after the power-down mode release and the vectored interrupt  
is then initiated. However, when the release signal is caused by INT2 or INTW, the operation is identical to the  
IME = "0" condition. Assuming that both interrupt enable flag and interrupt request flag are set to "1", the  
release signal is generated when power-down mode is entered.  
8-1  
POWER-DOWN  
S3C72K9/P72K8  
Table 8-1. Hardware Operation During Power-Down Modes  
Operation  
Stop Mode (STOP)  
Idle Mode (IDLE)  
System clock status  
Clock oscillator  
Basic timer  
Can be changed only if the main system  
clock is used  
Can be changed if the main system clock  
or subsystem clock is used  
Main system clock oscillation stops  
CPU clock oscillation stops (main and  
subsystem clock oscillation continues)  
Basic timer stops  
Basic timer operates (with IRQB set at  
each reference interval)  
Serial I/O interface  
Operates if a clock other than the CPU  
clock is selected as the serial I/O clock  
Operates only if external SCK input is  
selected as the serial I/O clock  
Timer/counter 0  
Watch timer  
Operates only if TCL0 is selected as the  
counter clock  
Timer/counter 0 operates  
Operates only if subsystem clock (fxt) is  
selected as the counter clock  
Watch timer operates  
LCD controller  
External interrupts  
Operates only if a subsystem clock is se- LCD controller operates  
lected as LCDCK  
INT1, INT2, INT4, and INTK are  
INT0, INT1, INT2, INT4, and INTK are  
(note)  
acknowledged; INT0 is not serviced  
acknowledged  
CPU  
All CPU operations are disabled  
All CPU operations are disabled  
Mode release signal  
Interrupt request signals (except INT0) are Interrupt request signals are enabled by  
enabled by an interrupt enable flag or by  
an interrupt enable flag or by RESET input  
(note)  
RESET input  
NOTE: INT0 can be operated in idle mode only when fxx/64 is selected as a sampling clock.  
Table 8-2. System Operating Mode Comparison  
Mode  
Condition  
Main oscillator runs  
STOP/IDLE Mode Start  
Current  
Consumption  
A
Method  
Main operating  
mode  
Sub oscillator runs  
System clock is the main oscillation clock  
Main Idle mode Main oscillator runs  
Sub oscillator runs  
System clock is the main oscillation clock  
Main Stop mode Main oscillator runs  
Sub oscillator runs  
IDLE instruction  
STOP instruction  
B
D
C
D
System clock is the main oscillation clock  
Sub operating  
mode  
Main oscillator is stopped by SCMOD.3.  
Sub oscillator runs  
System clock is the sub oscillation clock  
Main oscillator is stopped by SCMOD.3.  
Sub oscillator runs  
Sub Idle mode  
IDLE instruction  
System clock is the sub oscillation clock  
NOTE: The current consumption is: A > B > C > D  
8-2  
S3C72K9/P72K8  
POWER-DOWN  
IDLE MODE TIMING DIAGRAMS  
Oscillator  
Idle  
Stabilization Wait Time  
Instruction  
(31.3 ms/4.19 MHz)  
RESET  
Normal Mode  
Idle Mode  
Normal Mode  
Normal Oscillation  
Clock  
Signal  
Figure 8-1. Timing When Idle Mode is Released by RES ET  
Idle  
Instruction  
Mode  
Release  
Signal  
Interrupt Acknowledge (IME = 1)  
Normal Mode  
Idle Mode  
Normal Mode  
Normal Oscillation  
Clock  
Signal  
Figure 8-2. Timing When Idle Mode is Released by an Interrupt  
8-3  
POWER-DOWN  
S3C72K9/P72K8  
STOP MODE TIMING DIAGRAMS  
Oscillator  
Stabilization Wait Time  
(31.3 ms/4.19 MHz)  
Stop  
Instruction  
RESET  
Normal Mode  
Idle Mode  
Normal Mode  
Stop mode  
Oscillation  
Stops  
Oscillation Resumes  
Clock  
Signal  
Figure 8-3. Timing When Stop Mode is Released by RES ET  
Oscillator  
Stabilization Wait Time  
(BMOD Setting)  
Stop  
Instruction  
Mode  
Release  
signal  
INT ACK (IME=1)  
Normal Mode  
Normal Mode  
Idle Mode  
Stop mode  
Oscillation  
Stops  
Oscillation Resumes  
Clock  
Signal  
Figure 8-4. Timing When Stop Mode is Release by an Interrupt  
8-4  
S3C72K9/P72K8  
POWER-DOWN  
F
PROGRAMMING TIP — Reducing Power Consumption for Key Input Interrupt Processing  
The following code shows real-time clock and interrupt processing for key inputs to reduce power consumption. In  
this example, the system clock source is switched from the main system clock to a subsystem clock and the LCD  
display is turned on:  
KEYCLK  
DI  
CALL  
SMB  
LD  
LD  
LD  
MA2SUB  
15  
;
Main system clock ® subsystem clock switch subroutine  
EA,#00H  
P2,EA  
A,#3H  
IMODK,A  
0
IRQW  
IRQK  
IEW  
IEK  
WATDIS  
IRQK  
CIDLE  
SUB2MA  
;
;
All key strobe outputs to low level  
Select K0–K3 enable  
LD  
SMB  
BITR  
BITR  
BITS  
BITS  
CALL  
BTSTZ  
JR  
CLKS1  
CIDLE  
;
;
;
Execute clock and display changing subroutine  
Subsystem clock ® main system clock switch subroutine  
Engage idle mode  
CALL  
EI  
RET  
IDLE  
NOP  
NOP  
NOP  
JPS  
CLKS1  
8-5  
POWER-DOWN  
S3C72K9/P72K8  
RECOMMENDED CONNECTIONS FOR UNUSED PINS  
To reduce overall power consumption, please configure unused pins according to the guidelines described in Table 8-  
3.  
Table 8-3. Unused Pin Connections for Reduced Power Consumption  
Pin/Share Pin Names  
P0.0/SCK/K0  
Recommended Connection  
Input mode: Connect to V  
DD  
P0.1/SO/K1  
P0.2/SI/K2  
Output mode: No connection  
P0.3/BUZ/K3  
(1)  
Connect to V  
DD  
P1.0/CIN0/INT0  
P1.1/CIN1/INT1  
P1.2/INT2  
P1.3/INT4  
P2.0–P2.3  
Input mode: Connect to V  
DD  
Output mode: No connection  
P3.0–P3.1  
P3.2/LCDSY  
P3.0/LCDCK  
P4.0/CLO  
Input mode: Connect to V  
DD  
Output mode: No connection  
P4.1/TCL0  
P4.2/TCLO0  
(2)  
P5.0/SEG32–P5.7/SEG39  
No connection  
SEG0–SEG29  
SEG30–SEG31  
COM0–COM7  
No connection  
V
–V  
No connection  
LC1 LC5  
XT  
Connect XT to V or V  
IN  
IN  
SS  
DD  
XT  
No connection  
OUT  
TEST  
Connect to V  
SS  
NOTES:  
1. Digital mode at P1.0–P1.1.  
2. Used as segment.  
8-6  
S3C72K8/P72K8  
RES ET  
9
RES ET  
OVERVIEW  
When a RESET signal is input during normal operation or power-down mode, a hardware reset operation is initiated  
and the CPU enters idle mode. Then, when the standard oscillation stabilization interval of 31.3 ms at 4.19 MHz has  
elapsed, normal system operation resumes.  
Regardless of when the RESET occurs — during normal operating mode or during a power-down mode — most  
hardware register values are set to the reset values described in Table 9-1 below. The current status of several  
register values is, however, always retained when a RESET occurs during idle or stop mode; If a RESET occurs  
during normal operating mode, their values are undefined. Current values that are retained in this case are as follows:  
— Carry flag  
— Data memory values  
— General-purpose registers E, A, L, H, X, W, Z, and Y  
— Serial I/O buffer register (SBUF)  
Oscillator  
Stabilization Wait Time  
(31.3 ms/4.19 MHz)  
RESET  
Input  
Normal Mode or  
Operatng Mode  
Idle Mode  
Power-down  
Mode  
RESET Operation  
Figure 9-1. Timing for Oscillation Stabilization After RES ET  
9-1  
RES ET  
S3C72K8/P72K8  
HARDWARE REGISTER VALUES AFTER RES ET  
Table 9-1 gives you detailed information about hardware register values after a RESET occurs during power-down  
mode or during normal operation.  
Table 9-1. Hardware Register Values After RES ET  
Hardware Component  
or Sub component  
If RES ET Occurs During  
If RES ET Occurs During  
Power-Down Mode  
Normal Operation  
Program counter (PC)  
Lower six bits of address 0000H  
are transferred to PC11–8, and  
the contents of 0001H to PC7–0.  
Lower six bits of address 0000H  
are transferred to PC11–8, and  
the contents of 0001H to PC7–0.  
Bank selection registers (SMB, SRB)  
BSC register (BSC0–BSC3)  
Program Status Word (PSW):  
Carry flag (C)  
0, 0  
0
0, 0  
0
Retained  
Undefined  
Skip flag (SC0–SC2)  
0
0
0
0
Interrupt status flags (IS0, IS1)  
Bank enable flags (EMB, ERB)  
Bit 6 of address 0000H in program Bit 6 of address 0000H in program  
memory is transferred to the ERB memory is transferred to the ERB  
flag, and bit 7 of the address to  
the EMB flag.  
flag, and bit 7 of the address to  
the EMB flag.  
Stack pointer (SP)  
Undefined  
Undefined  
Data Memory (RAM):  
General registers E, A, L, H, X, W, Z, Y  
General purpose registers  
Clocks:  
Values retained  
Values retained  
Undefined  
Undefined  
Power control register (PCON)  
Clock output mode register (CLMOD)  
System clock mode register (SCMOD)  
Interrupts:  
0
0
0
0
0
0
Interrupt request flags (IRQx)  
Interrupt enable flags (IEx)  
Interrupt priority flag (IPR)  
Interrupt master enable flag (IME)  
INT0 mode register (IMOD0)  
INT1 mode register (IMOD1)  
INT2 mode register (IMOD2)  
INTK mode register (IMODK)  
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
9-2  
S3C72K8/P72K8  
RES ET  
Table 9-1. Hardware Register Values After RESET (Continued)  
Hardware Component  
or Sub component  
If RES ET Occurs During  
If RES ET Occurs During  
Power-Down Mode  
Normal Operation  
I/O Ports:  
Off  
0
Off  
0
Output buffers  
Output latches  
0
0
Port mode flags (PM)  
0
0
Pull-up resistor mode reg (PUMOD1/2)  
Basic Timer:  
Undefined  
Undefined  
Count register (BCNT)  
0
A5H  
0
0
A5H  
0
Mode register (BMOD)  
Watchdog Mode register (WDMOD)  
Watchdog counter clear flag (WDTCF)  
Timer/Counters 0:  
0
FFH  
0
0
FFH  
0
Count registers (TCNT0)  
Reference registers (TREF0)  
Mode registers (TMOD0)  
Output enable flags (TOE0)  
Watch Timer:  
0
0
0
0
Watch timer mode register (WMOD)  
LCD Driver/Controller:  
LCD mode register (LMOD)  
LCD control register (LCON)  
Display data memory  
0
0
0
Values retained  
Off  
0
Undefined  
Off  
Output buffers  
Serial I/O Interface:  
0
0
SIO mode register (SMOD)  
SIO interface buffer (SBUF)  
N-Channel Open-Drain Mode Register  
PNE1/2/3  
Values retained  
Undefined  
0
0
Comparator  
0
0
Comparator mode register (CMOD)  
Comparison result register  
Undefined  
Undefined  
9-3  
RES ET  
S3C72K8/P72K8  
NOTES  
9-4  
S3C72K8/P72K8  
I/O PORTS  
10 I/O PORTS  
OVERVIEW  
The S3C72K8 has 6 ports. There are total of 4 input pins, 8 output pins (sharing with segment driver output) and 15  
configurable I/O pins, for a maximum number of 27 pins.  
Pin addresses for all ports are mapped to bank 15 of the RAM. The contents of I/O port pin latches can be read,  
written, or tested at the corresponding address using bit manipulation instructions.  
Port Mode Flags  
Port mode flags (PM) are used to configure I/O ports to input or output mode by setting or clearing the corresponding  
I/O buffer.  
Port 1 Mode Register (P1MOD)  
Port 1 (P1.0–P1.1) can be used for either digital or analog input. P1MOD register settings determine the input mode  
(digital or analog) for specific port 1 pins.  
Pull-up Resistor Mode Register (PUMOD)  
The pull-up mode registers (PUMOD1, 2) are used to assign internal pull-up resistors by software to specific ports.  
When a configurable I/O port pin is used as an output pin, its assigned pull-up resistor is automatically disabled,  
even though the pin's pull-up is enabled by a corresponding PUMOD bit setting.  
N-Channel Open-Drain Mode Register (PNE)  
The n-channel open-drain mode register (PNE) is used to configure outputs as n-channel, open-drain outputs or as  
push-pull outputs.  
10-1  
I/O PORTS  
S3C72K8/P72K8  
Table 10-1. I/O Port Overview  
Port  
I/O  
Pins  
Pin Names  
Address  
Function Description  
4-bit I/O port.  
0
I/O  
4
P0.0–P0.3  
FF0H  
1-bit and 4-bit read/write and test is possible.  
Individual pins are software configurable as input  
or output.  
Individual pins are software configurable as  
open-drain or push-pull output.  
4-bit pull-up resistors are software assignable;  
pull-up resistors are automatically disabled for  
output pins.  
1
2
I
4
4
P1.0–P1.3  
P2.0–P2.3  
FF1H  
FF2H  
4-bit input port.  
1-bit and 4-bit read and test is possible.  
The 1-bit unit pull-up resistors are assigned to  
input pins by software.  
An interrupt is generated by digital input at  
P1.0, P1.1.  
I/O  
Same as port 0 except that 8-bit read/write and  
test possible.  
3
4
I/O  
I/O  
4
3
P3.0–P3.3  
P4.0–P4.2  
FF3H  
FF4H  
Same as port 0 except that port 4 is 3-bit I/O  
port and configurabled as analog input pin.  
(note)  
5
I/O  
8
P5.0–P5.7  
Output port for 1-bit data  
1FxH.0  
NOTE: "x" means an even-numbered value from "0H" to "FH".  
Table 10-2. Port Pin Status During Instruction Execution  
Instruction Type  
Example  
Input Mode Status  
Output Mode Status  
1-bit test  
1-bit input  
4-bit input  
8-bit input  
BTST P0.1  
Input or test data at each pin  
Input or test data at output latch  
LDB  
LD  
C,P1.3  
A,P0  
LD  
EA,P4  
1-bit output  
BITR  
P2.3  
Output latch contents undefined  
Output pin status is modified  
4-bit output  
8-bit output  
LD  
LD  
P2,A  
P6,EA  
Transfer accumulator data to the  
output latch  
Transfer accumulator data to the  
output pin  
10-2  
S3C72K8/P72K8  
I/O PORTS  
PORT MODE FLAGS (PM FLAGS)  
Port mode flags (PM) are used to configure I/O ports to input or output mode by setting or clearing the corresponding  
I/O buffer.  
For convenient program reference, PM flags are organized into six groups — PMG1 and PMG2 as shown in Table  
10-3. They are addressable by 8-bit write instructions only.  
When a PM flag is "0", the port is set to input mode; when it is "1", the port is enabled for output. RESET clears all  
port mode flags to logical zero, automatically configuring the corresponding I/O ports to input mode.  
Table 10-3. Port Mode Group Flags  
PM Group ID  
Address  
FE6H  
Bit 3  
PM0.3  
"0"  
Bit 2  
Bit 1  
Bit 0  
PMG1  
PM0.2  
PM4.2  
PM2.2  
PM3.2  
PM0.1  
PM4.1  
PM2.1  
PM3.1  
PM0.0  
PM4.0  
PM2.0  
PM3.0  
FE7H  
PMG2  
FE8H  
PM2.3  
PM3.3  
FE9H  
NOTE: If bit = "0", the corresponding I/O pin is set to input mode. If bit = "1", the pin is set to output mode: PM0.0 for  
P0.0, PM0.1 for P0.1, etc,. All flags are cleared to "0" following RESET.  
F
PROGRAMMING TIP — Configuring I/O Ports to Input or Output  
Configure ports 0 and 2 as an output port:  
BITS  
SMB  
LD  
EMB  
15  
EA,#7FH  
PMG1,EA  
LD  
; P0 and P4 ¬ Output  
PORT 1 MODE REGISTER (P1MOD)  
P1MOD register settings determine if port 1 is used for digital input or for analog input. The P1MOD register is a 4-bit  
write only register. P1MOD is mapped to address FE2H. A reset operation initializes all P1MOD values to logic  
zero, configuring port 1 as a analog input port.  
When a P1MOD bit is "0", the corresponding pin is configured as a analog input pin. When set to "1", it is  
configured as an digital input pin: P1MOD.0 corresponds to P1.0, and P1MOD.1 to P1.1.  
FE2H  
"0"  
"0"  
P1MOD.1  
P1MOD.0  
P1MOD  
NOTE  
INT0 and INT1 can occur only when the port is configured to digital input. If you change the input mode from  
digital to analog using P1MOD settings, IRQ0 and IRQ1 will be set. When use analog input, you must clear  
the corresponding interrupt enable flag (IEx). That is, clear IE0 when P1.0 is an analog input and clear IE1  
when P1.1 is an analog input.  
10-3  
I/O PORTS  
S3C72K8/P72K8  
PULL-UP RESISTOR MODE REGISTER (PUMOD)  
The pull-up resistor mode registers (PUMOD1 and PUMOD2) are used to assign internal pull-up resistors by  
software to specific ports. When a configurable I/O port pin is used as an output pin, its assigned pull-up resistor is  
automatically disabled, even though the pin's pull-up is enabled by a corresponding PUMOD bit setting.  
PUMOD1 is addressable by 8-bit write instructions only, and PUMOD2 by 4-bit write instruction only. RESET clears  
PUMOD register values to logic zero, automatically disconnecting all software-assignable port pull-up resistors.  
Table 10-4. Pull-Up Resistor Mode Register (PUMOD) Organization  
PUMOD ID  
Address  
FDCH  
Bit 3  
PUR3  
0
Bit 2  
PUR2  
0
Bit 1  
"0"  
Bit 0  
PUR0  
PUMOD1  
FDDH  
0
PUR4  
PUMOD2  
FDEH  
PUR1.3  
PUR1.2  
PUR1.1  
PUR1.0  
NOTE: When bit = "1", a pull-up resistor is assigned to the corresponding I/O port: PUR3 for port 3, PUR2 for port 2,  
and so on.  
F
PROGRAMMING TIP — Enabling and Disabling I/O Port Pull-Up Resistors  
P6 and P7 enable pull-up resistors.  
BITS  
SMB  
LD  
EMB  
15  
EA,#0CH  
PUMOD1,EA  
LD  
; P2 and P3 enable  
N-CHANNEL OPEN-DRAIN MODE REGISTER (PNE)  
The n-channel open-drain mode register (PNE) is used to configure ports 0, 2, 3 and 4 to n-channel, open-drain or as  
push-pull outputs. When a bit in the PNE register is set to "1", the corresponding output pin is configured to n-  
channel, open-drain; when set to "0", the output pin is configured to push-pull. The all PNE registers consist of an 8-  
bit register and a 4-bit register; PNE1 and PNE3 can be addressed by 4-bit write instruction only and PNE2 by 8-bit  
write instructions only.  
FA6H  
P0.3  
P0.2  
P0.1  
P0.0  
PNE1  
PNE2  
FA8H  
FA9H  
P2.3  
P3.3  
P2.2  
P3.2  
P2.1  
P3.1  
P2.0  
P3.0  
FAAH  
"0"  
P4.2  
P4.1  
P4.0  
PNE3  
10-4  
S3C72K8/P72K8  
I/O PORTS  
PORT 0 CIRCUIT DIAGRAM  
PNE1.3  
VDD  
PNE1.2  
PUR0  
PNE1.1  
PNE1.0  
PM0.3  
PM0.2  
PM0.1  
PM0.0  
P0.0/SCK/K0  
P0.1/SO/K1  
P0.2/SI/K2  
Output  
Latch  
1, 4  
P0.3/BUZ/K3  
CMOS Push-Pull,  
N-Channel  
Open-Drain  
PM0.0  
PM0.1  
PM0.2  
PM0.3  
MUX  
1, 4  
NOTE:  
When a port pin serves as an output, its pull-up resistor is automatically disabled, even though the  
port's pull-up resistor is enabled by bit settings in the pull-up resistor mode register (PUMOD).  
Figure 10-1. Port 0 Circuit Diagram  
10-5  
I/O PORTS  
S3C72K8/P72K8  
PORT 1 CIRCUIT DIAGRAM  
VDD  
INT0 INT1 INT2 INT4  
PUR1.0  
PUR1.1  
PUR1.2  
IMOD  
PUR1.3  
N/R  
Circuit  
P1.0/INT0/CIN0  
Digital Input  
Analog Input  
External Reference  
P1.1/INT1/CIN1  
Digital Input  
Analog Input  
Digital Input  
P1.2/INT2  
P1.3/INT4  
Digital Input  
N/R = Noise Reduction  
Figure 10-2. Port 1 Circuit Diagram  
10-6  
S3C72K8/P72K8  
I/O PORTS  
PORT 2 AND 3 CIRCUIT DIAGRAM  
VDD  
x = 2, 3  
b = 0, 1, 2, 3  
PURx  
PMx.b  
PURx  
P-CH  
Output  
Latch  
Px.b  
1, 4, 8  
MUX  
1, 4, 8  
PMx.b  
NOTE:  
When a port pin serves as an output, its pull-up resistor is automatically disable,  
even though the port's pull-up resistor is enable by bit settings to the pull-up  
resistor mode register (PUMOD).  
Figure 10-3. Port 2 and 3 Circuit Diagram  
10-7  
I/O PORTS  
S3C72K8/P72K8  
PORT 4 CIRCUIT DIAGRAM  
VDD  
PNE3.2  
PUR4  
PNE3.1  
PNE3.0  
PM4.2  
PM4.1  
PM4.0  
P4.0/CLO  
P4.1/TCL0  
Output  
Latch  
1, 4  
P4.2/TCLO0  
CMOS Push-Pull,  
N-Channel  
Open-Drain  
PM4.0  
PM4.1  
PM4.2  
MUX  
1, 4  
NOTE:  
When a port pin serves as an output, its pull-up resistor is automatically disabled, even  
though the port's pull-up resistor is enabled by bit settings to the pull-up resistor mode  
register (PUMOD).  
Figure 10-4. Port 4 Circuit Diagram  
10-8  
S3C72K8/P72K8  
TIMERS and TIMER/COUNTERS  
11 TIMERS and TIMER/COUNTERS  
OVERVIEW  
The S3C72K8 microcontroller has four timer and timer/counter modules:  
— 8-bit basic timer (BT)  
— 8-bit timer/counter (TC0)  
— Watch timer (WT)  
The 8-bit basic timer (BT) is the microcontroller's main interval timer and watchdog timer. It generates an interrupt  
request at a fixed time interval when the appropriate modification is made to its mode register. The basic timer is  
also used to determine clock oscillation stabilization time when stop mode is released by an interrupt and after a  
RESET.  
The 8-bit timer/counter (TC0) is programmable timer/counter that is used primarily for event counting and for clock  
frequency modification and output. In addition, TC0 generates a clock signal that can be used by the serial I/O  
interface.  
The watch timer (WT) module consists of an 8-bit watch timer mode register, a clock selector, and a frequency  
divider circuit. Watch timer functions include real-time and watch-time measurement, main and subsystem clock  
interval timing, buzzer output generation. It also generates a clock signal for the LCD controller.  
11-1  
TIMERS and TIMER/COUNTERS  
S3C72K8/P72K8  
BASIC TIMER (BT)  
OVERVIEW  
The 8-bit basic timer (BT) has five functional components:  
— Clock selector logic  
— 4-bit mode register (BMOD)  
— 8-bit counter register (BCNT)  
— 8-bit watchdog timer mode register (WDMOD)  
— Watchdog timer counter clear flag (WDTCF)  
The basic timer generates interrupt requests at precise intervals, based on the frequency of the system clock. You  
can use the basic timer as a "watchdog" timer for monitoring system events or use BT output to stabilize clock  
oscillation when stop mode is released by an interrupt and following RESET. Bit settings in the basic timer mode  
register BMOD turns the BT module on and off, selects the input clock frequency, and controls interrupt or  
stabilization intervals.  
Interval Timer Function  
The basic timer's primary function is to measure elapsed time intervals. The standard time interval is equal to 256  
basic timer clock pulses.  
To restart the basic timer, one bit setting is required: bit 3 of the mode register BMOD should be set to logic one.  
The input clock frequency and the interrupt and stabilization interval are selected by loading the appropriate bit  
values to BMOD.2-BMOD.0.  
The 8-bit counter register, BCNT, is incremented each time a clock signal is detected that corresponds to the  
frequency selected by BMOD. BCNT continues incrementing as it counts BT clocks until an overflow occurs  
(³ 255). An overflow causes the BT interrupt request flag (IRQB) to be set to logic one to signal that the designated  
time interval has elapsed. An interrupt request is than generated, BCNT is cleared to logic zero, and counting  
continues from 00H.  
Watchdog Timer Function  
The basic timer can also be used as a "watchdog" timer to signal the occurrence of system or program operation  
error. For this purpose, instruction that clear the watchdog timer (BITS WDTCF) should be executed at proper points  
in a program within given period. If an instruction that clears the watchdog timer is not executed within the given  
period and the watchdog timer overflows, reset signal is generated and the system restarts with reset status. An  
operation of watchdog timer is as follows:  
— Write some values (except #5AH) to watchdog timer mode register, WDMOD.  
— If WDCNT overflows, system reset is generated.  
11-2  
S3C72K8/P72K8  
TIMERS and TIMER/COUNTERS  
Oscillation Stabilization Interval Control  
Bits 2–0 of the BMOD register are used to select the input clock frequency for the basic timer. This setting also  
determines the time interval (also referred to as 'wait time') required to stabilize clock signal oscillation when stop  
mode is released by an interrupt. When a RESET signal is inputted, the standard stabilization interval for system  
clock oscillation following the RESET is 31.3 ms at 4.19 MHz.  
Table 11-1. Basic Timer Register Overview  
Register  
Name  
Type  
Description  
Size  
RAM  
Address  
Addressing  
Mode  
Reset  
Value  
BMOD  
Control Controls the clock frequency  
(mode) of the basic timer; also,  
the oscillation stabilization  
interval after stop mode release  
or RESET  
4-bit  
F85H  
4-bit write-only;  
BMOD.3: 1-bit  
writeable  
"0"  
(note)  
BCNT  
WDMOD  
WDTCF  
Counter Counts clock pulses matching  
the BMOD frequency setting  
8-bit F86H-F87H 8-bit read-only  
8-bit F98H-F99H 8-bit write-only  
U
Control Controls watchdog timer  
operation.  
A5H  
“0”  
Control Clears the watchdog timer's  
counter.  
1-bit  
F9AH.3  
1-, 4-bit write  
NOTE: 'U' means the value is undetermined after a RESET.  
11-3  
TIMERS and TIMER/COUNTERS  
S3C72K8/P72K8  
"Clear" Signal  
Clear  
BCNT  
Clear  
IRQB  
BITS  
Instruction  
BMOD.3  
BMOD.2  
BMOD.1  
BMOD.0  
Interrupt  
Request  
Overflow  
Clock  
Selector  
BCNT  
IRQB  
4
1-Bit R/W  
CPU Clock  
Start Signal  
8
(Power-Down Release)  
Clock Input  
1 Pulse Period = BT Input Clock 28 (1/2 Duty)  
3-Bit Counter  
Overflow  
WDCNT  
Reset Signal  
Generation  
RESET  
Clear  
WDMOD  
8
WDTCF  
BITS  
DELAY  
(note)  
Stop  
Clear  
WAIT  
RESET  
Instruction  
NOTES:  
1. WAIT means stabilization time after RESET or stabilization time after STOP mode release.  
2. The RESET signal can be generated if the WDMOD is toggled for 8 times where "toggle"  
means change from 5AH to other value and vice verse.  
3. When the watdog timer is enabled or the 3-bit counter of the watchdog timer is cleared to  
"0", the BCNT value is not cleared but increased continuously. As a result, the 3-bit counter of  
the watchdog timer (WDCNT) can be increased by 1. For example, when the BMOD value is  
x000B and the watchdog timer is enabled, the watchdog timer interval time is from  
2
3 x 2 12 x 2 8/fxx to (2 3 - 1) x 2 12 x 2 8/fxx.  
Figure 11-1. Basic Timer Circuit Diagram  
11-4  
S3C72K8/P72K8  
TIMERS and TIMER/COUNTERS  
BASIC TIMER MODE REGISTER (BMOD)  
The basic timer mode register, BMOD, is a 4-bit write-only register. Bit 3, the basic timer start control bit, is also 1-  
bit addressable. All BMOD values are set to logic zero following RESET and interrupt request signal generation is set  
to the longest interval. (BT counter operation cannot be stopped.) BMOD settings have the following effects:  
— Restart the basic timer;  
— Control the frequency of clock signal input to the basic timer;  
— Determine time interval required for clock oscillation to stabilize following the release of stop mode by an  
interrupt.  
By loading different values into the BMOD register, you can dynamically modify the basic timer clock frequency  
12  
5
during program execution. Four BT frequencies, ranging from fxx/2 to fxx/2 , are selectable. Since BMOD's reset  
12  
value is logic zero, the default clock frequency setting is fxx/2 .  
The most significant bit of the BMOD register, BMOD.3, is used to restart the basic timer. When BMOD.3 is set to  
logic one (ebable) by a 1-bit write instruction, the contents of the BT counter register (BCNT) and the BT interrupt  
request flag (IRQB) are both cleared to logic zero, and timer operation restarts.  
The combination of bit settings in the remaining three registers — BMOD.2, BMOD.1, and BMOD.0 — determine the  
clock input frequency and oscillation stabilization interval.  
Table 11-2. Basic Timer Mode Register (BMOD) Organization  
BMOD.3  
Basic Timer Start Control Bit  
1
Start basic timer; clear IRQB, BCNT, and BMOD.3 to "0"  
BMOD.2  
BMOD.1  
BMOD.0  
Basic Timer Input Clock  
Interrupt Interval Time  
(Wait time when STOP mode  
is released)  
12  
20  
0
0
1
1
0
1
0
1
0
1
1
1
fxx/2 (1.02 kHz)  
2 /fxx (250 ms)  
9
17  
fxx/2 (8.18 kHz)  
2 /fxx (31.3 ms)  
7
15  
fxx/2 (32.7 kHz)  
2 /fxx (7.82 ms)  
5
13  
fxx/2 (131 kHz)  
2 /fxx (1.95 ms)  
NOTES:  
1. Clock frequencies and oscillation stabilization assume a system oscillator clock frequency (fxx) of 4.19 MHz.  
2. fxx = system clock frequency.  
3. Oscillation stabilization time is the time required to stabilize clock signal oscillation after stop mode is released. The  
data in the table column 'Oscillation Stabilization' can also be interpreted as "Interrupt Interval Time".  
4. The standard stabilization time for system clock oscillation following a RESET is 31.3 ms at 4.19 MHz.  
11-5  
TIMERS and TIMER/COUNTERS  
S3C72K8/P72K8  
BASIC TIMER COUNTER (BCNT)  
BCNT is an 8-bit counter for the basic timer. It can be addressed by 8-bit read instructions.  
RESET leaves the BCNT counter value undetermined. BCNT is automatically cleared to logic zero whenever the  
BMOD register control bit (BMOD.3) is set to "1" to restart the basic timer. It is incremented each time a clock  
pulse of the frequency determined by the current BMOD bit settings is detected.  
When BCNT has incrementing to hexadecimal 'FFH' (³ 255 clock pulses), it is cleared to '00H' and an overflow is  
generated. The overflow causes the interrupt request flag, IRQB, to be set to logic one. When the interrupt request is  
generated, BCNT immediately resumes counting incoming clock signals.  
NOTE  
Always execute a BCNT read operation twice to eliminate the possibility of reading unstable data while the  
counter is incrementing. If, after two consecutive reads, the BCNT values match, you can select the latter  
value as valid data. Until the results of the consecutive reads match, however, the read operation must be  
repeated until the validation condition is met.  
BASIC TIMER OPERATION SEQUENCE  
The basic timer's sequence of operations may be summarized as follows:  
1. Set BMOD.3 to logic one to restart the basic timer  
2. BCNT is then incremented by one after each clock pulse corresponding to BMOD selection  
3. BCNT overflows if BCNT = 255 (BCNT = FFH)  
4. When an overflow occurs, the IRQB flag is set by hardware to logic one  
5. The interrupt request is generated  
6. BCNT is then cleared by hardware to logic zero  
7. Basic timer resumes counting clock pulses  
11-6  
S3C72K8/P72K8  
TIMERS and TIMER/COUNTERS  
F
PROGRAMMING TIP — Using the Basic Timer  
1. To read the basic timer count register (BCNT):  
BITS  
SMB  
LD  
LD  
LD  
EMB  
15  
BCNTR  
EA,BCNT  
YZ,EA  
EA,BCNT  
EA,YZ  
BCNTR  
CPSE  
JR  
2. When stop mode is released by an interrupt, set the oscillation stabilization interval to 31.3 ms:  
BITS  
SMB  
LD  
EMB  
15  
A,#0BH  
BMOD,A  
LD  
;
;
Wait time is 31.3 ms  
Set stop power-down mode  
STOP  
NOP  
NOP  
NOP  
Normal Mode  
Stop Mode  
Idle Mode  
(31.3 ms)  
Normal Mode  
CPU  
Operation  
STOP  
Instruction  
Stop Mode is  
Released by  
Interrupt  
3. To set the basic timer interrupt interval time to 1.95 ms (at 4.19 MHz):  
BITS  
SMB  
LD  
EMB  
15  
A,#0FH  
BMOD,A  
LD  
EI  
BITS  
IEB  
; Basic timer interrupt enable flag is set to "1"  
4. Clear BCNT and the IRQB flag and restart the basic timer:  
BITS  
SMB  
BITS  
EMB  
15  
BMOD.3  
11-7  
TIMERS and TIMER/COUNTERS  
S3C72K8/P72K8  
WATCHDOG TIMER MODE REGISTER (WDMOD)  
The watchdog timer mode register, WDMOD, is a 8-bit write-only register. WDMOD register controls to enable or  
disable the watchdog function. WDMOD values are set to logic "A5H" following RESET and this value enables the  
watchdog timer. Watchdog timer is set to the longest interval because BT overflow signal is generated with the  
longest interval.  
WDMOD  
Watchdog Timer Enable/Disable Control  
Disable watchdog timer function  
Enable watchdog timer function  
5AH  
Any other value  
WATCHDOG TIMER COUNTER (WDCNT)  
The watchdog timer counter, WDCNT, is a 3-bit counter. WDCNT is automatically cleared to logic zero, and restarts  
whenever the WDTCF register control bit is set to "1". RESET, stop, and wait signal clears the WDCNT to logic zero  
also.  
WDCNT increments each time a clock pulse of the overflow frequency determined by the current BMOD bit setting is  
generated. When WDCNT has incremented to hexadecimal '07H', it is cleared to ‘00H’ and an overflow is generated.  
The overflow causes the system RESET. When the interrupt request is generated, BCNT immediately resumes  
counting incoming clock signals.  
WATCHDOG TIMER COUNTER CLEAR FLAG (WDTCF)  
The watchdog timer counter clear flag, WDTCF, is a 1-bit write instruction. When WDTCF is set to one, it clears the  
WDCNT to zero and restarts the WDCNT. WDTCF register bits 2-0 are always logic zero.  
Table 11-3. Watchdog Timer Interval Time  
(3)  
BMOD  
x000b  
x011b  
x101b  
x111b  
BT Input Clock  
WDT Interval Time  
12  
3
12  
8
3
12  
8
1.75–2.0 sec  
218.7–250 ms  
54.6–62.5ms  
13.6–15.6 ms  
fxx/2  
2 ´ 2 ´ 2 /fxx - (2 -1) ´ 2 ´ 2 /fxx  
9
3
9
8
3
9
8
fxx/2  
2 ´ 2 ´ 2 /fxx - (2 -1) ´ 2 ´ 2 /fxx  
7
3
7
8
3
7
8
fxx/2  
2 ´ 2 ´ 2 /fxx - (2 -1) ´ 2 ´ 2 /fxx  
5
3
5
8
3
5
8
fxx/2  
2 ´ 2 ´ 2 /fxx - (2 -1) ´ 2 ´ 2 /fxx  
NOTES:  
1. Clock frequencies assume a system oscillator clock frequency (fx) of 4.19 MHz  
2. fxx = system clock frequency.  
3. When the watchdog timer is enabled or the 3-bit counter of the watchdog timer is cleared to "0", the BCNT value is not  
cleared but increased continuously. As a result, the 3-bit counter of the watchdog timer (WDCNT) can be increased  
by 1. For example, when the BMOD value is x000b and the watchdog timer is enabled, the watchdog timer interval time  
3
12  
8
3
12  
8
is from 2 ´ 2 ´ 2 /fxx to (2 –1) ´ 2 ´ 2 /fxx.  
11-8  
S3C72K8/P72K8  
TIMERS and TIMER/COUNTERS  
F
PROGRAMMING TIP — Using the Watchdog Timer  
RESET  
DI  
LD  
LD  
EA,#00H  
SP,EA  
·
·
·
LD  
A,#0DH  
;
WDCNT input clock is 7.82 ms  
LD  
BMOD,A  
·
·
·
MAIN  
BITS  
WDTCF  
MAIN  
;
;
Main routine operation period must be shorter than  
watchdog-timer's period  
·
·
·
JP  
11-9  
TIMERS and TIMER/COUNTERS  
S3C72K8/P72K8  
8-BIT TIMER/COUNTER 0 (TC0)  
OVERVIEW  
Timer/counter 0 (TC0) is used to count system 'events' by identifying the transition (high-to-low or low-to-high) of  
incoming square wave signals. To indicate that an event has occurred, or that a specified time interval has elapsed,  
TC0 generates an interrupt request. By counting signal transitions and comparing the current counter value with the  
reference register value, TC0 can be used to measure specific time intervals.  
TC0 has a reloadable counter that consists of two parts: an 8-bit reference register (TREF0) into which you write the  
counter reference value, and an 8-bit counter register (TCNT0) whose value is automatically incremented by counter  
logic.  
An 8-bit mode register, TMOD0, is used to activate the timer/counter and to select the basic clock frequency to be  
used for timer/counter operations. To dynamically modify the basic frequency, new values can be loaded into the  
TMOD0 register during program execution.  
Timer/counter 0 can supply a clock signal to the clock selector circuit of the serial I/O interface for data shifter and  
clock counter operations. (These internal SIO operations are controlled in turn by the SIO mode register, SMOD).  
This clock generation function enables you to adjust data transmission rates across the serial interface.  
TC0 FUNCTION SUMMARY  
8-bit programmable timer  
External event counter  
Generates interrupts at specific time intervals based on the selected clock  
frequency.  
Counts various system "events" based on edge detection of external clock  
signals at the TC0 input pin, TCL0. To start the event counting operation,  
TMOD0.2 is set to "1" and TMOD0.6 is cleared to "0".  
Arbitrary frequency output  
External signal divider  
Outputs selectable clock frequencies to the TC0 output pin, TCLO0.  
Divides the frequency of an incoming external clock signal according to a  
modifiable reference value (TREF0), and outputs the modified frequency to the  
TCLO0 pin.  
Serial I/O clock source  
Outputs a modifiable clock signal for use as the SCK clock source.  
11-10  
S3C72K8/P72K8  
TIMERS and TIMER/COUNTERS  
TC0 COMPONENT SUMMARY  
Mode register (TMOD0)  
Activates the timer/counter and selects the internal clock frequency or the  
external clock source at the TCL0 pin.  
Reference register (TREF0)  
Counter register (TCNT0)  
Clock selector circuit  
8-bit comparator  
Stores the reference value for the desired number of clock pulses between  
interrupt requests.  
Counts internal or external clock pulses based on the bit settings in TMOD0 and  
TREF0.  
Together with the mode register (TMOD0), lets you select one of four internal  
clock frequencies or an external clock.  
Determines when to generate an interrupt by comparing the current value of the  
counter register (TCNT0) with the reference value previously programmed into the  
reference register (TREF0).  
Output latch (TOL0)  
Where a clock pulse is stored pending output to the I/O circuit or to the TC0  
output pin, TCLO0.  
When the contents of the TCNT0 and TREF0 registers coincide, the  
timer/counter interrupt request flag (IRQT0) is set to "1", the status of TOL0 is in-  
verted, and an interrupt is generated.  
Output enable flag (TOE0)  
Interrupt request flag (IRQT0)  
Interrupt enable flag (IET0)  
Must be set to logic one before the contents of the TOL0 latch can be output to  
TCLO0.  
Cleared when TC0 operation starts and the TC0 interrupt service routine is  
executed and set to 1 whenever the counter value and reference value coincide.  
Must be set to logic one before the interrupt requests generated by timer/counter  
0 can be processed.  
Table 11-4. TC0 Register Overview  
Register  
Name  
Type  
Description  
Size  
RAM  
Address  
Addressing  
Mode  
Reset  
Value  
TMOD0  
Control  
Controls TC0 enable/disable (bit 8-bit F90H–F91H  
2); clears and resumes counting  
operation (bit 3); sets input  
8-bit write-only;  
(TMOD0.3 is also  
1-bit writeable)  
"0"  
clock and clock frequency (bits  
6–4)  
TCNT0  
TREF0  
TOE0  
Counter  
Counts clock pulses matching  
the TMOD0 frequency setting  
8-bit F94H–F95H  
8-bit F96H–F97H  
8-bit read-only  
8-bit write-only  
1-bit write-only  
"0"  
FFH  
"0"  
Reference Stores reference value for the  
timer/counter 0 interval setting  
Flag  
Controls timer/counter 0 output  
to the TCLO0 pin  
1-bit  
F92H.2  
11-11  
TIMERS and TIMER/COUNTERS  
S3C72K8/P72K8  
Clocks  
(fxx/2 10, fxx/2 6, fxx/2 4, fxx)  
TCL0  
8
8
TMOD0.7  
TMOD0.6  
8-Bit  
Comparator  
TCNT0  
TREF0  
Clock  
Selector  
TMOD0.5  
8
TMOD0.4  
Clear  
TMOD0.3  
TMOD0.2  
TMOD0.1  
TMOD0.0  
Inverted  
TOL0  
Clear  
IRQT0  
Set  
Clear  
Serial I/O  
TCLO0  
PM4.2  
P4.2 Latch  
TOE0  
Figure 11-2. TC0 Circuit Diagram  
TC0 ENABLE/DISABLE PROCEDURE  
Enable Timer/Counter 0  
— Set TMOD0.2 to logic one  
— Set the TC0 interrupt enable flag IET0 to logic one  
— Set TMOD0.3 to logic one  
TCNT0, IRQT0, and TOL0 are cleared to logic zero, and timer/counter operation starts.  
Disable Timer/Counter 0  
— Set TMOD0.2 to logic zero  
Clock signal input to the counter register TCNT0 is halted. The current TCNT0 value is retained and can be read if  
necessary.  
11-12  
S3C72K8/P72K8  
TIMERS and TIMER/COUNTERS  
TC0 PROGRAMMABLE TIMER/COUNTER FUNCTION  
Timer/counter 0 can be programmed to generate interrupt requests at various intervals based on the selected system  
clock frequency. Its 8-bit TC0 mode register TMOD0 is used to activate the timer/counter and to select the clock  
frequency.  
The reference register TREF0 stores the value for the number of clock pulses to be generated between interrupt  
requests. The counter register, TCNT0, counts the incoming clock pulses, which are compared to the TREF0 value  
as TCNT0 is incremented. When there is a match (TREF0 = TCNT0), an interrupt request is generated.  
To generate an interrupt request, the TC0 interrupt request flag (IRQT0) is set to logic one, the status of TOL0 is  
inverted, and the interrupt is generated. The content of TCNT0 is then cleared to 00H and TC0 continues counting.  
The interrupt request mechanism for TC0 includes an interrupt enable flag (IET0) and an interrupt request flag  
(IRQT0).  
TC0 OPERATION SEQUENCE  
The general sequence of operations for using TC0 can be summarized as follows:  
1. Set TMOD0.2 to "1" to enable TC0.  
2. Set TMOD0.6 to "1" to enable the system clock (fxx) input.  
n
3. Set TMOD0.5 and TMOD0.4 bits to desired internal frequency (fxx/2 ).  
4. Load a value to TREF0 to specify the interval between interrupt requests.  
5. Set the TC0 interrupt enable flag (IET0) to "1".  
6. Set TMOD0.3 bit to "1" to clear TCNT0, IRQT0, and TOL0, and start counting.  
7. TCNT0 increments with each internal clock pulse.  
8. When the comparator shows TCNT0 = TREF0, the IRQT0 flag is set to "1" and an interrupt request is generated.  
9. Output latch (TOL0) logic toggles high or low.  
10. TCNT0 is cleared to 00H and counting resumes.  
11. Programmable timer/counter operation continues until TMOD0.2 is cleared to "0".  
11-13  
TIMERS and TIMER/COUNTERS  
S3C72K8/P72K8  
TC0 EVENT COUNTER FUNCTION  
Timer/counter 0 can monitor or detect system 'events' by using the external clock input at the TCL0 pin as the  
counter source. The TC0 mode register selects rising or falling edge detection for incoming clock signals. The  
counter register TCNT0 is incremented each time the selected state transition of the external clock signal occurs.  
With the exception of the different TMOD0.4–TMOD0.6 settings, the operation sequence for TC0's event counter  
function is identical to its programmable timer/counter function. To activate the TC0 event counter function,  
— Set TMOD0.2 to "1" to enable TC0;  
— Clear TMOD0.6 to "0" to select the external clock source at the TCL0 pin;  
— Select TCL0 edge detection for rising or falling signal edges by loading the appropriate values to TMOD0.5 and  
TMOD0.4.  
— P4.2 must be set to input mode.  
Table 11-5. TMOD0 Settings for TCL0 Edge Detection  
TMOD0.5  
TMOD0.4  
TCL0 Edge Detection  
Rising edges  
0
0
0
1
Falling edges  
11-14  
S3C72K8/P72K8  
TIMERS and TIMER/COUNTERS  
TC0 CLOCK FREQUENCY OUTPUT  
Using timer/counter 0, a modifiable clock frequency can be output to the TC0 clock output pin, TCLO0. To select the  
clock frequency, load the appropriate values to the TC0 mode register, TMOD0. The clock interval is selected by  
loading the desired reference value into the reference register TREF0. To enable the output to the TCLO0 pin, the  
following conditions must be met:  
— TC0 output enable flag TOE0 must be set to "1"  
— I/O mode flag for P4.2 must be set to output mode ("1")  
— Output latch value for P4.2 must be set to "0"  
In summary, the operational sequence required to output a TC0-generated clock signal to the TCLO0 pin is as  
follows:  
1. Load a reference value to TREF0.  
2. Set the internal clock frequency in TMOD0.  
3. Initiate TC0 clock output to TCLO0 (TMOD0.2 = "1").  
4. Set P4.2 mode flag to "1".  
5. Set P4.2 output latch to "0".  
6. Set TOE0 flag to "1".  
Each time TCNT0 overflows and an interrupt request is generated, the state of the output latch TOL0 is inverted and  
the TC0-generated clock signal is output to the TCLO0 pin.  
F
PROGRAMMING TIP — TC0 Signal Output to the TCLO0 Pin  
Output a 30 ms pulse width signal to the TCLO0 pin:  
BITS  
SMB  
LD  
LD  
LD  
LD  
LD  
LD  
BITR  
BITS  
EMB  
15  
EA,#79H  
TREF0,EA  
EA,#4CH  
TMOD0,EA  
EA,#40H  
PMG1,EA  
P4.2  
;
;
P4.2 ¬ output mode  
P4.2 clear  
TOE0  
11-15  
TIMERS and TIMER/COUNTERS  
S3C72K8/P72K8  
TC0 SERIAL I/O CLOCK GENERATION  
Timer/count 0 can supply a clock signal to the clock selector circuit of the serial I/O interface for data shifter and  
clock counter operations. (These internal SIO operations are controlled in turn by the SIO mode register, SMOD).  
This clock generation function enables you to adjust data transmission rates across the serial interface.  
TC0 EXTERNAL INPUT SIGNAL DIVIDER  
By selecting an external clock source and loading a reference value into the TC0 reference register, TREF0, you can  
divide the incoming clock signal by the TREF0 value and then output this modified clock frequency to the TCLO0 pin.  
The sequence of operations used to divide external clock input can be summarized as follows:  
1. Load a signal divider value to the TREF0 register.  
2. Clear TMOD0.6 to "0" to enable external clock input at the TCL0 pin.  
3. Set TMOD0.5 and TMOD0.4 to desired TCL0 signal edge detection.  
4. Set port 3.0 mode flag (PM3.0) to output ("1").  
5. Set P3.0 output latch to "0".  
6. Set TOE0 flag to "1" to enable output of the divided frequency to the TCLO0 pin. TC0 Mode Register (TMOD0)  
F
PROGRAMMING TIP — External TCL0 Clock Output to the TCLO0 Pin  
Output external TCL0 clock pulse to the TCLO0 pin (divided by four):  
External (TCL0)  
Clock Pulse  
TCLO0  
Output Pulse  
BITS  
SMB  
LD  
LD  
LD  
LD  
LD  
LD  
BITR  
BITS  
EMB  
15  
EA,#01H  
TREF0,EA  
EA,#0CH  
TMOD0,EA  
EA,#40H  
PMG1,EA  
P4.2  
;
;
P4.2 ¬ output mode  
P4.2 clear  
TOE0  
11-16  
S3C72K8/P72K8  
TIMERS and TIMER/COUNTERS  
TC0 MODE REGISTER (TMOD0)  
TMOD0 is the 8-bit mode control register for timer/counter 0. It is addressable by 8-bit write instructions. One bit,  
TMOD0.3, is also 1-bit writeable. RESET clears all TMOD0 bits to logic zero and disables TC0 operations.  
F90H  
F91H  
TMOD0.3  
"0"  
TMOD0.2  
TMOD0.6  
"0"  
"0"  
TMOD0.5  
TMOD0.4  
TMOD0.2 is the enable/disable bit for timer/counter 0. When TMOD0.3 is set to "1", the contents of TCNT0, IRQT0,  
and TOL0 are cleared, counting starts from 00H, and TMOD0.3 is automatically reset to "0" for normal TC0  
operation. When TC0 operation stops (TMOD0.2 = "0"), the contents of the TC0 counter register TCNT0 are retained  
until TC0 is re-enabled.  
The TMOD0.6, TMOD0.5, and TMOD0.4 bit settings are used together to select the TC0 clock source. This selection  
involves two variables:  
— Synchronization of timer/counter operations with either the rising edge or the falling edge of the clock signal input  
at the TCL0 pin, and  
— Selection of one of four frequencies, based on division of the incoming system clock frequency, for use in internal  
TC0 operation.  
Table 11-6. TC0 Mode Register (TMOD0) Organization  
Bit Name  
TMOD0.7  
TMOD0.6  
TMOD0.5  
TMOD0.4  
TMOD0.3  
Setting  
Resulting TC0 Function  
Address  
0
Always logic zero  
F91H  
0,1  
1
Specify input clock edge and internal frequency  
Clear TCNT0, IRQT0, and TOL0 and resume counting immedi-  
ately (This bit is automatically cleared to logic zero immediately  
after counting resumes.)  
TMOD0.2  
0
1
0
0
Disable timer/counter 0; retain TCNT0 contents  
Enable timer/counter 0  
F90H  
TMOD0.1  
TMOD0.0  
Always logic zero  
Always logic zero  
11-17  
TIMERS and TIMER/COUNTERS  
S3C72K8/P72K8  
Table 11-7. TMOD0.6, TMOD0.5, and TMOD0.4 Bit Settings  
TMOD0.6  
TMOD0.5  
TMOD0.4  
Resulting Counter Source and Clock Frequency  
0
0
1
0
0
0
0
1
0
External clock input (TCL0) on rising edges  
External clock input (TCL0) on falling edges  
10  
fxx/2 (4.09 kHz)  
6
1
1
1
0
1
1
1
0
1
fxx /2 (65.5 kHz)  
4
fxx/2 (262 kHz)  
fxx = 4.19 MHz  
NOTE: 'fxx' = selected system clock of 4.19 MHz.  
F
PROGRAMMING TIP — Restarting TC0 Counting Operation  
1. Set TC0 timer interval to 4.09 kHz:  
BITS  
SMB  
LD  
EMB  
15  
EA,#4CH  
TMOD0,EA  
LD  
EI  
BITS  
IET0  
2. Clear TCNT0, IRQT0, and TOL0 and restart TC0 counting operation:  
BITS  
SMB  
BITS  
EMB  
15  
TMOD0.3  
11-18  
S3C72K8/P72K8  
TIMERS and TIMER/COUNTERS  
TC0 COUNTER REGISTER (TCNT0)  
The 8-bit counter register for timer/counter 0, TCNT0, is read-only and can be addressed by 8-bit RAM control  
instructions. RESET sets all TCNT0 register values to logic zero (00H).  
Whenever TMOD0.3 is enabled, TCNT0 is cleared to logic zero and counting resumes. The TCNT0 register value is  
incremented each time an incoming clock signal is detected that matches the signal edge and frequency setting of  
the TMOD0 register (specifically, TMOD0.6, TMOD0.5, and TMOD0.4).  
Each time TCNT0 is incremented, the new value is compared to the reference value stored in the TC0 reference  
buffer, TREF0. When TCNT0 = TREF0, an overflow occurs in the TCNT0 register, the interrupt request flag, IRQT0, is  
set to logic one, and an interrupt request is generated to indicate that the specified timer/counter interval has  
elapsed.  
Count  
Clock  
TREF0  
TCNT0  
Reference Value = n  
0
1
2
n-1  
n
0
1
2
n-1  
n
0
1
2
3
Match  
Match  
TOL0  
Interval Time  
Timer Start Instruction  
(TMOD0.3 is set)  
IRQT0 Set  
IRQT0 Set  
Figure 11-3. TC0 Timing Diagram  
11-19  
TIMERS and TIMER/COUNTERS  
S3C72K8/P72K8  
TC0 REFERENCE REGISTER (TREF0)  
The TC0 reference register TREF0 is an 8-bit write-only register. It is addressable by 8-bit RAM control instructions.  
RESET initializes the TREF0 value to 'FFH'.  
TREF0 is used to store a reference value to be compared to the incrementing TCNT0 register in order to identify an  
elapsed time interval. Reference values will differ depending upon the specific function that TC0 is being used to  
perform — as a programmable timer/counter, event counter, clock signal divider, or arbitrary frequency output source.  
During timer/counter operation, the value loaded into the reference register is compared to the TCNT0 value. When  
TCNT0 = TREF0, the TC0 output latch (TOL0) is inverted and an interrupt request is generated to signal the interval  
or event. The TREF0 value, together with the TMOD0 clock frequency selection, determines the specific TC0 timer  
interval. Use the following formula to calculate the correct value to load to the TREF0 reference register:  
1
TC0 timer interval = (TREF0 value + 1)  
´
TMOD0 frequency setting  
(TREF0 value ¹ 0)  
TC0 OUTPUT ENABLE FLAG (TOE0)  
The 1-bit timer/counter 0 output enable flag TOE0 controls output from timer/counter 0 to the TCLO0 pin. TOE0 is  
addressable by 1-bit read and write instructions.  
(MSB)  
"0"  
(LSB)  
"0"  
F92H  
TOE0  
"0"  
When you set the TOE0 flag to "1", the contents of TOL0 can be output to the TCLO0 pin. Whenever a RESET  
occurs, TOE0 is automatically set to logic zero, disabling all TC0 output. Even when the TOE0 flag is disabled,  
timer/counter 0 can continue to output an internally-generated clock frequency, via TOL0, to the serial I/O clock  
selector circuit.  
TC0 OUTPUT LATCH (TOL0)  
TOL0 is the output latch for timer/counter 0. When the 8-bit comparator detects a correspondence between the value  
of the counter register TCNT0 and the reference value stored in the TREF0 register, the TOL0 value is inverted — the  
latch toggles high-to-low or low-to-high. Whenever the state of TOL0 is switched, the TC0 signal is output. TC0  
output may be directed to the TCLO0 pin, or it can be output directly to the serial I/O clock selector circuit as the  
SCK signal.  
Assuming TC0 is enabled, when bit 3 of the TMOD0 register is set to "1", the TOL0 latch is cleared to logic zero,  
along with the counter register TCNT0 and the interrupt request flag, IRQT0, and counting resumes immediately.  
When TC0 is disabled (TMOD0.2 = "0"), the contents of the TOL0 latch are retained and can be read, if necessary.  
11-20  
S3C72K8/P72K8  
TIMERS and TIMER/COUNTERS  
F
PROGRAMMING TIP — Setting a TC0 Timer Interval  
To set a 30 ms timer interval for TC0, given fxx = 4.19 MHz, follow these steps.  
1. Select the timer/counter 0 mode register with a maximum setup time of 62.5 ms (assume the TC0 counter  
10  
clock = fxx/2 , and TREF0 is set to FFH):  
2. Calculate the TREF0 value:  
TREF0 value + 1  
30 ms =  
4.09 kHz  
30 ms  
244 µs  
TREF0 + 1 =  
= 122.9 = 7AH  
TREF0 value = 7AH – 1 = 79H  
3. Load the value 79H to the TREF0 register:  
BITS  
SMB  
LD  
LD  
LD  
EMB  
15  
EA,#79H  
TREF0,EA  
EA,#4CH  
TMOD0,EA  
LD  
11-21  
TIMERS and TIMER/COUNTERS  
S3C72K8/P72K8  
WATCH TIMER  
OVERVIEW  
The watch timer is a multi-purpose timer which consists of three basic components:  
— 8-bit watch timer mode register (WMOD)  
— Clock selector  
— Frequency divider circuit  
Watch timer functions include real-time and watch-time measurement and interval timing for the main and sub-  
system clock. It is also used as a clock source for the LCD controller and for generating buzzer (BUZ) output.  
Real-Time and Watch-Time Measurement  
To start watch timer operation, set bit 2 of the watch timer mode register (WMOD.2) to logic one. The watch timer  
starts, the interrupt request flag IRQW is automatically set to logic one, and interrupt requests commence in 0.5-  
second intervals.  
Since the watch timer functions as a quasi-interrupt instead of a vectored interrupt, the IRQW flag should be cleared  
to logic zero by program software as soon as a requested interrupt service routine has been executed.  
Using a Main System or Subsystem Clock Source  
The watch timer can generate interrupts based on the main system clock frequency or on the subsystem clock.  
When the zero bit of the WMOD register is set to "1", the watch timer uses the subsystem clock signal (fxt) as its  
source; if WMOD.0 = "0", the main system clock (fx) is used as the signal source, according to the following  
formula:  
Main system clock (fx)  
Watch timer clock (fw)  
=
= 32.768 kHz (fx = 4.19 MHz)  
128  
This feature is useful for controlling timer-related operations during stop mode. When stop mode is engaged, the  
main system clock (fx) is halted, but the subsystem clock continues to oscillate. By using the subsystem clock as  
the oscillation source during stop mode, the watch timer can set the interrupt request flag IRQW to "1", thereby  
releasing stop mode.  
Clock Source Generation for LCD Controller  
The watch timer supplies the clock frequency for the LCD controller (f  
the LCD controller does not operate.  
). Therefore, if the watch timer is disabled,  
LCD  
11-22  
S3C72K8/P72K8  
TIMERS and TIMER/COUNTERS  
Buzzer Output Frequency Generator  
The watch timer can generate a steady 2 kHz, 4 kHz, 8 kHz, or 16 kHz signal to the BUZ pin. To select the desired  
BUZ frequency , load the appropriate value to the WMOD register. This output can then be used to actuate an  
external buzzer sound. To generate a BUZ signal, three conditions must be met:  
— The WMOD.7 register bit is set to "1"  
— The output latch for I/O port 0.3 is cleared to "0"  
— The port 0.3 output mode flag (PM0.3) set to 'output' mode  
Timing Tests in High-Speed Mode  
By setting WMOD.1 to "1", the watch timer will function in high-speed mode, generating an interrupt every 3.91 ms.  
At its normal speed (WMOD.1 = '0'), the watch timer generates an interrupt request every 0.5 seconds. High-speed  
mode is useful for timing events for program debugging sequences.  
Check Subsystem Clock Level Feature  
The watch timer can also check the input level of the subsystem clock by testing WMOD.3. If WMOD.3 is "1", the  
input level at the XT pin is high; if WMOD.3 is "0", the input level at the XT pin is low.  
IN  
IN  
11-23  
TIMERS and TIMER/COUNTERS  
S3C72K8/P72K8  
P0.3 Latch  
PM0.3  
WMOD.7  
WMOD.6  
WMOD.5  
BUZ  
MUX  
WMOD.4  
8
fw/2  
(16 kHz)  
WMOD.3  
fw/4  
(8 kHz)  
ENABLE/DISABLE  
WMOD.2  
WMOD.1  
WMOD.0  
fw/8  
(4 kHz)  
Selector  
Circuit  
fw/16  
(2 kHz)  
IRQW  
fw/27  
fw/214 (2 Hz)  
Frequency  
Dividing  
Circuit  
fw  
(32.768 kHz)  
Clock  
Selector  
f
LCD  
fx = Main-system Clock (4.19 MHz)  
fxt = Sub-system Clock (32.768 kHz)  
fw = Watch Timer Frequency  
fxt  
fx/128  
Figure 11-4. Watch Timer Circuit Diagram  
11-24  
S3C72K8/P72K8  
TIMERS and TIMER/COUNTERS  
WATCH TIMER MODE REGISTER (WMOD)  
The watch timer mode register WMOD is used to select specific watch timer operations. It is 8-bit write-only  
addressable. An exception is WMOD bit 3 (the XT input level control bit) which is 1-bit read-only addressable. A  
IN  
RESET automatically sets WMOD.3 to the current input level of the subsystem clock, XT (high, if logic one; low, if  
IN  
logic zero), and all other WMOD bits to logic zero.  
F88H  
F89H  
WMOD.3  
WMOD.7  
WMOD.2  
"0"  
WMOD.1  
WMOD.5  
WMOD.0  
WMOD.4  
In summary, WMOD settings control the following watch timer functions:  
— Watch timer clock selection  
— Watch timer speed control  
— Enable/disable watch timer  
(WMOD.0)  
(WMOD.1)  
(WMOD.2)  
(WMOD.3)  
XT input level control  
IN  
— Buzzer frequency selection  
(WMOD.4 and WMOD.5)  
— Enable/disable buzzer output (WMOD.7)  
Table 11-8. Watch Timer Mode Register (WMOD) Organization  
Bit Name  
Values  
Function  
Disable buzzer (BUZ) signal output  
Address  
WMOD.7  
0
1
0
F89H  
Enable buzzer (BUZ) signal output  
Always logic zero  
WMOD.6  
WMOD.5–.4  
0
0
1
0
1
2 kHz buzzer (BUZ) signal output  
4 kHz buzzer (BUZ) signal output  
8 kHz buzzer (BUZ) signal output  
16 kHz buzzer (BUZ) signal output  
0
1
1
WMOD.3  
0
1
Input level to XT pin is low  
F88H  
IN  
Input level to XT pin is high  
IN  
WMOD.2  
WMOD.1  
WMOD.0  
0
1
0
1
0
1
Disable watch timer; clear frequency dividing circuits  
Enable watch timer  
Normal mode; sets IRQW to 0.5 seconds  
High-speed mode; sets IRQW to 3.91 ms  
Select (fx/128 ) as the watch timer clock (fw)  
Select subsystem clock as watch timer clock (fw)  
NOTE: Main system clock frequency (fx) is assumed to be 4.19 MHz; subsystem clock (fxt) is assumed to be 32.768 kHz.  
11-25  
TIMERS and TIMER/COUNTERS  
S3C72K8/P72K8  
F
PROGRAMMING TIP — Using the Watch Timer  
1. Select a subsystem clock as the LCD display clock, a 0.5 second interrupt, and 2 kHz buzzer enable:  
BITS  
SMB  
LD  
LD  
BITR  
LD  
EMB  
15  
EA,#8H  
PMG1,EA  
P0.3  
EA,#85H  
WMOD,EA  
IEW  
;
P0.3 ¬ output mode  
LD  
BITS  
2. Sample real-time clock processing method:  
CLOCK  
BTSTZ  
RET  
IRQW  
;
;
;
0.5 second check  
No, return  
Yes, 0.5 second interrupt generation  
;
Increment HOUR, MINUTE, SECOND  
11-26  
S3C72K8/P72K8  
LCD CONTROLLER/DRIVER  
12 LCD CONTROLLER/DRIVER  
OVERVIEW  
The S3C72K8 microcontroller can directly drive an up-to-320-dot (40 segments x 8 commons) LCD panel. Its LCD  
block has the following components:  
— LCD controller/driver  
— Display RAM for storing display data  
— 40 segment output pins (SEG0–SEG35)  
— 8 common output pins (COM0–COM7)  
— Five LCD operating power supply pins (V  
–V  
)
LC1 LC5  
— V  
pin for controlling the driver and bias voltage  
LC5  
The frame frequency, duty and bias, and the segment pins used for display output, are determined by bit settings in  
the LCD mode register, LMOD.  
The LCD control register, LCON, is used to turn the LCD display on and off, to switch current to the dividing resistors  
for the LCD display, and to output LCD clock (LCDCK) and synchronizing signal (LCDSY) for LCD display  
expansion. Data written to the LCD display RAM can be transferred to the segment signal pins automatically without  
program control.  
When a subsystem clock is selected as the LCD clock source, the LCD display is enabled even during main clock  
stop and idle modes.  
VLC1-VLC5  
5
COM0-COM7  
SEG0-SEG39  
LCD  
Controller/  
Driver  
8
8
40  
SEG32-SEG39/  
P5.0-P5.7  
8
Figure 12-1. LCD Function Diagram  
12-1  
LCD CONTROLLER/DRIVER  
LCD CIRCUIT DIAGRAM  
S3C72K8/P72K8  
SEG39/P5.7  
SEG32P5.0  
Display  
RAM  
MUX  
Selector  
40  
80  
SEG31  
SEG0  
(Bank "1")  
f
LCD  
LMOD  
LCON  
COM7  
COM0  
Timing  
Controller  
COM  
Control  
LCD  
Voltage  
Control  
V
LC5  
LC1  
V
LCDSY  
LCDCK  
PM3.2  
P3.3 Latch  
P3.2 Latch  
PM3.2  
Figure 12-2. LCD Circuit Diagram  
12-2  
S3C72K8/P72K8  
LCD CONTROLLER/DRIVER  
LCD RAM ADDRESS AREA  
RAM addresses of bank 1 are used as LCD data memory. These locations can be addressed by 1-bit, 4-bit, or 8-bit  
instructions. When the bit value of a display segment is "1", the LCD display is turned on; when the bit value is "0",  
the display is turned off.  
Display RAM data are sent out through segment pins SEG0–SEG40 using a direct memory access (DMA) method  
that is synchronized with the f  
signal. RAM addresses in this location that are not used for LCD display can be  
LCD  
allocated to general-purpose use.  
SEG39  
1FFH.3  
1FFH.2  
1FDH.2  
1FBH.2  
1F9H.2  
1F7H.2  
1F5H.2  
1F3H.2  
1F1H.2  
1EFH.2  
1FFH.1  
1FDH.1  
1FBH.1  
1F9H.1  
1F7H.1  
1F5H.1  
1F3H.1  
1F1H.1  
1EFH.1  
1FFH.0  
1FDH.0  
1FBH.0  
1F9H.0  
1F7H.0  
1F5H.0  
1F3H.0  
1F1H.0  
1EFH.0  
1FEH.3  
1FCH.3  
1FAH.3  
1F8H.3  
1F6H.3  
1F4H.3  
1F2H.3  
1F0H.3  
1EEH.3  
1FEH.2  
1FCH.2  
1FAH.2  
1F8H.2  
1F6H.2  
1F4H.2  
1F2H.2  
1F0H.2  
1EEH.2  
1FEH.1  
1FCH.1  
1FAH.1  
1F8H.1  
1F6H.1  
1F4H.1  
1F2H.1  
1F0H.1  
1EEH.1  
1FEH.0  
1FCH.0  
1FAH.0  
1F8H.0  
1F6H.0  
1F4H.0  
1F2H.0  
1F0H.0  
1EEH.0  
P5.7  
P5.6  
P5.5  
P5.4  
P5.3  
P5.2  
P5.1  
P5.0  
SEG38 1FDH.3  
SEG37 1FBH.3  
SEG36  
SEG35  
SEG34  
SEG33  
SEG32  
1F9H.3  
1F7H.3  
1F5H.3  
1F3H.3  
1F1H.3  
SEG31 1EFH.3  
SEG3  
SEG2  
SEG1  
SEG0  
1B7H.3  
1B5H.3  
1B3H.3  
1B1H.3  
1B7H.2  
1B5H.2  
1B3H.2  
1B1H.2  
1B7H.1  
1B5H.1  
1B3H.1  
1B1H.1  
1B7H.0  
1B5H.0  
1B3H.0  
1B1H.0  
1B6H.3  
1B4H.3  
1B2H.3  
1B0H.3  
1B6H.2  
1B4H.2  
1B2H.2  
1B0H.2  
1B6H.1  
1B4H.1  
1B2H.1  
1B0H.1  
1B6H.0  
1B4H.0  
1B2H.0  
1B0H.0  
COM7  
COM6  
COM5  
COM4  
COM3  
COM2  
COM1  
COM0  
Figure 12-3. LCD Display Data RAM Organization  
1-Bit Output  
The eight pins (P5.0-P5.7) of the 40 segment output can be set in 4-bits for 1-bit level output by LMOD.6 and  
LMOD.7. The 1F0H.0 in LCD display RAM is used as the output latch for P5.0, 1F2H.0 is for 5, 1, …. and 1FEH.0 is  
for P5.7.  
12-3  
LCD CONTROLLER/DRIVER  
S3C72K8/P72K8  
Table 12-1. Common and Segment Pins per Duty Cycle  
Duty  
1/8  
Common Pins  
COM0–COM7  
COM0–COM3  
COM0–COM2  
Segment Pins  
Dot Number  
32–40 pins  
256 dots–320 dots  
128 dots–160 dots  
96 dots–120 dots  
1/4  
1/3  
LCD CONTROL REGISTER (LCON)  
The LCD control register (LCON) is used to turn the LCD display on and off, to select duty, to output LCD SEG  
expand signal for LCD display expansion, and to control the flow of current to dividing resistors in the LCD circuit.  
Following a RESET, all LCON values are cleared to "0". This turns the LCD display off and stops the flow of current  
to the dividing resistors.  
LCON  
LCON.3  
LCON.2  
LCON.1  
LCON.0  
F8EH  
Table 12-2. LCD Control Register (LCON) Organization  
LCON Bit  
Setting  
Description  
1/4 bias select  
LCON.3  
0
1
0
1
0
1
0
1
1/3 bias select  
LCON.2  
LCON.1  
LCON.0  
Disable LCDCK andLCDSY signal outputs  
Enable LCDCK andLCDSY signal outputs  
LCD display off (All COM/SEG pins are high output)  
LCD display on  
Turn off the internal LCD bias TR  
Turn on the internal LCD bias TR  
NOTES:  
1. In case of LCON.0, you can turn on/off internal LCD bias TR.  
2. In case of internal LCD bias  
When LCON.1–.0 = #00B, LCD display is turned off. When LCON.1–.0 = #11B, LCD display is turned on.  
3. In case of external LCD bias  
When LCON.1–.0 = #00B and VLC5 = "High", LCD display is turned off.  
When LCON.1–.0 = #10B and VLC5 = "Low", LCD display is turned on  
4. To select LCD bias, you must use both the LCON.3 setting and an external LCD bias circuit connection.  
Table 12-3. LMOD.1–0 Bits Settings  
LMOD.1–0  
COM0–COM7  
SEG0–SEG39  
SEG32/P5.0–SEG39/P5.7  
Power Supply to the  
Dividing Resistor  
On  
0, 0  
0, 1  
1, 1  
All of the LCD dots off  
All of the LCD dots on  
Common and segment signal output  
corresponds to display data (normal  
display mode)  
1-bit output function  
12-4  
S3C72K8/P72K8  
LCD CONTROLLER/DRIVER  
LCD MODE REGISTER (LMOD)  
The LCD mode control register LMOD is used to control display mode; LCD clock, segment or port output, and  
display on/off. LMOD can be manipulated using 8-bit write instructions.  
The LCD clock signal, LCDCK, determines the frequency of COM signal scanning of each segment output. This is  
also referred to as the 'frame frequency. Since LCDCK is generated by dividing the watch timer clock (fw), the  
watch timer must be enabled when the LCD display is turned on.  
The LCD display can continue to operate during idle and stop modes if a subsystem clock is used as the watch  
timer source. The LCD mode register LMOD controls the output mode of the 8 pins used for normal outputs (P5.0–  
P5.7). Bits LMOD.7–5 define the segment output and normal bit output configuration.  
Table 12-4. LCD Clock Signal (LCDCK) Frame Frequency  
LCDCK  
128 Hz  
256 Hz  
512 Hz  
1024 Hz  
2048 Hz  
4096 Hz  
Display Duty Cycle  
1/8  
1/4  
1/3  
64  
128  
256  
256  
512  
512  
64  
128  
42.7  
85.3  
170.7  
341.3  
NOTE: fw = 32.768 kHz  
COM0  
1 Frame  
12-5  
LCD CONTROLLER/DRIVER  
S3C72K8/P72K8  
Table 12-5. LCD Mode Register (LMOD) Organization  
Segment /Output Port Selection Bits  
LMOD.7  
LMOD.6  
SEG39–36  
SEG35–32  
Total Number  
of Segment  
0
0
1
1
0
1
0
1
SEG port  
SEG port  
SEG port  
Output port  
SEG port  
40  
36  
36  
32  
Output port  
Output port  
Output port  
LCD Clock Selection Bits  
LMOD.5  
LMOD.4  
LCD Clock (LCDCK)  
1/8 duty (COM0–COM7)  
1/4 duty (COM0–COM3)  
1/3 duty (COM0–COM2)  
6
7
8
0
0
1
1
0
1
0
1
fxx/2 (512 Hz)  
fxx/2 (256 Hz)  
fxx/2 (128 Hz)  
5
6
7
fxx/2 (1024 Hz)  
fxx/2 (512 Hz)  
fxx/2 (256 Hz)  
4
5
6
fxx/2 (2048 Hz)  
fxx/2 (1024 Hz)  
fxx/2 (512 Hz)  
3
4
5
fxx/2 (4096 Hz)  
fxx/2 (2048 Hz)  
fxx/2 (1024 Hz)  
NOTE: LCDCK is supplied only when the watch timer operates. To use the LCD controller, bit-2 in the watch mode  
register WMOD should be set to 1.  
Display Mode Selection Bits  
LMOD.3  
LMOD.2  
Duty  
0
1
1
0
0
1
1/8 duty (COM0–COM7 select)  
1/4 duty (COM0–COM3 select)  
1/3 duty (COM0–COM2 select)  
Display Mode Selection Bits  
LMOD.1  
LMOD.0  
Function  
0
0
1
0
1
0
All LCD dots off  
All LCD dots on  
Normal display  
12-6  
S3C72K8/P72K8  
LCD CONTROLLER/DRIVER  
LCD VOLTAGE DIVIDING METHOD  
Power can be supplied without an external dividing resistor. Figure 12-4 shows the bias connections for the  
S3C72K8 LCD drive power supply.  
1/4 Bais  
1/3 Bais  
S3C72K8  
S3C72K8  
VCL1  
VCL2  
VCL3  
VCL4  
VCL5  
VCL1  
VCL2  
VCL3  
VCL4  
VCL5  
Figure 12-4. LCD Bias Circuit Connection  
12-7  
LCD CONTROLLER/DRIVER  
S3C72K8/P72K8  
APPLICATION WITHOUT CONTRAST CONTROL  
If you use an internal transistor (LCON.0) to turn on/off 'LCD display', you can get a merit that peripheral circuits are  
simple. But in that case, you can't control LCD contrast.  
Application With Internal Resistor  
VDD  
S3C72K8  
VCL1  
VCL2  
VCL3  
VCL4  
VCL5  
VLCD  
LCON.0 (3)  
VSS  
NOTES:  
1. A 1/4 bias is assumed for the above circuits; a 1/3 bias is assumed for Figure 12-5.  
2. Whe you turn off the LCD display using LCON settings, the amount of current flowing  
through the dividing resistors is reduced more than when you use LMOD to turn off the  
display.  
3. When LCON.1-0 = #00B, LCD display is turned off. When LCON.1-0 = #11B, LCD  
display is turned on.  
Figure 12-5. Connection For LCD On/Off Using Internal Transistor  
12-8  
S3C72K8/P72K8  
LCD CONTROLLER/DRIVER  
APPLICATION WITH CONTRAST CONTROL  
If only turn on/off 'LCD display' using external output pin, you can control LCD contrast using variable resistor.  
Application With External Resistor  
VDD  
S3C72K8  
VCL1  
VCL2  
VCL3  
VCL4  
VCL5  
VLCD  
LCON.0  
VR  
(Always "0")  
Px.b (3)  
VSS  
NOTES:  
1. A 1/4 bias is assumed for the above circuits; a 1/3 bias is assumed for Figure 12-6.  
2. Whe you turn off the LCD display using LCON settings, the amount of current flowing  
through the dividing resistors is reduced more than when you use LMOD to turn off the  
display.  
3. When LCON.1-0 = #00B and Px.b = "High", LCD display is turned off.  
When LCON.1-0 = #10B and Px.b = "Low", LCD display is turned on.  
Figure 12-6. Connection For LCD On/Off Using External Output Pin  
12-9  
LCD CONTROLLER/DRIVER  
COMMON (COM) SIGNALS  
S3C72K8/P72K8  
The common signal output pin selection (COM pin selection) varies according to the selected duty cycle.  
— In 1/8 duty mode, COM0–COM7 pins are selected  
— In 1/4 duty mode, COM0–COM3 pins are selected  
— In 1/3 duty mode, COM0–COM2 pins are selected  
SEGMENT (SEG) SIGNALS  
The 40 LCD segment signal pins are connected to corresponding display RAM locations at bank 1. Bits of the  
display RAM are synchronized with the common signal output pins.  
When the bit value of a display RAM location is "1", a select signal is sent to the corresponding segment pin. When  
the display bit is "0", a 'no-select' signal is sent to the corresponding segment pin.  
12-10  
S3C72K8/P72K8  
LCD CONTROLLER/DRIVER  
COM0  
COM1  
COM2  
COM3  
COM4  
COM5  
COM6  
COM7  
0
1 2 3 4 5 6 7 0 1 2 3 4 5 6 7  
V
DD  
SS  
V
FR  
1 Frame  
V
V
V
V
V
DD  
S S S S S  
LC1  
E E E E E  
G G G G G  
0 1 2 3 4  
COM0  
LC2 (VLC3  
)
)
)
LC4  
LC5  
V
V
V
V
V
DD  
LC1  
COM1  
COM2  
SEG0  
LC2 (VLC3  
LC4  
LC5  
V
V
V
V
V
DD  
LC1  
LC2 (VLC3  
LC4  
LC5  
V
V
V
V
V
DD  
LC1  
LC2 (VLC3  
)
)
LC4  
LC5  
V
V
V
V
LC1  
LC2 (VLC3  
LC4  
LC5  
SEG0-COM0  
0V  
-VLC5  
-VLC4  
-VLC2 (-VLC3  
)
-VLC1  
Figure 12-7. LCD Signal Waveforms (1/8 Duty, 1/4 Bias)  
12-11  
LCD CONTROLLER/DRIVER  
S3C72K8/P72K8  
0
1 2 3 4 5 6 7 0 1 2 3 4 5 6 7  
V
DD  
SS  
V
FR  
1 Frame  
V
V
V
LC1  
LC2 (VLC4  
)
SEG1  
LC4  
V
LC5  
SS  
V
V
V
V
V
LC1  
LC2 (VLC3  
)
LC4  
LC5  
SEG1-COM0  
0V  
-VLC5  
-VLC4  
-VLC2 (-VLC3  
)
-VLC1  
Figure 12-7. LCD Signal Waveforms (1/8 Duty, 1/4 Bias) (Continued)  
12-12  
S3C72K8/P72K8  
LCD CONTROLLER/DRIVER  
SEG0  
SEG1  
3
0
1
2
3
0
1
2
V
DD  
SS  
V
COM0  
COM1  
COM2  
COM3  
1 Frame  
V
V
V
V
DD  
LC1(VLC2  
LC3(VLC4  
SS  
)
COM0  
COM1  
COM2  
COM3  
SEG0  
SEG1  
)
V
V
V
V
DD  
LC1(VLC2  
LC3(VLC4  
SS  
)
)
VDD  
VLC1(VLC2  
VLC3(VLC4  
VSS  
)
)
V
V
V
V
DD  
LC1(VLC2  
LC3(VLC4  
SS  
)
)
V
V
V
V
DD  
LC1(VLC2  
LC3(VLC4  
SS  
)
)
VDD  
VLC1(VLC2  
VLC3(VLC4  
VSS  
)
)
+ VLCD  
+ 1/3 VLCD  
0V  
COM0-SEG0  
- 1/3 VLCD  
- VLCD  
Figure 12-8. LCD Signal Waveforms (1/4 Duty, 1/3 Bias)  
12-13  
LCD CONTROLLER/DRIVER  
S3C72K8/P72K8  
SEG1  
SEG0  
SEG2  
1
0
1
2
0
2
V
DD  
SS  
V
COM0  
1 Frame  
V
V
V
V
DD  
COM1  
COM2  
LC1(VLC2  
LC3(VLC4  
SS  
)
COM0  
COM1  
COM2  
SEG0  
SEG1  
)
V
V
V
V
DD  
LC1(VLC2  
LC3(VLC4  
SS  
)
)
V
V
V
V
DD  
LC1(VLC2  
LC3(VLC4  
SS  
)
)
V
V
V
V
DD  
LC1(VLC2  
LC3(VLC4  
SS  
)
)
V
V
V
V
DD  
LC1(VLC2  
LC3(VLC4  
SS  
)
)
+ VLCD  
+ 1/3 VLCD  
0V  
COM0-SEG0  
- 1/3 VLCD  
- VLCD  
Figure 12-9. LCD Signal Waveforms (1/3 Duty, 1/3 Bias)  
12-14  
S3C72K8/P72K8  
COMPARATOR  
13 COMPARATOR  
OVERVIEW  
P1.0,and P1.1 can be used as a analog input port for a comparator. The reference voltage for the 2-channel  
comparator can be supplied either internally or externally at P1.0. When an internal reference voltage is used, two  
channels (P1.0–P1.1) are used for analog inputs and the internal reference voltage is varied in 16 levels. If an  
external reference voltage is input at P1.0, the other P1.1 pins are used for analog input.  
When a conversion is completed, the result is saved in the comparison result register CMPREG. The initial values of  
the CMPREG are undefined and the comparator operation is disabled by a RESET. The comparator module has the  
following components:  
— Comparator  
— Internal reference voltage generator (4-bit resolution)  
— External reference voltage source at P1.0  
— Comparator mode register (CMOD)  
— Comparison result register (CMPREG)  
13-1  
COMPARATOR  
S3C72K8/P72K8  
P1.0/CIN0/INT0  
MUX  
+
-
Comparison  
Result  
Register  
4
P1.1/CIN1/INT1  
(CMPREG)  
VREF  
(External)  
MUX  
VDD  
CMOD.7  
CMOD.6  
CMOD.5  
0
1/2R  
R
R
VREF  
(Internal)  
8
MUX  
CMOD.3  
CMOD.2  
CMOD.1  
CMOD.0  
1/2R  
NOTES:  
1. INT occures only for digital input selecting: for analog input, any INT doesn't.  
2. The cpmparison results of CIN0, and CIN1 are respectively stored in  
CMPREG.0 and CMPREG.1.  
Figure 13-1. Comparator Circuit Diagram  
13-2  
S3C72K8/P72K8  
COMPARATOR  
COMPARATOR MODE REGISTER (CMOD)  
The comparator mode register CMOD is an 8-bit register that is used to select the operation mode of the  
comparator. It is mapped to addresses FD2H–FD3H and can be manipulated using 8-bit memory instructions.  
Based on the CMOD.5 bit setting, an internal or an external reference voltage is input for the comparator, as follows:  
When CMOD.5 is set to logic zero:  
— A reference voltage is selected by the CMOD.0 to CMOD.3 bit settings.  
— P1.0 to P1.1 are used as analog input pins.  
— The internal digital to analog converter generates 16 reference voltages.  
— The comparator can detect 150 mV differences between the reference voltage and the analog input voltages.  
— Comparator results are written into bit-0 to bit-2 of the comparison result register (CMPREG).  
When CMOD.5 is set to logic one:  
— An external reference voltage is supplied from P1.0/CIN0.  
— P1.1 is used as the analog input pins.  
— The comparator can detect 150 mV differences between the reference voltage and the analog input voltages.  
— Bits 0 and 1 in the CMPREG register contain the results.  
Bit 6 in the CMOD register controls conversion time while bit 7 enables or disables comparator operation to reduce  
power consumption. A RESET signal clears all bits to logic zero, causing the comparator to enter stop mode.  
CMOD.7  
CMOD.6  
CMOD.5  
"0"  
CMOD.3  
CMOD.2  
CMOD.1  
CMOD.0  
FD6H-FD7H  
Reference voltage (V REF) selection;  
DD x (n + 0.5)/16, n = 0 to 15  
V
1: CIN0; external reference, CIN1; analog input  
0: Internal reference, CIN0-1; analog input  
1: Conversion time (4 x 2 5/fx, 30.5  
0: Conversion time (4 x 2 6/fx, 244.4  
m
m
s @4.19 MHz)  
s @4.19 MHz)  
1: Comparator operation enable  
0: Comparator operation disable  
Figure 13-2. Comparator Mode Register (CMOD) Organization  
13-3  
COMPARATOR  
S3C72K8/P72K8  
PORT 1 MODE REGISTER (P1MOD)  
P1MOD register settings determine if P1.0 and P1.1 are used for analog or digital input. The P1MOD register is 4-bit  
write-only register. P1MOD is mapped to address FE2H. A reset operation initializes all P1MOD register values to  
zero, configuring P1.0 and P1.1 as a digital input port.  
FE2H  
"0"  
"0"  
P1MOD.1 P1MOD.0  
When a P1MOD bit is set to "0", the corresponding pin is configured as a digital input pin. When set to "1", it is  
configured as an analog input pin: P1MOD.0 for P1.0, and P1MOD.1 for P1.1.  
COMPARATOR OPERATION  
The comparator compares analog voltage input at CIN0–CIN2 with an external or internal reference voltage (V  
)
REF  
that is selected by the CMOD register. The result is written to the comparison result register CMPREG at address  
FD4H. The comparison result at internal reference is calculated as follows:  
If "1" Analog input voltage ³ V  
+ 150 mV  
– 150 mV  
REF  
REF  
If "0" Analog input voltage £ V  
To obtain a comparison result, the data must be read out from the CMPREG register after V  
changing the CMOD value after a conversion time has elapsed.  
is updated by  
REF  
Analog Input  
Voltage (CIN0-2)  
Reference  
Voltage (VREF  
)
Comparsion Time  
(CMPCLK x 8)  
Comparator Clock  
(CMPCLK, fx/16, fx/128)  
Comparison  
Start  
Comparison  
End  
Comparison  
Result (CMPREG)  
Unkwon  
1
1
Unkwon  
0
Figure 13-3. Conversion Characteristics  
13-4  
S3C72K8/P72K8  
COMPARATOR  
F
PROGRAMMING TIP — Programming the Comparator  
The following code converts the analog voltage input at the CIN0–CIN1 pins into 4-bit digital code.  
BITR  
LD  
EMB  
A,#0H  
LD  
LD  
P1MOD,A  
EA,#0CXH  
;
;
;
Analog input selection (CIN0–CIN1)  
x = 0–F, comparator enable  
Internal reference, conversion time (7.6 ms at 4.19 MHz)  
LD  
LD  
INCS  
JR  
CMOD,EA  
A,#0H  
A
WAIT  
WAIT  
LD  
LD  
A,CMPREG  
P2,A  
;
;
Read the result  
Output the result from port 2  
13-5  
COMPARATOR  
S3C72K8/P72K8  
NOTES  
13-6  
S3C72K8/P72K8  
SERIAL I/O INTERFACE  
14 SERIAL I/O INTERFACE  
OVERVIEW  
The serial I/O interface (SIO) has the following functional components:  
— 8-bit mode register (SMOD)  
— Clock selector circuit  
— 8-bit buffer register (SBUF)  
— 3-bit serial clock counter  
Using the serial I/O interface, 8-bit data can be exchanged with an external device. The transmission frequency is  
controlled by making the appropriate bit settings to the SMOD register.  
The serial interface can run off an internal or an external clock source, or the TOL0 signal that is generated by the 8-  
bit timer/counter, TC0. If the TOL0 clock signal is used, you can modify its frequency to adjust the serial data  
transmission rate.  
SERIAL I/O OPERATION SEQUENCE  
The general operation sequence of the serial I/O interface can be summarized as follows:  
1. Set SIO mode to transmit-and-receive or to receive-only.  
2. Select MSB-first or LSB-first transmission mode.  
3. Set the SCK clock signal in the mode register, SMOD.  
4. Set SIO interrupt enable flag (IES) to "1".  
5. Initiate SIO transmission by setting bit 3 of the SMOD to "1".  
6. When the SIO operation is complete, IRQS flag is set and an interrupt is generated.  
14-1  
SERIAL I/O INTERFACE  
S3C72K8/P72K8  
Internal Bus  
8
LSB or MSB first  
SO  
SBUF (8-bit)  
SI  
R
Over Flow  
Q
D
IRQS  
CK  
P0.0/SCK  
TOL0  
CPU CLK  
fxx/2 10  
Q0  
Q1  
Q2  
3-Bit Counter  
Clock  
Selector  
R
S
Q
fxx/2 4  
Clear  
-
SMOD.7 SMOD.6 SMOD.5  
SMOD.3 SMOD.2 SMOD.1 SMOD.0  
(note)  
8
BITS  
Internal Bus  
NOTE: Instruction Execution  
Figure 14-1. Serial I/O Interface Circuit Diagram  
14-2  
S3C72K8/P72K8  
SERIAL I/O INTERFACE  
SERIAL I/O MODE REGISTER (SMOD)  
The serial I/O mode register, SMOD, is an 8-bit register that specifies the operation mode of the serial interface. Its  
reset value is logical zero. SMOD is organized in two 4-bit registers, as follows:  
FE0H  
FE1H  
SMOD.3  
SMOD.7  
SMOD.2  
SMOD.6  
SMOD.1  
SMOD.5  
SMOD.0  
0
SMOD register settings enable you to select either MSB-first or LSB-first serial transmission, and to operate in  
transmit-and-receive mode or receive-only mode. SMOD is a write-only register and can be addressed only by 8-bit  
RAM control instructions. One exception to this is SMOD.3, which can be written by a 1-bit RAM control instruction.  
When SMOD.3 is set to 1, the contents of the serial interface interrupt request flag, IRQS, and the 3-bit serial clock  
counter are cleared, and SIO operations are initiated. When the SIO transmission starts, SMOD.3 is cleared to  
logical zero.  
Table 14-1. SIO Mode Register (SMOD) Organization  
SMOD.0  
SMOD.1  
SMOD.2  
0
1
0
1
0
Most significant bit (MSB) is transmitted first  
Least significant bit (LSB) is transmitted first  
Receive-only mode  
Transmit-and-receive mode  
Disable the data shifter and clock counter; retain contents of IRQS flag when serial  
transmission is halted  
1
1
0
Enable the data shifter and clock counter; set IRQS flag to "1" when serial  
transmission is halted  
SMOD.3  
SMOD.4  
Clear IRQS flag and 3-bit clock counter to "0"; initiate transmission and then reset this  
bit to logic zero  
Bit not used; value is always "0"  
SMOD.7  
SMOD.6  
SMOD.5  
Clock Selection  
R/W Status of SBUF  
0
0
0
SBUF is enabled when SIO  
External clock at SCK pin  
operation is halted or when SCK  
goes high.  
0
0
1
0
1
0
1
x
0
Use TOL0 clock from TC0  
CPU clock: fxx/4, fxx/8, fxx/64  
Enable SBUF read/write  
10  
SBUF is enabled when SIO  
4.09 kHz clock: fxx/2  
operation is halted or when SCK  
goes high.  
4
1
1
1
262 kHz clock: fxx/2  
NOTES:  
1. 'fxx' = system clock; 'x' means 'don't care'.  
2. kHz frequency ratings assume a system clock (fxx) running at 4.19 MHz.  
3. The SIO clock selector circuit cannot select a fxx/24 clock if the CPU clock is fxx/64.  
4. It must be selected MSB-first or LSB-first transmission mode before loading a data to SBUF.  
14-3  
SERIAL I/O INTERFACE  
S3C72K8/P72K8  
SERIAL I/O TIMING DIAGRAMS  
SCK  
SI  
SO  
DI7  
DI6  
DI5  
DI4  
DI3  
DI2  
DI1  
DI0  
DO7  
DO6  
DO5  
DO4  
DO3  
DO2  
DO1  
DO0  
Transmit  
Complete  
IRQS  
SET SMOD.3  
Figure 14-2. SIO Timing in Transmit/Receive Mode  
SCK  
SI  
DI7  
DI6  
DI5  
DI4  
DI3  
DI2  
DI1  
DI0  
High Impedance  
SO  
Transmit  
Complete  
IRQS  
SET SMOD.3  
Figure 14-3. SIO Timing in Receive-Only Mode  
14-4  
S3C72K8/P72K8  
SERIAL I/O INTERFACE  
SERIAL I/O BUFFER REGISTER (SBUF)  
The serial I/O buffer register ,SBUF, can be read or written using 8-bit RAM control instructions. Following a RESET,  
the value of SBUF is undetermined.  
When the serial interface operates in transmit-and-receive mode (SMOD.1 = "1"), transmit data in the SIO buffer  
register are output to the SO pin (P0.1) at the rate of one bit for each falling edge of the SIO clock. Receive data are  
simultaneously input from the SI pin (P0.2) to SBUF at the rate of one bit for each rising edge of the SIO clock.  
When receive-only mode is used, incoming data are input to the SIO buffer at the rate of one bit for each rising edge  
of the SIO clock.  
F
PROGRAMMING TIP — Setting Transmit/Receive Modes for Serial I/O  
4
1. Transmit the data value 48H through the serial I/O interface using an internal clock frequency of fxx/2 and in  
MSB-first mode:  
BITS  
SMB  
LD  
EMB  
15  
EA,#03H  
LD  
LD  
LD  
LD  
LD  
PMG1,EA  
EA,#48H  
SBUF,EA  
EA,#0EEH  
SMOD,EA  
;
;
P0.0/SCK and P0.1 / SO ¬ Output  
SIO data transfer  
SCK/P0.0  
External  
Device  
SO/P0.1  
[S3C72K8]  
2. Use CPU clock to transfer and receive serial data at high speed:  
BITR  
LD  
EMB  
EA,#03H  
LD  
LD  
LD  
LD  
PMG1,EA  
EA,TDATA  
SBUF,EA  
EA,#4FH  
SMOD,EA  
IES  
;
;
P0.0/SCK and P0.1/SO ¬ Output, P0.2/SI ¬ Input  
TDATA address = Bank0 (20H–7FH)  
LD  
;
SIO start  
BITR  
BTSTZ  
JR  
STEST  
IRQS  
STEST  
LD  
SMB  
LD  
EA,SBUF  
0
RDATA,EA  
;
RDATA address = Bank0 (20H–7FH)  
14-5  
SERIAL I/O INTERFACE  
S3C72K8/P72K8  
F
PROGRAMMING TIP — Setting Transmit/Receive Modes for Serial I/O (Continued)  
3. Transmit and receive an internal clock frequency of 4.09 kHz (at 4.19 MHz) in LSB-first mode:  
BITR  
LD  
EMB  
EA,#03H  
LD  
LD  
LD  
LD  
LD  
EI  
PMG1,EA  
EA,TDATA  
SBUF,EA  
EA,#8FH  
;
;
P0.0/SCK and P0.1/SO ¬ Output, P0.2/SI ¬ Input  
TDATA address = Bank0 (20H–7FH)  
SMOD,EA  
;
SIO start  
BITS  
IES  
.
.
INTS  
PUSH  
PUSH  
BITR  
LD  
SB  
EA  
EMB  
EA,TDATA  
;
;
Store SMB, SRB  
Store EA  
;
;
;
;
;
EA ¬ Transmit data  
TDATA address = Bank0 (20H–7FH)  
Transmit data « Receive data  
RDATA address = Bank0 (20H–7FH)  
SIO start  
XCH  
LD  
BITS  
POP  
POP  
IRET  
EA,SBUF  
RDATA,EA  
SMOD.3  
EA  
SB  
SCK/P0.0  
SO/P0.1  
SI/P0.2  
External  
Device  
[S3C72K8]  
14-6  
S3C72K8/P72K8  
SERIAL I/O INTERFACE  
F
PROGRAMMING TIP — Setting Transmit/Receive Modes for Serial I/O (Continued)  
4. Transmit and receive an external clock in LSB-first mode:  
BITR  
LD  
EMB  
EA,#02H  
LD  
LD  
LD  
LD  
LD  
EI  
PMG1,EA  
EA,TDATA  
SBUF,EA  
EA,#0FH  
;
;
P0.1/SO ¬ Output, P0.0/SCK and P0.2/SI ¬ Input  
TDATA address = Bank0 (20H–7FH)  
SMOD,EA  
;
SIO start  
BITS  
IES  
.
.
INTS  
PUSH  
PUSH  
BITR  
LD  
SB  
EA  
EMB  
EA,TDATA  
;
;
Store SMB, SRB  
Store EA  
;
;
;
;
;
EA ¬ Transmit data  
TDATA address = Bank0 (20H–7FH)  
Transmit data « Receive data  
RDATA address = Bank0 (20H–7FH)  
SIO start  
XCH  
LD  
BITS  
POP  
POP  
IRET  
EA,SBUF  
RDATA,EA  
SMOD.3  
EA  
SB  
SCK/P0.0  
SO/P0.1  
SI/P0.2  
External  
Device  
[S3C72K8]  
High Speed SIO Transmission  
14-7  
SERIAL I/O INTERFACE  
S3C72K8/P72K8  
NOTES  
14-8  
S3C72K8/P72K8  
ELECTRICAL DATA  
15 ELECTRICAL DATA  
OVERVIEW  
In this section, information on S3C72K8 electrical characteristics is presented as tables and graphics. The  
information is arranged in the following order:  
Standard Electrical Characteristics  
— Absolute maximum ratings  
— D.C. electrical characteristics  
— Main system clock oscillator characteristics  
— Subsystem clock oscillator characteristics  
— I/O capacitance  
— Comparator electrical characteristics  
— A.C. electrical characteristics  
— Operating voltage range  
Stop Mode Characteristics and Timing Waveforms  
— RAM data retention supply voltage in stop mode  
— Stop mode release timing when initiated by RESET  
— Stop mode release timing when initiated by an interrupt request  
Miscellaneous Timing Waveforms  
— A.C timing measurement points  
— Clock timing measurement at X  
IN  
— Clock timing measurement at XT  
IN  
— TCL timing  
— Input timing for RESET signal  
— Input timing for external interrupts  
— Serial data transfer timing  
15-1  
ELECTRICAL DATA  
S3C72K8/P72K8  
Table 15-1. Absolute Maximum Ratings  
°
(T = 25 C)  
A
Parameter  
Symbol  
Conditions  
Rating  
Units  
Supply Voltage  
Input Voltage  
V
– 0.3 to + 6.5  
V
DD  
V
All I/O pins active  
– 0.3 to V + 0.3  
V
V
I1  
O
DD  
Output Voltage  
Output Current High  
V
– 0.3 to V + 0.3  
DD  
I
One I/O pin active  
– 15  
mA  
OH  
All I/O pins active  
One I/O pin active  
– 35  
Output Current Low  
I
+ 30 (Peak value)  
mA  
OL  
(note)  
+ 15  
All I/O port, total  
+ 100 (Peak value)  
(note)  
+ 60  
°
Operating Temperature  
Storage Temperature  
T
– 40 to + 85  
– 65 to + 150  
C
A
°
T
C
stg  
NOTE: The values for Output Current Low ( IOL ) are calculated as Peak Value ´  
Duty .  
15-2  
S3C72K8/P72K8  
ELECTRICAL DATA  
Table 15-2. D.C. Electrical Characteristics  
°
°
(T = – 40 C to + 85 C, V  
= 2.0 V to 5.5 V)  
DD  
A
Parameter Symbol  
Conditions  
Min  
Typ  
Max  
Units  
Input High  
Voltage  
V
Ports 2, 3, P4.0 and P4.2  
0.7 V  
V
V
IH1  
DD  
DD  
V
V
0.8 V  
V
V
Ports 0, 1, P4.1 and RESET  
IH2  
IH3  
DD  
DD  
DD  
X , X  
and XT  
V
– 0.1  
DD  
IN  
OUT  
IN  
Input Low  
Voltage  
V
Ports 2, 3, P4.0 and P4.2  
0.3 V  
V
V
IL1  
DD  
V
V
0.2 V  
0.1  
Ports 0, 1, P4.1 and RESET  
IL2  
IL3  
DD  
X , X  
and XT  
IN  
IN  
OUT  
Output High  
Voltage  
V
V
= 4.5 V to 5.5 V  
V
V
– 2.0  
– 2.0  
V
– 0.4  
DD  
OH1  
DD  
DD  
DD  
I
= – 3 mA  
OH  
Ports 0, 2, 3 and 4  
V
V
= 4.5 V to 5.5 V  
0.4  
2
1
3
OH2  
DD  
I
= – 100 mA  
OH  
Ports 5  
Output Low  
Voltage  
V
V
I
V
= 4.5 V to 5.5 V  
DD  
V
OL1  
OL2  
I
= 15 mA  
OL  
Ports 0, 2, 3 and 4  
V
= 4.5 V to 5.5 V  
DD  
I
= – 100 mA  
OH  
Ports 5  
= V  
DD  
Input High  
Leakage  
Current  
V
mA  
mA  
LIH1  
IN  
All input pins except those specified  
below for I  
LIH2  
I
V
= V  
DD  
20  
LIH2  
IN  
X , X  
and XT  
IN  
IN  
OUT  
Input Low  
Leakage  
Current  
I
V
= 0 V  
IN  
– 3  
LIL1  
All input pins except X , X , XT ,  
IN  
OUT  
IN  
and RESET  
= 0 V  
I
V
– 20  
3
LIL2  
IN  
X , X  
and XT  
IN  
IN  
OUT  
Output High  
Leakage  
Current  
Output Low  
Leakage  
Current  
I
V = V  
mA  
mA  
LOH  
O
DD  
All output pins  
I
V = 0 V  
– 3  
LOL  
O
All output pins  
15-3  
ELECTRICAL DATA  
S3C72K8/P72K8  
Table 15-2. D.C. Electrical Characteristics (Continued)  
°
°
(T = – 40 C to + 85 C, V  
= 2.0 V to 5.5 V)  
A
DD  
Parameter Symbol  
Conditions  
Min  
Typ  
Max  
Units  
Pull-Up  
R
V
= 0 V; V = 5 V ± 10 %  
15  
40  
80  
kW  
LI  
IN  
DD  
Resistor  
Ports 0-4  
V
V
= 3 V ± 10 %  
30  
80  
200  
350  
DD  
R
= 0 V; V = 5 V ± 10 %  
150  
220  
IN  
L2  
DD  
RESET  
V
= 3 V ± 10 %  
300  
40  
400  
60  
800  
90  
DD  
LCD Voltage  
Dividing  
R
kW  
LCD  
Resistor  
V
V
V
= 2.7 V to 5.5 V  
120  
120  
mV  
|
-COMi|  
DD  
DC  
DS  
DD  
Voltage Drop  
(i = 0-7)  
– 15 mA per common pin  
V = 2.7 V to 5.5 V  
DD  
V
|
V
-SEGx|  
DD  
Voltage Drop  
(x = 0-39)  
– 15 mA per segment pin  
(1)  
V
V
0.8 V – 0.2 0.8 V  
0.8 V + 0.2  
V
V
= 2.0 V to 5.5 V  
Output  
LC1  
LC2  
DD  
DD  
DD  
DD  
Voltage  
LCD clock = 0 Hz, V  
= 0 V  
LC5  
V
V
V
V
0.6 V – 0.2 0.6 V  
0.6 V + 0.2  
Output  
LC2  
LC3  
LC4  
LC5  
DD  
DD  
DD  
DD  
DD  
Voltage  
V
0.4 V – 0.2 0.4 V  
0.4 V + 0.2  
Output  
LC3  
DD  
DD  
Voltage  
V
0.2 V – 0.2 0.2 V  
0.2 V + 0.2  
Output  
LC4  
DD  
DD  
Voltage  
15-4  
S3C72K8/P72K8  
ELECTRICAL DATA  
Table 15-2. D.C. Electrical Characteristics (Concluded)  
°
°
(T = – 40 C to + 85 C, V  
= 2.0 V to 5.5 V)  
A
DD  
Parameter  
Symbol  
Conditions  
= 5 V ± 10%  
Min  
Typ  
Max  
Units  
(2)  
Supply  
V
6.0 MHz  
4.19 MHz  
3.5  
2.5  
8.0  
5.5  
mA  
I
DD  
DD1  
(1)  
Current  
Crystal oscillator  
C1 = C2 = 22 pF  
V
= 3 V ± 10%  
6.0 MHz  
4.19 MHz  
1.8  
1.3  
4.0  
3.0  
DD  
(2)  
Idle mode  
= 5 V ± 10%  
6.0 MHz  
4.19 MHz  
1.3  
1.2  
2.5  
1.8  
I
DD2  
V
DD  
Crystal oscillator  
C1 = C2 = 22 pF  
V
= 3 V ± 10%  
6.0 MHz  
4.19 MHz  
0.5  
0.4  
1.5  
1.0  
DD  
(3)  
V
= 3 V ± 10%  
15  
30  
15  
5
mA  
I
DD  
DD3  
32 kHz crystal oscillator  
(3)  
Idle mode; V = 3 V ± 10%  
6
I
DD  
DD4  
32 kHz crystal oscillator  
I
Stop mode;  
= 5 V ± 10%  
SCMOD =  
0000B  
2.5  
DD5  
V
DD  
XT = 0V  
IN  
Stop mode;  
0.5  
3
V
= 3 V ± 10%  
DD  
V
= 5 V ± 10%  
= 3 V ± 10%  
SCMOD =  
0100B  
0.2  
0.1  
3
2
DD  
V
DD  
NOTES:  
1. Currents in the following circuits are not included; on-chip pull-up resistors, internal LCD voltage dividing resistors,  
output port drive currents, comparator.  
2. Data includes power consumption for subsystem clock oscillation.  
3. When the system clock control register, SCMOD, is set to 1001B, main system clock oscillation stops and the  
subsystem clock is used.  
4. Every values in this table is measured when the power control register (PCON) is set to "0011B".  
15-5  
ELECTRICAL DATA  
S3C72K8/P72K8  
Table 15-3. Main System Clock Oscillator Characteristics  
°
°
(T = – 40 C + 85 C, V  
= 2.0 V to 5.5 V)  
DD  
A
Oscillator  
Clock  
Configuration  
Parameter  
Test Condition  
Min  
Typ  
Max  
Units  
(1)  
Ceramic  
0.4  
6.0  
MHz  
XIN  
XOUT  
Oscillation frequency  
Oscillator  
C1  
C2  
(2)  
Stabilization occurs  
4
ms  
Stabilization time  
when V is equal to  
DD  
the minimum  
oscillator voltage  
range.  
(1)  
Crystal  
0.4  
6.0  
MHz  
XIN  
XOUT  
Oscillation frequency  
Oscillator  
C1  
C2  
(2)  
V
V
= 4.5 V to 5.5 V  
= 2.7 V to 4.5 V  
10  
30  
ms  
Stabilization time  
DD  
DD  
(1)  
External  
Clock  
0.4  
6.0  
MHz  
X
IN  
XOUT  
X input frequency  
IN  
X input high and low  
83.3  
2
1250  
ns  
IN  
level width (t , t  
)
XH XL  
RC  
Frequency  
R = 10 kW,  
V = 5 V  
DD  
MHz  
XIN  
XOUT  
Oscillator  
R
R = 30 kW,  
= 3 V  
1
V
DD  
NOTES:  
1. Oscillation frequency and X input frequency data are for oscillator characteristics only.  
IN  
2. Stabilization time is the interval required for oscillating stabilization after a power-on occurs, or when stop mode is  
terminated.  
15-6  
S3C72K8/P72K8  
ELECTRICAL DATA  
Table 15-4. Subsystem Clock Oscillator Characteristics  
°
°
(T = – 40 C + 85 C, V  
= 2.0 V to 5.5 V)  
DD  
A
Oscillator  
Clock  
Parameter  
Test Condition  
Min  
Typ  
Max  
Units  
Configuration  
(1)  
Crystal  
32  
32.768  
35  
kHz  
XTIN XT OUT  
Oscillation frequency  
Oscillator  
C1  
C2  
(2)  
V
V
= 4.5 V to 5.5 V  
1.0  
2
s
Stabilization time  
DD  
= 2.0 V to 4.5 V  
10  
DD  
(1)  
External  
Clock  
32  
100  
kHz  
XTIN XTOUT  
XT input frequency  
IN  
XT input high and low  
5
15  
ms  
IN  
level width (t  
, t  
)
XTL XTH  
NOTES:  
1. Oscillation frequency and XT input frequency data are for oscillator characteristics only.  
IN  
2. Stabilization time is the interval required for oscillating stabilization after a power-on occurs.  
15-7  
ELECTRICAL DATA  
S3C72K8/P72K8  
Table 15-5. Input/Output Capacitance  
°
(T = 25 C, V = 0 V )  
A
DD  
Parameter  
Symbol  
Condition  
Min  
Typ  
Max  
Units  
Input  
C
f = 1 MHz; Unmeasured  
15  
pF  
IN  
Capacitance  
pins are returned to V  
SS  
Output  
Capacitance  
C
15  
15  
pF  
pF  
OUT  
I/O Capacitance  
C
IO  
Table 15-6. Comparator Electrical Characteristics  
°
°
(T = – 40 C + 85 C, V  
= 4.0 V to 5.5 V)  
DD  
A
Parameter  
Symbol  
Condition  
Min  
Typ  
Max  
Units  
Input Voltage Range  
0
V
V
DD  
Reference Voltage Range  
Input Voltage Accuracy  
Input Leakage Current  
V
0
V
V
REF  
DD  
V
± 150  
mV  
mA  
CIN  
I
, I  
– 3  
3
CIN REF  
15-8  
S3C72K8/P72K8  
ELECTRICAL DATA  
Table 15-7. A.C. Electrical Characteristics  
°
°
(T = – 40 C to + 85 C, V  
= 2.0 V to 5.5 V)  
DD  
A
Parameter  
Symbol  
Conditions  
Min  
Typ  
Max  
Units  
Instruction Cycle  
t
V
V
= 2.7 V to 5.5 V  
0.67  
64  
ms  
CY  
DD  
DD  
(note)  
Time  
= 2.0 V to 5.5 V  
0.95  
114  
0
122  
64  
125  
1.5  
With subsystem clock (fxt)  
TCL0 Input  
Frequency  
f
, f  
V
= 2.7 V to 5.5 V  
MHz  
TI0 TI1  
DD  
V
V
= 2.0 V to 5.5 V  
= 2.7 V to 5.5 V  
1
DD  
DD  
TCL0 Input High,  
Low Width  
t
t
, t  
0.48  
ms  
TIH0 TIL0  
, t  
TIH1 TIL1  
V
V
= 2.0 V to 5.5 V  
1.8  
DD  
DD  
t
= 2.7 V to 5.5 V External  
800  
ns  
ns  
ns  
ns  
SCK Cycle Time  
KCY  
SCK source  
650  
Internal SCK source  
V
= 2.0 V to 5.5 V  
3200  
DD  
External SCK source  
Internal SCK source  
3800  
325  
t
, t  
V
= 2.7 V to 5.5 V  
DD  
SCK High, Low  
Width  
KH KL  
External SCK source  
Internal SCK source  
t
/2 – 50  
KCY  
V
= 2.0 V to 5.5 V  
1600  
DD  
External SCK source  
Internal SCK source  
t
KCY /2 – 150  
100  
SI Setup Time to  
t
V
= 2.7 V to 5.5 V  
DD  
SIK  
SCK High  
External SCK source  
Internal SCK source  
150  
150  
V
= 2.0 V to 5.5 V  
DD  
External SCK source  
Internal SCK source  
500  
400  
SI Hold Time to  
t
V
= 2.7 V to 5.5 V  
DD  
KSI  
SCK High  
External SCK source  
Internal SCK source  
400  
600  
V
= 2.0 V to 5.5 V  
DD  
External SCK source  
Internal SCK source  
500  
NOTE: Unless otherwise specified, Instruction Cycle Time condition values assume a main system clock ( fx ) source.  
15-9  
ELECTRICAL DATA  
S3C72K8/P72K8  
Table 15-7. A.C. Electrical Characteristics (Continued)  
°
°
(T = – 40 C to + 85 C, V  
= 2.0 V to 5.5 V)  
A
DD  
Parameter  
Symbol  
Conditions  
Min  
Typ  
Max  
Units  
Output Delay for  
t
V
= 2.7 V to 5.5 V  
DD  
300  
ns  
KSO  
SCK to SO  
External SCK source  
Internal SCK source  
250  
V
= 2.0 V to 5.5 V  
1000  
DD  
External SCK source  
Internal SCK source  
1000  
Interrupt Input  
High, Low Width  
t
, t  
INT0, INT1, INT2, INT4,  
K0–K3  
10  
10  
ms  
ms  
INTH INTL  
t
Input  
RESET Input Low  
RSL  
Width  
Main Oscillator Frequency  
(Divided by 4)  
CPU Clock  
1.5 MHz  
6 MHz  
1.05 MHz  
15.6 kHz  
4.2 MHz  
1
2
3
4
5
6
7
2.0 V 2.7 V  
Supply Voltage (V)  
CPU clock = 1/n x oscillator frequency (n = 4, 8 or 64)  
Figure 15-1. Standard Operating Voltage Range  
15-10  
S3C72K8/P72K8  
ELECTRICAL DATA  
Table 15-8. RAM Data Retention Supply Voltage in Stop Mode  
°
°
(T = – 40 C to + 85 C)  
A
Parameter  
Symbol  
Conditions  
Min  
Typ  
Max  
Unit  
Data retention supply voltage  
V
2.0  
5.5  
V
DDDR  
Data retention supply current  
I
V
= 2.0 V  
0.1  
10  
mA  
DDDR  
DDDR  
Release signal set time  
t
0
ms  
SREL  
17  
Oscillator stabilization wait  
t
ms  
Released by RESET  
2
/ fx  
WAIT  
(1)  
time  
(2)  
Released by interrupt  
NOTES:  
1. During oscillator stabilization wait time, all CPU operations must be stopped to avoid instability during oscillator  
start-up.  
2. Use the basic timer mode register (BMOD) interval timer to delay execution of CPU instructions during the wait time.  
15-11  
ELECTRICAL DATA  
S3C72K8/P72K8  
TIMING WAVEFORMS  
Internal RESET  
Operation  
Idle Mode  
Stop Mode  
Data Retention Mode  
Normal Mode  
VDD  
VDDDR  
Execution of  
STOP Instrction  
RESET  
tWAIT  
t
SREL  
Figure 15-2. Stop Mode Release Timing When Initiated By RES ET  
Idle Mode  
Normal Mode  
Stop Mode  
Data Retention Mode  
VDD  
VDDDR  
t
SREL  
Execution of  
STOP Instrction  
tWAIT  
Power-down Mode Terminating Signal  
(Interrupt Request)  
Figure 15-3. Stop Mode Release Timing When Initiated By Interrupt Request  
15-12  
S3C72K8/P72K8  
ELECTRICAL DATA  
0.8 VDD  
0.2 VDD  
0.8 VDD  
0.2 VDD  
Measurement  
Points  
Figure 15-4. A.C. Timing Measurement Points (Except for X and XT )  
IN  
IN  
1/fx  
tXL  
tXH  
XIN  
VDD - 0.1 V  
0.1 V  
Figure 15-5. Clock Timing Measurement at X  
IN  
1/fxt  
t
XTL  
tXTH  
XT IN  
VDD - 0.1 V  
0.1 V  
Figure 15-6. Clock Timing Measurement at XT  
IN  
15-13  
ELECTRICAL DATA  
S3C72K8/P72K8  
1/fTI  
t
TIL  
tTIH  
TCL0  
0.8 VDD  
0.2 VDD  
Figure 15-7. TCL Timing  
t
RSL  
RESET  
0.2 VDD  
Figure 15-8. Input Timing for RES ET Signal  
t
INTL  
tINTH  
INT0, 1, 2, 4,  
K0 to K3  
0.8 VDD  
0.2 VDD  
Figure 15-9. Input Timing for External Interrupts and Quasi-Interrupts  
15-14  
S3C72K8/P72K8  
ELECTRICAL DATA  
tKCY  
t
KL  
tKH  
SCK  
0.8 VDD  
0.2 VDD  
tSIK  
tKSI  
0.8 VDD  
0.2 VDD  
SI  
Input Data  
tKSO  
SO  
Output Data  
Figure 15-10. Serial Data Transfer Timing  
15-15  
ELECTRICAL DATA  
S3C72K8/P72K8  
NOTES  
15-16  
S3C72K8/P72K8  
MECHANICAL DATA  
16 MECHANICAL DATA  
OVERVIEW  
The S3C72K8 microcontroller is currently available in a 80-pin QFP package.  
23.90± 0.30  
20.00 ± 0.20  
0-8  
+ 0.10  
- 0.05  
0.15  
0.10 MAX  
80-QFP-1420C  
#80  
#1  
0.35 + 0.10  
0.05 MIN  
2.65 ± 0.10  
3.00 MAX  
0.80  
0.15 MAX  
(0.80)  
0.80 ± 0.20  
NOTE: Dimensions are in millimeters.  
Figure 16-1. 80-QFP-1420C Package Dimensions  
16-1  
MECHANICAL DATA  
S3C72K8/P72K8  
NOTES  
16-2  
S3C72K8/P72K8  
S3P72K8 OTP  
17 S3P72K8 OTP  
OVERVIEW  
The S3P72K8 single-chip CMOS microcontroller is the OTP (One Time Programmable) version of the S3C72K8  
microcontroller. It has an on-chip OTP ROM instead of masked ROM. The EPROM is accessed by serial data  
format.  
The S3P72K8 is fully compatible with the S3C72K8, both in function and in pin configuration except ROM size.  
Because of its simple programming requirements, the S3P72K8 is ideal for use as an evaluation chip for the  
S3C72K8.  
17-1  
S3P72K8 OTP  
S3C72K8/P72K8  
P5.6/SEG38  
P5.7/SEG39  
1
2
3
4
5
6
7
8
64  
63  
62  
61  
60  
59  
58  
57  
56  
55  
54  
53  
52  
51  
50  
49  
48  
47  
46  
45  
44  
43  
42  
41  
SEG21  
SEG20  
SEG19  
SEG18  
SEG17  
SEG16  
SEG15  
SEG14  
SEG13  
SEG12  
SEG11  
SEG10  
SEG9  
SEG8  
SEG7  
SEG6  
SEG5  
SEG4  
SEG3  
SEG2  
SEG1  
VLC1  
VLC2  
VLC3  
VLC4  
VLC5  
P0.0/SCK/K0  
P0.1/SO/K1  
SDAT/P0.2/SI/K2  
SCLK/P0.3/BUZ/K3  
9
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
S3P72K8  
V
V
DD/VDD  
SS/VSS  
OUT  
IN  
X
(80-QFP-1420C)  
X
VPP/TEST  
XTIN  
XT OUT  
RESET/RESET  
P1.0/INT0/CIN0  
P1.1/INT1/CIN1  
P1.1/INT2  
SEG0  
COM7  
COM6  
P1.3/INT4  
P2.0  
Figure 17-1. S3P72K8 Pin Assignments (80-QFP Package)  
17-2  
S3C72K8/P72K8  
S3P72K8 OTP  
Table 17-1. Descriptions of Pins Used to Read/Write the EPROM  
During Programming  
Main Chip  
Pin Name  
P0.2  
Pin Name  
Pin No.  
I/O  
Function  
SDAT  
10  
I/O  
Serial data pin. Output port when reading and  
input port when writing. Can be assigned as a  
Input/push-pull output port.  
P0.3  
SCLK  
11  
16  
I
I
Serial clock pin. Input only pin.  
TEST  
V
Power supply pin for EPROM cell writing  
(indicates that OTP enters into the writing mode).  
When 12.5 V is applied, OTP is in writing mode  
and when 5 V is applied, OTP is in reading mode.  
(Option)  
PP  
19  
I
I
Chip Initialization  
RESET  
RESET  
V
/V  
V
/V  
12/13  
Logic power supply pin. V should be tied to +5  
DD SS  
DD SS  
DD  
V during programming.  
Table 17-2. Comparison of S3P72K8 and S3C72K8 Features  
S3P72K8  
Characteristic  
S3C72K8  
Program Memory  
8-Kbyte EPROM  
2.0 V to 5.5 V  
8-Kbyte mask ROM  
2.0 V to 5.5 V  
Operating Voltage (V  
)
DD  
OTP Programming Mode  
V
= 5 V, V (TEST) = 12.5V  
DD PP  
Pin Configuration  
80 QFP  
User Program 1 time  
80 QFP  
EPROM Programmability  
Programmed at the factory  
OPERATING MODE CHARACTERISTICS  
When 12.5 V is supplied to the V (TEST) pin of the S3P72K8, the EPROM programming mode is entered. The  
PP  
operating mode (read, write, or read protection) is selected according to the input signals to the pins listed in Table  
17-3 below.  
Table 17-3. Operating Mode Selection Criteria  
V
V
REG/  
MEM  
Address  
(A15-A0)  
R/W  
Mode  
DD  
PP  
(TEST)  
5 V  
5 V  
0
0
0
1
0000H  
0000H  
0000H  
0E3FH  
1
0
1
0
EPROM read  
12.5 V  
12.5 V  
12.5 V  
EPROM program  
EPROM verify  
EPROM read protection  
NOTE: "0" means Low level; "1" means High level.  
17-3  
S3P72K8 OTP  
S3C72K8/P72K8  
NOTES  
17-4  
S3C72K8/P72K8  
DEVELOPMENT TOOLS  
18 DEVELOPMENT TOOLS  
OVERVIEW  
Samsung provides a powerful and easy-to-use development support system in turnkey form. The development  
support system is configured with a host system, debugging tools, and support software. For the host system, any  
standard computer that operates with MS-DOS as its operating system can be used. One type of debugging tool  
including hardware and software is provided: the sophisticated and powerful in-circuit emulator, SMDS2+, for S3C7,  
S3C9, S3C8 families of microcontrollers. The SMDS2+ is a new and improved version of SMDS2. Samsung also  
offers support software that includes debugger, assembler, and a program for setting options.  
SHINE  
Samsung Host Interface for In-Circuit Emulator, SHINE, is a multi-window based debugger for SMDS2+. SHINE  
provides pull-down and pop-up menus, mouse support, function/hot keys, and context-sensitive hyper-linked help. It  
has an advanced, multiple-windowed user interface that emphasizes ease of use. Each window can be sized,  
moved, scrolled, highlighted, added, or removed completely.  
SAMA ASSEMBLER  
The Samsung Arrangeable Microcontroller (SAM) Assembler, SAMA, is a universal assembler, and generates object  
code in standard hexadecimal format. Assembled program code includes the object code that is used for ROM data  
and required SMDS program control data. To assemble programs, SAMA requires a source file and an auxiliary  
definition (DEF) file with device specific information.  
SASM57  
The SASM57 is an relocatable assembler for Samsung's S3C7-series microcontrollers. The SASM57 takes a source  
file containing assembly language statements and translates into a corresponding source code, object code and  
comments. The SASM57 supports macros and conditional assembly. It runs on the MS-DOS operating system. It  
produces the relocatable object code only, so the user should link object file. Object files can be linked with other  
object files and loaded into memory.  
HEX2ROM  
HEX2ROM file generates ROM code from HEX file which has been produced by assembler. ROM code must be  
needed to fabricate a microcontroller which has a mask ROM. When generating the ROM code (.OBJ file) by  
HEX2ROM, the value 'FF' is filled into the unused ROM area up to the maximum ROM size of the target device  
automatically.  
TARGET BOARDS  
Target boards are available for all S3C7-series microcontrollers. All required target system cables and adapters are  
included with the device-specific target board.  
OTPs  
One time programmable microcontroller (OTP) for the S3C72K8 microcontroller and OTP programmer (Gang) are  
now available.  
18-1  
DEVELOPMENT TOOLS  
S3C72K8/P72K8)  
IBM-PC AT or Compatible  
RS-232C  
SMDS2+  
Target  
Application  
System  
PROM/OTP Writer Unit  
RAM Break/Display Unit  
Trace/Timer Unit  
Probe  
Adapter  
TB72K8  
Target  
POD  
SAM4 Base Unit  
Board  
Eva  
Power Supply Unit  
Chip  
Figure 18-1. SMDS Product Configuration (SMDS2+)  
18-2  
S3C72K8/P72K8  
DEVELOPMENT TOOLS  
TB72K8 TARGET BOARD  
The TB72K8 target board is used for the S3C72K8/P72K8 microcontroller. It is supported by the SMDS2+  
development system.  
TB72K8  
To User_VCC  
Off  
On  
Stop  
Idle  
RESET  
74HC11  
+
+
J101  
J102  
25  
1
2
1
2
144 QFP  
S3E72K0  
EVA Chip  
1
XI  
XTI  
39  
40 39  
40  
SM1247A  
Figure 18-2. TB72K8 Target Board Configuration  
18-3  
DEVELOPMENT TOOLS  
S3C72K8/P72K8)  
Table 18-1. Power Selection Settings for TB72K8  
Operating Mode  
'To User_Vcc' Settings  
Comments  
The SMDS2/SMDS2+ supplies  
to the target board  
To User_VCC  
V
CC  
Target  
System  
Off  
On  
TB72K8  
V
CC  
SS  
(evaluation chip) and the target  
system.  
V
VCC  
SMDS2/SMDS2+  
The SMDS2/SMDS2+ supplies  
To User_VCC  
V
only to the target board  
External  
CC  
Target  
System  
Off  
On  
VCC  
TB72K8  
(evaluation chip). The target  
system must have its own  
power supply.  
VSS  
VCC  
SMDS2/SMDS2+  
Table 18-2. Main-clock Selection Settings for TB72K8  
Operating Mode  
Sub Clock Setting  
Comments  
Set the XI switch to “MDS”  
when the target board is  
connected to the  
XI  
EVA Chip  
S3E72K0  
XTAL  
MDS  
SMDS2/SMDS2+.  
XOUT  
XIN  
No Connection  
100 Pin Connector  
SMDS2/SMDS2+  
Set the XI switch to “XTAL”  
when the target board is used  
as a standalone unit, and is  
not connected to the  
XI  
EVA Chip  
S3E72K0  
XTAL  
MDS  
SMDS2/SMDS2+.  
XOUT  
XIN  
XTAL  
Target Board  
18-4  
S3C72K8/P72K8  
DEVELOPMENT TOOLS  
Comments  
Table 18-3. Sub-clock Selection Settings for TB72K8  
Operating Mode  
Sub Clock Setting  
Set the XTI switch to “MDS”  
when the target board is  
connected to the  
XTI  
EVA Chip  
S3E72K0  
XTAL  
MDS  
SMDS2/SMDS2+.  
XT OUT  
XTIN  
No Connection  
100 Pin Connector  
SMDS2/SMDS2+  
Set the XTI switch to “XTAL”  
when the target board is used  
as a standalone unit, and is  
not connected to the  
XTI  
EVA Chip  
S3E72K0  
XTAL  
MDS  
SMDS2/SMDS2+.  
XT OUT  
XTIN  
XTAL  
Target Board  
IDLE LED  
This LED is ON when the evaluation chip (S3E72K0) is in idle mode.  
STOP LED  
This LED is ON when the evaluation chip (S3E72K0) is in stop mode.  
18-5  
DEVELOPMENT TOOLS  
S3C72K8/P72K8)  
J101  
J102  
P5.6/SEG38  
1
3
5
7
2
4
6
P5.7/SEG39  
COM6  
SEG0  
SEG2  
1
3
5
7
2
4
6
COM7  
SEG1  
SEG3  
SEG5  
VLC1  
VLC3  
VLC5  
VLC2  
VLC4  
8
P0.0/SCK/K0  
SEG4  
8
P0.1/SO/K1  
P0.3/BUZ/K3  
9
10  
12  
14  
16  
18  
20  
22  
24  
26  
28  
30  
32  
34  
36  
38  
40  
P0.2/SI/K2  
SEG6  
SEG8  
9
10  
12  
14  
16  
18  
20  
22  
24  
26  
28  
30  
32  
34  
36  
38  
40  
SEG7  
SEG9  
11  
13  
15  
17  
19  
21  
23  
25  
27  
29  
31  
33  
35  
37  
39  
VDD  
11  
13  
15  
17  
19  
21  
23  
25  
27  
29  
31  
33  
35  
37  
39  
VSS  
XOUT  
SEG10  
SEG12  
SEG14  
SEG16  
SEG18  
SEG20  
SEG22  
SEG24  
SEG26  
SEG28  
SEG30  
SEG32/P5.0  
SEG34/P5.2  
SEG36/P5.4  
SEG11  
SEG13  
SEG15  
SEG17  
SEG19  
SEG21  
SEG23  
SEG25  
SEG27  
SEG29  
SEG31  
SEG33/P5.1  
SEG35/P5.3  
SEG37/P5.5  
XIN  
TEST  
XTOUT  
P1.0/INT0/CIN0  
P1.2/INT2  
P2.0  
P2.2  
P3.0  
LCDSY/P3.2  
P4.0/CLO  
P4.2/TCLO0  
COM1  
XT IN  
RESET  
P1.1/INT1/CIN1  
P1.3/INT4  
P2.1  
P2.3  
P3.1  
LCDCK/P3.3  
P4.1/TCL0  
COM0  
COM2  
COM4  
COM3  
COM5  
Figure 18-3. 40-Pin Connectors for TB72K8  
Target Board  
J101 J102  
Target System  
J102 J101  
1
2
1
2
1
2
1
2
Target Cable for 40-Pin Connector  
Part Name: (AS64D-A)  
Order Cods: SM6309  
39 40 39 40  
39 40 39 40  
Figure 18-4. TB72K8 Adapter Cable for 80-QFP Package (S3C72K8/P72K8)  
18-6  

相关型号:

S3P72M5

single-chip CMOS microcontroller
SAMSUNG

S3P72M7

single-chip CMOS microcontroller
SAMSUNG

S3P72M9

single-chip CMOS microcontroller
SAMSUNG

S3P72M9-QA

Microcontroller, 4-Bit, OTPROM, 6MHz, CMOS, PQFP128, 14 X 20 MM, QFP-128
SAMSUNG

S3P72N4

The S3C72N2/C72N4 single-chip CMOS microcontroller has been designed for high performance using Samsungs newest 4-bit CPU core, SAM47 (Samsung Arrange
SAMSUNG

S3P72N5

single-chip CMOS microcontroller
SAMSUNG

S3P72P9

SINGLE-CHIP MICROCONTROLLER HAS BEEN DESIGNED FOR HIGH PERFORMANCE USING
SAMSUNG

S3P72P9-QX

Microcontroller, 4-Bit, OTPROM, SAM47 CPU, 6MHz, CMOS, PQFP100, 14 X 20 MM, QFP-100
SAMSUNG

S3P72P9XZZ-QX89

Microcontroller, 4-Bit, UVPROM, SAM47 CPU, 6MHz, CMOS, PQFP100,
SAMSUNG

S3P72P9XZZ-QXR9

Microcontroller, 4-Bit, UVPROM, SAM47 CPU, 6MHz, CMOS, PQFP100,
SAMSUNG

S3P72Q5

4?BIT CMOS MICROCONTROLLER USERS MANUAL
SAMSUNG

S3P72Q5-QX

Microcontroller, 4-Bit, OTPROM, SAM 48 CPU, 1.5MHz, CMOS, PQFP100, 14 X 20 MM, QFP-100
SAMSUNG