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.
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.
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.
"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.
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.
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 (BVQI Certificate No 9330) 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.samsungsemi.com
Printed in the Republic of Korea
Page 4
Preface
The S3C9228/P9228 Microcontrollers User's Manual is designed for application designers and programmers who
are using the S3C9228/P9228 microcontrollers for application development. It is organized in two main parts:
Part I Programming ModelPart 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 six chapters:
Chapter 1Product Overview
Chapter 2Address Spaces
Chapter 3Addressing Modes
Chapter 1, "Product Overview," is a high-level introduction to the 100% with general product descriptions, as well
as detailed information about individual pin characteristics and pin circuit types.
Chapter 2, "Address Spaces," explains the 100% program and data memory, internal register file, and mapped
control register, and explains how to address them. Chapter 2 also describes working register addressing, as well
as system stack and user-defined stack operations.
Chapter 3, "Addressing Modes," contains detailed descriptions of the addressing modes that are supported by the
CPU.
Chapter 4, "Control Registers," contains overview tables for all mapped system and peripheral control register
values, as well as detailed one-page descriptions in standard format. You can use these easy-to-read,
alphabetically organized, register descriptions as a quick-reference source when writing programs.
Chapter 5, "Interrupt Structure," describes the 100% interrupt structure in detail and further prepares you for
additional information presented in the individual hardware module descriptions in Part II.
Chapter 6, "SAM88RCRI Instruction Set," describes the features and conventions of the instruction set used for
all S3C9-series microcontrollers. Several summary tables are presented for orientation and reference. Detailed
descriptions of each instruction are presented in a standard format. Each instruction description includes one or
more practical examples of how to use the instruction when writing an application program.
A basic familiarity with the information in Part I will help you to understand the hardware module descriptions in
Part II. If you are not yet familiar with the SAM8 product family and are reading this manual for the first time, we
recommend that you first read chapters 1–3 carefully. Then, briefly look over the detailed information in chapters
4, 5, and 6. Later, you can reference the information in Part I as necessary.
Part II "hardware Descriptions," has detailed information about specific hardware components of the
S3C9228/P9228 microcontrollers. Also included in Part II are electrical, mechanical, OTP, and development
tools data. It has 13 chapters:
Chapter 4Control Registers
Chapter 5Interrupt Structure
Chapter 6SAM88RCRI Instruction Set
Chapter 7Clock Circuits
Chapter 8RESET and Power-Down
Two order forms are included at the back of this manual to facilitate customer order for S3C9228/P9228
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.
S3C9228/P9228 MICROCONTROLLERSiii
Chapter 1410-bit ADC
Chapter 15Serial I/O Interface
Chapter 16Electrical Data
Chapter 17Mechanical Data
Chapter 18S3P9228 OTP
Chapter 19Development Tools
Page 5
Page 6
Table of Contents
Part I — Programming Model
Chapter 1Product Overview
SAM88RCRI Product Family ...................................................................................................................1-1
Common Working Register Area (C0H–CFH)..........................................................................................2-4
System Stack ..........................................................................................................................................2-5
System Clock Circuit.......................................................................................................................7-1
CPU Clock Notation ........................................................................................................................7-1
Main Oscillator Circuits....................................................................................................................7-2
Sub Oscillator Circuits.....................................................................................................................7-2
Clock Status During Power-Down Modes.........................................................................................7-3
System Clock Control Register (CLKCON)......................................................................................7-4
Oscillator Control Register (OSCCON)............................................................................................7-5
Switching The CPU Clock................................................................................................................7-6
Stop Control Register (STPCON) ....................................................................................................7-7
Chapter 8RESETRESET and Power-Down
System Reset..........................................................................................................................................8-1
Port Data Registers.........................................................................................................................9-2
Port 0..............................................................................................................................................9-3
Port 1..............................................................................................................................................9-6
Port 2..............................................................................................................................................9-9
Port 3..............................................................................................................................................9-11
Port 4..............................................................................................................................................9-14
Port 5..............................................................................................................................................9-15
Port 6..............................................................................................................................................9-16
Function Description................................................................................................................................14-1
Samsung's SAM88RCRI family of 8-bit single-chip CMOS microcontrollers offer fast and efficient CPU, a wide
range of integrated peripherals, and supports OTP device.
A dual address/data bus architecture and bit- or nibble-configurable I/O ports provide a flexible programming
environment for applications with varied memory and I/O requirements. Timer/counters with selectable operating
modes are included to support real-time operations.
S3C9228/P9228 MICROCONTROLLER
The S3C9228 can be used for dedicated control functions in a variety of applications, and is especially designed
for application with FRS or etc.
The S3C9228/P9228 single-chip 8-bit microcontroller is fabricated using an advanced CMOS process. It is built
around the powerful SAM88RCRI CPU core.
Stop and Idle power-down modes were implemented to reduce power consumption. To increase on-chip register
space, the size of the internal register file was logically expanded. The S3C9228/P9228 has 8K-byte of program
ROM, and 264-byte of RAM (including 16-byte of working register and 20-byte LCD display RAM).
Using the SAM88RCRI design approach, the following peripherals were integrated with the SAM88RCRI core:
— 7 configurable I/O ports including ports shared with segment/common drive outputs
— 10-bit programmable pins for external interrupts
— One 8-bit basic timer for oscillation stabilization and watch-dog functions
— Two 8-bit timer/counters with selectable operating modes
— Watch timer for real time
— 4 channel A/D converter
— 8-bit serial I/O interface
OTP
The S3C9228 microcontroller is also available in OTP (One Time Programmable) version. S3P9228
microcontroller has an on-chip 8K-byte one-time-programmable EPROM instead of masked ROM. The S3P9228
is comparable to S3C9228, both in function and in pin configuration.
1-1
Page 24
PRODUCT OVERVIEWS3C9228/P9228
FEATURES
CPU
• SAM88RCRI CPU core
Memory
• 8192 × 8 bits program memory (ROM)
• 264 × 8 bits data memory (RAM)
(Including LCD data memory)
Instruction Set
• 41 instructions
• Idle and Stop instructions added for power-down
modes
36 I/O Pins
• I/O: 34 pins (44-pin QFP, 42-pin SDIP)
• Output only: 2 pins (44-pin QFP)
Interrupts
• 14 interrupt source and 1 vector
• One interrupt level
LCD Controller/Driver
• 16 segments and 8 common terminals
• 3, 4, and 8 common selectable
• Internal resistor circuit for LCD bias
8-bit Serial I/O Interface
• 8-bit transmit/receive mode
• 8-bit receive mode
• LSB-first or MSB-first transmission selectable
• Internal or external clock source
A/D Converter
• 10-bit converter resolution
• 50us conversion speed at 1MHz f
ADC
clock
• 4-channel
Two Power-Down Modes
• Idle: only CPU clock stops
• Stop: system clock and CPU clock stop
8-Bit Basic Timer
• Watchdog timer function
• 3 kinds of clock source
Two 8-Bit Timer/Counters
• The programmable 8-bit timer/counters
• External event counter function
•Configurable as one 16-bit timer/counters
Watch Timer
• Interval time: 3.91mS, 0.25S, 0.5S, and 1S
at 32.768 kHz
1-bit programmable I/O port. Input or
push-pull, open-drain output and
H-3235-38
(41-42,1-2)
COM3-COM0
software assignable pull-ups.
NOTE: Parentheses indicate pin number for 42-SDIP-600 package.
1-6
Page 29
S3C9228/P9228PRODUCT OVERVIEW
Table 1-1. Pin Descriptions (Continued)
Pin NamesPin
Type
VDD, V
X
OUT
XT
OUT
, X
SS
IN
, XT
IN
–Power input pins for internal power block–5,6(11,12)–
–Main oscillator pins for main clock–7,8(13,14)
–Sub oscillator pins for sub clock–11,10(17,16)–
A 16-bit address bus supports program memory operations. Special instructions and related internal logic
determine when the 16-bit bus carries addresses for program memory. A separate 8-bit register bus carries
addresses and data between the CPU and the internal register file.
The S3C9228 has 8K bytes of mask-programmable program memory on-chip. The S3C9228/P9228
microcontroller has 244 bytes general-purpose registers in its internal register file and the 20 bytes for LCD
display memory is implemented in the internal register file too. Fifty-six bytes in the register file are mapped for
system and peripheral control functions.
2-1
Page 36
ADDRESS SPACESS3C9228/P9228
PROGRAM MEMORY (ROM)
Program memory (ROM) stores program code or table data. The S3C9228 has 8K bytes of mask-programable
program memory. The program memory address range is therefore 0H-1FFFH. The first 2 bytes of the ROM
(0000H–0001H) are an interrupt vector address. The program reset address in the ROM is 0100H.
(Decimal)
8,192
8K bytes
Internal
Program
Memory
Area
256
Program Start
20002H
1
0
Interrupt
Vector
(Hex)
1FFFH
0100H
0001H
0000H
2-2
Figure 2-1. S3C9228/P9228 Program Memory Address Space
Page 37
S3C9228/P9228ADDRESS SPACES
REGISTER ARCHITECTURE
The upper 72 bytes of the S3C9228/P9228's internal register file are addressed as working registers, system
control registers and peripheral control registers. The lower 184 bytes of internal register file (00H–B7H) is called
the general purpose register space.
For many SAM88RCRI microcontrollers, the addressable area of the internal register file is further expanded by
the additional of one or more register pages at general purpose register space (00H–BFH). This register file
expansion is implemented by page 1 in the S3C9228/P9228. The page 1 (20 × 8 bits) is for LCD display register
and can be used as general-purpose registers.
FFH
Peripheral Control
Registers
E0H
72 Bytes of
Common Area
DFH
D0H
CFH
C0H
BFH
B8H
B7H
System Control
Registers
Working Registers
Peripheral Control
Registers
184 Bytes
General Purpose
Register File
and Stack Area
~
64 Bytes
00H
(Page 0)
Figure 2-2. Internal Register File Organization
3FH
13H
00H
General Purpose
Register File
LCD Display
Registers
(Page 1)
2-3
Page 38
ADDRESS SPACESS3C9228/P9228
COMMON WORKING REGISTER AREA (C0H–CFH)
The SAM88RCRI register architecture provides an efficient method of working register addressing that takes full
advantage of shorter instruction formats to reduce execution time.
This16-byte address range is called common area. That is, locations in this area can be used as working registers
by operations that address any location on any page in the register file. Typically, these working registers serve
as temporary buffers for data operations between different pages.
The Register (R) addressing mode can be used to access this area
Registers are addressed either as a single 8-bit register or as a paired 16-bit register. In 16-bit register pairs, the
address of the first 8-bit register is always an even number and the address of the next register is an odd number.
The most significant byte of the 16-bit data is always stored in the even-numbered register; the least significant
byte is always stored in the next (+ 1) odd-numbered register.
MSB
Rn
Figure 2-3. 16-Bit Register Pairs
LSB
Rn + 1
n = Even address
++ PROGRAMMING TIP — Addressing the Common Working Register Area
As the following examples show, you should access working registers in the common area, locations C0H–CFH,
using working register addressing mode only.
Examples:1. LD0C2H,40H; Invalid addressing mode!
Use working register addressing instead:
LDR2,40H; R2 (C2H) ← the value in location 40H
2. ADD0C3H,#45H; Invalid addressing mode!
Use working register addressing instead:
ADD R3,#45H; R3 (C3H) ← R3 + 45H
2-4
Page 39
S3C9228/P9228ADDRESS SPACES
SYSTEM STACK
S3C9-series microcontrollers use the system stack for subroutine calls and returns and to store data. The PUSH
and POP instructions are used to control system stack operations. The S3C9228/P9228 architecture supports
stack operations in the internal register file.
STACK OPERATIONS
Return addresses for procedure calls and interrupts and data are stored on the stack. The contents of the PC are
saved to stack by a CALL instruction and restored by the RET instruction. When an interrupt occurs, the contents
of the PC and the FLAGS register are pushed to the stack. The IRET instruction then pops these values back to
their original locations. The stack address is always decremented before a push operation and incremented after
a pop operation. The stack pointer (SP) always points to the stack frame stored on the top of the stack, as shown
in Figure 2-4.
High Address
PCL
PCL
Top of
stack
PCH
Stack contents
after a call
instruction
Top of
stack
Low Address
PCH
Flags
Stack contents
after an
interrupt
Figure 2-4. Stack Operations
STACK POINTER (SP)
Register location D9H contains the 8-bit stack pointer (SP) that is used for system stack operations. After a reset,
the SP value is undetermined.
Because only internal memory space is implemented in the S3C9228/P9228, the SP must be initialized to an 8bit value in the range 00H–B7H.
NOTE
In case a Stack Pointer is initialized to 00H, it is decreased to FFH when stack operation starts. This
means that a Stack Pointer access invalid stack area.
2-5
Page 40
ADDRESS SPACESS3C9228/P9228
++ PROGRAMMING TIP — Standard Stack Operations Using PUSH and POP
The following example shows you how to perform stack operations in the internal register file using PUSH and
POP instructions:
LDSP,#0B8H; SP ← B8H (Normally, the SP is set to 0B8H by the
Instructions that are stored in program memory are fetched for execution using the program counter. Instructions
indicate the operation to be performed and the data to be operated on. Addressing mode is the method used to
determine the location of the data operand. The operands specified in SAM88RCRI instructions may be condition
codes, immediate data, or a location in the register file, program memory, or data memory.
The SAM88RCRI instruction set supports six explicit addressing modes. Not all of these addressing modes are
available for each instruction. The addressing modes and their symbols are as follows:
In Register addressing mode, the operand is the content of a specified register (see Figure 3-1). Working register
addressing differs from Register addressing because it uses a 16-byte working register space in the register file
and a 4-bit register within that space (see Figure 3-2).
Program MemoryRegister File
8-bit Register
File Address
One-Operand
Instruction
(Example)
Sample Instruction:
dst
OPCODE
Point to One
OPERAND
Rigister in Register
File
Value used in
Instruction Execution
DECCNTR; Where CNTR is the label of an 8-bit register address
4-Bit
Working Register
Two-Operand
Instruction
(Example)
Figure 3-1. Register Addressing
Program Memory
dst
OPCODE
Sample Instruction:
src
4 LSBs
Point to the
Woking Register
(1 of 16)
Register File
CFH
.
.
.
.
OPERAND
C0H
3-2
ADDR1, R2; Where R1 = C1H and R2 = C2H
Figure 3-2. Working Register Addressing
Page 43
S3C9228/P9228ADDRESSING MODES
INDIRECT REGISTER ADDRESSING MODE (IR)
In Indirect Register (IR) addressing mode, the content of the specified register or register pair is the address of
the operand. Depending on the instruction used, the actual address may point to a register in the register file, to
program memory (ROM), or to an external memory space (see Figures 3-3 through 3-6).
You can use any 8-bit register to indirectly address another register. Any 16-bit register pair can be used to
indirectly address another memory location.
Program MemoryRegister File
8-Bit Register
File Address
One-Operand
Instruction
(Example)
dst
OPCODE
Point to One
ADDRESS
Rigister in Register
File
Address of Operand
used by Instruction
Value used in
Instruction Execution
Sample Instruction:
RL@SHIFT; Where SHIFT is the label of an 8-Bit register address
OPERAND
Figure 3-3. Indirect Register Addressing to Register File
3-3
Page 44
ADDRESSING MODESS3C9228/P9228
INDIRECT REGISTER ADDRESSING MODE (Continued)
Register File
Program Memory
Example
Instruction
References
Program
Memory
Sample Instructions:
CALL@RR2
JP@RR2
REGISTER
dst
OPCODE
Points to
Rigister Pair
Value used in
Instruction
PAIR
Program Memory
OPERAND
Figure 3-4. Indirect Register Addressing to Program Memory
16-Bit
Address
Points to
Program
Memory
3-4
Page 45
S3C9228/P9228ADDRESSING MODES
INDIRECT REGISTER ADDRESSING MODE (Continued)
Register File
CFH
.
.
.
.
OPERAND
C0H
4-Bit
Working
Register
Address
Program Memory
dst
OPCODE
src
4 LSBs
Point to the
Woking Register
(1 of 16)
Sample Instruction:
ORR6, @R2
Value used in
Instruction
OPERAND
Figure 3-5. Indirect Working Register Addressing to Register File
3-5
Page 46
ADDRESSING MODESS3C9228/P9228
INDIRECT REGISTER ADDRESSING MODE (Concluded)
Register File
CFH
.
.
.
.
Register
Pair
or
Data Memory
OPERAND
C0H
16-Bit
address
points to
program
memory
or data
memory
4-Bit Working
Register Address
Example Instruction
References either
Program Memory or
Data Memory
Program Memory
dst
OPCODE
src
Next 3 Bits Point
to Working
Register Pair
(1 of 8)
LSB Selects
Value used in
Instruction
Program Memory
3-6
Sample Instructions:
LCDR5,@RR6; Program memory access
LDER3,@RR14; External data memory access
LDE@RR4, R8; External data memory access
Figure 3-6. Indirect Working Register Addressing to Program or Data Memory
Page 47
S3C9228/P9228ADDRESSING MODES
INDEXED ADDRESSING MODE (X)
Indexed (X) addressing mode adds an offset value to a base address during instruction execution in order to
calculate the effective operand address (see Figure 3-7). You can use Indexed addressing mode to access
locations in the internal register file or in external memory.
In short offset Indexed addressing mode, the 8-bit displacement is treated as a signed integer in the range of
–128 to +127. This applies to external memory accesses only (see Figure 3-8).
For register file addressing, an 8-bit base address provided by the instruction is added to an 8-bit offset contained
in a working register. For external memory accesses, the base address is stored in the working register pair
designated in the instruction. The 8-bit or 16-bit offset given in the instruction is then added to the base address
(see Figure 3-9).
The only instruction that supports Indexed addressing mode for the internal register file is the Load instruction
(LD). The LDC and LDE instructions support Indexed addressing mode for internal program memory, external
program memory, and for external data memory, when implemented.
Register File
Two-Operand
Instruction
Example
Sample Instruction:
LD R0, #BASE[R1]; Where BASE is an 8-bit immediate value
~~
Value used in
Instruction
+
Program Memory
Base Address
dst
OPCODE
src
Figure 3-7. Indexed Addressing to Register File
4 LSBs
Point to One of the
Woking Register
(1 of 16)
OPERAND
~~
INDEX
3-7
Page 48
ADDRESSING MODESS3C9228/P9228
INDEXED ADDRESSING MODE (Continued)
4-Bit Working
Register Address
Sample Instructions:
LDCR4, #04H[RR2]; The values in the program address (RR2 + #04H)
LDER4,#04H[RR2]; Identical operation to LDC example, except that
Program Memory
XS (OFFSET)
dst
OPCODE
src
NEXT 3 Bits
Point to Working
Register Pair
(1 of 8)
LSB Selects
+
8-Bits
16-Bits
Register File
Register
Pair
16-Bits
Program Memory
or
Data Memory
OPERAND
are loaded into register R4.
external program memory is accessed.
16-Bit
address
added to
offset
Value used in
Instruction
3-8
Figure 3-8. Indexed Addressing to Program or Data Memory with Short Offset
Page 49
S3C9228/P9228ADDRESSING MODES
INDEXED ADDRESSING MODE (Concluded)
4-Bit Working
Register Address
Sample Instructions:
LDCR4, #1000H[RR2]; The values in the program address (RR2 +
#1000H)
LDER4, #1000H[RR2]; Identical operation to LDC example, except that
Program Memory
XLH (OFFSET)
XLL (OFFSET)
dstsrc
OPCODE
NEXT 3 Bits
Point to Working
Register Pair
(1 of 8)
LSB Selects
+
8-Bits
16-Bits
Register File
Register
Pair
16-Bits
Program Memory
or
Data Memory
OPERAND
are loaded into register R4.
external program memory is accessed.
Value used in
Instruction
16-Bit
address
added to
offset
Figure 3-9. Indexed Addressing to Program or Data Memory with Long Offset
3-9
Page 50
ADDRESSING MODESS3C9228/P9228
DIRECT ADDRESS MODE (DA)
In Direct Address (DA) mode, the instruction provides the operand's 16-bit memory address. Jump (JP) and Call
(CALL) instructions use this addressing mode to specify the 16-bit destination address that is loaded into the PC
whenever a JP or CALL instruction is executed.
The LDC and LDE instructions can use Direct Address mode to specify the source or destination address for
Load operations to program memory (LDC) or to external data memory (LDE), if implemented.
Program or
Data Memory
Memory
Program Memory
Address
Used
Upper Address Byte
Lower Address Byte
dst/src
Sample Instructions:
LDCR5,1234H; The values in the program address (1234H)
LDER5,1234H; Identical operation to LDC example, except that
"0" or "1"
OPCODE
are loaded into register R5.
external program memory is accessed.
LSB Selects Program
Memory or Data Memory:
"0" = Program Memory
"1" = Data Memory
Figure 3-10. Direct Addressing for Load Instructions
3-10
Page 51
S3C9228/P9228ADDRESSING MODES
DIRECT ADDRESS MODE (Continued)
Program Memory
Next OPCODE
Program
Memory
Address
Used
Lower Address Byte
Upper Address Byte
OPCODE
Sample Instructions:
JPC,JOB1; Where JOB1 is a 16-bit immediate address
CALLDISPLAY; Where DISPLAY is a 16-bit immediate address
Figure 3-11. Direct Addressing for Call and Jump Instructions
3-11
Page 52
ADDRESSING MODESS3C9228/P9228
RELATIVE ADDRESS MODE (RA)
In Relative Address (RA) mode, a two's-complement signed displacement between – 128 and + 127 is specified
in the instruction. The displacement value is then added to the current PC value. The result is the address of the
next instruction to be executed. Before this addition occurs, the PC contains the address of the instruction
immediately following the current instruction.
The instructions that support RA addressing is JR.
Program Memory
Next OPCODE
Program Memory
Address Used
Current
Current Instruction
Displacement
OPCODE
PC Value
Signed
Displacement Value
+
Sample Instructions:
JRULT,$ + OFFSET ; Where OFFSET is a value in the range + 127 to - 128
Figure 3-12. Relative Addressing
IMMEDIATE MODE (IM)
In Immediate (IM) addressing mode, the operand value used in the instruction is the value supplied in the
operand field itself. Immediate addressing mode is useful for loading constant values into registers.
Program Memory
OPERAND
OPCODE
(The Operand value is in the instruction)
Sample Instruction:
LD R0,#0AAH
3-12
Figure 3-13. Immediate Addressing
Page 53
S3C9228/P9228CONTROL REGISTERS
4CONTROL REGISTERS
OVERVIEW
In this section, detailed descriptions of the S3C9228/P9228 control registers are presented in an easy-to-read
format. These descriptions will help familiarize you with the mapped locations in the register file. You can also
use them as a quick-reference source when writing application programs.
System and peripheral registers are summarized in Table 4-1. Figure 4-1 illustrates the important features of the
standard register description format.
Control register descriptions are arranged in alphabetical order according to register mnemonic. More information
about control registers is presented in the context of the various peripheral hardware descriptions in Part II of this
manual.
4-1
Page 54
CONTROL REGISTERSS3C9228/P9228
Table 4-1. System and Peripheral Control Registers (Page 0)
Register NameMnemonicAddress (Page 0)R/W
DecimalHex
Port 0 Control RegisterP0CON235EBH
Port 0 Pull-up Resistor Enable RegisterP0PUR236ECH
Port 0 Interrupt Control RegisterP0INT237EDH
Port 0 Interrupt Edge Selection RegisterP0EDGE238EEH
Port 1 Control RegisterP1CON239EFH
Port 1 Pull-up Resistor Enable RegisterP1PUR240F0H
Port 1 Interrupt Control RegisterP1INT241F1H
Port 1 Interrupt Edge Selection RegisterP1EDGE242F2H
Port 2 Control RegisterP2CON243F3H
Port 2 Pull-up Resistor Enable RegisterP2PUR244F4H
Port 3 Control RegisterP3CON245F5H
Port 3 Pull-up Resistor Enable RegisterP3PUR246F6H
Port 3 Interrupt Control RegisterP3INT247F7H
Port 3 Interrupt Edge Selection RegisterP3EDGE248F8H
Port 4 Control Register (High Byte)P4CONH249F9H
Port 4 Control Register (Low Byte)P4CONL250FAH
Port 5 Control Register (High Byte)P5CONH251FBH
Port 5 Control Register (Low Byte)P5CONL252FCH
Port 6 Control RegisterP6CON253FDH
LCD Mode RegisterLMOD254FEH
Table 4-1. System and Peripheral Control Registers (Page 0)
Register NameMnemonicAddress (Page 0)R/W
DecimalHex
Locations D8H-B9H are not mapped.
Timer B Control Register
Timer 1/A Control Register
Timer B Data Register
Timer A Data Register
Timer B Counter
Timer A Counter
A/D Converter Control Register
A/D Converter Data Register (High Byte)
A/D Converter Data Register (Low Byte)
Oscillator Control Register
System Clock Control Register
System Flags Register
Interrupt Pending Register 1
Interrupt Pending Register 2
LCD Port Control Register
Stack Pointer
Watch Timer Control Register
Location DBH is not mapped.
Basic Timer Control RegisterBTCON220DCHR/W
Basic Timer CounterBTCNT221DDHR
Location DEH is not mapped.
System Mode RegisterSYM223DFHR/W
STOP Control RegisterSTPCON224E0HR/W
SIO Control RegisterSIOCON225E1HR/W
SIO Data RegisterSIODATA226E2HR/W
SIO Prescaler RegisterSIOPS227E3HR/W
Port 0 Data RegisterP0228E4HR/W
Port 1 Data RegisterP1229E5HR/W
Port 2 Data RegisterP2230E6HR/W
Port 3 Data RegisterP3231E7HR/W
Port 4 Data RegisterP4232E8HR/W
Port 5 Data RegisterP5233E9HR/W
Port 6 Data RegisterP6234EAHR/W
4-3
Page 56
CONTROL REGISTERSS3C9228/P9228
Bit number(s) that is/are appended to the
register name for bit addressing
Register
mnemonic
Full Register name
Name of individual
bit or bit function
Register address
(hexadecimal)
FLAGS- System Flags Register
Bit Identifier
RESET RESET Value
Read/Write
.7
.6
.5
R = Read-only
W = Write-only
R/W = Read/write
' - ' = Not used
Addressing mode or
modes you can use to
modify register values
.7.6.5.4.2.3.1.0
x
R/WxR/W
Carry Flag (C)
0Operation dose not generate a carry or borrow condition
1Operation generates carry-out or borrow into high-order bit7
Zero Flag
0Operation result is a non-zero value
1Operation result is zero
Sign Flag
0Operation generates positive number (MSB = "0")
1Operation generates negative number (MSB = "1")
x
R/W
Description of the
effect of specific
bit settings
x
R/W
D5H
x
R/W
x
R/W
RESET value notation:
'-' = Not used
'x' = Undetermind value
'0' = Logic zero
'1' = Logic one
0Disable operation
1Start operation (automatically disable operation after conversion complete)
4-5
Page 58
CONTROL REGISTERSS3C9228/P9228
BTCON — Basic Timer Control RegisterDCH
Bit Identifier.7.6.5.4.3.2.1.0
RESETRESET Value
Read/Write
.7-.4Watchdog Timer Enable Bits
.3-.2Basic Timer Input Clock Selection Bits
00000000
R/WR/WR/WR/WR/WR/WR/WR/W
1010Disable watchdog function
Any other valueEnable watchdog function
00fxx/4096
01fxx/1024
10fxx/128
11fxx/16
.1
Basic Timer Counter Clear Bit
(1)
0No effect
1Clear the basic timer counter value (BTCNT)
.0
Clock Frequency Divider Clear Bit for Basic Timer and Timer/Counters
(2)
0No effect
1Clear clock frequency dividers
NOTES
1.When "1" is written to BTCON.1, the basic timer counter value is cleared to "00H". Immediately following the write
operation, the BTCON.1 value is automatically cleared to "0".
2.When "1" is written to BTCON.0, the corresponding frequency divider is cleared to "00H". Immediately following the
write operation, the BTCON.0 value is automatically cleared to "0".
4-6
Page 59
S3C9228/P9228CONTROL REGISTERS
CLKCON — System Clock Control Register D4H
Bit Identifier.7.6.5.4.3.2.1.0
RESETRESET Value
Read/Write
.7Oscillator IRQ Wake-up Function Bit
.6-.5Bits 6-5
.4-.3CPU Clock (System Clock) Selection Bits
00000000
R/WR/WR/WR/WR/WR/WR/WR/W
0Enable IRQ for main or sub oscillator wake-up in power down mode
1Disable IRQ for main or sub oscillator wake-up in power down mode
0Always logic zero
00Divide by 16 (fxx/16)
01Divide by 8 (fxx /8)
10Divide by 2 (fxx /2)
11Non-divided clock (fxx)
.2-.0Bits 2-0
0Always logic zero
4-7
Page 60
CONTROL REGISTERSS3C9228/P9228
FLAGS— System Flags RegisterD5H
Bit Identifier.7.6.5.4.3.2.1.0
RESETRESET Value
Read/Write
.7Carry Flag (C)
.6Zero Flag (Z)
.5Sign Flag (S)
xxxx––––
R/WR/WR/WR/W––––
0
Operation does not generate a carry or borrow condition
0
Operation result is a non-zero value
1
Operation result is zero
0
Operation generates a positive number (MSB = "0")
1
Operation generates a negative number (MSB = "1")
.4Overflow Flag (V)
0
Operation result is ≤ +127 or ≥ –128
1
Operation result is ≥ +127 or ≤ –128
.3-.0
Not used for S3C9228/P9228
4-8
Page 61
S3C9228/P9228CONTROL REGISTERS
INTPND1 — Interrupt Pending Register 1D6H
Bit Identifier.7.6.5.4.3.2.1.0
RESETRESET Value
Read/Write
.7P1.3's Interrupt Pending Bit
.6P1.2's Interrupt Pending Bit
.5P1.1's Interrupt Pending Bit
00000000
R/WR/WR/WR/WR/WR/WR/WR/W
0No interrupt pending (when read), clear pending bit (when write)
1Interrupt is pending (when read)
0No interrupt pending (when read), clear pending bit (when write)
1Interrupt is pending (when read)
0No interrupt pending (when read), clear pending bit (when write)
1Interrupt is pending (when read)
.4P1.0's Interrupt Pending Bit
0No interrupt pending (when read), clear pending bit (when write)
1Interrupt is pending (when read)
.3P0.3's Interrupt Pending Bit
No interrupt pending (when read), Clear pending bit (when write)
0
Interrupt is pending (when read)
1
.2P0.2's Interrupt Pending Bit
No interrupt pending (when read), Clear pending bit (when write)
0
Interrupt is pending (when read)
1
.1P0.1's Interrupt Pending Bit
No interrupt pending (when read), Clear pending bit (when write)
0
Interrupt is pending (when read)
1
.0P0.0's Interrupt Pending Bit
No interrupt pending (when read), Clear pending bit (when write)
0
Interrupt is pending (when read)
1
NOTE: Refer to Page 5-6 to clear any pending bits.
4-9
Page 62
CONTROL REGISTERSS3C9228/P9228
INTPND2 — Interrupt Pending Register 2D7H
Bit Identifier.7.6.5.4.3.2.1.0
RESETRESET Value
Read/Write
––000000
––R/WR/WR/WR/WR/WR/W
.7-.6
.5P3.1 (INTP) Interrupt Pending Bit
.4P3.0 (INTP) Interrupt Pending Bit
.3Watch Timer Interrupt Pending Bit
.2SIO Interrupt Pending Bit
Not used for S3C9228/P9228
0No interrupt pending (when read), clear pending bit (when write)
1Interrupt is pending (when read)
0No interrupt pending (when read), clear pending bit (when write)
1Interrupt is pending (when read)
No interrupt pending (when read), Clear pending bit (when write)
0
Interrupt is pending (when read)
1
No interrupt pending (when read), Clear pending bit (when write)
0
Interrupt is pending (when read)
1
.1Timer B Interrupt Pending Bit
No interrupt pending (when read), Clear pending bit (when write)
0
Interrupt is pending (when read)
1
.0Timer 1/A Interrupt Pending Bit
No interrupt pending (when read), Clear pending bit (when write)
0
Interrupt is pending (when read)
1
NOTE: Refer to Page 5-6 to clear any pending bits.
4-10
Page 63
S3C9228/P9228CONTROL REGISTERS
LMOD— LCD Mode Control RegisterFEH
Bit Identifier.7.6.5.4.3.2.1.0
RESETRESET Value
Read/Write
–0000000
–R/WR/WR/WR/WR/WR/WR/W
.7
.6COM Pins High Impedance Control Bit
.5Port3 High Impedance Control Bit
.4LCD Display Control Bit
.3-.2LCD Duty and Bias Selection Bits
Not used for S3C9228/P9228
0Normal COMs signal output
1COM pins are at high impedance
0Normal I/O
1High impedance input
Display off (cut off the LCD voltage dividing resistors)
fw/27 (256 Hz when fw is 32.768 kHz)
fw/26 (512 Hz when fw is 32.768 kHz)
fw/25 (1,024 Hz when fw is 32.768 kHz)
fw/24 (2,048 Hz when fw is 32.768 kHz)
Set watch timer interrupt to 1s
Set watch timer interrupt to 0.5s
Set watch timer interrupt to 0.25s
Set watch timer interrupt to 3.91ms
Disable watch timer; Clear frequency dividing circuits
Enable watch timer
4-38
Page 91
S3C9228/P9228INTERRUPT STRUCTURE
5INTERRUPT STRUCTURE
OVERVIEW
The SAM88RCRI interrupt structure has two basic components: a vector, and sources. The number of interrupt
sources can be serviced through a interrupt vector which is assigned in ROM address 0000H–0001H.
SOURCESVECTOR
S1
0000H
0001H
S2
S3
Sn
NOTES:
1. The SAM88RCRI interrupt has only one vector address (0000H-0001H).
2. The number of Sn value is expandable.
Figure 5-1. S3C9-Series Interrupt Type
INTERRUPT PROCESSING CONTROL POINTS
Interrupt processing can be controlled in two ways: globally, or by specific interrupt level and source. The systemlevel control points in the interrupt structure are therefore:
— Global interrupt enable and disable (by EI and DI instructions)
— Interrupt source enable and disable settings in the corresponding peripheral control register(s)
ENABLE/DISABLE INTERRUPT INSTRUCTIONS (EI, DI)
The system mode register, SYM (DFH), is used to enable and disable interrupt processing.
SYM.3 is the enable and disable bit for global interrupt processing, which you can set by modifying SYM.3. An
Enable Interrupt (EI) instruction must be included in the initialization routine that follows a reset operation in order
to enable interrupt processing. Although you can manipulate SYM.3 directly to enable and disable interrupts
during normal operation, we recommend that you use the EI and DI instructions for this purpose.
5-1
Page 92
INTERRUPT STRUCTURES3C9228/P9228
INTERRUPT PENDING FUNCTION TYPES
When the interrupt service routine has executed, the application program's service routine must clear the
appropriate pending bit before the return from interrupt subroutine (IRET) occurs.
INTERRUPT PRIORITY
Because there is not a interrupt priority register in SAM87RCRI, the order of service is determined by a sequence
of source which is executed in interrupt service routine.
"EI" Instruction
Execution
RESET
Source
Interrupts
Source
Interrupt
Enable
S
Q
R
Interrpt priority
is determind by
software polling
Interrupt Pending
Register
method
Global Interrupt
Control (EI, Di instruction)
Figure 5-2. Interrupt Function Diagram
Vector
Interrupt
Cycle
5-2
Page 93
S3C9228/P9228INTERRUPT STRUCTURE
INTERRUPT SOURCE SERVICE SEQUENCE
The interrupt request polling and servicing sequence is as follows:
1. A source generates an interrupt request by setting the interrupt request pending bit to "1".
2. The CPU generates an interrupt acknowledge signal.
3. The service routine starts and the source's pending flag is cleared to "0" by software.
4. Interrupt priority must be determined by software polling method.
INTERRUPT SERVICE ROUTINES
Before an interrupt request can be serviced, the following conditions must be met:
— Interrupt processing must be enabled (EI, SYM.3 = "1")
— Interrupt must be enabled at the interrupt's source (peripheral control register)
If all of the above conditions are met, the interrupt request is acknowledged at the end of the instruction cycle.
The CPU then initiates an interrupt machine cycle that completes the following processing sequence:
1. Reset (clear to "0") the global interrupt enable bit in the SYM register (DI, SYM.3 = "0")
to disable all subsequent interrupts.
2. Save the program counter and status flags to stack.
3. Branch to the interrupt vector to fetch the service routine's address.
4. Pass control to the interrupt service routine.
When the interrupt service routine is completed, an Interrupt Return instruction (IRET) occurs. The IRET restores
the PC and status flags and sets SYM.3 to "1"(EI), allowing the CPU to process the next interrupt request.
GENERATING INTERRUPT VECTOR ADDRESSES
The interrupt vector area in the ROM contains the address of the interrupt service routine. Vectored interrupt
processing follows this sequence:
1. Push the program counter's low-byte value to stack.
2. Push the program counter's high-byte value to stack.
3. Push the FLAGS register values to stack.
4. Fetch the service routine's high-byte address from the vector address 0000H.
5. Fetch the service routine's low-byte address from the vector address 0001H.
6. Branch to the service routine specified by the 16-bit vector address.
5-3
Page 94
INTERRUPT STRUCTURES3C9228/P9228
S3C9228/P9228 INTERRUPT STRUCTURE
The S3C9228/P9228 microcontroller has fourteen peripheral interrupt sources:
— Timer 1/A interrupt
— Timer B interrupt
— SIO interrupt
— Watch Timer interrupt
— Four external interrupts for port 0
— Four external interrupts for port 1
— Two external interrupts for port 3
5-4
Page 95
S3C9228/P9228INTERRUPT STRUCTURE
VectorEnable/DisablePendingSources
P0.0 External Interript
P0.1 External Interript
P0.2 External Interript
P0.3 External Interript
P1.0 External Interript
P1.1 External Interript
P1.2 External Interript
P1.3 External Interrupt
Timer 1/A Interrupt
Timer B Interrupt
SIO Interrupt
Watch Timer Interrupt
P3.0 Interrupt
P3.1 Interrupt
0000H
0001H
SYM.3
(EI, DI)
INTPND1.0
P0INT.0
INTPND1.1
P0INT.1
INTPND1.2
P0INT.2
INTPND1.3
P0INT.3
INTPND1.4
P1INT.0
INTPND1.5
P1INT.1
INTPND1.6
P1INT.2
INTPND1.7
P1INT.3
INTPND2.0
TACON.1
INTPND2.1
TBCON.1
INTPND2.2
SIOCON.1
INTPND2.3
WTCON.1
INTPND2.4
P3INT.0
INTPND2.5
P3INT.1
Figure 5-3. S3C9228/P9228 Interrupt Structure
5-5
Page 96
INTERRUPT STRUCTURES3C9228/P9228
Programming Tip —How to clear an interrupt pending bit
As the following examples are shown, a load instruction should be used to clear an interrupt pending bit.
Examples:
1.LD INTPND1, #11111011B; Clear P0.2's interrupt pending bit
•
•
•
IRET
2. LD INTPND2, #11110111B; Clear watch timer interrupt pending bit
•
•
•
IRET
5-6
Page 97
S3C9228/P9228SAM88RCRI INSTRUCTION SET
6SAM88RCRI INSTRUCTION SET
OVERVIEW
The SAM88RCRI instruction set is designed to support the large register file. It includes a full complement of 8bit arithmetic and logic operations. There are 41 instructions. No special I/O instructions are necessary because
I/O control and data registers are mapped directly into the register file. Flexible instructions for bit addressing,
rotate, and shift operations complete the powerful data manipulation capabilities of the SAM88RCRI instruction
set.
REGISTER ADDRESSING
To access an individual register, an 8-bit address in the range 0-255 or the 4-bit address of a working register is
specified. Paired registers can be used to construct 16-bit program memory or data memory addresses. For
detailed information about register addressing, please refer to Section 2, "Address Spaces".
ADDRESSING MODES
There are six addressing modes: Register (R), Indirect Register (IR), Indexed (X), Direct (DA), Relative (RA), and
Immediate (IM). For detailed descriptions of these addressing modes, please refer to Section 3, "Addressing
Modes".
6-1
Page 98
SAM88RI INSTRUCTION SETS3C9228/P9228
Table 6-1. Instruction Group Summary
MnemonicOperandsInstruction
Load Instructions
CLRdstClear
LDdst,srcLoad
LDCdst,srcLoad program memory
LDEdst,srcLoad external data memory
LDCDdst,srcLoad program memory and decrement
LDEDdst,srcLoad external data memory and decrement
LDCIdst,srcLoad program memory and increment
LDEIdst,srcLoad external data memory and increment
POPdstPop from stack
PUSHsrcPush to stack
Arithmetic Instructions
ADCdst,srcAdd with carry
ADDdst,srcAdd
CPdst,srcCompare
DECdstDecrement
INCdstIncrement
SBCdst,srcSubtract with carry
SUBdst,srcSubtract
Logic Instructions
ANDdst,srcLogical AND
COMdstComplement
ORdst,srcLogical OR
XORdst,srcLogical exclusive OR
6-2
Page 99
S3C9228/P9228SAM88RCRI INSTRUCTION SET
Table 6-1. Instruction Group Summary (Continued)
MnemonicOperandsInstruction
Program Control Instructions
CALLdstCall procedure
IRETInterrupt return
JPcc,dstJump on condition code
JPdstJump unconditional
JRcc,dstJump relative on condition code
RETReturn
Bit Manipulation Instructions
TCMdst,srcTest complement under mask
TMdst,srcTest under mask
Rotate and Shift Instructions
RLdstRotate left
RLCdstRotate left through carry
RRdstRotate right
RRCdstRotate right through carry
SRAdstShift right arithmetic
CPU Control Instructions
CCFComplement carry flag
DIDisable interrupts
EIEnable interrupts
IDLEEnter Idle mode
NOPNo operation
RCFReset carry flag
SCFSet carry flag
STOPEnter Stop mode
6-3
Page 100
SAM88RI INSTRUCTION SETS3C9228/P9228
FLAGS REGISTER (FLAGS)
The FLAGS register contains eight bits that describe the current status of CPU operations. Four of these bits,
FLAGS.4 – FLAGS.7, can be tested and used with conditional jump instructions;
FLAGS register can be set or reset by instructions as long as its outcome does not affect the flags, such as, Load
instruction. Logical and Arithmetic instructions such as, AND, OR, XOR, ADD, and SUB can affect the Flags
register. For example, the AND instruction updates the Zero, Sign and Overflow flags based on the outcome of
the AND instruction. If the AND instruction uses the Flags register as the destination, then simultaneously, two
write will occur to the Flags register producing an unpredictable result.
System Flags Register (FLAGS)
D5H, R/W
.7.6.5.4.3.2.1.0LSBMSB
Carry flag (C)
Zero flag (Z)
Sign flag (S)
Overflow flag (V)
Not mapped
Figure 6-1. System Flags Register (FLAGS)
FLAG DESCRIPTIONS
Overflow Flag (FLAGS.4, V)
The V flag is set to "1" when the result of a two's-complement operation is greater than + 127 or less than – 128.
It is also cleared to "0" following logic operations.
Sign Flag (FLAGS.5, S)
Following arithmetic, logic, rotate, or shift operations, the sign bit identifies the state of the MSB of the result. A
logic zero indicates a positive number and a logic one indicates a negative number.
Zero Flag (FLAGS.6, Z)
For arithmetic and logic operations, the Z flag is set to "1" if the result of the operation is zero. For operations that
test register bits, and for shift and rotate operations, the Z flag is set to "1" if the result is logic zero.
Carry Flag (FLAGS.7, C)
The C flag is set to "1" if the result from an arithmetic operation generates a carry-out from or a borrow to the
bit 7 position (MSB). After rotate and shift operations, it contains the last value shifted out of the specified
register. Program instructions can set, clear, or complement the carry flag.
6-4
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.