DATA SHEET MOS INTEGRATED CIRCUIT µPD17072,17073 4-BIT SINGLE-CHIP MICROCONTROLLER WITH HARDWARE FOR DIGITAL TUNING SYSTEM DESCRIPTION µPD17072 and 17073 are low-voltage 4-bit single-chip CMOS microcontrollers containing hardware ideal for organizing a digital tuning system. The CPU employs 17K architecture and can manipulate the data memory directly, perform arithmetic operations, and control peripheral hardware with a single instruction. All the instructions are 16-bit one-word instructions. As peripheral hardware, a prescaler that can operate at up to 230 MHz for a digital tuning system, a PLL frequency synthesizer, and an intermediate frequency (IF) counter are integrated in addition to I/O ports, an LCD controller/driver, A/D converter, and BEEP. Therefore, a high-performance, multi-function digital tuning system can be configured with a single chip of µPD17072 or 17073. Because the µPD17072 and 17073 can operate at low voltage (VDD = 1.8 to 3.6 V), they are ideal for controlling battery-cell driven portable devices such as portable radio equipment, headphone stereos, or radio cassette recorders. FEATURES • 17K architecture: general-purpose register system • Program memory (ROM) 6 KB (3072 × 16 bits): µPD17072 8 KB (4096 × 16 bits): µPD17073 • General-purpose data memory (RAM) 176 × 4 bits • Instruction execution time 53.3 µs (with 75-kHz crystal resonator: normal operation) 106.6 µs (with 75-kHz crystal resonator: low-speed mode) • Decimal operation • Table reference • Hardware for PLL frequency synthesizer Dual modulus prescaler (230 MHz max.), programmable divider, phase comparator, charge pump • Various peripheral hardware General-purpose I/O ports, LCD controller/driver, serial interface, A/D converter, BEEP, intermediate frequency (IF) counter • Many interrupts External: 1 channel Internal: 2 channels • Power-ON reset, CE reset, and power failure detector • CMOS low power consumption • Supply voltage: VDD = 1.8 to 3.6 V Unless otherwise stated, the µPD17073 is taken as a representative product in this document. The information in this document is subject to change without notice. Document No. U11450EJ1V0DS00 (1st edition) Date Published September 1996 P Printed in Japan © 1996 µPD17072,17073 ORDERING INFORMATION Part Number Package µPD17072GB-×××-1A7 56-pin plastic QFP (10 × 10 mm, 0.65-mm pitch) µPD17072GB-×××-9EU 64-pin plastic TQFP (fine pitch) (10 × 10 mm, 0.5-mm pitch) µPD17073GB-×××-1A7 56-pin plastic QFP (10 × 10 mm, 0.65-mm pitch) µPD17073GB-×××-9EU 64-pin plastic TQFP (fine pitch) (10 × 10 mm, 0.5-mm pitch) Remark ××× is a ROM code number. 2 µPD17072,17073 FUNCTION OUTLINE Item Function Program memory (ROM) • 6K bytes (3072 × 16 bits): µPD17072 • 8K bytes (4096 × 16 bits): µPD17073 • Table reference area: 4096 × 16 bits General-purpose data memory (RAM) • 176 × 4 bits General-purpose register: 16 × 4 bits (fixed at 00H through 0FH of BANK0, shared with data buffers.) LCD segment register 15 × 4 bits Peripheral control register 32 × 4 bits Instruction execution time • 53.3 µs (with 75-kHz crystal resonator: normal operation) • 106.6 µs (with 75-kHz crystal resonator: low-speed mode) Selectable by software Stack level • Address stack: 2 levels (stack can be manipulated) • Interrupt stack: 1 level (stack cannot be manipulated) General-purpose port • I/O port: 8 • Input port: 4 • Output port: 9 BEEP • 1 type • Selectable frequency (1.5 kHz, 3 kHz) LCD controller/driver • 15 segments, 4 commons 1/4 duty, 1/2 bias, frame frequency of 62.5 Hz, drive voltage VLCD1 = 3.1 V (TYP.) Serial interface • 1 channel (Serial I/O mode) 3-wire/2-wire mode selectable A/D converter 4 bits × 2 channels (successive approximation via software) Interrupt • 3 channels (maskable interrupt) External interrupt: 1 (INT pin) Internal interrupt: 2 (basic timer 1, serial interface) Timer • 2 channels Basic timer 0: 125 ms Basic timer 1: 8 ms, 32 ms Reset • Power-ON reset (on power application) • Reset by CE pin (CE pin: low level → high level) • Power failure detection function PLL frequency synthesizer Division method • Direct division method • Pulse swallow method (VCOL pin: 8 MHz MAX.) (VCOL pin: 55 MHz MAX.) (VCOH pin: 230 MHz MAX.) Reference frequency • 6 types selectable by program 1, 3, 5, 6.25, 12.5, 25 kHz Charge pump Error out output: 1 line (EO pin) Phase comparator Unlock detectable by program Frequency counter • Frequency measurement P0D3/FMIFC/AMIFC pin: FMIF mode, 10 to 11 MHz P0D3/FMIFC/AMIFC pin: AMIF mode 400 to 500 kHz P0D2/AMIFC pin Supply voltage VDD = 1.8 to 3.6 V Package • 56-pin plastic QFP (10 × 10 mm, 0.65-mm pitch) • 64-pin plastic TQFP (10 × 10 mm, 0.5-mm pitch) 3 µPD17072,17073 BLOCK DIAGRAM SCK/P0B2 P0A0-P0A3 Serial Interface P0B0-P0B3 SO0/P1C0 RAM 176×4 bits P0C0, P0C1 SI/SO1/P0B3 BEEP BEEP SYSTEM REG. P0D2, P0D3 Port Interrupt Controller P1A0-P1A3 INT ALU Basic Timer0 P1B0-P1B3 Instruction Decoder P1C0 REGLCD0 REGLCD1 CAPLCD0 ROM 3072×16 bits ( µ PD17072) 4096×16 bits ( µ PD17073) Voltage Doubler CAPLCD1 LCD0 A/D Converter Frequency Counter Program Counter 12 bits COM0 COM3 Basic Timer1 VCOH REG0 CPU XIN OSC VDD Peripheral Reset 4 AMIFC/P0D2 VCOL PLL Voltage Regulator REG1 FMIFC/AMIFC/P0D3 Stack 2×12 bits LCD14 XOUT AD1/P1A3 EO PLL LCD Controller /Driver AD0/P1A2 XTAL Voltage Regulator CE GND µPD17072,17073 PIN CONFIGURATION (Top View) 56-pin plastic QFP (10 × 10 mm) µPD17072GB-×××-1A7 P1C0/SO0 P0B3/SI/SO1 P0B2/SCK P0B1 P0B0 BEEP INT CE LCD14 LCD13 LCD12 LCD11 LCD10 LCD9 LCD8 µPD17073GB-×××-1A7 56 55 54 53 52 51 50 49 48 47 46 45 44 43 LCD4 P0A3 5 38 LCD3 P1B0 6 37 LCD2 P1B1 7 36 LCD1 P1B2 8 35 LCD0 P1B3 9 34 COM3 P1A0 10 33 COM2 P1A1 11 32 COM1 P1A2/AD0 12 31 COM0 P1A3/AD1 13 30 REGLCD1 P0C0 14 29 CAPLCD1 15 16 17 18 19 20 21 22 23 24 25 26 27 28 CAPLCD0 39 REGLCD0 4 REG1 P0A2 XIN LCD5 XOUT 40 VDD 3 REG0 P0A1 VCOH LCD6 VCOL 41 EO 2 GND P0A0 P0D3/FMIFC/AMIFC LCD7 P0D2/AMIFC 42 P0C1 1 5 µPD17072,17073 64-pin plastic TQFP (fine pitch) (10 × 10 mm) µPD17072GB-×××-9EU LCD8 LCD9 LCD10 LCD11 LCD12 NC LCD13 LCD14 CE INT NC BEEP P0B0 P0B1 P0B2/SCK P0B3/SI/SO1 µPD17073GB-×××-9EU 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 P1C0/SO0 1 48 LCD7 P0A0 2 47 LCD6 P0A1 3 46 LCD5 P0A2 4 45 NC NC 5 44 LCD4 P0A3 6 43 LCD3 P1B0 7 42 LCD2 P1B1 8 41 LCD1 P1B2 9 40 LCD0 P1B3 10 39 COM3 P1A0 11 38 NC NC 12 37 COM2 P1A1 13 36 COM1 P1A2/AD0 14 35 COM0 P1A3/AD1 15 34 REGLCD1 P0C0 16 33 CAPLCD1 6 CAPLCD0 REGLCD0 REG1 XIN XOUT VDD VDD REG0 VCOH VCOL EO GND GND P0D3/FMIFC/AMIFC P0D2/AMIFC P0C1 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 µPD17072,17073 PIN IDENTIFICATION AD0, AD1 : A/D converter input AMIFC : Intermediate frequency (IF) counter input BEEP : BEEP output CAPCLD0, CAPLCD1 : Capacitor connection for LCD drive voltage CE : Chip enable COM0-COM2 : LCD common signal output EO : Error out FMIFC : Intermediate frequency (IF) counter input GND : Ground INT : External interrupt request signal input LCD0-LCD14 : LCD segment signal output NC : No connection P0A0-P0A3 : Port 0A P0B0-P0B3 : Port 0B P0C0, P0C1 : Port 0C P0D2, P0D3 : Port 0D P1A0-P1A3 : Port 1A P1B0-P1B3 : Port 1B P1C0 : Port 1C REGLCD0, REGLCD1 : LCD drive voltage REG0 : PLL voltage regulator REG1 : Oscillation circuit voltage regulator SCK : Serial clock I/O SI : Serial data input SO0, SO1 : Serial data output VCOL : Local oscillator input VCOH : Local oscillator input VDD : Positive power supply XIN, XOUT : Crystal resonator connection pins 7 µPD17072,17073 CONTENTS 1. PIN FUNCTION .................................................................................................................................. 12 1.1 Pin Function List ...................................................................................................................................... 12 1.2 Equivalent Circuits of Pins ....................................................................................................................... 15 1.3 Processing of Unused Pins ..................................................................................................................... 18 1.4 Notes on Using CE Pin ............................................................................................................................ 19 2. PROGRAM MEMORY (ROM) ........................................................................................................... 20 2.1 General ..................................................................................................................................................... 20 2.2 Program Memory ..................................................................................................................................... 21 2.3 Program Counter ...................................................................................................................................... 21 2.4 Execution Flow of Program Memory ....................................................................................................... 22 2.5 Notes on Using Program Memory ........................................................................................................... 22 3. ADDRESS STACK (ASK) ................................................................................................................. 23 3.1 General ..................................................................................................................................................... 23 3.2 Address Stack Register (ASR) ................................................................................................................ 23 3.3 Stack Pointer (SP) ................................................................................................................................... 24 3.4 Operations of Address Stack ................................................................................................................... 25 3.5 Notes on Using Address Stack ................................................................................................................ 25 4. DATA MEMORY (RAM) ..................................................................................................................... 26 4.1 General ..................................................................................................................................................... 26 4.2 Configuration and Function of Data Memory .......................................................................................... 27 4.3 Addressing Data Memory ........................................................................................................................ 30 4.4 Notes on Using Data Memory ................................................................................................................. 31 5. SYSTEM REGISTER (SYSREG) ...................................................................................................... 32 5.1 General ..................................................................................................................................................... 32 5.2 Address Register (AR) ............................................................................................................................. 33 5.3 Bank Register (BANK) ............................................................................................................................. 35 5.4 Program Status Word (PSWORD) .......................................................................................................... 36 5.5 Notes on Using System Register ............................................................................................................ 37 6. GENERAL REGISTERS (GR) ........................................................................................................... 38 6.1 Outline of General Registers ................................................................................................................... 38 6.2 Address Creation of General Register with Each Instruction ................................................................ 39 6.3 Notes on Using General Register ........................................................................................................... 39 7. ALU (ARITHMETIC LOGIC UNIT) BLOCK ....................................................................................... 40 8 7.1 General ..................................................................................................................................................... 40 7.2 Configuration and Function of Each Block ............................................................................................. 41 7.3 ALU Processing Instructions ................................................................................................................... 41 7.4 Notes on Using ALU ................................................................................................................................ 44 µPD17072,17073 8. PERIPHERAL CONTROL REGISTERS ........................................................................................... 45 8.1 Outline of Peripheral Control Registers .................................................................................................. 45 8.2 Configuration and Function of Peripheral Control Registers ................................................................. 46 9. DATA BUFFER (DBF) ....................................................................................................................... 54 9.1 General ..................................................................................................................................................... 54 9.2 Data Buffer ............................................................................................................................................... 55 9.3 List of Peripheral Hardware and Data Buffer Functions ........................................................................ 56 9.4 Notes on Using Data Buffer ..................................................................................................................... 56 10. GENERAL-PURPOSE PORT ............................................................................................................ 57 10.1 General ..................................................................................................................................................... 57 10.2 General-Purpose I/O Ports (P0B, P0C, P0D) ......................................................................................... 58 10.3 General-Purpose Input Ports (P1A) ........................................................................................................ 62 10.4 General-Purpose Output Ports (P0A, P1B, P1C) ................................................................................... 65 11. INTERRUPT ....................................................................................................................................... 66 11.1 General ..................................................................................................................................................... 66 11.2 Interrupt Control Block ............................................................................................................................. 67 11.3 Interrupt Stack Register ........................................................................................................................... 70 11.4 Stack Pointer, Address Stack Register, and Program Counter ............................................................. 72 11.5 Interrupt Enable Flip-Flop (INTE) ............................................................................................................ 72 11.6 Accepting Interrupt ................................................................................................................................... 73 11.7 Operations after Accepting Interrupt ....................................................................................................... 77 11.8 Exiting from Interrupt Service Routine .................................................................................................... 78 11.9 External (INT Pin) Interrupts ................................................................................................................... 79 11.10 Internal Interrupt ....................................................................................................................................... 81 12. TIMER ................................................................................................................................................ 82 12.1 General ..................................................................................................................................................... 82 12.2 Basic Timer 0 ........................................................................................................................................... 82 12.3 Basic Timer 1 ........................................................................................................................................... 91 13. A/D CONVERTER ............................................................................................................................. 98 13.1 General ..................................................................................................................................................... 98 13.2 Setting A/D Converter Power Supply ...................................................................................................... 99 13.3 Input Selector Block ............................................................................................................................... 100 13.4 Compare Voltage Generator Block and Compare Block ..................................................................... 102 13.5 Comparison Timing Chart ...................................................................................................................... 107 13.6 Performance of A/D Converter .............................................................................................................. 107 13.7 Using A/D Converter .............................................................................................................................. 108 13.8 Status at Reset ....................................................................................................................................... 111 14. SERIAL INTERFACE ....................................................................................................................... 112 14.1 General ................................................................................................................................................... 112 14.2 Clock Input/Output Control Block and Data Input/Output Control Block ............................................. 113 14.3 Clock Control Block ............................................................................................................................... 116 14.4 Clock Counter ........................................................................................................................................ 116 9 µPD17072,17073 14.5 Presettable Shift Register ...................................................................................................................... 117 14.6 Wait Control Block ................................................................................................................................. 117 14.7 Serial Interface Operation ..................................................................................................................... 118 14.8 Notes on Setting and Reading Data ..................................................................................................... 122 14.9 Operational Outline of Serial Interface ................................................................................................. 123 14.10 Status on Reset ..................................................................................................................................... 125 15. PLL FREQUENCY SYNTHESIZER ................................................................................................ 126 15.1 General ................................................................................................................................................... 126 15.2 Input Selector Block and Programmable Divider ................................................................................. 127 15.3 Reference Frequency Generator ........................................................................................................... 133 15.4 Phase Comparator (φ-DET), Charge Pump, and Unlock FF ............................................................... 135 15.5 PLL Disable Status ................................................................................................................................ 139 15.6 Use of PLL Frequency Synthesizer ...................................................................................................... 140 15.7 Status on Reset ..................................................................................................................................... 143 16. INTERMEDIATE FREQUENCY (IF) COUNTER ............................................................................. 144 16.1 Outline of Intermediate Frequency (IF) Counter .................................................................................. 144 16.2 IF Counter Input Selector Block and Gate Time Control Block ........................................................... 145 16.3 Start Control Block and IF Counter ....................................................................................................... 147 16.4 Using IF Counter .................................................................................................................................... 152 16.5 Status at Reset ...................................................................................................................................... 154 17. BEEP ................................................................................................................................................ 155 17.1 Configuration and Function of BEEP .................................................................................................... 155 17.2 Output Wave Form of BEEP ................................................................................................................. 156 17.3 Status at Reset ...................................................................................................................................... 157 18. LCD CONTROLLER/DRIVER ......................................................................................................... 158 18.1 Outline of LCD Controller/Driver ........................................................................................................... 158 18.2 LCD Drive Voltage Generation Block .................................................................................................... 159 18.3 LCD Segment Register .......................................................................................................................... 160 18.4 Common Signal Output and Segment Signal Output Timing Control Blocks ..................................... 162 18.5 Common Signal and Segment Signal Output Waves .......................................................................... 163 18.6 Using LCD Controller/Driver .................................................................................................................. 165 18.7 Status at Reset ...................................................................................................................................... 167 19. STANDBY ........................................................................................................................................ 168 10 19.1 General ................................................................................................................................................... 168 19.2 Halt Function .......................................................................................................................................... 170 19.3 Clock Stop Function ............................................................................................................................... 178 19.4 Device Operations in Halt and Clock Stop Statuses ............................................................................ 181 19.5 Note on Processing of Each Pin in Halt and Clock Stop Statuses ..................................................... 182 19.6 Device Control Function by CE Pin ...................................................................................................... 185 19.7 Low-Speed Mode Function .................................................................................................................... 187 µPD17072,17073 20. RESET .............................................................................................................................................. 188 20.1 Configuration of Reset Block ................................................................................................................. 188 20.2 Reset Function ....................................................................................................................................... 189 20.3 CE Reset ................................................................................................................................................ 190 20.4 Power-ON Reset .................................................................................................................................... 194 20.5 Relations between CE Reset and Power-ON Reset ............................................................................ 197 20.6 Power Failure Detection ........................................................................................................................ 199 21. µPD17012 INSTRUCTIONS ............................................................................................................ 204 21.1 Instruction Set Outline ........................................................................................................................... 204 21.2 Legend .................................................................................................................................................... 205 21.3 Instruction List ........................................................................................................................................ 206 21.4 Assembler (AS17K) Embedded Macroinstructions .............................................................................. 207 22. µPD17073 RESERVED WORDS .................................................................................................... 208 22.1 Data Buffer (DBF) .................................................................................................................................. 208 22.2 System Register (SYSREG) .................................................................................................................. 208 22.3 LCD Segment Register .......................................................................................................................... 209 22.4 Port Register .......................................................................................................................................... 210 22.5 Peripheral Control Register ................................................................................................................... 211 22.6 Peripheral Hardware Register ..................................................................................................................... 22.7 Others ..................................................................................................................................................... 213 23. ELECTRICAL CHARACTERISTICS ............................................................................................... 214 24. PACKAGE DRAWINGS ................................................................................................................... 217 25. RECOMMENDED SOLDERING CONDITIONS .............................................................................. 219 APPENDIX A. NOTES ON CONNECTING CRYSTAL RESONATOR ................................................ 220 APPENDIX B. DEVELOPMENT TOOLS.............................................................................................. 221 11 µPD17072,17073 1. PIN FUNCTION 1.1 Pin Function List Pin No. QFP TQFP 1 1 Symbol Function Output format At power-ON reset P1C0/SO0 Port 1C and output of serial interface. P1C0 • 1-bit output port • SO0 • Serial data output CMOS push-pull Low-level output • 2 3 4 5 2 3 4 6 P0A0 P0A1 P0A2 P0A3 4-bit output port (port 0A). CMOS push-pull Low-level output 6 7 8 9 7 8 9 10 P1B0 P1B1 P1B2 P1B3 4-bit output port (port 1B). CMOS push-pull Low-level output 10 11 11 13 P1A0 P1A1 • 12 13 14 15 P1A2/AD0 P1A3/AD1 • 14 15 16 17 P0C0 P0C1 2-bit I/O port (port 0C). Input/output mode can be set in 1-bit units. CMOS push-pull Input 16 17 18 19 P0D2/AMIFC P0D3/FMIFC/ AMIFC Port 0D and IF counter inputs. • P0D3, P0D2 • 2-bit I/O port • Can be set in input/output mode in 1-bit units. • FMIFC, AMIFC • IF counter inputs CMOS push-pull Input 20 GND Ground 18 Port 1A and analog inputs to A/D converter. — P1A3-P1A0 • 4-bit input port AD1, AD0 • Analog inputs to A/D converter Inputs with pulldown resistor — — 21 19 22 EO Output from charge pump of PLL frequency synthesizer 20 21 23 24 VCOL VCOH Input local oscillation frequency of PLL. — Floating 22 25 REG0 Output of PLL voltage regulator. Connect this pin to GND via 0.1-µF capacitor. — Low-level output REG0 0.1 µF 12 CMOS 3-state Floating µPD17072,17073 Pin No. Symbol Function Output format At power-ON QFP TQFP reset 23 26 27 VDD Positive power supply. Supply 1.8 to 3.6 V (TA = –20 to +70 °C) to operate all functions. Do not apply voltage higher than that of VDD pin to any pin other than VDD. 24 28 XOUT Pins for connecting crystal resonator for system — — — — — 25 29 XIN clock oscillation. 26 30 REG1 Output of voltage regulator for oscillation circuit. Connect this pin to GND via 0.1-µF capacitor. — — CMOS push-pull — REG1 0.1 µF 27 28 29 30 31 32 33 34 REGLCD0 CAPLCD0 CAPLCD1 REGLCD1 • • REGLCD1, REGLCD0 LCD drive power pins. CAPLCD1, CAPLCD0 Connect capacitors for doubler circuit to generate LCD drive voltage, across these pins. To configure doubler circuit, connect capacitors as shown below. C1 C1 = C2 = 0.1 µ F C3 = 0.01 µF REGLCD1 CAPLCD1 C3 CAPLCD0 REGLCD0 C2 Caution The value of the LCD drive voltage differs if the values of C1, C2, and C3 are changed because of the configuration of the doubler circuit. 13 µPD17072,17073 Pin No. Symbol Function Output format At power-ON QFP TQFP 31 32 33 34 35 36 37 39 COM0 COM1 COM2 COM3 Common signal outputs of LCD controller/driver. CMOS ternary output Low-level output 35 | 49 40 | 56 LCD0 | LCD14 Segment signal outputs of LCD controller/driver. CMOS push-pull Low-level output 50 57 CE Device operation select and reset signal input. — Input 51 58 INT External interrupt request signal input. Interrupt request is issued at rising or falling edge of signal input to this pin. — Input 52 60 BEEP BEEP signal output pin. BEEP output of 1.5 kHz or 3 kHz can be selected. CMOS push-pull Low-level output 53 54 55 56 61 62 63 64 P0B0 P0B1 P0B2/SCK P0B3/SI/SO1 Port 0B and serial interface I/O. • P0B3-P0B0 • 4-bit I/O port • Can be set in input or output mode in 1-bit units. • SCK • Serial clock I/O • SO1 • Serial data output • SI • Serial data input CMOS push-pull Input — 5 12 38 45 54 59 NC No connection 14 reset — — µPD17072,17073 1.2 Equivalent Circuits of Pins (1) P0B (P0B3/SI/SO1, P0B2/SCK, P0B1, P0B0) P0C (P0C1, P0C0) (I/O) P0D (P0D3/FMIFC/AMIFC, P0D2/AMIFC) VDD VDD (2) P0A (P0A3, P0A2, P0A1, P0A0) P1B (P1B3, P1B2, P1B1, P1B0) P1C (P1C0/SO0) LCD14-LCD0 (Output) BEEP EO VDD (3) P1A (P1A3/AD1, P1A2/AD0, P1A1, P1A0) (Input) VDD High ON resistance 15 µPD17072,17073 (4) CE (Schmitt trigger input) VDD CE flag (5) INT (Schmitt trigger input) VDD (6) XOUT (output), XIN (input) VDD XIN High ON resistance XOUT 16 High ON resistance VDD µPD17072,17073 (7) COM3 through COM0 (output) VLCD0 VLCD1 (8) VCOH (input) High ON resistance VDD VDD (9) VCOL (input) High ON resistance VDD PLL disable signal High ON resistance VDD PLL disable signal 17 µPD17072,17073 1.3 Processing of Unused Pins It is recommended that the unused pins be connected as follows: Table 1-1. Processing of Unused Pins Pin name Port pin P0A0-P0A3 P0B0, P0B1 I/O mode CMOS push-pull output I/O Note 1 Recommended processing of unused pins Open Set by software to output low level and open P0B2/SCK P0B3/SI/SO1 P0C0, P0C1 P0D2/AMIFC P0D3/FMIFC/AMIFC P1A0, P1A1 Input Connect each of these pins to VDD or GND via resistor CMOS push-pull output Open Note 2 . P1A2/AD0 P1A3/AD1 P1B0-P1B3 P1C0/SO0 Pins other BEEP CMOS push-pull output Open than port CE Input Connect to VDD via resistor COM0-COM3 Output Open EO Output INT Input Connect to GND via resistor LCD0-LCD14 CMOS push-pull output Open VCOH, VCOL Input Connect each of these pins to GND via resistorNote 2. pins Note 2 . Note 2 . Notes 1. The I/O ports are set in the input mode on power application, on clock stop, and on CE reset. 2. When pulling up (connecting to VDD via resistor) or pulling down (connecting to GND via resistor) a pin externally with high resistance, the pin almost goes into a high-impedance state, and consequently, the current consumption (through current) of the port increases. Generally, the pull-up or pull-down resistance is several 10 kΩ, though it varies depending on the application circuit. 18 µPD17072,17073 1.4 Notes on Using CE Pin The CE pin has a function to set a test mode in which the internal operations of the µPD17073 are tested (dedicated to IC test), in addition to the functions listed in 1.1 Pin Function List. When a voltage higher than VDD is applied to the CE pin, the test mode is set. This means that if noise exceeding VDD is applied to the CE pin even during normal operation, the test mode is set, affecting the normal operation. If the wiring of the CE pin is too long, the above problem occurs because wiring noise is superimposed on the CE pin. Therefore, wire the CE pin with as short a wiring length as possible to suppress noise. If noise cannot be avoided, use external components as shown below to suppress noise. • Connect a diode with low VF between CE and VDD • Connect a capacitor between CE and VDD VDD Diode with low VF VDD VDD CE VDD CE 19 µPD17072,17073 2. PROGRAM MEMORY (ROM) 2.1 General Figure 2-1 shows the configuration of the program memory. As shown in this figure, the program memory consists of a program memory and a program counter. The addresses of the program memory are specified by the program counter. The program memory has the following two major functions: (1) Stores program (2) Stores constant data Figure 2-1. Outline of Program Memory Program counter Program memory Specifies address • • • Instruction • • • • • • Constant data • • • 20 µPD17072,17073 2.2 Program Memory Figure 2-2 shows the configuration of the program memory. As shown in this figure, the program memory is configured as follows: µPD17072: 3072 × 16 bits (0000H-0BFFH) µPD17073: 4096 × 16 bits (0000H-0FFFH) Therefore, the addresses of the program memory range from 0000H to 0FFFH. All the “instructions” are “one-word instructions” each of which is 16 bits long. Consequently, one instruction can be stored in one address of the program memory. As constant data, the contents of the program memory are read to the data buffer by using a table reference instruction. Figure 2-2. Configuration of Program Memory 0 0 0 0H Reset start address 0 0 0 1H Serial interface interrupt vector 0 0 0 2H Basic timer 1 interrupt vector BR addr instruction branch address CALL addr instruction subroutine entry address Page 0 0 0 0 3H INT pin interrupt vector BR @AR instruction branch address CALL @AR instruction subroutine entry address 0 7 F FH MOVT DBF @AR instruction table reference address (with µ PD17072) 0 B F FH Page 1 (with µ PD17073) 0 F F FH 16 bits Caution With the µPD17072, the range of addresses that can be called by each instruction is 0000H to 0BFFH. The area from addresses 0C00H through 0FFFH is an undefined area. 2.3 Program Counter Figure 2-3 shows the configuration of the program counter. The program counter specifies an address of the program memory. As shown in this figure, the program counter is a 12-bit binary counter. The most significant bit b11 indicates a page. Figure 2-3. Configuration of Program Counter PC11 PC10 PC9 PC8 PC7 PC6 PC5 PC4 PC3 PC2 PC1 PC0 Page PC 21 µPD17072,17073 2.4 Execution Flow of Program Memory Execution of the program is controlled by the program counter which specifies an address of the program memory. Figure 2-4 shows the values to be set to the program counter when each instruction is executed. Table 2-1 shows the vector addresses that are to be set to the program counter when each interrupt occurs. Figure 2-4. Specification by Program Counter On Execution of Each Instruction Program counter Instruction Contents of program counter (PC) b 11 Page 0 0 Page 1 1 b 10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 0 0 Instruction operand (addr) BR addr 0 CALL addr Instruction operand (addr) BR @AR CALL @AR MOVT DBF, @AR Contents of address register Contents of address stack register (ASR) specified by stack pointer (SP) (Return address) RET RETSK RETI When interrupt is accepted Vector address of each interrupt 0 Power-ON reset, CE reset 0 0 0 0 0 0 0 0 0 Table 2-1. Interrupt Vector Address Priority Internal/external Interrupt source Vector address 1 External INT pin 0003H 2 External Basic timer 1 0002H 3 External Serial interface 0001H 2.5 Notes on Using Program Memory (1) µPD17072 The program memory addresses of the µPD17072 are 0000H through 0BFFH. However, because the addresses that can be specified by the program counter (PC) are 0000H through 0FFFH, keep the following points in mind when specifying a program memory address: • Be sure to write a branch instruction to address 0BFFH, when writing an instruction to this address. • Do not write an instruction to addresses 0C00H through 0FFFH. • Do not branch to addresses 0C00H through 0FFFH. (2) With µPD17073 The program memory addresses of the µPD17073 are 0000H through 0FFFH. Keep the following point in mind: • Be sure to write a branch instruction to address 0FFFH, when writing an instruction to this address. 22 µPD17072,17073 3. ADDRESS STACK (ASK) 3.1 General Figure 3-1 outlines the address stack. The address stack consists of a stack pointer and an address stack register. The address of the address stack register is specified by the stack pointer. The address stack saves return addresses when a subroutine call instruction has been executed and when an interrupt has been accepted. The address stack is also used when a table reference instruction is executed. Figure 3-1. Outline of Address Stack Stack pointer Address stack register Specifies address Return address 3.2 Address Stack Register (ASR) Figure 3-2 shows the configuration of the address stack register. The address stack register consists of three 12-bit registers ASR0-ASR2. Actually, however, no register is assigned to ASR2, and the address stack register therefore consists of two 12-bit registers (ASR0 and ASR1). The address stack saves return addresses when a subroutine call instruction has been executed, when an interrupt has been accepted, and when a table reference instruction is executed. Figure 3-2. Configuration of Address Stack Register Stack pointer (SP) Address stack register (ASR) Bit Bit Address b3 b2 0 0 b1 b0 SP1 SP0 b 11 0H 1H 2H b 10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 ASR0 ASR1 ASR2 (Undefined) Cannot be used 23 µPD17072,17073 3.3 Stack Pointer (SP) Figure 3-3 shows the configuration and functions of the stack pointer. The stack pointer is a 4-bit binary counter. The stack pointer specifies the addresses of the address stack registers. The value of the stack pointer can be directly read or written by using a register manipulation instruction. Figure 3-3. Configuration and Functions of Stack Pointer Flag symbol Name Stack pointer SP b3 b2 b1 b0 0 0 S P 1 S P 0 Address Read/ Write 01H R/W Specifies address of address stack register (ASR) 0 0 Address 0 (ASR0) 0 1 Address 1 (ASR1) 1 0 Address 2 (ASR2) Fixed to "0" 1 0 At reset Clock stop 1 0 CE 1 0 Power-ON 24 0 0 µPD17072,17073 3.4 Operations of Address Stack 3.4.1 Subroutine call (“CALL addr” or “CALL @AR”) and return (“RET” or “RETSK”) instructions When a subroutine call instruction is executed, the value of the stack pointer is decremented by one and the return address is stored to the address stack register specified by the stack pointer. When a return instruction is executed, the contents of the address stack specified by the stack pointer (return address) is restored to the program counter, and the value of the stack pointer is incremented by one. 3.4.2 Table reference instruction (“MOVT DBF, @AR”) When the table reference instruction is executed, the value of the stack pointer is decremented by one and the return address is stored to the address stack register specified by the stack pointer. Next, the contents of the program memory addressed by the address register are read to the data buffer, and the contents of the address stack register specified by the stack pointer (return address) are restored to the program counter. The value of the stack pointer is then incremented by one. 3.4.3 On acceptance of interrupt and execution of return instruction (“RETI” instruction) When an interrupt is accepted, the value of the stack pointer is decremented by one, and the return address is stored to the address stack register specified by the stack address. When the return instruction is executed, the contents of the address stack register specified by the stack pointer (return address) are restored to the program counter and the value of the stack pointer is incremented by one. 3.4.4 Address stack manipulation instructions (“PUSH AR” and “POP AR”) When the “PUSH” instruction is executed, the value of the stack pointer is decremented by one, and the contents of the address register are transferred to the address stack register specified by the stack pointer. When the “POP” instruction is executed, the contents of the address stack register specified by the stack pointer are transferred to the address register, and the value of the stack pointer is incremented by one. 3.5 Notes on Using Address Stack The nesting level of the address stack is two, and the value of the address stack register ASR2 is “undefined” when the value of the stack pointer is 2H. Consequently, if a subroutine is called or an interrupt is used exceeding 2 levels without manipulating the stack, program execution returns to an “undefined” address. 25 µPD17072,17073 4. DATA MEMORY (RAM) 4.1 General Figure 4-1 outlines the data memory. As shown in this figure, the data memory consists of a general-purpose data memory, system register, data buffer, general register, LCD segment register, port register, and peripheral control register. The data memory stores data, transfers data with peripheral hardware, sets conditions for the peripheral hardware, display data, transfers data with ports, and controls the CPU. Figure 4-1. Outline of Data Memory Peripheral hardware Data transfer Column address 0 1 2 3 4 5 6 7 8 9 A B C D E F Data buffer 0 General register 1 Row address 2 3 Data memory 4 5 BANK0 6 7 Port register BANK1 LCD segment register Peripheral control register Port register System register Data transfer Data transfer Port Condition setting LCD Peripheral hardware 26 µPD17072,17073 4.2 Configuration and Function of Data Memory Figure 4-2 shows the configuration of the data memory. As shown in this figure, the data memory is divided into three banks, and each bank consists of 128 nibbles with 7H row addresses and 0FH column addresses. In terms of function, the data memory can be divided into six blocks each of which is described in the following paragraphs 4.2.1 through 4.2.8. The contents of the data memory can be operated, compared, judged, and transferred in 4-bit units by data memory manipulation instructions. Table 4-1 lists the data memory manipulation instructions. 4.2.1 System registers (SYSREG) The system registers are allocated to addresses 74H through 7FH. These registers are allocated independently of the bank and directly control the CPU. The same system registers exist at addresses 74H through 7FH of each bank. With the µPD17073, only AR (address register: addresses 75H through 77H), BANK (bank register: address 79H), and PSWORD (program status word: addresses 7EH and 7FH) can be manipulated. For details, refer to 5. SYSTEM REGISTER (SYSREG). 4.2.2 Data buffer (DBF) The data buffer is allocated to addresses 0CH through 0FH of BANK0. The data buffer reads the constant data in the program memory (table reference), and transfers data with peripheral hardware. For details, refer to 9. DATA BUFFER (DBF). 4.2.3 General registers With the µPD17073, the general registers are fixed at row address 0 of BANK0, i.e., addresses 00H through 0FH, and cannot be moved. Operations and data transfer between the general registers and data memory can be executed with a single instruction. The general registers can be controlled by data memory manipulation instructions, like the other data memory areas. For details, refer to 6. GENERAL REGISTER (GR). 4.2.4 LCD segment registers The LCD segment registers are allocated to addresses 41H through 4FH of BANK1 of the data memory, and are used to set the display data of the LCD controller/driver. For details, refer to 18. LCD CONTROLLER/DRIVER. 4.2.5 Port registers The port registers are allocated to addresses 70H through 73H of BANK0 and addresses 70H through 73H of BANK1, and are used to set the output data of each general-purpose port and read the data of the input ports. For details, refer to 10. GENERAL-PURPOSE PORT. 4.2.6 Peripheral control registers The peripheral control registers are allocated to addresses 50H through 6FH of BANK1 and are used to set the conditions of the peripheral hardware (such as PLL, serial interface, A/D converter, IF counter, and timer). For details, refer to 8. PERIPHERAL CONTROL REGISTER. 27 µPD17072,17073 4.2.7 General-purpose data memory The general-purpose data memory is allocated to the area of the data memory excluding the system register, LCD segment register, port register, and peripheral control register. With the µPD17073, a total of 176 nibbles (176 × 4 bits), 112 nibbles of BANK0 and 64 nibbles of BANK1, can be used as the general-purpose data memory. 4.2.8 Data memory areas not provided For these data memory areas, refer to 4.4.2 Notes on data memory areas not provided, 8.2 Configuration and Function of Peripheral Control Registers, and Table 10-1 Relation between Each Port (Pin) and Port Register. 28 µPD17072,17073 Figure 4-2. Configuration of Data Memory Column address 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 Row address 1 Data memory 2 3 4 5 BANK0 6 BANK1 7 System register Column address 0 1 2 3 4 5 6 7 8 9 A B C General register 0 D E F Data buffer Row address 1 Example BANK0 2 Address 2BH of BANK0 3 4 b3 b2 b1 b0 5 6 7 Port register 0 1 2 3 System register (SYSREG) 4 5 6 7 8 9 A B C D E F 0 Row address 1 BANK1 2 Same system register exists. 3 LCD segment register 4 5 Peripheral control register 6 7 Port register System register (SYSREG) Caution Address 40H of BANK1, bit 3 of address 50H, and address 73H are test mode areas. Do not write “1” to these areas. 29 µPD17072,17073 Table 4-1. Data Memory Manipulation Instructions Function Instruction ADD Add Operation ADDC SUB Subtract SUBC AND Logical OR XOR SKE SKGE Compare SKLT SKNE MOV Transfer LD ST SKT Judge SKF 4.3 Addressing Data Memory Figure 4-3 shows how to address the data memory. An address of the data memory is specified by using a bank, row address, and column address. The row address and column address are directly specified by a data memory manipulation instruction, but the bank is specified by the contents of the bank register. For details of the bank register, refer to 5. SYSTEM REGISTER (SYSREG). Figure 4-3. Addressing Data Memory Bank b3 Data memory address 30 M b2 b1 Row address Column address b0 Bank register b2 b1 b0 b3 b2 Instruction operand b1 b0 µPD17072,17073 4.4 Notes on Using Data Memory 4.4.1 On power-ON reset On power-ON reset, the contents of the general-purpose data memory are “undefined”. Initialize the memory if necessary. 4.4.2 Notes on data memory not provided If a data memory manipulation instruction is executed to manipulate an address where no data memory is assigned, the following operations are performed: (1) Device operation When a read instruction is executed, “0” is read. Nothing is changed even when a write instruction is executed. Address 40H of BANK1, bit 3 of address 50H, and address 73H are test mode areas. Do not write “1” to these areas. (2) Assembler operation The program is assembled normally. No “error” occurs. (3) In-circuit emulator operation “0” is read when a read instruction is executed. Nothing is changed when a write instruction is executed. No “error” occurs. 31 µPD17072,17073 5. SYSTEM REGISTER (SYSREG) 5.1 General Figure 5-1 shows the location of the system register on the data memory and outline. As shown, the system register is assigned to addresses 74H-7FH of the data memory, regardless of bank. In other words, the same system register is assigned to addresses 74H-7FH of any bank. Since the system register is located on the data memory, it can be manipulated by all the data memory manipulation instructions. With the µPD17073, only the address register (AR: 74H through 77H), bank register (BANK: 79H), and program status word (PSWORD: 7EH, 7FH) of addresses 74H through 7FH can be manipulated. Figure 5-1. Location of System Register on Data Memory and Outline Row address 0 1 2 3 0 1 2 4 5 Column address 6 7 8 9 A B C D E F Data memory 3 4 5 BANK0 6 7 BANK1 System register Address 74H 75H Outline Name Outline 32 77H Address register (AR) Name Address 76H 78H 79H Fixed to 0 Bank register (BANK) Specifies data memory bank Controls program memory address 7AH 7BH 7CH Fixed to 0 7DH 7EH 7FH Program status word (PSWORD) Controls operation µPD17072,17073 5.2 Address Register (AR) 5.2.1 Configuration of address register Figure 5-2 shows the configuration of the address register. As shown in this figure, the address register consists of 16 bits of the system register: 74H through 77H (AR3 through AR0). However, the higher 4 bits are always fixed to 0, and therefore, the address register actually functions as a 12-bit register. Figure 5-2. Address Register Configuration Address 74H 75H Symbol At reset Data 77H Address register (AR) Name Bit 76H AR3 b3 0 b1 b2 0 0 AR2 b0 0 b3 b2 b1 AR1 b0 b3 b2 b1 AR0 b0 b3 b2 b1 b0 M L S S B B Power-ON 0 0 0 0 Clock stop 0 0 0 0 CE 0 0 0 0 Remark Power-ON : On power-ON reset Clock stop : On execution of clock stop instruction CE : On CE reset 33 µPD17072,17073 5.2.2 Functions of address register The address register specifies a program memory address when the table reference instruction (“MOVT DBF, @AR”), stack manipulation instruction (“PUSH AR” or “POP AR”), indirect branch instruction (“BR @AR”), and indirect subroutine call instruction (“CALL @AR”) has been executed. A dedicated instruction (“INC AR”) that can increment the value of the address register by one is available. The following paragraphs (1) through (5) describe the operations of the address register when each of these instructions has been executed. (1) Table reference instruction (“MOVT DBF, @AR”) When the “MOVT DBF, @AR” instruction is executed, the constant data (16 bits) of the program memory address specified by the contents of the address register are read to the data buffer. The addresses of the constant data which can be specified by the address register are 0000H-0FFFH. (2) Stack manipulation instruction (“PUSH AR”, “POP AR”) By executing the “PUSH AR” instruction, the stack pointer is decremented by one and the contents of the address register (AR) are stored to the address stack register specified by the stack pointer. When the “POP AR” instruction is executed, the contents of the address stack register specified by the stack pointer are transferred to the address register, and the stack pointer is incremented by one. (3) Indirect branch instruction (“BR @AR”) When the “BR @AR” instruction is executed, the program execution branches to a program memory address specified by the contents of the address register. The branch addresses that can be specified by the address register are 0000H-0FFFH. (4) Indirect subroutine call instruction (“CALL @AR”) When the “CALL @AR” instruction is executed, the subroutine at the program memory address specified by the contents of the address register can be called. The first addresses of the subroutine that can be specified by the address register are 0000H-0FFFH. (5) Address register increment instruction (“INC AR”) This instruction increments the contents of the address register by one each time it is executed. Since the address register is configured of 12 bits, its contents become “0000H” when the “INC AR” instruction is executed with the contents of the address register being “0FFFH”. 5.2.3 Address register and data buffer The address register can transfer data through the data buffer as a part of the peripheral hardware. For details, refer to 9. DATA BUFFER (DBF). 34 µPD17072,17073 5.3 Bank Register (BANK) 5.3.1 Configuration of bank register Figure 5-3 shows the configuration of the bank register. As shown in this figure, the bank register consists of 4 bits of address 79H (BANK) of the system register. Note, however, that the higher 3 bits are always fixed to “0”; therefore, this register actually serves as a 1-bit register. Figure 5-3. Bank Register Configuration Address 79H Name Bank register (BANK) At reset Symbol BANK Bit b3 b2 b1 Data 0 0 0 Power-ON 0 Clock stop 0 CE 0 b0 5.3.2 Function of bank register The bank register selects a bank of the data memory. Table 5-1 shows the value of the bank register and how a bank of the data memory is specified. Since the bank register exists on the system register, its contents can be rewritten regardless of the currently specified bank. In other words, the current bank status has nothing to do with manipulation of the bank register. Table 5-1. Specifying Bank of Data Memory Bank register (BANK) b3 0 0 0 b0 –––––– 0 b1 –––––– 0 –––––– 0 b2 Bank of data memory 0 BANK0 1 BANK1 35 µPD17072,17073 5.4 Program Status Word (PSWORD) 5.4.1 Configuration of program status word Figure 5-4 shows the configuration of the program status word. As shown in this figure, the program status word consists of a total of 5 bits: the least significant bit of address 7EH (RPL) and 4 bits of 7FH (PSW) of the system register. However, bit 0 of 7FH is always fixed to 0. Each of the 5 bits in the program status word has its own function as a BCD flag (BCD), compare flag (CMP), carry flag (CY), zero flag (Z), respectively. Figure 5-4. Program Status Word Configuration Address 7EH Name Bit Program status word (PSWORD) (RP) Symbol 7FH RPL b0 b2 b2 PSW b0 b0 b2 b2 B C C Z C M Y D P 0 At reset Data 36 b0 Power-ON 0 0 Clock stop 0 0 CE 0 0 µPD17072,17073 5.4.2 Functions of program status word The program status word sets conditions, under which the ALU (Arithmetic Logic Unit) performs arithmetic or transfer operations, and indicates the results of the operations. Table 5-2 outlines the function of each flag of the program status word. For details, refer to 7. ALU (Arithmetic Logic Unit) BLOCK. Table 5-2. Functional Outline of Each Flag of Program Status Word Program status word (PSWORD) (RP) RPL b3 b2 b1 PSW b0 b3 b2 b1 b0 B C C Z 0 C M Y D P Flag name Function Zero flag (Z) Indicates that the result of arithmetic operation is 0. Condition under which this flag is set differs depending on contents of compare flag. Carry flag (CY) Indicates occurrence of carry or borrow as a result of executing addition or subtraction instruction. Reset (0) when carry or borrow does not occur. Set (1) when carry or borrow occurs. Also used as shift bit of "RORC r" instruction. Compare flag (CMP) Stores or does not store result of arithmetic operation in data memory or general register. 0: Stores result 1: Does not store result BCD flag (BCD) Executes arithmetic operation in decimal. 0: Executes binary operation 1: Executes decimal operation 5.4.3 Notes on using program status word When an arithmetic operation (addition or subtraction) instruction is executed to the program status word, the result of the arithmetic operation is stored in the program status word. Even if an operation that generates a carry has been executed, for example, if the result of the operation is 0000B, 0000B is stored in PSW. 5.5 Notes on Using System Register The data in the system register which are fixed to “0” are not influenced even when a write instruction is executed. When these data are read, “0” is always read. 37 µPD17072,17073 6. GENERAL REGISTERS (GR) 6.1 Outline of General Registers With the µPD17073, the general registers are fixed at row address 0 of BANK0 on the data memory, and consist of 16 nibbles (16 × 4 bits) of 00H through 0FH. The 16 nibbles of the row address 0 specified as the general registers can perform operations and data transfer with the data memory with a single instruction. In other words, operations and data transfer between data memory areas can be executed with a single instruction. The general registers can be controlled by data memory manipulation instructions, like the other data memory areas. Figure 6-1. Outline of General Registers Column address 0 0 1 2 3 4 5 6 7 8 9 B C 3 4 Data memory 5 7 BANK0 BANK1 System registers 38 E F Transfer, operation 2 6 D General registers 1 Row address A µPD17072,17073 6.2 Address Creation of General Register with Each Instruction The following paragraphs 6.2.1 and 6.2.2 describe how the address of the general register is created when each instruction is executed. For details of the operation of each instruction, refer to 7. ALU (Arithmetic Logic Unit) BLOCK. 6.2.1 Addition (“ADD r, m”, “ADDC r, m”), subtraction (“SUB r, m”, “SUBC r, m”), logical operation (“AND r, m”, “OR r, m”, “XOR r, m”), direct transfer (“LD r, m”, “ST m, r”), rotate processing (“RORC r”) instructions Table 6-1 shows the address of general register “R” specified by an instruction operand “r”. The operand “r” specifies only the column address. Table 6-1. Address Creation of General Register Bank b3 General register address b2 b1 Row address Column address b0 Fixed to 0 R b2 b1 b0 b3 b2 Fixed to 1 b1 b0 r 6.2.2 Indirect transfer (“MOV @r, m”, “MOV m, @r”) instructions Table 6-2 shows the address of the general register “R” specified by instruction operand “r”, and the indirect transfer address specified by “@R”. Table 6-2. Address Creation of General Register Bank b3 b2 b1 Row address Column address b0 b2 b1 b0 b3 b2 b1 b0 General register address R Fixed to 0 Fixed to 0 r Indirect transfer address @R Fixed to 0 Fixed to 0 Contents of R 6.3 Notes on Using General Register There is no instruction available that performs an operation between the general register and immediate data. To perform an operation between the data memory specified as the general register and immediate data, the data memory must be treated as data memory instead of as the general register. 39 µPD17072,17073 7. ALU (ARITHMETIC LOGIC UNIT) BLOCK 7.1 General Figure 7-1 shows the configuration of the ALU block. As shown in the figure, the ALU block consists of an ALU, temporary registers A and B, program status word, decimal adjuster circuit, and data memory address control circuit. The ALU performs arithmetic operation, judgment, comparison, rotation, and transfer of 4-bit data on the data memory. Figure 7-1. Outline of ALU Block Data bus Address control Temporary register A Temporary register B Program status word Carry/borrow/zero detection/decimal/storage Data memory ALU • Arithmetic operation • Logical operation • Bit judgment • Comparison • Rotation • Transfer Decimal adjuster circuit 40 µPD17072,17073 7.2 Configuration and Function of Each Block 7.2.1 Functions of ALU The ALU performs arithmetic operation, logical operation, bit judgment, comparison, rotation, and transfer of 4bit data as the instruction specified by the program. 7.2.2 Temporary registers A and B Temporary registers A and B temporarily stores 4-bit data. These registers are automatically used when an instruction is executed and cannot be controlled by program. 7.2.3 Program status word The program status word controls the operations of the ALU and stores the status of the ALU. For details, refer to 5.4 Program Status Word (PSWORD). 7.2.4 Decimal adjuster circuit When the BCD flag of the program status word is set to 1 during an arithmetic operation, the result of the operation is converted into decimal numbers by the decimal adjuster circuit. 7.2.5 Address control circuit The address control circuit specifies an address of the data memory. 7.3 ALU Processing Instructions Table 7-1 shows the operations of the ALU when each instruction is executed. Table 7-2 shows the decimal adjusted data when a decimal operation is performed. 41 µPD17072,17073 Table 7-1. ALU Processing Instruction List Difference of operation due to program status word (PSWORD) ALU function Instruction 0 ADD m, #n4 r, m 0 ADDC m, #n4 Subtraction r, m 1 SUB m, #n4 r, m 1 SUBC m, #n4 Logical operation r, m OR Any (retained) m, #n4 r, m AND m, #n4 r, m XOR m, #n4 Judgment Comparison Transfer Any (retained) SKT m, #n SKF m, #n SKE SKNE m, #n4 Any (retained) m, #n4 SKGE m, #n4 SKLT m, #n4 LD r, m ST m, r Any (retained) m, #n4 MOV @r, m m, @r Rotation 42 RORC r Any (retained) Value of CMP flag –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– r, m Addition Value of BCD flag Operation Operation of CY flag Operation of Z flag 0 Stores result of binary addition 1 Does not store result of binary operation Retains status if result of operation is 0000B; otherwise, reset 0 Stores result of decimal operation Set if result of operation is 0000B; otherwise, reset 1 Does not store result of decimal operation Retains status if result of operation is 0000B; otherwise, reset Set if carry or borrow occurs; otherwise, reset Set if result of operation is 0000B; otherwise, reset Any (retained) No change Retains previous status Retains previous status Any (reset) No change Retains previous status Retains previous status Any (retained) No change Retains previous status Retains previous status Any (retained) No change Retains previous status Retains previous status Any (retained) No change Value of b0 of general register Retains previous status µPD17072,17073 Table 7-2. Decimal Adjusted Data Result of operation Hexadecimal addition Decimal addition CY Result of operation CY Result of operation 0 0 0000B 0 0000B 1 0 0001B 0 2 0 0010B 3 0 4 Hexadecimal subtraction Result of operation Decimal subtraction CY Result of operation CY Result of operation 0 0 0000B 0 0000B 0001B 1 0 0001B 0 0001B 0 0010B 2 0 0010B 0 0010B 0011B 0 0011B 3 0 0011B 0 0011B 0 0100B 0 0100B 4 0 0100B 0 0100B 5 0 0101B 0 0101B 5 0 0101B 0 0101B 6 0 0110B 0 0110B 6 0 0110B 0 0110B 7 0 0111B 0 0111B 7 0 0111B 0 0111B 8 0 1000B 0 1000B 8 0 1000B 0 1000B 9 0 1001B 0 1001B 9 0 1001B 0 1001B 10 0 1010B 1 0000B 10 0 1010B 1 1100B 11 0 1011B 1 0001B 11 0 1011B 1 1101B 12 0 1100B 1 0010B 12 0 1100B 1 1110B 13 0 1101B 1 0011B 13 0 1101B 1 1111B 14 0 1110B 1 0100B 14 0 1110B 1 1100B 15 0 1111B 1 0101B 15 0 1111B 1 1101B 16 1 0000B 1 0110B –16 1 0000B 1 1110B 17 1 0001B 1 0111B –15 1 0001B 1 1111B 18 1 0010B 1 1000B –14 1 0010B 1 1100B 19 1 0011B 1 1001B –13 1 0011B 1 1101B 20 1 0100B 1 1110B –12 1 0100B 1 1110B 21 1 0101B 1 1111B –11 1 0101B 1 1111B 22 1 0110B 1 1100B –10 1 0110B 1 0000B 23 1 0111B 1 1101B – 9 1 0111B 1 0001B 24 1 1000B 1 1110B – 8 1 1000B 1 0010B 25 1 1001B 1 1111B – 7 1 1001B 1 0011B 26 1 1010B 1 1100B – 6 1 1010B 1 0100B 27 1 1011B 1 1101B – 5 1 1011B 1 0101B 28 1 1100B 1 1010B – 4 1 1100B 1 0110B 29 1 1101B 1 1011B – 3 1 1101B 1 0111B 30 1 1110B 1 1100B – 2 1 1110B 1 1000B 31 1 1111B 1 1101B – 1 1 1111B 1 1001B Remark The shaded part indicates that decimal adjustment is not made correctly. 43 µPD17072,17073 7.4 Notes on Using ALU 7.4.1 Notes on executing operation to program status word When an arithmetic operation is performed to the program status word, the result of the operation is stored in the program status word. The CY and Z flags of the program status word are usually set or reset according to the result of an arithmetic operation executed. However, if the program status word itself is used for an operation, the result of the operation is stored in the program status word, making it impossible to judge whether a carry or borrow occurs, or the result of the operation is zero. However, if the CMP flag is set, the result of the operation is not stored in the program status word; consequently, the CY and Z flags are set (1) or cleared (0) normally. 7.4.2 Notes on using decimal operation A decimal operation can be executed only if the result of the operation falls within the following range: (1) Result of addition must be 0 to 19 in decimal. (2) Result of subtraction must be 0 to 9 or –10 to –1 in decimal. If a decimal operation is executed exceeding this range, the CY flag is set, and the result is 1010B (0AH) or higher. 44 µPD17072,17073 8. PERIPHERAL CONTROL REGISTERS 8.1 Outline of Peripheral Control Registers Figure 8-1 outlines the peripheral control registers. Thirty-two 4-bit peripheral registers are available that control the peripheral hardware such as the PLL frequency synthesizer, serial interface, and intermediate frequency counter (IF). Because the peripheral control registers are located on the data memory, they can be manipulated by all the data memory manipulation instructions. Figure 8-1. Outline of Peripheral Control Registers Column address 0 0 1 2 3 4 5 6 7 8 9 A B C D E BANK0 Row address 1 2 F B C E F 0 BANK1 3 4 D 1 Data memory 5 2 3 6 4 7 Peripheral control register 5 6 System registers 7 Peripheral hardware 45 µPD17072,17073 8.2 Configuration and Function of Peripheral Control Registers Figure 8-2 shows the configuration of the peripheral control registers. Table 8-1 lists the peripheral hardware control functions of the peripheral control registers. As shown in Figure 8-2, the peripheral control registers consist of a total of 32 nibbles (32 × 4 bits) of addresses 50H through 6FH of BANK1. Each peripheral control register has an attribute of 1 nibble, and is classified into four types: read/write (R/W), readonly (R), write-only (W), and read-and-reset (R&Reset) registers. Nothing is changed even if data is written to the read only (R and R&Reset) registers. If a write-only (W) register is read, the value is undefined. Of the 4-bit data of 1 nibble, the bits fixed to “0” are always “0” when read, and also “0” when data is written to these bits. Caution Bit 3 of address 50H of BANK1 (bit 3 of the LCD driver display start register) is allocated to a test mode area. Therefore, do not write “1” to this bit. 46 µPD17072,17073 [MEMO] 47 µPD17072,17073 Figure 8-2. Configuration of Peripheral Control Registers (1/2) (BANK1) Column address Row address 0 1 2 3 4 5 6 7 Item Name LCD driver Basic timer 0 CE pin status display carry register detection register start register Note 5 Symbol 0 Read/ A D C O 0 N L C D E N 0 R/W 0 B T M 0 0 C 0 Y C P P E 1 1 A A P P 0 L L D D 3 2 0 R&Reset Port 1A Stack pointer pull-down resistor select register R P 1 A P L D 1 P 1 A P L 0 D 0 R/W System clock select register select enable register S S P P 1 0 0 Interrupt edge Interrupt 0 0 R/W S Y S C 0 K R/W register I B I I I I N T E P P P T M G S B 1 I T 0 C 0 O M K 1 R/W R/W Write Serial I/O Name Read/ IF counter mode select register register 6 Symbol Serial I/O mode select clock select 0 S I O S E L S I O H I Z R/W register S I O T S 0 S I O C 0 K 1 R/W S I O C K 0 I F C M D 1 I F C M D 0 I F C C K 1 R/W I F C C K 0 IF counter gate status detection register 48 PLL control mode select register register I F C G 0 0 0 R Write Note IF counter This is a test mode area. Do not write “1” to this area. 0 I F C S T R T 0 W I F C R E S 0 P L L M 0 D 1 R/W P L L M D 0 PLL PLL reference data register frequency select register P L L R 0 F C K 2 P L L R F C K 1 R/W P L L R F C K 0 P L L R 1 7 P L L R 1 6 P L L R 1 5 R/W P L L R 1 4 µPD17072,17073 Figure 8-2. Configuration of Peripheral Control Registers (2/2) 8 9 INT pin interrupt request register 0 0 R/W B C D Basic timer 1 Serial interface BEEP clock A/D converter interrupt interrupt request select register channel select request register register register I R Q 0 A 0 0 I R Q B 0 T 0 M 1 R/W 0 I R Q S 0 I 0 O R/W B E E P 0 0 C K 1 B E E P 0 0 C K 0 R/W P L L R 5 R/W P L L R 4 P L L R 3 P L L R 2 P L L R 1 0 0 A D C C H 0 0 F A/D converter A/D converter reference compare start voltage setting register register A D C R F S E L 3 A D C R F S E L 2 R/W PLL data register P P P P P P P P L L L L L L L L L L L L L L L L R R R R R R R R 1 1 1 1 9 8 7 6 3 2 1 0 A D C C 0 H 1 E A D C R F S E L 1 A D C R F 0 S E L 0 R/W 0 A/D converter compare result detection register A D C S 0 T 0 R T A D C C 0 M P 0 R/W R PLL data PLL Port 0B Port 0C set register unlock FF bit I/O bit I/O register select register select register 0 P L L P 0 U 0 T 0 W 0 P L L U 0 L R&Reset P 0 B B I O 3 P 0 B B I O 2 P 0 B B I O 1 R/W P 0 B B I O 0 P 0 D B I O 3 P 0 D B I O 2 P 0 C B I O 1 P 0 C B I O 0 R/W 49 µPD17072,17073 Table 8-1. Peripheral Hardware Control Functions of Peripheral Control Registers (1/4) Peripheral Control register hardware Name Address Peripheral hardware control function Functional outline Read/ b3 At reset Set value Power- Clock CE Write b2 Symbol ON stop b1 b0 Stack Stack pointer (BANK1) R/W 0 0 1 Fixed to 0 2 2 2 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 – – – 0 R R ––––––––- (SP) 54H 0 – – – – – – – – –– – – – – – – – –– – – – – – – – –– – – – – – – –– SP1 Stack pointer ––––––––- SP0 Timer Basic timer 0 (BANK1) R& 0 Fixed to 0 ––––––––- carry register 51H Reset 0 ––––––––- 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– Interrupt Interrupt edge (BANK1) R/W BTM0CY Detects status of carry FF 0 Fixed to 0 Reset Set –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– select register 56H INT Detects status of INT Pin Low level High level –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– BTM1CK Sets set time interval of IRQBTM1 flag 32 ms (31.25 Hz) 8 ms (125 Hz) –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– Interrupt enable (BANK1) R/W IEG Sets interrupt issuing edge of INT pin 0 Fixed to 0 Rising edge Falling edge –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– register 57H IPSIO Serial interface Disables interrupt Enables interrupt ––––––––- IPBTM1 Basic timer 1 Enables interrupt ––––––––- INT pin interrupt (BANK1) R/W IP INT pin 0 Fixed to 0 ––––––––- request register 58H 0 ––––––––- 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– Basic timer 1 (BANK1) R/W IRQ Detects interrupt request of INT pin 0 Fixed to 0 Not requested Requested ––––––––- interrupt request 59H 0 ––––––––- register 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– Serial interface (BANK1) R/W IRQBTM1 Detects interrupt request of basic timer 1 Not requested 0 Fixed to 0 Requested ––––––––- interrupt request 5AH 0 ––––––––- register 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– Pin CE pin status (BANK1) R IRQSIO Detects interrupt of serial interface 0 Fixed to 0 Not requested Requested ––––––––- detection register 52H 0 ––––––––- 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– Port 1A pull-down (BANK1) R/W CE Detects status of CE pin Low level High level P1APLD3 P1A3 Resistor ON Resistor OFF ––––––––– select register 53H P1APLD2 P1A2 Selects pull-down P1A1 resistor of these pins ––––––––– P1APLD1 ––––––––– P1APLD0 P1A0 Remark –: Determined by status of pin, R: Previous status is retained. 50 µPD17072,17073 Table 8-1. Peripheral Hardware Control Functions of Peripheral Control Registers (2/4) Peripheral hardware Control register Name Address Peripheral hardware control function Functional outline Read/ b3 At reset Set value Power- Clock CE Write b2 Symbol ON stop b1 b0 PLL PLL mode select (BANK1) R/W 0 0 1 Fixed to 0 0 0 R 0 0 R U R R 0 0 0 U R R ––––––––- frequency register 65H 0 ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– synthesizer PLLMD1 Sets division mode of PLL ––––––––- PLLMD0 PLL reference (BANK1) R/W 0 0 0 Disable 0 1 1 MF 1 VHF 0 HF 1 Fixed to 0 ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– frequency select 66H PLLRFCK2 Sets reference frequency of PLL ––––––––- register PLLRFCK1 ––––––––- 0:1 kHz 1:3 kHz 2:5 kHz 3:6.25 kHz 4:12.5 kHz 5:25 kHz 6, 7: PLL disable PLLRFCK0 PLL data register (BANK1) R/W PLLR17 Sets division ratio of PLL – – – –– – – – – 67H PLLR16 ––––––––– PLLR15 – – – – – – – –– PLLR14 (BANK1) PLLR13 • In direct division mode PLLR6-PLLR17: Valid data PLLR1-PLLR5: don’t care 0-15 (000H-00FH): Setting prohibited 16-212 – 1 (010H-FFFH): Can be setNote – – – –– – – – – 68H • In pulse swallow mode PLLR1-PLLR17: Valid data 0-1023 (0000H-03FFH): Setting prohibited 17 1024-2 – 1 (0400H-1FFFFH): Note Can be set PLLR12 ––––––––– PLLR11 – – – – – – – –– PLLR10 (BANK1) PLLR9 – – – –– – – – – 69H PLLR8 ––––––––– PLLR7 – – – – – – – –– PLLR6 (BANK1) PLLR5 – – – –– – – – – 6AH PLLR4 ––––––––– PLLR3 – – – – – – – –– PLLR2 (BANK1) PLLR1 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 6BH 0 Fixed to 0 ––––––––- 0 ––––––––- 0 PLL data set (BANK1) W 0 Fixed to 0 ––––––––- register 6CH 0 ––––––––- 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– PLL unlock FF (BANK1) R& PLLPUT Data transfer to programmable counter 0 Fixed to 0 Does not transfer Transfers ––––––––- register 6DH Reset 0 ––––––––- 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– PLLUL Note Detects status of unlock FF Locked status Unlocked status For the details of the set value, refer to Figure 15-4 Configuration of PLL Data Register. Remark U: Undefined, R: Previous status is retained. 51 µPD17072,17073 Table 8-1. Peripheral Hardware Control Functions of Peripheral Control Registers (3/4) Peripheral hardware Control register Name Address Peripheral hardware control function Functional outline Read/ b3 At reset Set value Power- Clock CE Write b2 Symbol ON stop b1 b0 A/D A/D converter (BANK1) R/W 0 0 1 Fixed to 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ––––––––- converter channel select 5CH 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– register ADCCH1 Selects pin used for A/D converter ––––––––- ADCCH0 A/D converter (BANK1) R/W 0 0 1 1 Not used AD0 AD1 AD1 0 1 0 1 ADCRFSEL3 Sets compare voltage – – – –– – – – – reference 5DH ADCRFSEL2 VREF = – – – –– – – – – voltage setting ADCRFSEL1 – – – –– – – – – register A/D converter x + 0.5 × VDD (V) 16 (0 ≤ x ≤ 0FH) ADCRFSEL0 (BANK1) R/W 0 Fixed to 0 ––––––––- compare start 5EH 0 ––––––––- register 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– A/D converter (BANK1) R ADCSTRT Starts A/D converter operation/checks comparator operation 0 Fixed to 0 Invalid/Stop Starts/operates ––––––––- compare result 5FH 0 ––––––––- detection register 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– General- Port 0B bit I/O (BANK1) R/W ADCCMP Detects compare result VADCIN < VREF VADCIN > VREF P0BBIO3 P0B3 pin Input Output – – – –– – – – – purpose select register 6EH P0BBIO2 P0B2 pin – – – –– – – – – port P0BBIO1 P0B1 pin – – – –– – – – – Port 0C bit I/O (BANK1) R/W P0BBIO0 P0B0 pin Sets I/O mode of P0DBIO3 P0D3 pin these pins (bit I/O) – – – –– – – – – select register 6FH P0DBIO2 P0D2 pin – – – –– – – – – P0CBIO1 P0C1 pin – – – –– – – – – Serial Serial I/O mode (BANK1) R/W P0CBIO0 P0C0 pin 0 Fixed to 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– interface select register 60H SIOSEL Selects serial I/O mode of P0B3/SI/SO1 pin Serial input Serial output –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– SIOHIZ Sets P1C0/SO0 pin in serial output mode General-purpose Serial output output port –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– Serial I/O clock (BANK1) R/W SIOTS Sets start or stop of operation 0 Fixed to 0 Stops operation Starts operation ––––––––- select register 61H 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– SIOCK1 ––––––––- SIOCK0 52 Sets clock of serial interface 0 0 1 1 External clock 12.5 kHz 18.75 kHz 37.5 kHz 0 1 0 1 µPD17072,17073 Table 8-1. Peripheral Hardware Control Functions of Peripheral Control Registers (4/4) Peripheral hardware Control register Name Address Peripheral hardware control function Functional outline Read/ b3 At reset Set value Power- Clock CE Write b2 Symbol ON stop b1 b0 IF counter IF counter mode (BANK1) R/W IFCMD1 0 Sets mode of IF counter ––––––––- select register 62H IFCMD0 0 1 0 1 1 IF counter OFF FMIFC pin AMIFC pin FMIFC pin (General I/O port) FMIF mode AMIF mode AMIF mode 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 R 1 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– IFCCK1 Sets gate time of IF counter ––––––––- 1 ms IFCCK0 IF counter gate (BANK1) R 0 0 4 ms 1 1 8 ms 0 Open 1 Fixed to 0 ––––––––- status detection 63H 0 ––––––––- register 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– IF counter control (BANK1) W IFCG Detects opening/closing gate of IF counter 0 Fixed to 0 Closed Open ––––––––- register 64H 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– IFCSTRT Starts counting of IF counter Does not start Starts –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– BEEP BEEP clock (BANK1) R/W IFCRES Resets IF counter 0 Fixed to 0 Does not reset Resets ––––––––- select register 5BH 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– BEEP0CK1 Sets output status of BEEP pin ––––––––- LCD driver (BANK1) R/W 0 0 1 1 General output port General output port BEEP (low-level output) BEEP0CK0 LCD 0 0 BEEP (high-level output) (1.5 kHz) (3 kHz) 1 0 1 Fixed to 0 ––––––––- controller/ display start 50H 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– driver ADCONNote Sets A/D converter power supply and register ––––––––- Standby System clock (BANK1) R/W LCDEN ON/OFF of all LCD display 0 Fixed to 0 0 0 1 1 Power OFF Power ON Power ON Power ON Display OFF Display ON Display OFF Display ON 0 1 0 0 0 0 ––––––––––– 1 0 0 R 0 R R ––––––––- select register 55H 0 ––––––––- 0 –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– SYSCK Note Selects system clock (1 instruction execution time) 53.3 µs 106.6 µs When LCDEN= 1, the power supply for the A/D converter is ON even if ADCON = 0. Remark R: Previous status is retained. 53 µPD17072,17073 9. DATA BUFFER (DBF) 9.1 General Figure 9-1 outlines the data buffer. The data buffer is located on the data memory and has the following two functions: (1) Reads constant data on program memory (table reference) (2) Transfers data with hardware peripherals Figure 9-1. Outline of Data Buffer Data buffer Data write (PUT instruction) Table reference (MOVT instruction) Data read (GET instruction) Peripheral hardware Constant data Program memory 54 µPD17072,17073 9.2 Data Buffer 9.2.1 Configuration of data buffer Figure 9-2 shows the configuration of the data buffer. As shown in this figure, the data buffer is configured of 16 bits of addresses 0CH-0FH of BANK0 on the data memory. Of these 16 bits, bit 3 of address 0CH is the MSB, while bit 0 of address 0FH is the LSB. Since the data buffer is on the data memory, it can be manipulated by all the data memory manipulation instructions. Figure 9-2. Configuration of Data Buffer 0 1 2 3 4 Column address 6 7 8 9 A 5 0 C D E F Data buffer (DBF) 1 Row address B 2 3 Data memory 4 5 6 BANK0 7 BANK1 7 System register 0CH Address 0DH 0EH 0FH Data memory Bit b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 Bit b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 DBF3 Symbol Data buffer Data DBF2 DBF1 DBF0 M L S S B B Data 55 µPD17072,17073 9.2.2 Table reference instruction (“MOVT DBF, @AR”) When this instruction is executed, the contents of the program memory addressed by the contents of the address register are incorporated into the data buffer. The program memory addresses to which table reference can be executed are addresses 0000H-0FFFH, i.e., all the addresses of the program memory. 9.2.3 Peripheral hardware control instructions (“PUT” and “GET”) The operations of the “PUT” and “GET” instructions are as follows: (1) GET DBF, p Reads the data of the peripheral register addressed by p to the data buffer. (2) PUT p, DBF Sets the data of the data buffer to the peripheral register addressed by p. 9.3 List of Peripheral Hardware and Data Buffer Functions Table 9-1 lists the peripheral hardware and data buffer functions. 9.4 Notes on Using Data Buffer When transferring data with the peripheral hardware through the data buffer, keep in mind the following three points in respect with the unused peripheral addresses, write-only peripheral registers (only when using PUT), and readonly peripheral registers (only when using GET): (1) An “undefined value” is read when a write-only register is read. (2) Nothing is changed even when data is written to a read-only register. (3) An “undefined value” is read when an unused address is read. Nothing is changed when data is written to this address. Table 9-1. Relation between Peripheral Hardware and Data Buffer Peripheral hardware Peripheral register transferring data with data buffer Name Symbol Serial interface Presettable shift register SIOSFR 03H Address register (AR) Address register AR IF counter IF counter data register IFC 56 Peripheral Execution address of PUT/GET instruction Function No. of data buffer I/O bits No. of actual bits Outline PUT/ GET 8 8 Sets serial out data and reads serial in data 40H PUT/ GET 16 12 Transfers data with address register 43H GET 16 16 Reads count value of IF counter µPD17072,17073 10. GENERAL-PURPOSE PORT The general-purpose ports output high or low floating signals to external circuits, and reads high or low level signals from external circuits. 10.1 General Table 10-1 shows the relations between each port and port register. The general-purpose ports are classified into I/O ports, input ports, and output ports. The I/O port is the bit I/O ports, which can be set in the input or output mode in 1-bit (1-pin) units. Table 10-1. Relations between Each Port (Pin) and Port Register Port Pin No. Symbol Data setting method I/O 56-pin 64-pin Port 0A QFP TQFP 5 6 Port register (data memory) Bank Address Symbol (reserved word) P0A3 –––––––––––––––––––- 4 4 P0A2 3 3 P0A1 Output BANK0 70H P0A 2 2 P0A0 64 P0B3 b2 b1 I/O 71H P0B 63 62 P0B2 (bit I/O) 53 61 b0 P0A0 b3 P0B3 b2 P0B2 –––––––––––– P0B1 b1 –––––––––––––––––––- Port 0C P0A1 –––––––––––– –––––––––––––––––––- 54 P0A2 –––––––––––– –––––––––––––––––––- 55 P0A3 –––––––––––– –––––––––––––––––––- 56 b3 –––––––––––– –––––––––––––––––––- Port 0B Remarks Bit symbol P0B1 –––––––––––– P0B0 No pin 72H P0C b0 P0B0 b3 – Fixed to “0” –––––––––––– b2 15 17 P0C1 I/O b1 14 16 P0C0 (bit I/O) 17 19 P0D3 I/O 16 18 P0D2 (bit I/O) – – – – – – – – – – – – – – – – – – –- 73H P0D –––––––––––––––––––––––––––– 13 15 P1A3 Input BANK1 70H P1A 14 13 10 11 P1A0 9 10 P1B3 9 8 6 7 b0 – b3 P1A3 Fixed to “0” P1A2 P1A1 –––––––––––– Output 71H P1B b0 P1A0 b3 P1B3 –––––––––––– P1B2 b2 P1B2 –––––––––––– P1B1 b1 –––––––––––––––––––- Port 1C – b1 –––––––––––––––––––- 7 P0D2 b2 –––––––––––––––––––- 8 b2 b1 –––––––––––– P1A1 –––––––––––––––––––- Port 1B P0D3 –––––––––––– –––––––––––– P1A2 –––––––––––––––––––- 11 P0C0 b3 –––––––––––– –––––––––––––––––––- 12 b0 – – – – – – – –– – – – – – – – –– –– – – – – – – – – – – – – – – – – – – No pin Port 1A P0C1 –––––––––––– – – – – – – – – – – – – – – – – – – –- Port 0D – – – – – – – – –– – – – – – – – –– –– – – – – – – – – – – – – – – – – – – –––––––––––––––––––––––––––– P1B1 –––––––––––– P1B0 No pin 72H P1C b0 P1B0 b3 – –––––––––––– b2 – Fixed to “0” –––––––––––– b1 – – – – – – – –– – – – – – – – –– –– – – – – – – – – – – – – – – – – – – –––––––––––––––––––––––––––– 1 1 P1C0 – Output 73H – b0 P1C0 b3 – Test mode area. Do not write ––––– b2 “1” to this area. ––––– b1 ––––– b0 57 µPD17072,17073 10.2 General-Purpose I/O Ports (P0B, P0C, P0D) 10.2.1 Configuration of I/O ports The configurations of the I/O ports are shown below. P0B (P0B3, P0B2, P0B1, P0B0) P0C (P0C1, P0C0) P0D (P0D3, P0D2) VDD I/O mode selector flag Output latch Write instruction Port register (1 bit) VDD 1 0 Read instruction RESET 10.2.2 Use of I/O ports The I/O port is set in the input or output mode by the I/O select registers P0B and P0C of the control register. P0D, P0C, and P0D are the bit I/O ports. Therefore, these ports can set in input or output mode in 1-bit units. To set output data or to read input data, data is written to the corresponding port register, or an instruction that reads the data is executed. 10.2.3 describes the configuration of the I/O select register of each port. 10.2.4 describes how to use an I/O port as an input port. 10.2.5 describes how to use an I/O port as an output port. 58 µPD17072,17073 10.2.3 Control register of I/O port The port 0B bit I/O select register sets the input or output mode of each pin of P0B. The port 0C bit I/O select register sets the input or output mode of each pin of P0C and P0D. The following paragraphs (1) and (2) describe the configuration and function. (1) Port 0B bit I/O select register Flag symbol Name Port 0B bit I/O select register b3 b2 b1 b0 P 0 B B I O 3 P 0 B B I O 2 P 0 B B I O 1 P 0 B B I O 0 Address Read/ Write (BANK1) 6EH R/W Sets input or output mode 0 Sets P0B0 in input mode 1 Sets P0B0 in output mode Sets input or output mode 0 Sets P0B1 in input mode 1 Sets P0B1 in output mode Sets input or output mode 0 Sets P0B2/SCK in input mode 1 Sets P0B2/SCK in output mode Sets input or output mode 0 Sets P0B3/SI/SO1 in input mode 1 Sets P0B3/SI/SO1 in output mode Power-ON 0 0 0 0 At reset Clock stop 0 0 0 0 CE 0 0 0 0 59 µPD17072,17073 (2) Port 0C bit I/O select register Flag symbol Name Port 0C bit I/O select register b3 b2 b1 b0 P 0 D B I O 3 P 0 D B I O 2 P 0 C B I O 1 P 0 C B I O 0 Address Read/ Write (BANK1) 6FH R/W Sets input or output of port 0 Sets P0C0 pin in input mode 1 Sets P0C0 pin in output mode Sets input or output of port 0 Sets P0C1 pin in input mode 1 Sets P0C1 pin in output mode Sets input or output of port 0 Sets P0D2/AMIFC pin in input mode 1 Sets P0D2/AMIFC pin in output mode Sets input or output of port At reset 60 0 Sets P0D3/FMIFC/AMIFC pin in input mode 1 Sets P0D3/FMIFC/AMIFC pin in output mode Power-ON 0 0 0 0 Clock stop 0 0 0 0 CE 0 0 0 0 µPD17072,17073 10.2.4 To use I/O port in input mode The port pin to be used in the input mode is selected by the I/O select register of each port. The pin set in the input mode is floated (Hi-Z) and waits for the input of an external signal. The input data can be read by executing a read instruction (such as SKT instruction) to the port register corresponding to each pin. “1” is read from the port register when the high level is input to the corresponding pin, and “0” is read from the register when the low level is input to the pin. If a write instruction (such as MOV instruction) is executed to the port register corresponding to a port set in the input mode, the contents of the output latch are rewritten. 10.2.5 To use I/O Port in output mode The port pin to be set in the output mode is selected by the I/O select register corresponding to the port. The pin set in the output mode outputs the contents of the output latch. The output data is set by executing a write instruction (such as MOV instruction) to the port register corresponding to each pin. To output the high level to each pin, “1” is written to the port register, and to output the low level, “0” is written. The port pin can be floated (Hi-Z) by setting it in the input mode. If a read instruction (such as SKT) is executed to the port register corresponding to a port set in the output mode, the contents of the output latch are read. 10.2.6 I/O port status on reset (1) On power-ON reset All the ports are set in the input mode. The contents of the output latch become 0. (2) On CE reset All the ports are set in the input mode. The contents of the output latch are retained. (3) On execution of clock stop instruction All the ports are set in the input mode. The contents of the output latch are retained. Increasing current consumption can be prevented due to noise of the input buffer, by using the RESET signal, as described in 10.2.1. (4) In halt status The previous status is retained. 61 µPD17072,17073 10.3 General-Purpose Input Ports (P1A) 10.3.1 Configuration of input ports The configuration of the input ports is illustrated below. P1A (P1A3, P1A2, P1A1, P1A0) To A/D converter Write instruction VDD Port register (1 bit) Read instruction RESET High ON resistance 62 P1APLD3 P1APLD2 P1APLD1 P1APLD0 µPD17072,17073 10.3.2 Using input port The input data can be read by executing an instruction that reads the contents of the port register P1A (such as SKT instruction). “1” is read from each bit of the port register when the high level is input to the corresponding port pin, and “0” is read when the low level is input. Nothing is changed even if a write instruction (such as MOV) is executed to the port register. Port 1A can be connected to or disconnected from a pull-down resistor bitwise by software. Whether the pull-down resistor is connected or disconnected is specified by the port 1A pull-down resistor select register. Figure 10-1 shows the configuration and function of the port 1A pull-down resistor select register. Figure 10-1. Configuration of Port 1A Pull-Down Resistor Select Register Read/ Flag symbol Name Address b3 b2 b1 b0 P P P P 1 1 1 1 A A A A P P P P Port 1A pull-down Write (BANK1) resistor select register R/W 53H L L L L D D D D 3 2 1 0 Selects ON/OFF of pull-down resistor of P1A0 pin 0 Pull-down resistor ON 1 Pull-down resistor OFF Selects ON/OFF of pull-down resistor of P1A1 pin 0 Pull-down resistor ON 1 Pull-down resistor OFF Selects ON/OFF of pull-down resistor of P1A2/AD0 pin 0 Pull-down resistor ON 1 Pull-down resistor OFF Selects ON/OFF of pull-down resistor of P1A3/AD1 pin Power-ON At reset Clock stop CE 0 Pull-down resistor ON 1 Pull-down resistor OFF 0 0 0 0 Retained Retained 63 µPD17072,17073 10.3.3 Reset status of input port (1) On power-ON reset All pins are specified as a input port. Pulled down internally. (2) On CE reset All pins are specified as a input port. The previous status of the pull-down resistor is retained. (3) On execution of clock stop instruction All pins are specified as a input port. The previous status of the pull-down resistor is retained. (4) In halt status The previous status is retained. 64 µPD17072,17073 10.4 General-Purpose Output Ports (P0A, P1B, P1C) 10.4.1 Configuration of output ports The configurations of the output ports are shown below. P0A (P0A3, P0A2, P0A1, P0A0) P1B (P1B3, P1B2, P1B1, P1B0) P1C (P1C0) VDD Output latch Write instruction Port register (1 bit) Read instruction 10.4.2 Using output port The output port outputs the contents of the output latch from its pins. The output data is set by executing an instruction that writes data to the port register corresponding to each pin (such as MOV instruction). “1” is written to each bit of the port register when the high level is output to the corresponding port pin, and “0” is written when the low level is output. If a read instruction (such as SKT instruction) is executed to the port register, the contents of the output latch are read. 10.4.3 Reset status of output port (1) On power-ON reset All the pins output the contents of the output latch. The contents of the output latch become 0. (2) On CE reset Retains the contents of the output latch. The contents of the output latch are retained; therefore, the output data is not changed on CE reset. (3) On execution of clock stop instruction Retains the contents of the output latch. The contents of the output latch are retained; therefore, the output data is not changed on execution of the clock stop instruction. Initialize the port through program as necessary. (4) In halt status The contents of the output latch are output. The contents of the output latch are retained; therefore, the output data is not changed in the halt status. 65 µPD17072,17073 11. INTERRUPT 11.1 General Figure 11-1 shows the outline of the interrupt block. As shown in this figure, the interrupt block temporarily stops the program under execution, and branches to an interrupt vector address according to an interrupt request output by each peripheral hardware. The interrupt block consists of “interrupt control blocks” that control interrupt requests output from the corresponding peripheral hardware, “interrupt enable flip-flop” that enables all the interrupts, “stack pointer” that is controlled when an interrupt is accepted, “address stack register”, “program counter”, and “interrupt stack”. The “interrupt control block” of each peripheral hardware consists of an “interrupt request flag (IRQxxx)“ that detects each interrupt, “interrupt enable flag (IPxxx)“ that enables each interrupt, and “vector address generator (VAG)“ that specifies each vector address when an interrupt is accepted. The following peripheral hardware have the interrupt functions: • INT pin • Basic timer 1 • Serial interface Figure 11-1. Outline of Interrupt Block Interrupt control block IPSIO flag Serial interface IRQSIO flag Program counter Vector address generator 01H Stack pointer Address stack register IPBTM1 flag Bank register Basic timer 1 IRQBTM1 flag Vector address generator 02H Interrupt stack IP flag INT pin IRQ flag Vector address generator 03H DI, EI instruction 66 Interrupt enable flip-flop µPD17072,17073 11.2 Interrupt Control Block An interrupt control block is available for each peripheral hardware. Each of these blocks detects the presence/ absence of an interrupt request, enables/disables the interrupt, and generates a vector address when the interrupt is accepted. 11.2.1 Interrupt request flag (IRQxxx) The interrupt request flags are set to (1) when an interrupt request has been issued from the corresponding peripheral hardware, and is cleared (0) when the interrupt has been accepted. Therefore, even when the interrupt is not enabled, whether an interrupt request has been issued can be detected by checking these interrupt request flags. Writing “1” directly to an interrupt request flag is equivalent to issuance of an interrupt request. Once this flag has been set, it will not be cleared until the corresponding interrupt has been accepted, or “0” is written to the flag by an instruction. If two or more interrupt requests are issued at the same time, the interrupt request flag corresponding to the interrupt request that has not been accepted is not cleared. The interrupt request flags are address 58H through 5AH of BANK1 of RAM. Figures 11-2 through 11-4 show the configuration and functions of each interrupt request register. Figure 11-2. Configuration of INT Pin Interrupt Request Register Flag symbol Name INT pin interrupt request register b3 b2 b1 b0 0 0 0 I R Q Address (BANK1) 58H Read/ Write R/W Sets interrupt request issuing status of INT pin. 0 Interrupt request not issued. 1 Interrupt request issued. Fixed to "0". Power-ON 0 0 0 0 At reset Clock stop 0 CE 0 67 µPD17072,17073 Figure 11-3. Configuration of Basic Timer 1 Interrupt Request Register Flag symbol Name Address b3 Basic timer 1 interrupt request register 0 b2 0 b1 b0 0 I R Q B T M 1 (BANK1) 59H Read/ Write R/W Sets interrupt request issuing status of basic timer 1. 0 Interrupt request not issued. 1 Interrupt request issued. Fixed to "0". Power-ON 0 0 0 0 At reset Clock stop 0 CE 0 Figure 11-4. Configuration of Serial Interface Interrupt Request Register Flag symbol Name b3 Serial interface interrupt request register 0 b2 0 b1 0 Address Read/ Write (BANK1) 5AH R/W b0 I R Q S I O Sets interrupt request issuing status of serial interface. 0 Interrupt request not issued. 1 Interrupt request issued. Fixed to "0". Power-ON 0 0 0 0 At reset Clock stop 0 CE 0 68 µPD17072,17073 11.2.2 Interrupt enable flag (IPxxx) Each interrupt enable flag enables or disables the interrupt request of the corresponding peripheral hardware. So that an interrupt is accepted, all the following three conditions must be satisfied: • The interrupt must be enabled by the corresponding interrupt enable flag. • The interrupt request must be issued from the corresponding interrupt request flag. • The “EI” instruction (which enables all the interrupts) must be executed. The interrupt enable flags are located on the interrupt enable registers on the register file. Figure 11-5 shows the configuration and functions of the interrupt enable register. Figure 11-5. Configuration of Interrupt Enable Register Flag symbol Name Interrupt enable register b3 b2 b1 b0 I P B T M 1 I P 0 I P S I O Address Read/ Write (BANK1) 57H R/W Enables interrupt from INT pin 0 Disables interrupt 1 Enables interrupt Enables interrupt from basic timer 1 0 Disables interrupt 1 Enables interrupt Enables interrupt from serial interface 0 Disables interrupt 1 Enables interrupt Fixed to 0 Power-ON At reset 0 0 0 0 Clock stop 0 0 0 CE 0 0 0 69 µPD17072,17073 11.2.3 Vector address generator (VAG) When an interrupt request from peripheral hardware has been accepted, the vector address generator generates a branch address (vector address) to which the program execution is to be branched. The vector addresses corresponding to each interrupt source are listed in Table 11-1. Table 11-1. Vector Address of Each Interrupt Source Interrupt source Vector address INT pin 03H Basic timer 1 02H Serial interface 01H 11.3 Interrupt Stack Register 11.3.1 Configuration and functions of interrupt stack register Figure 11-6 shows the configuration of the interrupt stack register. The interrupt stack saves the contents of the bank registers when an interrupt has been accepted: When an interrupt has been accepted, and the contents of bank registers have been saved to the interrupt stack, the contents of the registers are reset to “0”. The interrupt stack can save up to one level of the contents of the bank registers; therefore, multiplexed interrupt cannot be performed. The contents of the interrupt stack register are restored to the respective system registers when an interrupt return (“RETI”) instruction has been executed. Caution With the µPD17073, the contents of the program status word (PSWORD) are not saved to the stack but retained when an interrupt is accepted. Therefore, the contents of the program status word must be backed up by software. Figure 11-6. Configuration of Interrupt Stack Register Interrupt stack register (INTSK) Name Bank stack Bit b3 b2 b1 0H _ _ _ b0 Remark –: Bit not saved 70 µPD17072,17073 11.3.2 Operations of interrupt stack Figure 11-7 illustrates the operations of the interrupt stack. When multiplexed interrupts have been accepted, the first contents saved to the stack are popped. If these contents are necessary, therefore, they must be saved through program. Figure 11-7. Operations of Interrupt Stack (a) If interrupt level does not exceed 1 Undefined Application of VDD BANK1 Interrupt A (BANK1) BANK1 RETI (b) If interrupt level exceeds 1 BANK0 BANK1 Interrupt A (BANK1) Interrupt B (BANK0) BANK0 BANK0 RETI RETI 71 µPD17072,17073 11.4 Stack Pointer, Address Stack Register, and Program Counter The address stack register saves the return address to which the program execution is to restore when execution exits from an interrupt service routine. The stack pointer specifies the address of the address stack register. When an interrupt has been accepted, therefore, the value of the stack pointer is decremented by one, and the value of the program counter at that time is saved to the address stack register specified by the stack pointer. Next, when dedicated instruction “RETI” has been executed after the interrupt service routine has been executed, the contents of the address stack register specified by the stack pointer are restored to the program counter, and the value of the stack pointer is incremented by one. Also refer to 3. ADDRESS STACK (ASK). 11.5 Interrupt Enable Flip-Flop (INTE) The interrupt enable flip-flop enables all the interrupts. When this flip-flop is set, all the interrupts are enabled. When it is reset, all the interrupts are disabled. This flip-flop is set or reset by dedicated instruction “EI (set)” or “DI (reset)”. The “EI” instruction sets this flip-flop when the instruction next to it has been executed, while the “DI” instruction resets the flip-flop while it is executed. When an interrupt has been accepted, this flip-flop is automatically reset. This flip-flop is reset on power-ON reset, execution of the clock stop instruction, or CE reset. 72 µPD17072,17073 11.6 Accepting Interrupt 11.6.1 Interrupt accepting operation and priority An interrupt is accepted in the following sequence: (1) Each peripheral hardware issues an interrupt request signal to an interrupt request block when a certain condition is satisfied (for example, when a falling signal has been input to the INT pin). (2) Each interrupt request block sets the corresponding interrupt request flag (e.g., IRQ flag for the INT pin) to “1” when it has received an interrupt request signal from peripheral hardware. (3) When the interrupt request flag is set, the interrupt request block whose interrupt enable flag (e.g., IP flag for IRQ flag) is set to “1” outputs “1”. (4) The signal output by the interrupt request block is ORed with the output of the interrupt enable flip-flop and an interrupt accept signal is output. This interrupt enable flip-flop can be set to “1” by the EI instruction and reset to “0” by the DI instruction. When “1” is output from an interrupt request block with the interrupt enable flip-flop set to “1”, the interrupt enable flip-flop outputs “1” and the interrupt is accepted. When the interrupt has been accepted, the output of the interrupt enable flip-flop is input to the block that has issued the interrupt request, through an AND circuit, as shown in Figure 11-1. The signal input to the block that has issued the interrupt request clears the interrupt request flag of that block to “0”, and a vector address corresponding to the interrupt is output. If any of the blocks that have issued an interrupt request outputs “1” at this time, the interrupt accept signal is not transmitted to the next stage. When two or more interrupt request have generated at the same time, therefore, the interrupts are accepted according to the following priority: INT pin > basic timer 1 > serial interface The interrupt corresponding to an interrupt source is not accepted unless the interrupt enable flag is set to “1”. Therefore, by clearing the interrupt enable flag to “0”, an interrupt with a high hardware priority can be disabled. 73 µPD17072,17073 11.6.2 Timing to accept interrupt Figure 11-8 is a timing chart illustrating how interrupts are accepted. (1) in this figure illustrate how one type of interrupt is accepted. (a) in (1) indicates the case where the interrupt request flag is set to “1” last, while (b) shows the case where the interrupt enable flag is set to “1” last. In either case, the interrupt is accepted after all the interrupt request flag, interrupt enable flip-flop, and interrupt enable flag have been set. If it is during the first instruction cycle of the “MOVT DBF, @AR” instruction or an instruction with the skip condition satisfied that sets the last flag or flip-flop to “1”, the interrupt is accepted during the second instruction cycle of the “MOVT DBF, @AR” instruction or when the skipped instruction (“NOP”) has been executed. The interrupt enable flip-flop is set in the instruction cycle next to the one in which the “EI” instruction is executed. (2) in Figure 11-8 shows the timing chart where two or more interrupts are used. When using two or more interrupts, the interrupt given the highest hardware priority at that time is accepted if all the interrupt enable flags are set. However, the hardware priority can be changed by manipulating the interrupt enable flag through program. “Interrupt cycle” in Figure 11-8 is a special cycle in which the interrupt request flag is clear, a vector address is specified, and the contents of the program counter are saved after an interrupt has been accepted, and lasts for 53.3 µs, (normal operation) or one instruction execution time. For details, refer to 11.7 Operations after Accepting Interrupt. 74 µPD17072,17073 Figure 11-8. Interrupt Accepting Timing Chart (1/2) (1) When one type of interrupt (e.g., rising edge of INT pin) is used (a) When there is no time to mask interrupt by interrupt enable flag (IPxxx) <1> If an ordinary instruction which is not “MOVT” or does not satisfy the skip condition is executed when interrupt is accepted Instruction EI Ordinary instruction MOV POKE WR, #0001B INTPM1, WR Interrupt cycle INTE INT pin IRQ flag IP flag 1 instruction cycle 53.3 µ s (normal operation) Interrupt service routine Interrupt enable period Interrupt accepted <2> If “MOVT” or an instruction that satisfies the skip condition is executed when interrupt is accepted Instruction EI MOV POKE WR, #0001B INTPM1, WR Interrupt cycle MOVT DBF,@AR skip instruction INTE INT pin IRQ flag IP flag Interrupt service routine Interrupt enable period Interrupt accepted (b) When there is interrupt pending time by interrupt enable flag Instruction EI Interrupt POKE MOV cycle WR, #0001B INTPM1, WR INTE INT pin IRQ flag IP flag Interrupt pending period Interrupt service routine Interrupt accepted 75 µPD17072,17073 Figure 11-8. Interrupt Accepting Timing Chart (2/2) (2) When two or more interrupts are used (e.g., INT pin and basic timer 1) (a) Hardware priority MOV POKE WR, #0011B INTPM1, WR Instruction Interrupt cycle EI EI RETINote Interrupt cycle INTE INT pin IRQ flag Basic timer 1 IRQBTM1 flag IP flag IPBTM1 flag INT pin interrupt pending period INT pin interrupt service routine Basic timer 1 interrupt service Basic timer 1 interrupt pending period INT pin interrupt accepted Basic timer 1 interrupt accepted (b) Software priority Instruction MOV POKE WR, #0010B INTPM1, WR Interrupt cycle EI MOV POKE WR, #0011B INTPM1, WR EI RETINote Interrupt cycle INTE INT pin IRQ flag Basic timer 1 IRQBTM1 flag IP flag IPBTM1 flag Basic timer 1 interrupt pending period INT pin interrupt pending period Basic timer 1 interrupt service routine Basic timer 1 interrupt accepted Note 76 Because the level of the interrupt stack is 1, multiplexed interrupt cannot be performed. INT pin interrupt service INT pin interrupt accepted µPD17072,17073 11.7 Operations after Accepting Interrupt When an interrupt has been accepted, the following processing is automatically executed in sequence: (1) The interrupt enable flip-flop and the interrupt request flag corresponding to the accepted interrupt request are cleared to “0”. Therefore, the interrupt is disabled. (2) The contents of the stack pointer are decremented by one. (3) The contents of the program counter are saved to the address stack register specified by the stack pointer. At this time, the content of the program counter is the program memory address next to the one at which the interrupt has been accepted. For example, if the interrupt has been accepted while a branch instruction is executed, the branch destination address is loaded to the program counter. If a subroutine call instruction is executed when the interrupt has been accepted, the address that called the subroutine is loaded to the program counter. When the skip condition of a skip instruction is satisfied, the next instruction is treated as a no-operation instruction (“NOP”) and then the interrupt is accepted. Consequently, the contents of the program counter are the skipped address. (4) The lower 1 bit of the bank register (BANK) is saved to the interrupt stack. Caution At this time, the contents of the program status word (PSWORD) are not saved. Save the contents of the program status word by software as necessary. (5) The contents of the vector address generator corresponding to the accepted interrupt are transferred to the program counter. Therefore, the execution branches to an interrupt service routine. The above steps (1) through (5) are executed in one special instruction cycle (53.3 µs: normal operation) that does not involve execution of an ordinary instruction. This instruction cycle is called an interrupt cycle. Therefore, it takes the CPU one instruction cycle to branch to the corresponding vector address after it has accepted an interrupt. 77 µPD17072,17073 11.8 Exiting from Interrupt Service Routine To return to the service that was executed when the interrupt was accepted from the interrupt service routine, a dedicated instruction “RETI” is used. When this instruction is executed, the following processing is automatically executed in sequence: (1) The contents of the address stack register specified by the stack pointer are restored to the program counter. (2) The contents of the interrupt stack are restored to the lower 1 bit of the bank register (BANK). Caution If the contents of the program status word are saved in the program, its contents must be restored to the program status word at the same time. (3) The contents of the stack pointer are incremented by one. The processing (1) through (3) above is executed in one instruction cycle during which the “RETI” instruction is executed. The only difference between the “RETI” and subroutine return instructions “RET” and “RETSK” is the restore operation of each system register described in step (2) above. 78 µPD17072,17073 11.9 External (INT Pin) Interrupts 11.9.1 Outline of external interrupts Figure 11-9 outlines the external interrupts. As shown in this figure, an interrupt request for an external interrupt is issued at the rising or falling edge of the signal input to the INT pin. Whether the interrupt request is to be issued at the rising or falling edge of INT is specified independently through program. The INT pin is Schmitt trigger input pin to protect malfunctioning due to noise. This pin do not accept a pulse input that lasts for less than 100 ns. Figure 11-9. Outline of External Interrupt INT flag IEG flag Edge detection block INT pin Interrupt control block IRQ flag Schmitt trigger Remark INT: detects pin status IEG: selects interrupt edge 11.9.2 Edge Detection Block The edge detection block specifies the edge (rising or falling edge) of the input signal that issues the external interrupt request of the INT pin, and detects the specified edge. The edge is specified by IEG flag. Figure 11-10 shows the configuration and function of the interrupt edge select register. 79 µPD17072,17073 Figure 11-10. Configuration of Interrupt Edge Select Register Flag symbol Read/ Name Address b3 Interrupt edge select b2 b1 b0 I B I N T E T M G Write (BANK1) 0 R/W register 1 56H C K Sets input edge to issue interrupt request of INT pin 0 Rising edge 1 Falling edge Sets time interval at which IRQBTM1 flag is setNote 0 32 ms (31.25 Hz) 1 8 ms (125 Hz) Detects status of INT pin 0 Low level is input to INT pin 1 High level is input to INT pin Fixed to “0” Power-ON At reset Clock stop CE Note 0 0 0 0 0 0 0 0 0 0 For the function of the BTM1CK flag, refer to 12.3.1 Outline of basic timer 1. Note that as soon as the interrupt request issuing edge is changed by the IEG flag, the interrupt request signal may be issued. Suppose that the IEG flag is set to “1” (specifying the falling edge) and that a high level is input to the INT pin, as shown in Table 11-2. If the IEG flag is cleared at this time, the edge detector circuit judges that a rising edge has been input, and issues an interrupt request. 80 µPD17072,17073 Table 11-2. Issuing Interrupt Request By Changing IEG Flag Changes in IEG flag 1 → 0 (falling) (rising) 0 → 1 (rising) (falling) INT pin status Interrupt request IRQ flag status Low level Not issued Retains previous status High level Issued Set to “1” Low level Issued Set to “1” High level Not issued Retains previous status 11.9.3 Interrupt control block The level of a signal input to the INT pin can be detected by using the INT flag. This flag is set or cleared independently of interrupts; therefore, it can be used as a 1-bit general-purpose input port when the interrupt function is not used. The INT flag can also be used as a general-purpose port that can detect the rising or falling edge by reading an interrupt request flag if the interrupt corresponding to the flag is not enabled. In this case, however, the interrupt request flag is not automatically cleared and must be cleared by program. Also refer to Figure 11-10. 11.10 Internal Interrupt Two internal interrupt sources, basic timer 1, and serial interface, are available. 11.10.1 Interrupt by basic timer 1 This interrupt request is issued at fixed time intervals. For details, refer to 12. TIMER. 11.10.2 Interrupt by serial interface This interrupt request is issued when a serial output or serial input operation has been completed. For details, refer to 14. SERIAL INTERFACE. 81 µPD17072,17073 12. TIMER The timers are used to control the program execution time. 12.1 General As shown in this figure, the µPD17013 is provided with the following two timers: • Basic timer 0 • Basic timer 1 The basic timer 0 is used to detect the status of a flip-flop that is set at fixed time intervals. The basic timer 1 is used to issue an interrupt request at fixed time intervals. The basic timer 0 can also be used to detect a power failure. The clock of each timer is generated by dividing the system clock (75 kHz). 12.2 Basic Timer 0 12.2.1 General Figure 12-1 outlines the basic timer 0. The basic timer 0 is used as a timer by detecting the status of a flip-flop which is set at fixed time intervals, by using the BTM0CY flag (BANK1 of RAM: address 51H, bit 0). The content of the flip-flop corresponds to the BTM0CY flag on a one-to-one basis. The set time for BTM0CY flag (BTM0CY flag set pulse) is 125 ms (8 Hz). If the BTM0CY flag is read for the first time after power-ON reset, its content is always “0”. After that, the flag is set to “1” at fixed time intervals. If the CE pin goes high, CE reset is effected when the BTM0CY flag is set next time. By reading the content of the BTM0CY flag at system reset (power-ON reset and CE reset), therefore, a power failure can be detected. For details on power failure detection, refer to 20. RESET. Figure 12-1. Outline of Basic Timer 0 75 kHz Divider 125 ms (8 Hz) Basic timer 0 carry FF Set/clear BTM0CY flag Remark BTM0CY (bit 0 of basic timer 0 carry register: refer to Figure 12-2) detects the status of the flip-flop. 82 µPD17072,17073 12.2.2 Flip-flop and BTM0CY flag The flip-flop is set at fixed time intervals and its status is detected by the BTM0CY flag of the basic timer 0 carry register. The BTM0CY flag is a read-only flag, and is reset to “0” if its contents are read (Read & Reset) by using the instructions shown in Table 12-1. The BTM0CY flag is reset to “0” at power-ON reset, and is set to “1” at CE reset and at CE reset after the clock stop instruction is executed. Therefore, this flag can be used as a power failure detection flag. The BTM0CY flag is not set until its contents are read by the instruction shown in Table 12-1 after application of the supply voltage. Once a read instruction has been executed, this flag is set at fixed time intervals. Figure 12-2 shows the configuration and function of the basic timer 0 carry register. Table 12-1. Instructions to Reset BTM0CY Flag Mnemonic ADD Operand m, #n4 Mnemonic ADD ADDC ADDC SUB SUB SUBC SUBC AND AND OR OR XOR XOR SKE LD SKEG SKT SKLT SKF SKNE MOV Operand r, m m, #n @r, m m, @rNote Note When the row address of m is 5H and 1H is written to r. Remark m = 51H 83 µPD17072,17073 Figure 12-2. Configuration of Basic Timer 0 Carry Register Flag symbol Name Address b2 b3 Basic timer 0 carry register 0 0 b1 b0 0 B T M 0 C Y (BANK1) 51H Read/ Write R&Reset Detects status of flip-flop. 0 Flip-flop is not set. 1 Flip-flop is set. Fixed to "0". 0 Power-ON 0 0 0 At reset Clock stop 1 CE 1 12.2.3 Application example of basic timer 0 An example of a program in which the basic timer 0 is used is shown below. In this example, processing A is executed every 1 second. Example M1 MEM 1.10H ; 1-second counter, set to bank 1 SKT1 BTM0CY ; Branches to NEXT if BTM0CY flag is “0” BR NEXT ADD M1, #0010B LOOP: BANK1 ; Adds 2 to M1 SKT1 CY ; Executes processing A if CY flag is “1” BR NEXT ; Branches to NEXT if CY flag is “0” Processing A NEXT: Processing B BR 84 LOOP ; Executes processing B and branches to LOOP µPD17072,17073 12.2.4 Error of basic timer 0 The time at which the BTM0CY flag is to be detected must be shorter than the time at which the BTM0CY flag is to be set (refer to 12.2.5 Notes on using basic timer 0). Where the time interval at which the BTM0CY flag is to be detected is tCHECK and the time interval at which the BTM0CY flag is to be set (125 ms) is tSET, the relation between tCHECK and tSET must be as follows: tCHECK < tSET At this time, as shown in Figure 12-3, the timer error when the BTM0CY flag is detected is: 0 < error < tSET Figure 12-3. Error of Basic Timer 0 due to Detection Time of BTM0CY Flag BTM0CY flag setting pulse H L tSET 1 BTM0CY flag 0 tCHECK1 SKT1 BTM0CY <1> tCHECK2 SKT1 BTM0CY <2> tCHECK3 SKT1 BTM0CY <3> SKT1 BTM0CY <4> As shown in Figure 12-3, the timer is updated because the BTM0CY flag is detected as “1” in <2>. In <3>, the flag is “0”; therefore, the timer is not updated until the BTM0CY flag is detected again in <4>. At this time, the time of the timer is extended by tCHECK3. 85 µPD17072,17073 12.2.5 Notes on using basic timer 0 (1) BTM0CY flag detection time interval The time interval at which the BTM0CY flag is to be detected must be shorter than the time interval at which the flag is to be set. This is because, if the time of processing B in Figure 12-4 is longer than the time interval at which the BTM0CY flag is to be set, the BTM0CY flag is not set accurately. Figure 12-4. Detection of BTM0CY Flag and BTM0CY Flag BTM0CY flag setting pulse H L 1 <1> <2> <3> <4> <5> BTM0CY flag 0 SKT1 BTM0CY SKT1 BTM0CY Processing A SKT1 BTM0CY Processing B Because execution time of processing B is too long after BTM0CY flag, which has been set to "1" in step <2> above, has been detected, BTM0CY flag is not detected in step <3>. (2) Sum of timer updating processing time and BTM0CY flag detection time interval As described in (1) above, the time interval tCHECK at which the BTM0CY flag is to be detected must be shorter than the time at which the BTM0CY flag is to be set. At this time, even if the time interval at which the BTM0CY flag is to be detected is short, the timer processing may not be executed normally when CE reset is effected if the updating processing time of the timer is long. Therefore, the following conditions must be satisfied: tCHECK + tTIMER < tSET where, tCHECK: time interval at which BTM0CY flag is detected tTIMER: timer updating processing time tSET: time interval at which BTM0CY flag is set An example is shown below. 86 µPD17072,17073 Example Timer updating processing and BTM0CY flag detection time interval BTIMER: BANK1 SKT1 BTM0CY ; Executes timer updating processing if BTM0CY flag is “1”. BR ; Branches to AAA if BTM0CY flag is “0”. AAA Timer updating BR BTIMER AAA: Processing A BR BTIMER The following is the timing chart of the above program. CE pin H L BTM0CY flag setting pulse H L 1 BTM0CY flag 0 BTM0CY detection interval tCHECK SKT1 BTM0CY Timer updating processing tTIMER SKT1 BTM0CY If this timer updating processing time is too long, CE reset is effected while processing is in progress. CE reset 87 µPD17072,17073 (3) Adjusting basic timer 0 at CE reset An example of adjusting the basic timer 0 at CE reset is shown on the next page. As shown in this example, the timer may have to be adjusted if the BTM0CY flag is used for power failure detection and, at the same time, the flag is used for a watch timer. When the power is applied the first time (power-ON reset), the BTM0CY flag is cleared to “0”, and not set until the contents of the flag is read again by an instruction shown in Table 12-1. If the CE pin goes high, CE reset is effected in synchronization with rising edge of the BTM0CY flag setting pulse. At this time, the BTM0CY flag is set to “1” and starts. Therefore, it can be judged, when system reset (power-ON reset or CE reset) has been effected, whether the system reset is power-ON reset or CE reset, by checking the status of the BTM0CY flag. That is, if the BTM0CY flag is “0”, power-ON reset has been effected; if the flag is “1”, CE reset has been effected (for power failure detection). At this time, the watch timer must continue its operation even when CE reset has been effected. However, because the BTM0CY flag is cleared to “0” as a result of reading the BTM0CY flag to detect a power failure, the set (1) status of the BTM0CY flag is overlooked once. Consequently, it is necessary to update the watch timer if CE reset has been detected as a result of power failure detection. For details on power failure detection, refer to 20.6 Power Failure Detection. Example Adjusting timer at CE reset (to detect power failure and update watch by BTM0CY flag) START: ; Program address 0000H Processing A ; <1> BANK1 SKT1 BTM0CY ; Embedded macro ; Tests BTM0CY flag. BR INITIAL ; If BTM0CY is “0”, branches to INITIAL (power failure detection). BACKUP: ; <2> Updates watch 125 ms. ; Adjusts watch because this is back up (CE reset) LOOP: ; <3> Processing B ; While performing processing B, SKF1 BTM0CY ; tests BTM0CY flag and updates watch. BR BACKUP BR LOOP INITIAL: Processing C BR ; Initialization of ports and peripheral hardware. LOOP Figure 12-5 shows the timing chart of the above program. 88 µPD17072,17073 Figure 12-5. Timing Chart 3V VDD 0V CE Internal pulse 8 Hz BTM0CY flag setting pulse BTM0CY flag H L H L H L 1 0 Program processing A Program instruction C <1> B <3> B <3> Watch UP Power application B <3> B B B <3> <3> <3> B B <3> <3> Watch UP Watch UP B B <3><3> B <1> Watch UP B B <3> <3> Watch UP CE reset starts from address 0. Power-ON reset starts from address 0. BTM0CY flag is detected. Time updated because flag is set to 1. BTM0CY flag detection Point A A Point B Point C Point D Point E As shown in Figure 12-5, the program is started from address 0000H in synchronization with the rising of the internal 8-Hz pulse when supply voltage VDD is applied first. When the BTM0CY flag is detected next at point A, the BTM0CY flag is cleared to 0 because power has been just applied. It is therefore judged that a power failure (i.e., power-ON reset) has been detected, and “processing C” is executed. Because the content of the BTM0CY flag has been read once at point A, the BTM0CY flag is set to 1 every 125 ms afterward. Next, even if the CE pin goes low at point B and goes high at point C, the program executes “processing B” and increments the watch, unless the clock stop instruction is executed. Because the CE pin goes high at point C, CE reset is effected at point D where the BTM0CY flag setting pulse rises, and the program is started from address 0000H. At this time, if the BTM0CY flag is detected at point E, it is judged that back up (CE reset) has been effected, because the BTM0CY flag is set to 1. As is evident from the above figure, the watch is delayed by 125 ms each time CE reset is effected, unless the watch is updated 125 ms at point E. If processing A takes 125 ms or longer when a power failure is detected at point E, setting of the BTM0CY flag is overlooked two times; therefore, processing A must be completed within 125 ms. Therefore, the BTM0CY flag must be detected for a power failure detection within the BTM0CY flag setting time after the program has been started from the address 0000H. 89 µPD17072,17073 (4) If detection of BTM0CY flag overlaps with CE reset As described in (3), the CE reset is effected as soon as the BTM0CY flag has been set to 1. If the BTM0CY flag read instruction happens to be executed at the same time as the CE reset, the BTM0CY flag read instruction takes precedence. Therefore, if setting of the BTM0CY flag after the CE pin has gone high overlaps with the BTM0CY flag read instruction, the CE reset is effected when “the BTM0CY flag is set next time”. This operation is illustrated in Figure 12-6. Figure 12-6. Operation when CE Reset and BTM0CY Flag Read Instruction Overlap H CE pin BTM0CY flag setting pulse L H BTM0CY flag L 1 0 SKT 1 BTM0CY BTM0CY flag setting pulse BTM0CY flag SKT 1 BTM0CY CE reset H L 1 0 Instruction SKT1 BTM0CY 53.3 µ s Embedded macro SKT .MF. BTM0CY SHR4, #.DF. BTM0CY AND 0FH If BTM0CY flag is read during this period, CE is delayed. Originally, program starts from address 0000H here. However, because it happens to overlap with a program that reads BTM0CY, CE reset is not effected. In a program that cyclically detects the BTM0CY flag, in which the BTM0CY flag detection time interval coincides with the BTM0CY flag setting time, CE reset is never effected. 90 µPD17072,17073 12.3 Basic Timer 1 12.3.1 General Figure 12-7 outlines the basic timer 1. The basic timer 1 issues an interrupt request at fixed time interval and sets the IRQBTM1 flag to 1. The time interval of the IRQBTM1 flag is set by the BTM1CK flag of the interrupt edge select register. Figure 128 shows the configuration and function of the interrupt edge select register. The interrupt generated by the basic timer 1 is accepted when the IRQBTM1 flag is set, if the EI instruction has been issued and the IPBTM1 flag has been set (refer to 11. INTERRUPT). Figure 12-7. Outline of Basic Timer 1 BTM1CK flag Internal signal 75 kHz (fixed) 32 ms (31.25 Hz) Divider Selector IRQBTM1 set signal 8 ms (125 Hz) Remark BTM1CK (bit 1 of interrupt edge select register. Refer to Figure 12-8) set the time interval at which the IRQBTM1 flag is set. 91 µPD17072,17073 Figure 12-8. Configuration of Interrupt Edge Select Register Read/ Flag symbol Name Address b3 Interrupt edge b2 b1 b0 I B I N T E T M G Write (BANK1) 0 R/W select register 1 56H C K Sets input edge to issue interrupt request of INT pinNote 0 Rising edge 1 Falling edge Sets time interval at which IRQBTM1 flag is set 0 32 ms (31.25 Hz) 1 8 ms (125 Hz) Detects status of INT pinNote 0 Low level is input to INT pin. 1 High level is input to INT pin. Fixed to “0”. Power-ON At reset Clock stop CE Note 92 0 0 0 0 0 0 0 0 0 0 For the functions of IEG and INT flags, refer to 11.9 External (INT pin) Interrupt. µPD17072,17073 12.3.2 Application example of basic timer 1 A program example is shown below. Example M1 MEM 0.10H ; 80-ms counter 0002H ; Symbol definition of basic timer 1 interrupt vector address START ; Branches to START M1, #0001B ; Adds 1 to M1 SKT1 CY ; Tests CY flag BR EI_RETI ; Returns if no carry MOV M1, #0110B BTIMER1 DAT BR ORG BTIMER1 ADD ; Program address (0002H) Processing A EI_RETI: EI RETI START: MOV M1, #0110B ; Initializes contents of M1 to 6 BANK1 SET1 BTM1CK ; Embedded macro ; Sets basic timer 1 interrupt pulse to 8 ms SET1 IPBTM1 EI ; Enables basic timer 1 interrupt ; Enables all interrupts LOOP: BANK0 Processing B BR LOOP This program executes processing A every 80 ms. The points to be noted in this case are that the DI status is automatically set when an interrupt has been accepted, and that the IRQBTM1 flag is set to 1 even in the DI status. This means that the interrupt is accepted even if execution exits from an interrupt service routine by execution of the “RETI” instruction, if processing A takes longer than 8 ms. Consequently, processing B is not executed. 93 µPD17072,17073 12.3.3 Error of basic timer 1 As described in 12.3.2, the interrupt generated by basic timer 1 is accepted each time the basic timer 1 interrupt pulse falls, if the EI instruction has been executed, and if the interrupt has been enabled. Therefore, an error of basic timer 1 occurs only when any of the following operations are performed: • When the first interrupt after basic timer 1 interrupt has been enabled has been accepted • When the time interval at which the IRQBTM1 flag is to be set is changed, i.e., when the first interrupt is accepted after the interrupt pulse has been changed • When data has been written to the IRQBTM1 flag Figure 12-9 shows an error in each of the above operations. Figure 12-9. Error of Basic Timer 1 (1/2) (a) When interrupt by basic timer 1 is enabled Basic timer 1 interrupt pulse IRQBTM1 flag IPBTM1 flag INTE FF H L tSET 1 0 1 0 EI DI EI EI EI Interrupt pending <1> <2> SET1 IPBTM1 Interrupt accepted <3> Interrupt accepted Interrupt accepted At point <1> in the above figure, the interrupt by basic timer 1 is accepted as soon as the interrupt is enabled. At this time, the error is –tSET. If an interrupt is enabled by the “EI” instruction at the next point <3>, the interrupt occurs at the falling edge of the basic timer 1 interrupt pulse. At this time, the error is: –tSET < error < 0 94 µPD17072,17073 Figure 12-9. Error of Basic Timer 1 (2/2) (b) When basic timer 1 interrupt pulse is changed Internal pulse A H Internal pulse B Basic timer 1 interrupt pulse IRQBTM1 flag IPBTM1 flag L H L H L 1 0 1 0 EI INTE FF DI EI EI <3> Basic timer 1 interrupt EI EI <1> Basic timer 1 interrupt pulse changed pulse changed Interrupt accepted Interrupt accepted <2> Interrupt accepted Even if the basic timer 1 interrupt pulse is changed to B at point <1> in the above figure, the interrupt is accepted at the next point <2> because the basic timer 1 interrupt pulse does not fall. If the basic timer 1 interrupt pulse is changed to A at <3>, the interrupt is immediately accepted because the basic timer 1 interrupt pulse falls. (c) When IRQBTM1 flag is manipulated Basic timer 1 interrupt pulse IRQBTM1 flag IPBTM1 flag INTE FF H L 1 0 1 0 EI DI EI Interrupt accepted EI <1> SET1 IRQBTM1 <2> CLR1 IRQBTM1 Interrupt not accepted Interrupt accepted EI Interrupt accepted The interrupt is immediately accepted if the IRQBTM1 flag is set to 1 at <1>. If clearing the IRQBTM1 flag to 0 overlaps with the falling of the basic timer 1 interrupt pulse at <2>, the interrupt is not accepted. 95 µPD17072,17073 12.3.4 Notes on using basic timer 1 When creating a program, such as a program for watch, in which processing is always performed at fixed time intervals by using the basic timer 1 after the supply voltage has been once applied (power-ON reset), the basic timer 1 interrupt service must be completed in a fixed time. Let’s take the following example: Example M1 MEM BTIMER1 DAT BR ORG 0.10H ; 80-ms counter 0002H ; Symbol definition of interrupt vector address of basic timer 1 START ; Branches to START BTIMER1 ; Program address (0002H) ADD M1, #0001B ; Adds 1 to M1 SKT1 CY ; Watch processing if carry occurs BR EI_RETI ; Restores if no carry occurs MOV M1, #0110B ; <1> Processing B EI_RETI: EI RETI START: MOV M1, #0110B ; Initializes contetns of M1 to 6 BANK1 SET1 BTM1CK ; Embedded macro ; Sets time of interrupt by basic timer 1 to 8 ms SET1 IPBTM1 ; Embedded macro ; Enables interrupt by basic timer 1 EI ; Enables all interrupts LOOP: Processing A BR LOOP In this example, processing B is executed every 80 ms while processing A is executed. If the CE pin goes high as shown in Figure 12-10, CE reset is effected in synchronization with the rising of the BTM0CY flag setting pulse. If issuance of an interrupt request by the basic timer 1 happens to overlap with the setting of the BTM0CY flag at this time, CE reset takes precedence. When CE reset is effected, the basic timer 1 interrupt request (IRQBTM1) flag is cleared. Consequently, the timer processing is skipped once. 96 µPD17072,17073 Figure 12-10. Timing Chart CE pin BTM0CY flag setting pulse Basic timer 1 interrupt pulse H L H L H L Basic timer 1 interrupt Because BTM0CY flag setting pulse rises, CE reset is effected here. As a result, basic timer 1 interrupt is skipped once. 97 µPD17072,17073 13. A/D CONVERTER 13.1 General Figure 13-1 outlines the A/D converter. The A/D converter compares an analog voltage input to the AD0 or AD1 pins with the internal compare voltage, judge the comparison result via software, and converts the analog signal into a 4-bit digital signal. The comparison result can be detected by the ADCCMP flag. As the comparison method, successive approximation is employed. Figure 13-1. Outline of A/D Converter ADCCH1 flag ADCCH0 flag P1A2/AD0 P1A3/AD1 Input selector block Compare block Set/reset ADCCMP flag Compare voltage generator block (R-string D/A converter) Remarks 1. ADCCH0 and ADCCH1 (bits 0 and 1 of A/D converter channel select register. Refer to Figure 134) select the pin used for the A/D converter. 2. ADCCMP (bit 0 of A/D converter compare result detection register. Refer to Figure 13-7) detects the result of comparison. 98 µPD17072,17073 13.2 Setting A/D Converter Power Supply The µPD17073 has a power supply for the A/D converter. This power supply is also used for LCD display. When using the A/D converter, therefore, the A/D converter power supply must be set to ON by using the ADCON flag of the LCD driver display start register. Figure 13-2 shows the configuration and function of the LCD driver display start register. Figure 13-2. Configuration of LCD Driver Display Start Register Read/ Flag symbol Name Address b3 b2 b1 b0 A L D C C D LCD driver display Write (BANK1) 0 0 start register R/W 50H O E N N Turns ON/OFF A/D converter power supply and all LCD displays 0 0 A/D converter power supply OFF, LCD display OFF 0 1 A/D converter power supply ON, LCD display ON 1 0 A/D converter power supply ON, LCD display OFF 1 1 A/D converter power supply ON, LCD display ON Fixed to “0”. 0 Power-ON At reset Clock stop CE 0 0 0 0 0 0 R Remark R: Retained Cautions 1. When the LCD display is ON (LCDEN = 1), the A/D converter power supply is ON regardless of the setting of the ADCON flag. 2. Bit 3 of the LCD driver display start register is a test mode area. Therefore, do not write “1” to this bit. 99 µPD17072,17073 13.3 Input Selector Block Figure 13-3 shows the configuration of the input selector block. The input selector block selects the pin to be used by using the A/D converter channel select register. Two or more pins cannot be used at the same time with the A/D converter. Figure 13-4 shows the configuration and function of the A/D converter channel select register. For the configuration and function of the port 1A pull-down resistor select register, refer to Figure 10-1 Port 1A Pull-Down Resistor Select Register. Figure 13-3. Configuration of Input Selector Block ADCCH1 flag ADCCH0 flag Selector P1A2/AD0 Compare block VADCIN P1A3/AD0 Each I/O port 100 µPD17072,17073 Figure 13-4. Configuration of A/D Converter Channel Select Register Flag symbol Name Address b3 A/D converter channel select register 0 b2 0 b1 b0 A A D D C C C C H H 1 0 (BANK1) 5CH Read/ Write R/W Sets pins used for A/D converter 0 0 A/D converter is not used (general-purpose input port) 0 1 P1A2/AD0 1 0 P1A3/AD1 pin 1 1 P1A3/AD1 pin Fixed to "0" 0 0 At Clock stop reset 0 0 CE 0 0 Power-ON 0 0 101 µPD17072,17073 13.4 Compare Voltage Generator Block and Compare Block Figure 13-5 shows the configuration of the compare voltage generator block and compare block. The compare voltage generator block switches over the tap decoder by using 4-bit data set to the A/D converter reference voltage setting register to generate 16 steps of compare voltage VREF. In other words, this block is an R-string D/A converter. The power source of the R string is the same as VDD that is supplied to the device. The compare block judges which of the voltage VADCIN input from a pin and compare voltage VREF is greater. Data is compared by the comparator as soon as the ADCSTRT flag has been written to. One compare time of the A/D converter is equal to two instruction execution times (106.6 µs in normal operation mode, and 213.2 µs in the low-speed mode). By reading the content of the ADCSTRT flag, the current operating status of the comparator can be checked. The compare result is detected by the ADCCMP flag. Figure 13-6 shows the configuration and function of the A/D converter compare start register. Figures 13-7 and 13-8 show the configuration and function of the A/D converter compare result detection register and A/D converter reference voltage setting register. Table 13-1 lists the compare voltages. Figure 13-5. Configuration of Compare Voltage Generator Block and Compare Block 1/2 VDD _ VADCIN 2pF VREF Comparator + A/D converter reference voltage setting register (ADCR) Tap decoder 0 1 R 2 1 R E VDD F R 1 R 2 Write to ADCSTRT flag 102 ADCCMP flag µPD17072,17073 Figure 13-6. Configuration of A/D Converter Compare Start Register Flag symbol Read/ Address Name b3 b2 b1 b0 Write A D A/D converter C (BANK1) compare start 0 0 0 S R/W 5EH register T R T Write Read Checks operating status of comparator Sets start of compare operation by comparator 0 Operation stops (compare completes) Invalid 1 Operating (analog voltage comparison in progress) Start Fixed to 0 Power-ON At reset Clock stop CE 0 0 0 0 0 0 Remarks 1. Even if the A/D converter channel select register or A/D converter reference voltage setting register is manipulated when ADCSTRT = 1 (when comparison by the comparator is in progress), the contents of the register remain unchanged. Therefore, the operating status of the A/D converter cannot be changed while the comparator is operating. 2. The ADCSTRT flag is cleared to “0” only when the voltage comparison operation by the comparator is completed or when the “STOP s” instruction is executed. 103 µPD17072,17073 Figure 13-7. Configuration of A/D Converter Compare Result Detection Register Flag symbol Name Address b3 A/D converter compare result detection register 0 b2 0 b1 b0 0 A D C C M P (BANK1) 5FH Read/ Write R Detects result of comparison by A/D converter 0 VADCIN < VREF 1 VADCIN > VREF Fixed to "0" Power-ON 0 0 0 0 At reset Clock stop 0 CE 0 104 µPD17072,17073 Figure 13-8. Configuration of A/D Converter Reference Voltage Setting Register Read/ Flag symbol Name Address b3 b2 b1 b0 A A A A D D D D C C C C A/D converter R R R R reference voltage F F F F S S S S E E E E L L L L 3 2 1 0 setting register Write (BANK1) R/W 5DH Sets compare voltage of A/D converter 0 | x + 0.5 VREF = x × VDD (V) 16 | 0FH Power-ON 0 0 0 0 At Clock stop reset 0 0 0 0 0 0 0 0 CE 105 µPD17072,17073 Table 13-1. Set Value of A/D Converter Reference Voltage Setting Register and Compare Voltage A/D Converter reference voltage setting register set data 106 Compare voltage Decimal (DEC) Hexadecimal (HEX) Logic voltage Unit: × VDD V At VDD = 3 V Unit: V 0 00H 0.5/16 0.094 1 01H 1.5/16 0.281 2 02H 2.5/16 0.469 3 03H 3.5/16 0.656 4 04H 4.5/16 0.844 5 05H 5.5/16 1.031 6 06H 6.5/16 1.219 7 07H 7.5/16 1.406 8 08H 8.5/16 1.594 9 09H 9.5/16 1.781 10 0AH 10.5/16 1.969 11 0BH 11.5/16 2.156 12 0CH 12.5/16 2.344 13 0DH 13.5/16 2.531 14 0EH 14.5/16 2.719 15 0FH 15.5/16 2.906 µPD17072,17073 13.5 Comparison Timing Chart The ADCEN flag is automatically cleared to 0 when the comparison operation has been completed. The ADCSTRT flag is reset to 0 two instructions after the ADCSTRT flag has been set. At this point, the compare result (ADCCMP flag) can be read. Figure 13-9 shows the timing chart. Figure 13-9. Timing Chart of A/D Converter’s Compare Operation Instruction cycle A/D A/D converter start converter start instruction instruction NOP NOP ADCCMP read Sample & hold ADCSTRT flag Comparison result ADCCMP flag 13.6 Performance of A/D Converter Table 13-2 shows the performances of the A/D converter. Table 13-2. Performances of A/D Converter Parameter Performance Resolution 4 bits Input voltage range 0-VDD Quantization error ±1/2 LSB Over range 15.5/16 × VDD Error of offset, gain, and non-linearity ±3/2 LSBNote Note Including quantization error 107 µPD17072,17073 13.7 Using A/D Converter 13.7.1 Comparing one reference voltage The following shows a program example. Example To compare voltage input to AD0 pin, VADCIN against reference voltage VREF (8.5/16 VDD). VADCIN > VREF, execution branches to AAA; if VADCIN < VREF, execution branches to BBB. BANK1 SET1 ADCON INITFLG NOT ADCCH1, ADCCH0 ; P1A2/AD0 pin used as A/D converter pin ; A/D converter ON INITFLG ADCRFSEL3, NOT ADCRFSEL2, NOT ADCRFSEL1, NOT ADCRFSEL0 ; Sets compare voltage VREF to 8.5/16 × VDD SET1 ADCSTRT NOP ; Comparison in progress NOP 108 ; A/D operation starts ; Comparison in progress SKT1 ADCCMP ; Detects ADCCMP flag and, BR AAA ; Branches to AAA if False (0) BR BBB ; Branches to BBB if True (1) If µPD17072,17073 13.7.2 Successive comparison by means of binary search The A/D converter can compare only one reference voltage at a time. Consequently, successive comparison must be executed through program in order to convert input voltages into digital signals. If the processing time of the successive comparison program is different depending on the input voltage, it is not desirable because of the relations with the other programs. Therefore, the binary search method described in (1) through (3) below is useful. (1) Concept of binary search The following figure illustrates the concept of binary search. First, the reference voltage is set to 1/2VDD. If the result of comparison is True (high level), a voltage of 1/ 4VDD is applied; if the result is False (low level), a voltage of 1/4VDD is subtracted for comparison. Similarly, comparison is performed in sequence from 1/8VDD to 1/16VDD. If the result is False after comparison has been executed six times, 1/64VDD is subtracted, and the comparison ends. 1 1 H H H L L 13/16 H 11/16 L L H H L L L 5/16 H 3/16 L L First L Second Third Fourth 2/16 1/16 1/16 0 4/16 3/16 L 1/8 6/16 5/16 L 1/4 8/16 7/16 7/16 3/8 10/16 9/16 9/16 1/2 12/16 11/16 L 5/8 14/16 13/16 L 3/4 L Compare voltage (×VDD) 15/16 15/16 7/8 0/16 Subtract 1/16 if false 109 µPD17072,17073 (2) Flowchart of binary search START Initial setting : Select pin to be used. (A/D converter reference voltage setting register) = #1000B ADCCMP = 1? : Set reference voltage to 1/2VDD Y : Detect reference voltage and, N : if "0", subtract 1/2VDD and, Reset ADCRFSEL3 flag : add both "0" and "1" to 1/4VDD and set reference voltage. Set ADCRFSEL2 flag ADCCMP = 1? Y : Detect reference voltage and, N : if "0", subtract 1/4VDD and, Reset ADCRFSEL2 flag Set ADCRFSEL1 flag ADCCMP = 1? : add both "0" and "1" to 1/8VDD and set reference voltage. Y : Detect reference voltage and, N : if "0", subtract 1/8VDD and, Reset ADCRFSEL1 flag : add both "0" and "1" to 1/16VDD and set reference voltage. Set ADCRFSEL0 flag ADCCMP = 1? Y : Detect reference voltage and, N Reset ADCRFSEL0 flag Detect content of A/D converter reference voltage setting register END 110 : if "0", subtract 1/16VDD and, µPD17072,17073 (3) Program example of binary search START: BANK1 INITFLG NOT ADCCH1, ADCCH0 ; Selects AD0 pin INITFLG P1APLD2 ; Sets pull-down resistor of AD0 pin OFF INITFLG NOT ADCRFSEL3, ADCRFSEL2, ADCRFSEL1, ADRFSEL0 ; Sets compare voltage to 7.5/16 VDD SET1 ADCSTRT ; A/D converter starts operating. NOP ; 2 wait NOP SKF1 ; ADCCMP ; Detects ADCCMP SET1 ADCRFSEL3 ; If 0, adds 7.5/16 VDD and CLR1 ADCRFSEL2 ; subtracts 3.5/16 VDD SET1 ADCSTRT ; A/D converter starts operating. NOP ; 2 wait NOP SKF1 ; ADCCMP ; Detects ADCCMP SET1 ADCRFSEL2 ; If 0, adds 3.5/16 VDD and CLR1 ADCRFSEL1 ; subtracts 1.5/16 VDD SET1 ADCSTRT ; A/D converter starts operating. NOP ; 2 wait NOP SKF1 ; ADCCMP ; Detects ADCCMP SET1 ADCRFSEL1 ; If 0, adds 1.5/16 VDD and CLR1 ADCRFSEL0 ; subtracts 0.5/16 VDD SET1 ADCSTRT ; A/D converter starts operating. NOP ; 2 wait NOP ; SKF1 ADCCMP ; Detects ADCCMP SET1 ADCRFSEL0 ; If 0, adds 0.5/16 VDD END: 13.8 Status at Reset 13.8.1 At power-ON reset The P1A2/AD0 and P1A3/AD1 pins are set in the general-purpose input port mode, and internally pulled down. 13.8.2 On execution of clock stop instruction The P1A2/AD0 and P1A3/AD1 pins are set in the general-purpose input port mode. The previous status of the pull-down resistor is retained. 13.8.3 At CE reset The P1A2/AD0 and P1A3/AD1 pins are set in the general-purpose input port mode. The previous status of the pull-down resistor is retained. 111 µPD17072,17073 14. SERIAL INTERFACE 14.1 General Figure 14-1 shows the outline of the serial interface. This serial interface is of two-wire/three-wire serial I/O type. The former type uses SCK and SO1/SI pins. The latter uses SCK, SI, and SO0 pins. Figure 14-1. Outline of Serial Interface SIOCK1, 0 flags Wait signal Clock I/O control block SCK/P0B2 SIOTS flag Clock control block 75 kHz Wait control block Clock counter SIOHIZ flag SIOSEL flag Count value 8 IRQSIO flag Presettable shift register OUT SO1/SI/P0B3 (SIOSFR) IN Data I/O control block SO0/P1C0 Remarks 1. SIOCK1 and 0 (bits 0 and 1 of serial I/O clock select register. Refer to Figure 14-2) set a shift clock. 2. SIOTS (bit 0 of serial I/O mode select register. Refer to Figure 14-3) starts/stops communication. 3. SIOHIZ (bit 1 of serial I/O mode select register. Refer to Figure 14-3) sets the function of the SO0/ P1C0 pin. 4. SIOSEL (bit 3 of serial I/O mode select register. Refer to Figure 14-3) selects I/O of SO1/SI/P0B3 pin. 112 µPD17072,17073 14.2 Clock Input/Output Control Block and Data Input/Output Control Block The clock input/output control block and data input/output control block select the operation mode of the serial interface (2-wire or 3-wire mode), control the transmit/receive operation, and select a shift clock. The flags that control these blocks are allocated to the serial I/O clock select register and serial I/O mode select register. Figure 14-2 shows the configuration and function of the serial I/O clock select register. Figure 14-3 shows the configuration and function of the serial I/O mode select register. Table 14-1 shows the setting status of each pin by the corresponding control flags. As shown in this table, the input/output setting flag of each pin must be also manipulated in addition to the control flag of the serial interface, to set each pin. The SIOCK1 and 0 flags select the internal clock (master) or external clock (slave) operation. The SIOHIZ flag selects whether the SO0/P1C0 pin is used as a serial data output pin. The SIOSEL flag selects whether the SO1/SI/P0B3 pin is used as a serial data input (SI pin) or serial data output (SO1) pin. Figure 14-2. Configuration of Serial I/O Clock Select Register Read/ Flag symbol Name Address b3 b2 b1 b0 S S I I O O (BANK1) C C 61H K K 1 0 Write Serial I/O clock select 0 0 R/W register Sets shift clock of serial interface 0 0 External clock 0 1 12.5 kHz 1 0 18.75 kHz 1 1 37.5 kHz Internal clock Fixed to “0” Power-ON At Clock stop reset CE 0 0 0 0 0 0 0 0 113 µPD17072,17073 Figure 14-3. Configuration of Serial I/O Mode Select Register Read/ Flag symbol Name Address b3 b2 b1 b0 S S S I I I O O O (BANK1) S H T 60H E I S L Z Write Serial I/O mode select 0 R/W register Starts/stops serial communication 0 Stops (wait status) 1 Starts Sets function of P1C0/SO0 pin 0 General-purpose output port 1 Serial data output pin Selects function of P0B3/SI/SO1 pin 0 As serial data input (SI) pin 1 As serial data output (SO1) pin Fixed to 0 Power-ON At Clock stop reset CE 114 0 0 0 0 0 0 0 0 0 0 µPD17072,17073 Table 14-1. Set Status of Each Pin By Control Flags Control flags of serial interface Communication mode S I O S E L Serial I/O select S I O H I Z I/O setting flag of each pin S I interface O C pin setting K 1 S I O C K 0 Clock 0 0 External Serial 3-wire serial Note 1 I/O Pin name setting P 0 B B I O 3 P0B2/SCK P 0 B B I O 2 Set status of pin 0 During wait: general-purpose input port clock Wait released: external clock input and 2-wire serial 1 General-purpose output port 0 1 Internal 0 General-purpose input port 1 0 clock 1 During wait: waits for internal clock output 1 1 Note 2 I/O 0 1 Internal clock (reception) Wait released: internal clock output P0B3/SI/ 0 SO1 Output (transmission) P1C0/SO0 During wait: general-purpose input port Wait released: serial input 1 General-purpose output port 0 During wait: waits for serial output 1 Wait released: serial output General-purpose output port 0 Generalpurpose output 1 Serial During wait: waits for serial output output Wait released: serial output Notes 1. To set the 3-wire serial I/O mode, be sure to reset SIOSEL to 0 and set SIOHIZ to 1. 2. To use the 2-wire serial I/O mode, be sure to reset SIOHIZ to 0. 115 µPD17072,17073 14.2.1 Setting 2-/3-wire mode The serial interface uses two pins in the two-wire mode: SCK/P0B2 and SO1/SI/P0B3. The SCK/P0B2 pin is used as a shift clock input/output pin, and the SO1/SI/P0B3 pin is used as a serial data input/ output pin. The SO0/P1C0 pin is not used for the serial interface and is set in the general-purpose output port mode by the SIOHIZ flag. In this way, the serial interface operates in the two-wire mode. In the three-wire mode, three pins, SCK/P0B2, SO0/P1C0, and SO1/SI/P0B3 are used. The SCK/P0B2 is used as a shift clock input/output pin, the SO0/P1C0 pin is used as a serial data output pin, and the SO1/SI/P0B3 pin is used as a serial data input pin. Unlike in the two-wire mode, the SO0/P1C0 pin is used as a serial data output pin according to the setting of the SIOHIZ flag. The SO1/SI/P0B3 pin is used as a serial data input pin according to the setting of the SIOSEL flag. In this way, the serial interface operates in the three-wire mode. 14.2.2 Selecting data input/output using 2-wire serial interface In the two-wire mode, the SO1/SI/P0B3 pin is used as an input/output pin for serial data. Whether the SO1/SI/P0B3 pin is used as a serial data input pin (SI pin) or serial data output pin (SO1 pin) is specified by the SIOSEL flag (refer to Figure 14-3 Configuration of Serial I/O Mode Select Register). 14.3 Clock Control Block The clock control block generates a clock when the internal clock is used (master operation), and controls clock output timing. The frequency fSC of the internal clock is set by the SIOCK0 and SIOCK1 flags of the serial I/O clock select register. Figure 14-2 shows the configuration and function of the serial I/O clock select register. For the clock generation timing, refer to 14.7 Operation of Serial Interface. 14.4 Clock Counter The clock counter counts the shift clock output or input from the shift clock pin (SCK/P0B2 pin). Because the clock counter directly reads the status of the clock pin, it cannot identify whether the clock is an internal clock or an external clock. The contents of the clock counter cannot be directly read by software. For the operation and timing chart of the clock counter, refer to 14.7 Operation of Serial Interface. 116 µPD17072,17073 14.5 Presettable Shift Register The presettable shift register is an 8-bit shift register that writes serial-out data and reads serial-in data. Writing/reading data to/from the presettable shift register is performed by PUT and GET instructions via data buffer. The presettable shift register outputs (transmits) the content of its most significant bit (MSB) from the serial data I/O pin in synchronization with the falling edge of the shift clock, and reads data to its least significant bit (LSB) in synchronization with the rising edge of the shift clock. Figure 14-4 shows the configuration and function of the presettable shift register. Figure 14-4. Configuration of Presettable Shift Register Data buffer DBF3 DBF2 Don't care Don't care DBF1 DBF0 Transfer data GETNote 8 PUTNote Peripheral register Name b7 Presettable shift register M S B b6 b5 b4 b3 b2 b1 Valid data b0 Symbol Peripheral address L S B 03H SIOSFR Setting of serial-out data and reading of serial-in data D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 Serial out Note D2 D1 D0 Serial in If the PUT or GET instruction is executed during serial communication, the data may be lost. For details, refer to 14.8 Notes on Setting and Reading Data. 14.6 Wait Control Block The wait control block performs wait (pause) control of communication. By releasing the wait status by using the SIOTS flag of the serial I/O mode select register, serial communication is started. After the wait status has been released, and communication has been started, the wait status is resumed if shift clock rises at clock counter “8”. The communication status can be detected by the SIOTS flag. That is, the communication status can be detected by detecting the status of the SIOTS flag after setting “1” to the SIOTS flag. If “0” is written to the SIOTS flag while the wait status is released, the wait status is set. This is called a forced wait status. For the configuration and function of the serial I/O mode select register, refer to Figure 14-3. 117 µPD17072,17073 14.7 Serial Interface Operation The timing of each operation of the serial interface is described below. This timing is applicable to both 2-wire and 3-wire modes. 14.7.1 Timing chart Figure 14-5 shows a timing chart. Figure 14-5. Timing Chart of Serial Interface Shift clock 2 1 Serial data La Clock counter 0 3 7 D7 D6 D5 1 2 3 8 D1 6 7 1 D0 8 D7 0 SIOTS <1> <2> <3> INT <4> <5> <6> Remarks <1> Initial status (general-purpose input port) <2> Start condition satisfied by general-purpose I/O port <3> Wait released <4> Wait timing <5> General-purpose input port mode set <6> Stop condition satisfied by general-purpose I/O port 14.7.2 Operation of clock counter The initial value of the clock counter is “0”. The value of the clock counter is incremented each time the falling edge of the clock pin has been detected. When the value of the clock counter reaches “8”, it is reset to “0” at the next rising edge of the clock pin. After the clock counter has been reset to “0”, the serial communication is placed in the wait status. The conditions under which the clock counter is reset are as follows: (1) At power-ON reset (2) When clock stop instruction is executed (3) When “0” is written to SIOTS flag (4) If shift clock rises while wait status is released and present value of clock counter is “8” 118 µPD17072,17073 14.7.3 Wait operation and note When the wait status has been released, serial data is output at the next falling edge of the clock (transmission operation), and the wait released status continues until eight clocks are counted. After the eight clocks have been output, make the shift clock pin high and stop the operations of the clock counter and presettable shift register. Note that, if data is written to or read from the presettable shift register while the wait status is released and the shift clock pin is high, the correct data is not set. If data is written to the presettable shift register while the wait status is released and the shift clock pin is low, the content of the MSB of the data is output to the serial data output pin when the “PUT” instruction is executed. If the forced wait status is set while the wait status is released, the wait status is immediately set when “0” is written to the SIOTS flag. 14.7.4 Interrupt request issuance timing An interrupt request is issued when eight clocks have been transmitted (received). 14.7.5 Shift clock generation timing (1) When wait status is released from initial status The “initial status” means the point at which the P0B2/SCK pin has been made high with the internal clock operation selected. During the wait status, a high level is output to the shift clock pin. The wait status can be released and a clock can be selected at the same time. 119 µPD17072,17073 Figure 14-6. Shift Clock Generation Timing of Serial Interface (1/4) Shift clock (37.5 kHz) 1:1 Wait status Initialization 1/fSC 13.33 µ s Wait released Shift clock (18.75 kHz) 1:1 Wait status 1/fSC 13.33 µ s Initialization Wait released Shift clock (12.5 kHz) 2:1 Wait status Initialization 26.66 µ s 1/fSC Wait released (2) When wait operation is performed (a) When wait status is set at the 8th clock (normal operation) Figure 14-6. Shift Clock Generation Timing of Serial Interface (2/4) Contents of output latch Shift clock Wait released status Wait status Wait 120 Wait released 1/fSC µPD17072,17073 (b) When forced wait status is set during wait status Figure 14-6. Shift Clock Generation Timing of Serial Interface (3/4) Shift clock Contents of output latch Contents of output latch Wait period Wait period Forced wait by SIOTS (c) When forced wait status is set while wait status is released Figure 14-6. Shift Clock Generation Timing of Serial Interface (4/4) Contents of output latch Shift clock Wait released status Wait status Forced wait by SIOTS 1/fSC Wait released Contents of output latch Shift clock Wait released status Wait status Forced wait by SIOTS 1/fSC Wait released (d) When wait status is released while wait status is released The clock output waveform does not change. Neither is the counter reset. However, do not change the clock frequency while the wait status is released. 121 µPD17072,17073 14.8 Notes on Setting and Reading Data Use the “PUT SIOSFR, DBF” instruction to set data to the presettable shift register. Use the “GET DBF, SIOSFR” instruction to read data. Set or read the data in the wait status. While the wait status is released, the data may not be correctly set or read depending on the status of the shift clock pin. The following table describes the points to be noted in setting and reading data. Table 14-2. Data Read and Write Operations of Presettable Shift Register and Notes Status on execution of PUT/GET Status of shift clock pin Read (GET) Wait status Write (PUT) Operation of presettable shift register Normal read • Floating with external clock • Value of output latch with internal clock. Normally, used with high level Normal write Content of MSB is output as data at falling edge of shift clock after wait status is released next (transmission operation). Clock MSB Data PUT SIOSFR, DBF Low level Normal read High level Cannot be read normally. Contents of SIOSFR are lost. Low level Cannot be written normally. Contents of SIOSFR are lost. Read (GET) Wait released Normal write Content of MSB is output as data when PUT instruction is executed. Clock counter is not reset. Wait release status Write (PUT) High level Clock Data MSB PUT SIOSFR, DBF 122 µPD17072,17073 14.9 Operational Outline of Serial Interface Tables 14-3 and 14-4 outline the operations of the serial interface. Table 14-3. Operation in 3-wire Serial I/O Mode Operation mode Item Status of Slave operation (SIOCK1 = SIOCK0 = 0) During wait (SIOTS = 0) SCK/P0B2 each pin • When P0BBIO2 = 0 General-purpose input port • When P0BBIO2 = 1 SI/SO1/P0B3 Master operation (SIOCK1 = SIOCK0 = other than 0) Wait released (SIOTS = 1) • When P0BBIO2 = 0 During wait (SIOTS = 0) • When P0BBIO2 = 0 External clock input port • When P0BBIO2 = 1 General-purpose input port • When P0BBIO2 = 1 General-purpose output General-purpose output Waits for internal clock port port output Wait released (SIOTS = 1) • When P0BBIO2 = 0 General-purpose input port • When P0BBIO2 = 1 Internal clock output SIOSEL = 0 ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– • When P0BBIO3 = 0 General-purpose input port • When P0BBIO3 = 1 • When P0BBIO3 = 0 • When P0BBIO3 = 0 Serial input General-purpose input port • When P0BBIO3 = 1 • When P0BBIO3 = 1 • When P0BBIO3 = 0 Serial input • When P0BBIO3 = 1 General-purpose output General-purpose output General-purpose output General-purpose output port port port port SO0/P1C0 SIOHIZ = 1 ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– Waits for serial output Serial output Program counter Incremented at falling edge of SCK pin Operation of • When SIOHIZ = 0 Output presettable Waits for serial output Serial output Not output shift register • When SIOHIZ = 1 Shifted from MSB and output from SO0 pin at falling edge of SCK pin Input • When SIOSEL = 0 Shifted from LSB and status of SI pin is input at rising edge of SCK pin. If SI pin is set in output mode, however, contents of output latch are input. 123 µPD17072,17073 Table 14-4. Operation in Two-Wire Serial I/O Mode Operation mode Item Status of Slave operation (SIOCK1 = SIOCK0 = 0) During wait (SIOTS = 0) SCK/P0B2 each pin • When P0BBIO2 = 0 General-purpose input port • When P0BBIO2 = 1 Master operation (SIOCK1 = SIOCK0 = other than 0) Wait released (SIOTS = 1) • When P0BBIO2 = 0 During wait (SIOTS = 0) • When P0BBIO2 = 0 External clock input port • When P0BBIO2 = 1 General-purpose input port • When P0BBIO2 = 1 General-purpose output General-purpose output Waits for internal clock port port output SI/SO1/P0B3 Wait released (SIOTS = 1) • When P0BBIO2 = 0 General-purpose input port • When P0BBIO2 = 1 Internal clock output SIOSEL = 0 ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– • When P0BBIO3 = 0 General-purpose input port • When P0BBIO3 = 1 • When P0BBIO3 = 0 • When P0BBIO3 = 0 Serial input General-purpose input port • When P0BBIO3 = 1 • When P0BBIO3 = 1 • When P0BBIO3 = 0 Serial input • When P0BBIO3 = 1 General-purpose output General-purpose output General-purpose output General-purpose output port port port port SIOSEL = 0 ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– Waits for serial output Serial output regardless of Waits for serial output Serial output regardless of regardless of P0BBIO3 P0BBIO3 regardless of P0BBIO3 P0BBIO3 SO0/P1C0 SIOHIZ = 1 ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– General-purpose output port Program counter Incremented at falling edge of SCK pin Operation of • When SIOSEL = 1 Output presettable shift register Shifted from MSB and output from SIO1 pin at falling edge of SCK pin Input • When SIOSEL = 0 Shifted from LSB and status of SI pin is input at rising edge of SCK pin. If SI pin is set in output port mode, however, contents of output latch are input. 124 µPD17072,17073 14.10 Status on Reset 14.10.1 At power-ON reset P0B2/SCK and P0B3/SI/SO1 pins are set in the general-purpose input port mode. P1C0/SO0 pin is set in the general-purpose port. The contents of the presettable shift register are undefined. 14.10.2 At clock stop P0B2/SCK and P0B3/SI/SO1 pins set in the general-purpose input port mode. P1C0/SO0 pin is set in the general-purpose port. The previous contents of the presettable shift register are retained. 14.10.3 At CE reset P0B2/SCK and P0B3/SI/SO1 pins are set in the general-purpose input port mode. P1C0/SO0 pin is set in the general-purpose port. The previous contents of the presettable shift register are retained. 14.10.4 In halt status All the pins hold the current status. The internal clock stops output in the status in which the HALT instruction is executed. When the external clock is used, the operation continued even if the HALT instruction is executed. 125 µPD17072,17073 15. PLL FREQUENCY SYNTHESIZER The PLL (Phase Locked Loop) frequency synthesizer is used to lock a frequency in the MF (Medium Frequency), HF (High Frequency), and VHF (Very High Frequency) bands to a fixed frequency, by means of phase difference comparison. 15.1 General Figure 15-1 outlines the PLL frequency synthesizer. By connecting an external lowpass filter (LPF) and voltage controlled oscillator (VCO), the PLL frequency synthesizer can be configured. The PLL frequency synthesizer divides a signal input from the VCOH or VCOL pin by using a programmable divider, and outputs the phase difference between the signal and the reference frequency from the EO pin. However, the signal input from the VCOH pin is halved immediately before it is input to the programmable divider. The PLL frequency synthesizer operates only while the CE pin is high. When the CE pin is low, the synthesizer is disabled. For details of the PLL disable status, refer to 15.5 PLL Disable Status. Figure 15-1. Outline of PLL Frequency Synthesizer VCOH VCOL Input selector block Programmable divider (PD) Phase comparator ( φ -DET) Charge pump EO Note 75 kHz Reference frequency generator Lowpass filter (LPF) Unlock FF Note Voltage-controlled oscillator (VCO) PLLMD1 flag PLLMD0 flag PLLRFCK2 flag PLLRFCK1 flag PLLRFCK0 flag PLLUL flag Note External circuit Remarks 1. PLLMD1 and 0 (bits 1 and 0 of PLL mode select register. Refer to Figure 15-3) set the division method of the PLL frequency synthesizer. 2. PLLRFCK2, 1, and 0 (bits 2-0 of PLL reference frequency select register. Refer to Figure 15-7) set the reference frequency fr of the PLL frequency synthesizer. 3. PLLUL (bit 0 of PLL unlock FF register. Refer to Figure 15-10) detects the status of the unlock FF. 126 µPD17072,17073 15.2 Input Selector Block and Programmable Divider 15.2.1 Configuration and function of input selector block and programmable divider Figure 15-2 shows the configuration of the input selector block and programmable divider. The input selector block selects the input pin and division method of the PLL frequency synthesizer. As the input pin, the VCOH or VCOL pin can be selected. The selected pin is at the intermediate potential (approx. 1/2VDD). The pin not selected is internally pulled down. These pins have an AC amplifier at the input stage; therefore, cut the DC component of the input signal by connecting a capacitor in series. As the division method, DC division method or pulse swallow method can be selected. The programmable divider performs frequency division according to the values set to the swallow counter and programmable counter. Table 15-1 shows each input pin (VCOH and VCOL) and division method. The input pin and division method to be used are selected by the PLL mode select register. Figure 15-3 shows the configuration of the PLL mode select register. A division value is set by using the PLL data register. The division value is transferred to the programmable divider using PLL data set register. Figure 15-2. Configuration of Input Selector Block and Programmable Divider PLL PUT flag PLLMD1 flag PLLMD0 flag PLL data register 12 bits 5 bits 5 VCOH 1/2 2 modular prescalers 1/32, 1/33 12 Swallower counter, 5 bits Programmable counter, 12 bits To fN f -DET VCOL PLL disable signal 127 µPD17072,17073 Table 15-1. Input Pins and Division Modes Division mode Pin Input frequency (MHz) Input amplitude (Vp-p) Division value Direct division (MF) VCOL 0.3 - 8 0.2 Pulse swallow (HF) VCOL 5 - 130 0.3 1024 to 217 – 1 0400H – 1FFFFH Pulse swallow (VHF) VCOH 40 - 230 0.2 1024 to 217 – 1 0400H – 1FFFFH 16 to 2 12 –1 Division value set to data buffer 010xH - FFFxH (x: don’t care) Figure 15-3. Configuration of PLL Mode Select Register Flag symbol Name b3 PLL mode select register 0 b2 b1 b0 0 P L L M D 1 P L L M D 0 Address Read/ Write (BANK1) 65H R/W Sets division mode of PLL frequency synthesizer 0 0 PLL disabled 0 1 Direct division (VCOL pin MF mode) 1 0 Pulse swallow (VCOH pin VHF mode, 1/2 division) 1 1 Pulse swallow (VCOL pin HF mode) Fixed to "0" Power-ON At reset Clock stop CE 128 0 0 0 0 0 0 Retained µPD17072,17073 15.2.2 Outline of each division mode (1) Direct division mode (MF) In this mode, the VCOL pin is used. The VCOH pin is floated. The frequency of the input signal is divided only by the programmable counter in this mode. (2) Pulse swallow mode (HF) The VCOL pin is used, and the VCOH pin is floated. In this mode, the frequency is divided by the swallow counter and programmable counter. (3) Pulse swallow mode (VHF) The VCOH pin is used, and the VCOL pin is floated. If this mode is selected 1/2 division is inserted in the stage previous to programmable divider. In this mode, the swallow counter and programmable counter are used for frequency division. (4) PLL disable Refer to 15.5 PLL Disable Status. 129 µPD17072,17073 15.2.3 Programmable divider, PLL data register, and PLL data set register A division value is set to the swallow counter and programmable counter by the PLL data register. The value set by the PLL data register is transferred by the PLL data set register to the swallow counter and programmable counter. The swallow counter and programmable counter are 5-bit and 12-bit binary counters. The value to be divided is called an “N value”. For how to set the division value (N value) in each division mode, refer to 15.6 Using PLL Frequency Synthesizer. (1) Configuration and functions of PLL data register The configuration of the PLL data register is shown in Figure 15-4. The higher 12 bits of the 16-bit PLL data register are valid in the direct division mode, and all the 17 bits of the register are valid in the pulse swallow mode. In the direct division mode, the 12 valid register bits are set to the programmable counter. In the pulse swallow mode, the higher 12 bits are set to the programmable counter, and the remaining lower 5 bits are set to the swallow counter. (2) Configuration and function of PLL data set register Figure 15-5 shows the configuration of the PLL data set register. By writing “1” to the PLLPUT flag, the division value set by the PLL data register is transferred to the swallow counter and programmable counter. After the data has been set, the PLLPUT flag is reset to “0”. (3) Relations between value N of programmable divider and output frequency Value “N” set to the PLL data register and the frequency “fN” that is divided and output by the programmable divider are determined as follows. For details, refer to 15.6 Use of PLL Frequency Synthesizer. (a) In direct division mode (MF) fN = fIN N N: 12 bits (b) In pulse swallow mode (HF, VHF) fN = Note 130 fIN N N: 17 bits In VHF mode, frequency fIN of the signal input from VCOH pin is divided by two immediately before 1 fIN in the VHF mode. input to the programmable divider. Therefore, fN = 2 N µPD17072,17073 Figure 15-4. Configuration of PLL Data Register Name PLL data register BANK1 Address 67H 68H 69H 6AH 6BH b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 Bit Data P P P P P P P P P P P P P P P P P L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L R R R R R R R R R R R R R R R R R 1 1 1 1 1 1 1 1 9 8 7 6 5 4 3 2 1 7 6 5 4 3 2 1 0 0 0 0 Fixed to “0” Valid bit: 12 bits (direct division mode) Sets division ratio of PLL frequency synthesizer 0 | don't care Setting prohibited don't care Division ratio N : N = x 15 (00FH) 16 (010H) Direct division mode | x | 212 –1 (FFFH) Valid bit: 17 bits (in pulse swallow mode) Sets division ratio of PLL frequency synthesizer 0 | Setting prohibited 1023 (03FFH) Pulse swallow mode 1024 (0400H) | x Division ratio N : N = x | 217–1 (1FFFFH) Remark On power application and at power-ON reset, the contents of the PLL data register are undefined. On execution of the clock stop instruction and at CE reset, the contents of the PLL data register are retained. 131 µPD17072,17073 Figure 15-5. Configuration of PLL Data Set Register Flag symbol Read/ Address Name b3 b2 b1 b0 Write P L PLL data set register 0 0 L (BANK1) P 6CH 0 W U T Data transfer to program counter 0 Does not transfer (data latch) 1 Transfers Fixed to “0” Power-ON At Clock stop reset CE 132 0 0 0 0 0 0 µPD17072,17073 15.3 Reference Frequency Generator Figure 15-6 shows the configuration of the reference frequency generator. The reference frequency generator divides 75 kHz output by the crystal oscillator to generate the reference frequency “fr” of the PLL frequency synthesizer. As reference frequency fr, six frequencies can be selected: 1, 3, 5, 6.25, 12.5, and 25. Reference frequency fr is selected by the PLL reference frequency select register. Figure 15-7 shows the configuration and functions of the PLL reference frequency select register. Figure 15-6. Configuration of Reference Frequency Generator PLLRFCK2 flag PLLRFCK1 flag PLLRFCK0 flag MUX 1 kHz 3 kHz 5 kHz 75 kHz To φ -DET Divider 6.25 kHz 12.5 kHz 25 kHz OFF PLL disable signal 133 µPD17072,17073 Figure 15-7. Configuration of PLL Reference Frequency Select Register Flag symbol Name PLL reference frequency select register b3 b2 b1 b0 0 P L L R F C K 2 P L L R F C K 1 P L L R F C K 0 Address Read/ Write (BANK1) 66H R/W Sets reference frequency fr of PLL frequency synthesizer Power-ON At reset Clock stop CE reset 0 0 0 0 1 kHz 0 0 1 3 kHz 0 1 0 5 kHz 0 1 1 6.25 kHz 1 0 0 12.5 kHz 1 0 1 25 kHz 1 1 0 PLL disable 1 1 1 PLL disable 0 0 0 0 0 0 Retained Remark When the PLL reference frequency select register is set to “PLL disable” status, the VCOH and VCOL pins are floated. The EO pin is floated. 134 µPD17072,17073 15.4 Phase Comparator (φ-DET), Charge Pump, and Unlock FF 15.4.1 Configurations of phase comparator, charge pump, and unlock FF Figure 15-8 shows the configurations of the phase comparator, charge pump, and unlock FF. The phase comparator compares the output frequency of the programmable divider, “fN”, against the output frequency of the reference frequency generator, “fr”, and outputs UP or DW request signal. The charge pump outputs the output signal of the phase comparator from the error out pin (EO). The unlock FF detects the unlock status of the PLL frequency synthesizer. The following paragraphs 15.4.2 through 15.4.4 respectively describe the operations of the phase comparator, charge pump, and unlock FF. Figure 15-8. Configurations of Phase Comparator, Charge Pump, and Unlock FF PLLUL flag Reference frequency generator UP fr Unlock FF Phase comparator ( φ -DET) Programable divider fN DW Charge pump EO PLL disable signal 135 µPD17072,17073 15.4.2 Functions of phase comparator As shown in Figure 15-8, the phase comparator compares the output frequency of the programmable divider “fN” against reference frequency “fr”, and outputs UP or DOWN request signal. That is, if fN is lower than fr, it outputs the UP request signal; if fN is higher than fr, the DOWN request signal is output. Figure 15-9 shows the relations among fr, fN, and UP and DOWN request signals. In the PLL disable status, neither UP nor DOWN request signal is output. The UP and DOWN request signals are input to the charge pump and unlock FF. Figure 15-9. Relations among fr, fN, UP, and DW (a) If fN lags behind fr fr fN UP DW (b) If fN advances fr fr fN UP DW (c) If fN and fr are in phase fr fN UP DW (d) If fN is lower than fr fr fN UP DW 136 µPD17072,17073 15.4.3 Charge pump As shown in Figure 15-8, the charge pump outputs the UP and DOWN request signals from the phase comparator to the error out pin (EO). Therefore, the relations among the outputs of the error out pins, divided frequency fN, and reference frequency fr are as follows: When fr > fN: Low-level output When fr < fN: High-level output When fr = fN: Floating 15.4.4 Unlock FF As shown in Figure 15-8, the unlock FF detects the unlock status of the PLL frequency synthesizer in response to the UP or DOWN request signal output from the phase comparator. In the unlock status, either one of the UP or DOWN request signals goes low. Therefore, the unlock status can be detected when one of the request signals has gone low. In the unlock status, the unlock FF is set to 1. The status of the unlock FF is detected by the PLL unlock FF register. Figure 15-10 shows the configuration and function of the PLL unlock FF register. The unlock FF is set at the cycle of the selected reference frequency fr. The unlock FF is reset when the contents of the PLL unlock FF register is read by the instruction shown in Table 15-2 (Read & Reset). Therefore, the unlock FF must be detected at a cycle longer than the cycle of the reference frequency fr (which is 1/fr). The delay of the up and down request signals of the phase comparator is fixed to about 1 µs. Figure 15-10. Configuration of PLL Unlock FF Register Flag symbol Name PLL unlock FF register b3 b2 b1 b0 0 0 0 P L L U L Address Read/ Write (BANK1) 6DH R& Reset Detects unlock FF status 0 Unlock FF = 0: PLL lock status 1 Unlock FF = 1: PLL unlock status Fixed to "0" Power-ON 0 0 0 U At Clock stop reset R CE R Remark U: Undefined R: Retained 137 µPD17072,17073 Table 15-2. Instructions to Reset PLL Unlock FF Register Mnemonic ADD Operand m, #n4 Mnemonic ADD ADDC ADDC SUB SUB SUBC SUBC AND AND OR OR XOR XOR SKE LD SKEG SKT SKLT SKF SKNE MOV Operand r, m m, #n @r, m m, @rNote Note When the row address of m is 6H and 0DH is written to r. Remark m = 6DH 138 µPD17072,17073 15.5 PLL Disable Status The PLL frequency synthesizer stops its operation (i.e., is disabled) while the CE pin is low. Similarly, the synthesizer stops when the “PLL disable status” is selected by the PLL reference frequency select register or PLL mode select register even the CE pin is high. Table 15-3 shows the operations of the respective blocks when the PLL synthesizer is disabled. The PLL reference frequency select register and PLL mode select register are not initialized on CE reset, but retains their previous contents; therefore, the original status of the synthesizer is restored when the CE pin goes high after the CE pin has gone low and the PLL disable status has been set. To set the PLL disable status after the CE reset has been effected, initialization must be performed through program. The PLL disable status is set on power-ON reset. Table 15-3. Operations of Respective Blocks in PLL Disable Status Condition CE pin = low (PLL disable) CE pin = high PLL reference frequency select register = 0110B, 0111B Block VCOL, VCOH pins Floated Programmable divider Division stopped Reference frequency generator Output stopped PLL mode select register = 0000B Phase comparator Charge pump EO pin floated 139 µPD17072,17073 15.6 Use of PLL Frequency Synthesizer To control the PLL frequency synthesizer, the following data are necessary: (1) Division mode : direct division (MF) or pulse swallow (HF, VHF) (2) Pin to be used : VCOL or VCOH (3) Reference frequency : fr (4) Division value : N The following paragraphs 15.6.1 through 15.6.3 describe how to set the above data in each division mode (MF, HF, or VHF). 15.6.1 Direct Division Mode (MF) (1) Selecting division mode Select the direct division mode by the PLL mode select register. (2) Pin to be used The VCOL pin is enabled when the direct division mode is selected. (3) Setting of reference frequency fr Set the reference frequency by using the PLL reference frequency select register. (4) Calculating division value N Calculate as follows: N= fVCOL fr where, fVCOL : input frequency of VCOL pin : reference frequency fr (5) Example of PLL data setting Suppose that broadcasting in the following MW band is to be received: Receive frequency : 1422 kHz (MW band) Reference frequency : Intermediate frequency : +450 kHz 3 kHz The division value N is: fVCOL fr N= = 1422 + 450 3 = 624 (decimal) = 270H (hexadecimal) Then set the PLL data register, PLL mode select register, and PLL reference frequency select register as follows: PLL data register 0 0 1 2 140 0 0 1 1 7 1 0 0 0 0 PLL mode select register 0 don’t care 0 0 0 MF 1 PLL reference frequency select register 0 0 0 3 kHz 1 µPD17072,17073 15.6.2 Pulse swallow mode (HF) (1) Selecting division mode Select the pulse swallow mode by the PLL mode select register. (2) Pin to be used The VCOL pin is enabled when the pulse swallow mode is selected. (3) Setting reference frequency fr Set the reference frequency by using the PLL reference frequency select register. (4) Calculating division value N Calculate as follows: N= fVCOL fr where, fVCOL : input frequency of VCOL pin : reference frequency fr (5) Example of PLL data setting Suppose that broadcasting in the following SW band is to be received: Receive frequency : 25.50 MHz (SW band) Reference frequency : 5 kHz Intermediate frequency : +450 kHz The division ratio N is: N= fVCOL = fr 25500 + 450 5 = 5190 (decimal) = 1446H (hexadecimal) Then set the PLL data register, PLL mode select register, and PLL reference frequency select register as follows: PLL data register 0 0 0 0 1 0 1 0 0 0 PLL mode select register 1 0 0 0 1 1 0 0 0 1 HF 1 4 4 1 PLL reference frequency select register 0 0 1 0 5 kHz 6 141 µPD17072,17073 15.6.3 Pulse swallow mode (VHF) (1) Selecting division mode Select the pulse swallow mode by the PLL mode select register. (2) Pin to be used The VCOH pin is enabled when the pulse swallow mode is selected. (3) Setting of reference frequency fr Set the reference frequency by using the PLL reference frequency select register. (4) Calculating division value N Calculate as follows: fVCOH fr N= 1 Note 2 × where, fVCOH : input frequency of VCOH pin : reference frequency fr (5) Example of PLL data setting Suppose that broadcasting in the following FM band is to be received: Receive frequency : 100.0 MHz (FM band) Reference frequency : 25 kHz Intermediate frequency : +10.7 MHz The division ratio N is: N= fVCOH 1Note 100.0 + 10.7 1 Note × = × = 2214 (decimal) 2 0.025 2 fr = 08A6 (hexadecimal) Then set the PLL data register, PLL mode select register, and PLL reference frequency select register as follows: PLL data register 0 0 0 0 0 1 0 0 0 1 0 1 0 0 1 1 0 0 0 1 VHF 0 Note 142 8 A PLL reference frequency select register PLL mode select register 0 0 1 0 1 25 kHz 6 The signal input from VCOH pin is divided by two immediately before input to the programmable divider. µPD17072,17073 15.7 Status on Reset 15.7.1 On power-ON reset The PLL mode select register is initialized to 0000B; therefore, the PLL disable status is set. 15.7.2 On clock stop The PLL disable status is set when the CE pin goes low. 15.7.3 On CE reset (1) Transition from clock stop to CE reset status The PLL mode select register has been initialized to 0000B when the clock stop instruction has been executed; therefore, the PLL disable status is set. (2) On CE reset The PLL reference frequency select register retains the previous status; therefore, the previous status is restored when the CE pin goes high. 15.7.4 In halt status The set status is retained if the CE pin is high. 143 µPD17072,17073 16. INTERMEDIATE FREQUENCY (IF) COUNTER 16.1 Outline of Intermediate Frequency (IF) Counter Figure 16-1 outlines the IF counter. The IF counter is mainly used to detect broadcasting stations, and is used to count the intermediate frequency (IF) output from a tuner. The IF counter counts the frequency input to the P0D3/FMIFC/AMIFC or P0D2/AMIFC pin for a fixed time (1 ms, 4 ms, 8 ms, or open), by using a 16-bit counter. Figure 16-1. Outline of Frequency Counter IFCMD0 flag IFCMD1 flag IFCCK1 flag IFCCK0 flag IFCSTRT flag DBF Gate time control block Start control block IF counter (16 bits) IFCG flag IFCRES flag P0D3/FMIFC/AMIFC IF counter input select block P0D2/AMIFC Remarks 1. IFCMD1 and IFCMD0 (bits 3 and 2 of IF counter mode select register. Refer to Figure 16-3) select the IF counter function. 2. IFCCK1 and IFCCK0 (bits 1 and 0 of IF counter mode select register. Refer to Figure 16-3) select the gate time of the IF counter. 3. IFCSTRT (bit 1 of IF counter control register. Refer to Figure 16-5) controls starting of the IF counter. 4. IFCG (bit 0 of IF counter gate status detection register. Refer to Figure 16-6) detects opening/closing of the gate of the IF counter. 5. IFCRES (bit 0 of IF counter control register. Refer to Figure 16-5) resets the count value of the IF counter. 144 µPD17072,17073 16.2 IF Counter Input Select Block and Gate Time Control Block Figure 16-2 shows the configuration of the IF counter input select block and gate time control block. The IF counter input select block selects, by using the IF counter mode select register, whether the P0D3/FMIFC/ AMIFC and P0D2/AMFIC pin are used as IF counter function pins or general-purpose I/O port pins. When using the IF counter function, be sure to set the P0D3/FMIFC/AMIFC and P0D2/AMIFC pins in the input mode. These pins can be set in the input or output mode by using the port 0C bit I/O select register at address 6FH of BANK1 of RAM. For the configuration and function of the port 0C bit I/O select register, refer to 10.2.3 (2) Port 0C bit I/O select register. The gate time control block sets the gate time when the IF counter function is used, by using the IF counter mode select register. Figure 16-3 shows the configuration and function of the IF counter mode register. Figure 16-2. Configuration of IF Counter Input Select Block and Gate Time Control Block IFCMD1 flag IFCMD0 flag FMIFC mode P0D3/FMIFC/AMIFC AMIFC mode P0D2/AMIFC Pin select Operation mode select 1/2 To start control block Input port Gate signal generator IFCCK1 flag IFCCK0 flag 145 µPD17072,17073 Figure 16-3. Configuration of IF Counter Mode Select Register Flag symbol Name IF counter mode select register Address b3 b2 b1 b0 I I I I F F F F C C C C M M C C D D K K 1 0 1 0 (BANK1) 62H Read/ Write R/W Sets gate time of IF counter 0 0 1 ms 0 1 4 ms 1 0 8 ms 1 1 Open Selects function of IF counter 0 0 IF counter OFF mode (general-purpose I/O port) 0 1 FMIFC/AMIFC pin: FMIF count mode 1 0 AMIFC pin: AMIF count mode 1 1 FMIFC/AMIFC pin: AMIF count mode Power-ON 0 0 0 0 At reset Clock stop 0 0 0 0 CE 0 0 0 0 146 µPD17072,17073 16.3 Start Control Block and IF Counter 16.3.1 Configuration of start control block and IF counter Figure 16-4 shows the configuration of the start control block and IF counter. The start control block starts counting of the frequency counter and detects the end of counting. The counter is started by the IF counter control register. The end of counting is detected by the IF counter gate status detection register. Figure 16-5 shows the configuration and function of the IF counter control register. Figure 16-6 shows the configuration and function of the IF counter gate status detection register. The 16.3.2, describe the gate operations when the IF counter function is selected. The IF counter is a 16-bit binary counter that counts up the input frequency when the IF counter function is selected. When the IF counter function is used, the IF counter counts the frequency input to the pin while the gate is opened by an internal gate signal. Although this frequency is counted as is in the AMIF count mode, it is halved and then counted in the FMIF count mode. The IF counter is cleared to 0000H when its count value has reached FFFFH, and then continues counting. The count value is read via data buffer by the IF counter data register (IFC). The count value is reset by the IF counter control register. Figure 16-7 shows the configuration and function of the IF counter data register. Figure 16-4. Configuration of Start Control Block and IF Counter DBF 16 IF counter data register (IFC) IFCSTRT flag IFCG flag IFCRES flag 16 From gate time selector Gate signal block RES Start control IF counter (16 bits) 147 µPD17072,17073 Figure 16-5. Configuration of IF Counter Control Register Flag symbol Name b3 IF counter control register 0 b2 b1 b0 0 I F C S T R T I F C R E S Address Read/ Write (BANK1) 64H W Controls count value of IF counter 0 Nothing is changed 1 Resets counter Starts counting of IF counter 0 Nothing is changed 1 Starts counting Fixed to "0" Power-ON At reset 148 0 0 0 0 Clock stop 0 0 CE 0 0 µPD17072,17073 Figure 16-6. Configuration of IF Counter Gate Status Detection Register Flag symbol Name b3 b2 b1 b0 Address Read/ Write (BANK1) 63H R I F C IF counter gate status detection register 0 0 0 G Detects opening/closing of IF counter 0 Close 1 Open Fixed to "0" Power-ON At reset 0 0 0 0 Clock stop 0 CE 0 Caution When the IFCG flag is set to 1 (the gate is open), do not read the contents of the IF counter data register (IFC) to the data buffer. 149 µPD17072,17073 16.3.2 Gate operation of IF counter function (1) When gate time is set to 1, 4, or 8 ms As shown below, the gate is opened for 1, 4, or 8 ms starting from the rising edge of an internal 1-kHz signal after the IFCSTRT flag has been set. While the gate is open, the frequency of a signal input to a specific pin is counted by a 16-bit counter. When the gate is closed, the IFCG flag is cleared (0). The IFCG flag is automatically set to “1” as soon as the IFCSTRT flag has been set. H L OPEN CLOSE Gate time Internal 1 kHz 1 ms 4 ms 8 ms Count period (IFCG flag = 1) Actual gate open at this point IFCSTRT flag is set (IFCG flag is set by the instruction after IFCSTRT flag is set) Count ends IFCG flag is cleared (2) When gate time is open When the gate time is specified by the IFCCK1 and IFCCK0 flags to be open, the gate is immediately opened. If counting is started by the IFCSTRT flag while the gate is open, the gate is closed after an undefined time. Therefore, do not set the IFCSTRT flag to “1” when the gate time is open. However, the counter can be reset by the IFCRES flag. Internal 1 kHz Gate H L OPEN CLOSE Count period If IFCSTRT flag is set during this period, gate is closed after undefined time Sets IFCCK1 = IFCCK0 = 1 Gate is actually opened at this point. If gate is opened with IFCG flag set to 1, it is closed after undefined time When the gate time is open, the gate can be opened and closed by resetting the gate time other than open by using IFCCK1 and IFCCK0 flags. Gate OPEN CLOSE Count period Sets IFCCK1 = IFCCK0 = 1 150 Other than open is set by IFCCK1 and IFCCK0 flags µPD17072,17073 Figure 16-7. Configuration of IF Counter Data Register Data buffer DBF3 DBF2 DBF0 DBF1 Transfer data GET can be executed 16 Nothing changes when PUT is executed Peripheral register Name b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 Symbol Peripheral address IF counter data register Valid data IFC 43H Measured value of IF counter 0 • FMIF counter Counts the rising edge of the signal input to the P0D3/FMIFC/AMIFC pin (in FMIF count mode) via a 1/2 divider. X • AMIF counter Counts the rising edge of the signal input to the P0D2/AMIFC pin (in AMIF count mode) or P0D3/FMIFC/AMIFC pin (in AMIF count mode). 216 - 1 (FFFFH) 151 µPD17072,17073 16.4 Using IF Counter The following sections 16.4.1 through 16.4.3 describe how to use the hardware of the IF counter, program example, and count error. 16.4.1 Using hardware of IF counter Figure 16-8 shows the block diagram when the P0D2/AMIFC pin and P0D3/FMIFC/AMIFC pins are used. Table 16-1 shows the range of frequency that can be input to the P0D2/AMIFC pin and P0D3/FMIFC/AMIFC pin. As shown in Figure 16-8, the input pin of the IF counter is provided with an AC amplifier; therefore, cut off the DC component of the input signal with a capacitor C. When the P0D2/AMIFC or P0D3/FMIFC/AMIFC pin is selected for the IF counter function, switch SW turns ON and the voltage applied to the pin is about 1/2VDD. If the intermediate voltage does not rise sufficiently at this time, the AC amplifier is not in the normal operating range; consequently, the IF counter does not function normally. Therefore, provide a sufficient wait time after each pin has been specified to be used for the IF counter function, until counting is started. When using the IF counter function for the auto tuning function of a radio to detect broadcasting stations, it is recommended to use the function with the SD (Station Detection) output, and so on, of the tuner. Figure 16-8. Block Diagram of IF Count Function of Each Pin R SW C External frequency To internal counter FMIFC AMIFC Table 16-1. IF Counter Input Frequency Range Input pin P0D3/FMIFC/AMIFC Input frequency (MHz) Input amplitude (VP-P) 10 - 11 0.1 FMIF mode 152 P0D3/FMIFC/AMIFC 0.4 - 2 0.15 AMIF mode 0.4 - 0.5 0.1 P0D2/AMIFC 0.4 - 2 0.15 AMIF mode 0.4 - 0.5 0.1 µPD17072,17073 16.4.2 Program example of IF counter A program example of the IF counter is shown below. As shown in this example, make sure that a wait time of a certain length elapses after an instruction that specifies the P0D2/AMIFC or P0D3/FMIFC/AMIFC pin to be used for the IF counter has been executed, until the counter is actually started. This is because the internal AC amplifier is not ready for normal operation immediately after the pin has been selected for the IF counter function, as described in 16.4.1. Example To count frequency of P0D3/FMIFC/AMIFC pin (FMIF count mode) (gate time: 8 ms) BANK1 INITFLG IFCMD1, NOT IFCMD0, IFCCK1, NOT IFCCK0 ; Selects FMIFC pin (FMIF count mode) and sets gate time to 8 ms Wait ; Internal AC amplifier stabilization time SET1 IFCRES ; Resets IF counter SET1 IFCSTRT ; Starts IF count LOOP: SKT1 IFCG ; Detects opening/closing of gate BR READ ; Branches to READ: if gate is closed Processing A BR LOOP GET DBF, IFC ; Do not read data of IF counter with this processing A. READ: 16.4.3 ; Reads value of IF counter data register to data buffer Error of IF counter The IF counter has a gate time error and count error, as described in (1) and (2) below. (1) Gate time error The gate time of the IF counter is created by dividing the 75-kHz system clock frequency. Therefore, if this frequency has an error of “+x” ppm, the gate time accordingly has an error of “-x” ppm. (2) Count error The IF counter counts frequency at the rising edge of the input signal. Therefore, if a high-level signal is input to the pin when the gate is opened, one extra pulse is counted. However, this extra pulse may not be counted, depending on the status of the pin, when the gate is closed. Therefore, the count error is “+1, -0”. 153 µPD17072,17073 16.5 Status at Reset 16.5.1 Power-ON reset The P0D3/FMIFC/AMIFC and P0D2/AMIFC pins are set in the general-purpose input port mode. The contents of the output latch are “0”. 16.5.2 On execution of clock stop instruction The P0D3/FMIFC/AMIFC and P0D2/AMIFC pins are set in the general-purpose input port mode. The contents of the output latch are retained. 16.5.3 At CE reset The P0D3/FMIFC/AMIFC and P0D2/AMIFC pins are set in the general-purpose input port mode. The contents of the output latch are retained. 16.5.4 In halt status The P0D3/FMIFC/AMIFC and P0D2/AMIFC pins retain the status immediately before the halt mode is set. 154 µPD17072,17073 17. BEEP 17.1 Configuration and Function of BEEP Figure 17-1 outlines BEEP. BEEP outputs a clock of 1.5 kHz or 3 kHz from the BEEP pin. The output select block selects, by using the BEEP0CK0 and BEEP0CK1 flags of the BEEP clock select register, whether 1.5 kHz or 3 kHz is output from the BEEP pin, or whether the BEEP pin is used as a 1-bit general-purpose output port. The clock generation block generates the 1.5-kHz or 3-kHz clock to be output to the BEEP pin. Figure 17-2 shows the configuration and function of the BEEP clock select register. Figure 17-1. Outline of BEEP BEEP0CK0 flag BEEP0CK1 flag Output select 1.5 kHz Output select block block 3 kHz Clock generation block BEEP Figure 17-2. Configuration and Function of BEEP Clock Select Register Read/ Flag symbol Name Address b3 b2 b1 b0 0 B E E P 0 C K 1 B E E P 0 C K 0 BEEP clock select 0 register Write (BANK1) R/W 5BH Setting of BEEP pin 0 0 Used as general-purpose output port and outputs low level 0 1 Used as general-purpose output port and outputs high level 1 0 Outputs 1.5 kHz clock 1 1 Outputs 3 kHz clock Fixed to “0” Power-ON At Clock stop reset CE 0 0 0 0 0 0 Retained 155 µPD17072,17073 17.2 Output Wave Form of BEEP (1) Output wave of f = 1.5 kHz and f = 3 kHz BEEP (f = 1.5 kHz) 333.3 µ s 333.3 µ s BEEP (f = 3 kHz) 133.3 µ s Example 200 µ s Program to output 3-kHz clock from BEEP pin BANK1 MOV ; Same as MOV BANK, #0001B 5BH, #0011B ; Writes 0011B to data memory address 5BH ; Outputs 3 kHz from BEEP pin (2) Maximum time until clock is output from BEEP pin after instruction execution BEEP (f = 1.5 kHz) 325.8 µs Instruction execution BEEP (f = 3 kHz) 325.8 µs Instruction execution (3) Minimum time until clock is output from BEEP pin after instruction execution BEEP (f = 1.5 kHz) 133.3 µs Instruction execution BEEP (f = 3 kHz) 133.3 µs Instruction execution 156 µPD17072,17073 17.3 Status at Reset 17.3.1 At power-ON reset The BEEP pin is set in the general-purpose output port mode, and outputs a low level. The value of the latch of the output port is “0”. 17.3.2 On execution of clock stop instruction The BEEP pin is set in the general-purpose output port mode, and outputs a low level. The value of the latch of the output port is “0”. 17.3.3 At CE reset The BEEP pin retains the previous output status. The contents of the latch are also retained. 17.3.4 In halt status The BEEP output pin retains the previous output status. 157 µPD17072,17073 18. LCD CONTROLLER/DRIVER The LCD (Liquid Crystal Display) controller/driver can display an LCD of up to 60 dots by a combination of command signal and segment signal outputs. 18.1 Outline of LCD Controller/Driver Figure 18-1 outlines the LCD controller/driver. The LCD controller/driver can be used to display up to 60 dots by using a combination of common signal output pins (COM0 through COM3) and segment signal output pins (LCD0 through LCD14). The drive mode is 1/4 duty, 1/2 bias, the frame frequency is 62.5 Hz, and drive voltage is VLCD1. Figure 18-1. Outline of LCD Controller/Driver … Segment signal output timing control block … … LCD0 pin Common signal output timing control block LCD segment register (data memory space) LCD14 pin … COM0 pin COM3 pin Basic clock for timing control LCDEN flag REGLCD0 pin REGLCD1 pin CAPLCD0 pin LCD drive voltage generation block CAPLCD1 pin Remark LCDEN (bit 3 of LCD driver display start register: refer to Figure 18-6) turns ON/OFF all LCD display. 158 µPD17072,17073 18.2 LCD Drive Voltage Generation Block The LCD drive voltage generation block generates a voltage to drive the LCD. The µPD17073 supplies the LCD drive voltage from an external doubler circuit. To configure a doubler circuit, connect a capacitor to the REGLCD0, CAPLCD0, CAPLCD1, and REGLCD1 pins. Figure 18-2 shows an example of configuration of the doubler circuit. To use a voltage of 3.1 V (TYP.), connect as shown in Figure 18-2. To operate the doubler circuit, the LCDEN flag of the LCD display start register must be set to “1”. Unless this flag is set to “1”, the LCD drive voltage generation block does not operate. For the LCDEN flag, refer to 18.4 Common Signal Output and Segment Signal Output Timing Control Blocks. Figure 18-2. Configuration of Doubler Circuit C1 REGLCD1 CAPLCD1 C3 CAPLCD0 REGLCD0 C2 C1 = C2 = 0.1 µF C3 = 0.01 µF Remark ( ): pin number Note that, because of the configuration of the doubler circuit, the values of the LCD drive voltages (VLCD1 and VLCD0) differ if the values of C1, C2, and C3 are changed. 159 µPD17072,17073 18.3 LCD Segment Register The LCD segment register sets dot data to turn on or turn off dots on the LCD. Figure 18-3 shows the location in the data memory and configuration of the LCD segment register. Because the LCD segment register is located in data memory, it can be controlled by all the data memory manipulation instructions. One nibble of the LCD segment register can set display data of 4 dots (data to turn dots on or off). If the LCD segment register is set to “1” at this time, the LCD display dot is on; the dot goes off if the register is set to “0”. Figure 18-4 shows the relation between the LCD segment register and LCD display dot. Figure 18-3. Location on Data Memory and Configuration of LCD Segment Register Column address Row address 0 0 1 2 3 4 5 6 7 1 2 3 4 5 6 7 8 9 A B C D E F DBF BANK0 B C D E F 0 1 2 3 4 5 6 BANK1 Data memory LCD segment register 7 System register LCD segment register Address 41H 42H 43H 44H 45H 46H 47H 48H 49H 4AH 4BH 4CH 4DH 4EH 4FH Symbol LCDD14 LCDD13 LCDD12 LCDD11 LCDD10 LCDD9 LCDD8 LCDD7 LCDD6 LCDD5 LCDD4 LCDD3 LCDD2 LCDD1 LCDD0 LCDD14 b3 160 b2 b1 b0 Figure 18-4. Relation between LCD Segment Register and LCD Display Dot LCD segment register Address 41H 42H 43H 44H 45H 46H 47H 4EH 4FH Symbol LCDD14 LCDD13 LCDD12 LCDD11 LCDD10 LCDD9 LCDD8 LCDD1 LCDD0 Bit b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 Display dot A COM3 pin COM2 pin COM1 pin COM0 pin B C D A B C D E F G H A B C D E F G H A B C D E F G H A B C D E F G H A A E A E A E A E B B F B F B F B F C C G C G C G C G D D H D H D H D H LCD14 pin LCD13 pin LCD12 pin LCD11 pin LCD10 pin LCD9 pin LCD8 pin LCD1 pin LCD0 pin µPD17072,17073 161 µPD17072,17073 18.4 Common Signal Output and Segment Signal Output Timing Control Blocks Figure 18-5 shows the common signal output and segment signal output timing control blocks. The common signal output timing control block controls the common signal output timing of the COM0 through COM3 pins. The segment signal output timing control block controls the segment signal output timing of the LCD0 through LCD14 pins. The common and segment signals are output when the LCDEN flag of the LCD driver display start register is set to “1”. When this flag is reset to “0”, all the LCD display dots can be extinguished (refer to Figure 18-6). When LCD display is not carried out, the COM0 through COM3 and LCD0 through LCD14 pins output low level. Figure 18-5. Configuration of Common Signal Output and Segment Signal Output Timing Control Blocks b0 LCD0 | LCD14 Segment signal Segment signal output timing control block b1 LCDD0 | b2 LCDD14 b3 Basic clock for timing control COM0 Common signal Common signal output | timing control block COM3 162 LCDEN flag µPD17072,17073 Figure 18-6. Configuration of LCD Driver Display Start Register Flag symbol Read/ Address Name b3 LCD driver display start b2 b1 b0 A L D C C D Write (BANK1) 0 0 R/W 50H register O E N N Sets ON/OFF of all LCD displays 0 Display OFF (all segment and common output pins output low level) 1 Display ON Fixed to “0” Power-ON At Clock stop reset CE 0 0 0 0 0 0 0 R Remark R: Retained Cautions 1. Bit 3 of the LCD display start register is a test mode area. Therefore, do not write “1” to this bit. 2. For the function of the ADCON flag, refer to 13.2 Setting of A/D Converter Power Supply. 18.5 Common Signal and Segment Signal Output Waves Figure 18-7 shows an example of the common signal and segment signal output waves. The µPD17073 outputs a signal with a frame frequency of 62.5 Hz using a 1/4 duty, 1/2 bias (voltage average method) drive mode. As the common signals, the COM0 through COM3 pins output three levels of voltages (GND, VLCD0, and VLCD1) each having a phase difference of 1/8 from the others. In other words, voltages of ±1/2VDD are output with the VLCD0 as the reference. This display method is called the 1/2 bias drive method. As the segment signals, the segment signal output pins output voltages of two levels (GND and VLCD1) having a phase corresponding to each display dot. Because one segment pin can turn on or off four display dots (A, B, C, and D) as shown in figure 18-7, sixteen phases can be output by combining lighting and extinguishing of each dot. Each display dot turnd on when the potential difference between a common signal and a segment signal is VLCD1. In other words, the duty factor at which each display dot turns on is 1/4. This display method is called the 1/4 duty display method, and the frame frequency is 62.5 Hz. 163 µPD17072,17073 Figure 18-7. Common Signal and Segment Signal Output Waves COM0 pin A COM1 pin B COM2 pin C COM3 pin D Each segment signal output pin (LCDn pin) Common signal 1 frame (16 ms) 4 ms VLCD1 COM0 pin VLCD0 GND VLCD1 COM1 pin VLCD0 GND VLCD1 COM2 pin VLCD0 GND VLCD1 COM3 pin VLCD0 GND Segment signal (example) A, B, C, D = extinguishes VLCD1 LCDn pin GND A, B, C, D = lights VLCD1 LCDn pin GND A, B, C = lights, D = extinguishes VLCD1 LCDn pin GND 164 µPD17072,17073 18.6 Using LCD Controller/Driver Figure 18-8 shows an example of wiring of an LCD panel An example of a program that lights the 7 segments connected to LCD0 and LCD1 pins shown in Figure 18-8 is given below. Example PMN0 MEM 0.01H ; Preset number storage area CH FLG LCDD0.3 ; Defines symbol with high-order 1 bit of LCD0 register for ‘CH’ display LCDDATA: ; LCD segment table data DW 0000000000000000B ; BLANK DW 0000000000000110B ;1 DW 0000000010110101B ;2 DW 0000000010100111B ;3 DW 0000000001100110B ;4 DW 0000000011100011B ;5 DW 0000000011110011B ;6 DW 0000000010000110B ;7 DW 0000000011110111B ;8 DW 0000000011100111B ;9 MOV AR0, #.DL.LCDDATA SHR 12 AND 0FH MOV AR1, #.DL.LCDDATA SHR 8 AND 0FH MOV AR2, #.DL.LCDDATA SHR 4 AND 0FH MOV AR3, #.DL.LCDDATA LD DBF0, AR0 LD DBF1, AR1 LD DBF2, AR2 LD DBF3, AR3 ADD DBF0, PMN0 ADDC DBF1, #0 ADDC DBF2, #0 ADDC DBF3, #0 ST AR0, DBF0 ST AR1, DBF1 ST AR2, DBF2 ST AR3, DBF3 MOVT DBF, @AR AND 0FH ; Table reference instruction BANK1 ST LCDD0, DBF0 ST LCDD1, DBF1 SET1 CH SET1 LCDEN ; LCD ON 165 166 Figure 18-8. Example of Wiring of LCD Panel A B 1a FM 1 f MW SW 2a 1 b 2 f 1g LW 1 e C 3a 2 b 3 f 2g 1 c 2 e 1d D 4a 3 b 3g 2 c 3 e 2d E 4 f 4 b 4g 3 c 4 e 3d 5a AM F PM G MHz 4 c 5 f 5 b 5g 5 e kHz 4d 5 c 5d LCD1 LCD0 LCD2 LCD3 LCD4 LCD5 LCD6 LCD7 LCD8 LCD9 LCD10 LCD11 LCD12 LCD13 LCD14 COM0 COM1 COM2 COM3 L C D 8 L C D 7 L C D 6 L C D 5 L C D 4 L C D 3 L C D 2 L C D 1 L C D 0 2a C 4a D E AM 5a CH CH Correspondence of Segment and Common Pins, and LCD Panel Display L C D 13 L C D 12 L C D 11 L C D 10 L C D 9 COM3 FM B 1a 3a COM2 MW A 1f 1b 2f 2b 3f 3b 4f 4b F PM 5f 5b COM1 SW 1g 1c 2g 2c 3g 3c 4g 4c G MHz 5g 5c COM0 LW 1e 1d 2e 2d 3e 3d 4e 4d kHz 5e 5d µPD17072,17073 Common L C D 14 ·· Segment Pin µPD17072,17073 18.7 Status at Reset 18.7.1 At power-ON reset The LCD0 through LCD14 pins output a low level. The COM0 through COM3 pins also output a low level. Therefore, the LCD display is OFF. The contents of the LCD segment register are undefined. 18.7.2 On execution of clock stop instruction The LCD0 through LCD14 pins output a low level. The COM0 through COM3 pins also output a low level. Therefore, the LCD display is OFF. The LCD segment register retains the previous contents. 18.7.3 At CE reset The LCD0 through LCD14 pins output segment signals. The COM0 through COM3 pins output common signals. The LCD segment register retains the previous contents. 18.7.4 In halt status The LCD0 through LCD14 pins output segment signals. The COM0 through COM3 pins output common signals. The LCD segment register retains the previous contents. 167 µPD17072,17073 19. STANDBY The standby function is used for the purpose of reducing the current consumption of the device when the device is in the backup status. 19.1 General Figure 19-1 shows the outline of the standby block.The standby function is to reduce the current consumption of the device by stopping part of or entire device, or slowing down the CPU clock. The standby function can be used in the following four modes, which can be selected according to the application: <1> Halt mode <2> Clock stop mode <3> Controlling device operation by CE pin <4> Low-speed function The halt mode is to reduce the current consumption of the device by stopping the operation of the CPU when a dedicated instruction, “HALT h”, has been executed. The clock stop mode is to reduce the current consumption of the device by stopping the oscillation of the oscillator circuit when a dedicated instruction, “STOP s”, has been executed. The CE pin is usually used to control the operation of the PLL frequency synthesizer and to reset the device. However, it can be said to be a mode of the standby function in that this pin controls operations. The low-speed function is to reduce the current consumption of the device by slowing down the CPU clock. 168 µPD17072,17073 Figure 19-1. Outline of Standby Block Halt block Interrupt control block Halt control circuit HALT h P1A3/AD1 P1A2/AD0 P1A1 Input latch Basic timer 0 CPU Program counter P1A0 Instruction decoder Clock stop block ALU CE flag CE Clock stop control circuit STOP s XOUT XIN Internal block System register Peripheral control register Remark CE flag (bit 0 of CE pin status detection register. Refer to Figure 19-6) detects the status of the CE pin. 169 µPD17072,17073 19.2 Halt Function 19.2.1 General The halt function is to stop the operation clock of the CPU by executing the “HALT h” instruction. When this instruction has been executed, the program is stopped and is not executed unless the halt status is released. Therefore, the current consumption of the device is reduced by the operating current of the CPU in the halt status. The halt status is released by key input, basic timer 0, or interrupt. The releasing condition is specified by the operand “h” of the HALT h instruction. The HALT h instruction is valid regardless of the input level of the CE pin. 19.2.2 Halt status In the halt status, all the operations of the CPU are stopped. In other words, the program execution is stopped by the “HALT h” instruction. However, the peripheral hardware retains the status set before the HALT h instruction is executed. For the operation of each peripheral hardware, refer to 19.4 Device Operations in Halt and Clock Stop Statuses. 19.2.3 Halt release condition Figure 19-2 shows the halt release conditions. The halt release condition is set by 4-bit data that is specified by the operand “h” of the HALT h instruction. The halt status is released when the condition specified as “1” in operand “h” is satisfied. When the halt status has been released, program execution is started from the instruction next to "HALT h" instruction. If two or more release conditions are specified, the halt status is released if any one of the specified conditions has been satisfied. When the device has been reset (by means of power-ON reset or CE reset), the halt status is released, and the appropriate reset operation is performed. If 0000B is set as the halt release condition “h”, no release condition is set. In this case, the halt status is released when the device is reset (power-ON reset or CE reset). Figure 19-2. Halt Release Condition HALT h (4 bits) Operand b3 b2 b1 b0 0: Does not release halt status even if condition is satisfied 1: Releases halt status if condition is satisfied Sets halt status release condition Releases if high level is input to port 1A Releases if basic timer 0 carry FF is set (1) Undefined (Fix this bit to "0".) Releases when interrupt request flag and interrupt enable flag are set (When executing EI and DI instructions) 170 µPD17072,17073 19.2.4 Releasing halt by key input To release the halt mode by key input, the HALT instruction is specified as “HALT 0001B”. With the key input specified as the halt release condition, the halt mode is released when a high-level signal is input to any one of the P1A0, P1A1, P1A2/AD0, and P1A3/AD1 pin. However, halt mode cannot be released by a pin disconnected to the pull-down resistor. (1) When using general-purpose output port as key source signal P1A3/AD1 Latch P1A2/AD0 P1A1 Switch A P1A0 General-purpose output port To use a general-purpose output port as the key source signal, make the output port high-level, and execute the “HALT 0001B” instruction. When an alternate switch is used at this time as switch A in the above figure, a high-level is always input to the P1A0 pin while switch A is closed, and the halt mode is immediately released. Therefore, care must be exercised when key input is specified as the halt mode releasing condition and an alternate switch is used. (2) To release halt by other microcontroller Output port P1A3/AD1 Latch P1A2/AD0 Microcontroller, etc. P1A1 P1A0 General-purpose output port The P1A0, P1A1, P1A2/AD0, and P1A3/AD1 pins can also be used as general-purpose input ports with pulldown resistor. Therefore, other microcontrollers can also be used as shown above after the halt mode has been released. 171 µPD17072,17073 19.2.5 Releasing halt status with basic timer 0 To release the halt condition by using the basic timer 0, use the “HALT 0010B” instruction. When it has been set that the halt status is to be released by the basic timer 0, the basic timer 0 carry FF is set to 1, and at the same time, the halt status is released. The basic timer 0 carry FF corresponds to the BTM0CY flag on a one-to-one basis and is set at fixed time intervals (125 ms). Therefore, the halt status can be released at specific time intervals. Example To release halt status every 125 ms and perform processing A every 1 second M1 MEM 0.10H ; 1-second counter HLTTMR DAT 0010B ; Symbol definition HALT HLTTMR ; Specifies that halt status is released by basic LOOP: timer 0 carry FF, and sets halt status BANK1 SKT1 BTM0CY ; Embedded macro BR LOOP ; Branches to LOOP if BTM0CY flag is not set M1, #0010B ; Adds 0010B to contents of M1 BANK0 ADD SKT1 CY ; Embedded macro BR LOOP ; Executes processing A if carry occurs Processing A BR 172 LOOP µPD17072,17073 19.2.6 Releasing halt status by interrupt To release the halt status by interrupt, use the “HALT 1000B” instruction. There are three interrupt sources available as explained in 11. INTERRUPT. Therefore, the interrupt by which the halt status is to be released must be specified by software. The halt status is released if the following conditions (1) through (3) are satisfied: (1) The “HALT 1000B” instruction is set. (2) Each interrupt is enabled by the corresponding interrupt enable flag (IP××× flag = 1). (3) An interrupt request is issued by the corresponding interrupt request flag (IRQ××× flag = 1). Depending on whether the EI or DI instruction is executed at this time, the operation to be performed after the halt status has been released differs. If the EI instruction is executed, the program branches to the vector address of the interrupt. If the RETI instruction is executed after the interrupt has been serviced, the program returns to the next instruction after the HALT instruction. If the DI instruction is executed, the program does not branch to a vector address, but the next instruction next after the HALT instruction is executed as soon as the halt status has been released. Examples of programs when the EI and DI instruction are executed, and notes on releasing the halt status by interrupt are described below. 173 µPD17072,17073 Example 1. Example of program when EI instruction is executed HLTINT DAT 1000B ; Symbol definition for halt mode INTTM DAT 0002H ; Defines symbol of interrupt vector address INTPIN DAT 0003H ; Defines symbol of interrupt vector address BR MAIN START: ORG INTTM BR ORG ; Program address 0000H ; Basic timer 1 interrupt vector address INTTIMER INTPIN ; Interrupt service by INT pin Processing A BR EI_RETI INTTIMER: ; Interrupt service by basic timer 1 Processing B EI_RETI: EI RETI MAIN: BANK1 SET2 IPBTM, IP ; Embedded macro SET1 BTM1CK ; Sets time interval of basic timer 1 to 8 ms LOOP: Processing C EI HALT ; Main routine processing ; Enables all interrupts HLTINT ; Sets releasing halt mode by interrupt ; <1> BR LOOP In this example, the halt mode is released when an interrupt by basic timer 1 has been accepted, processing B is executed, and processing A is executed when an interrupt by INT pin has been accepted. Each time the halt mode is released, processing C is executed. If the interrupt request by INT pin and interrupt request by basic timer 1 are issued exactly at the same time in the halt mode, processing A of INT pin, which is assigned the higher hardware priority, is executed. When “RETI” is executed after execution of processing A, the execution is returned to the “BR LOOP” instruction in <1>. However, the “BR LOOP” instruction is not executed, but the basic timer 1 interrupt is accepted immediately, and processing B is executed. If the “RETI” instruction is executed after processing B, the “BR LOOP” instruction is executed. 174 µPD17072,17073 Example 2. Example of program when DI instruction is executed HLTINT DAT 1000B ; Symbol definition of halt condition START: DI ; Disables all interrupts BANK1 SET2 IPBTM1, IP ; Embedded macro SET1 BTM1CK ; Sets time of interrupt by basic timer 1 to 8 ms HALT HLTINT ; Sets releasing halt status by interrupt SKT1 IRQ ; Detects halt release trigger BR INTBTM1 CLR1 IRQ LOOP: Processing A ; ; Interrupt service by INT pin INTBTM1: SKT1 IRQBTM1 BR LOOP CLR1 IRQBTM1 Processing B BR ; Detects halt release trigger ; ; Interrupt service by basic timer 1 LOOP Because the DI instruction is executed in the above example, the program does not branch to the respective vector addresses but executes the next instruction even if interrupt by basic timer 1 or INT pin is accepted. 175 µPD17072,17073 Caution When executing the HALT instruction that is released when an interrupt request flag (IRQ×××), for which the corresponding interrupt enable flag (IP×××) is set, is set, describe a NOP instruction immediately before the HALT instruction. When the NOP instruction is described immediately before the HALT instruction, time of one instruction is generated between the IRQ××× manipulation instruction and HALT instruction. In the case of the CLR1 IRQ××× instruction, for example, clearing IRQ××× correctly is reflected upon the HALT instruction (Example 1 below). If the NOP instruction is not described immediately before the HALT instruction, the CRL1 IRQ××× instruction is not correctly reflected on the HALT instruction, and the HALT mode is not set (Example 2). ... ... ... Examples 1. To execute HALT instruction correctly CLR1 ; Sets IRQ××× IRQ××× NOP ; NOP instruction is described immediately before HALT instruction ; (Clearing IRQ××× is correctly reflected on HALT instruction) 1000B ; HALT instruction is executed correctly (HALT mode is set) ... ... HALT ... ... ... 2. Program that does not set HALT mode ; Sets IRQ××× CLR1 IRQ××× ; Clearing IRQ××× is not reflected on HALT instruction HALT 1000B ... ... ; (It is reflected on instruction next to HALT instruction) 176 ; HALT instruction is ignored (HALT mode is not set) µPD17072,17073 19.2.7 When two or more release conditions are specified When two or more halt release conditions are specified, the halt mode is released if any one of the specified conditions is satisfied. The following example shows how the condition is identified when two or more conditions are specified: Example HLTINT DAT 1000B HLTTMR DAT 0010B HLTKEY DAT 0001B INTPIN DAT 0003H BR MAIN ; Vector address symbol definition of INT pin interrupt ; INT pin interrupt service ; Basic timer 0 processing ; Key input processing START: ORG INTPIN Processing A EI RETI TMRUP: Processing B RET KEYDEC: Processing C RET MAIN: BANK1 MOV P1B, #1111B ; Outputs P1B3-P1B0 at high level as key source output SET1 IP ; Embedded macro ; Enables INT pin interrupt EI LOOP: HALT HLTINT OR HLTTMR OR HLTKEY SKT1 BTM0CY BR KEY_DEC CALL TMRUP BR LOOP ; Specifies external interrupt (INT pin), basic timer 0, ; and key input as halt release condition ; Embedded macro ; Detects BTM0CY flag ; Basic timer 0 processing if set to “1” KEYDEC: Key processing BR LOOP 177 µPD17072,17073 19.3 Clock Stop Function The clock stop function stops the 75 kHz crystal resonator when the “STOP s” instruction (clock stop status) is executed. Therefore, the current dissipation of the device is reduced to 3 µA maximum (TA = 25 °C, VDD = 3.0 V). As the operand “s” of the “STOP s” instruction, “0000B” is specified. The “STOP s” instruction is valid only when the CE pin is at the low level, and is executed as a no-operation (“NOP”) instruction when the CE is at the high level. Therefore, the “STOP s” instruction must be executed when the CE pin is at the low level. The clock stop mode can be released by CE reset rising the CE pin, or by power-ON reset with supply voltage VDD application. 19.3.1 Clock stop status In the clock stop status, the crystal resonator is stopped. As a result, the CPU and all the peripheral hardware stop their operations. For the operations of the CPU and peripheral hardware, refer to 19.4 Device Operations in Halt and Clock Stop Statuses. 19.3.2 Releasing clock stop status The clock stop status can be released in the following two ways. After the clock stop status has been released, the program is started from address 0000H, regardless of which of (1) and (2) has been used to release the clock stop status. (1) Raise the CE pin from low to high (CE reset). (2) Lower the supply voltage VDD of the device to 1.8 V or lessNote, and then raise it again to 1.8 V or higher (TA = –20 to +70 °C, normal operation) (power-ON reset). Note This voltage is called power-ON clear voltage. The maximum value of the power-ON clear voltage is 1.8 V, and the actual value is in a range not exceeding this maximum value. For details, refer to 20.4.1 Power-ON clear voltage. 19.3.3 Releasing clock stop status by CE reset Figure 19-3 illustrates how the clock stop status is released by the CE reset. 178 µPD17072,17073 Figure 19-3. Releasing Clock Stop by CE Reset 3V VDD 0V H CE pin L H XOUT pin L 125 ms or more STOP s instruction 3V Program starts from address 0 (CE reset) If the clock stop instruction is not used, the operation is performed as follows: VDD 0V H CE pin L H XOUT pin L 0-tSET Program starts from address 0 (CE reset) CE reset is effected in synchronization with next setting of basic timer 0 carry FF after CE pin goes high 19.3.4 Releasing clock stop status by power-ON reset Figure 19-4 illustrates how the clock stop status is released by power-ON reset. When the clock stop status is released by power-ON reset, the power failure detection circuit operates. Figure 19-4. Releasing Clock Stop by Power-ON Reset 3V 1.8 VNote VDD 0V H CE pin L H XOUT pin L 125 ms or more STOP s instruction 3V VDD Program starts from address 0 (power-ON reset) If the clock stop instruction is not used, the operation is performed as follows: 1.8 VNote 0V H CE pin L H XOUT pin L 125 ms or more Oscillation stops Note Program starts from address 0 (power-ON reset) This voltage is called power-ON clear voltage. The maximum value of the power-ON clear voltage is 1.8 V, and the actual value is in a range not exceeding this maximum value. For details, refer to 20.4.1 PowerON clear voltage. 179 µPD17072,17073 19.3.5 Notes on using clock stop instruction The clock stop instruction (“STOP s”) is valid only when the CE pin is at the low level. Therefore, it is necessary to design program taking into consideration the chance that the “STOP s” instruction is to be executed when the CE pin happens to be at the high level. Here is an example: Example XTAL DAT 0000B ; Symbol definition of clock stop condition CEJDG: ; <1> SKF1 CE BR MAIN ; Embedded macro ; Detects input level of CE pin ; Branches to main processing ; if CE = high level Processing A ; Processing when CE = low ; <2> STOP XTAL ; Clock stops ; <3> BR $-1 MAIN: Main processing BR CEJDG In this program example, the status of the CE pin is detected in <1>. If it is at the low level, the clock stop instruction “STOP XTAL” in <2> is executed after processing A has been performed. However, if the CE pin goes high while the “STOP XTAL” instruction is executed as shown below, the instruction is treated as a no-operation (“NOP”) instruction. At this time, assuming that the branch instruction “BR $-1” in <3> is missing, the program execution enters the main processing, and malfunctioning may take place. Therefore, either insert the branch instruction as shown in <3>, or the program must be designed so that malfunctioning does not take place even after the execution enters the main processing. If the CE pin is at high level when the “STOP XTAL” instruction is executed, CE reset is effected when the basic timer 0 carry FF is set next time. 3V VDD 0V H CE pin L Main processing Processing A <1> <1> <1> <2> STOP XTAL Treated as "NOP" CE pin is detected because CE pin is high 180 Program starts from address 0 in synchronization with setting of basic timer 0 carry FF (CE reset) µPD17072,17073 19.4 Device Operations in Halt and Clock Stop Statuses Table 19-1 shows the operations of the CPU and peripheral hardware in the halt and clock stop statuses. In the halt status, all the peripheral hardware continue the normal operation, except that instruction execution is stopped. In the clock stop status, all peripheral hardware stop. The peripheral control register that controls the operating status of the peripheral hardware operates normally (not initialized) in the halt status, but is initialized to a specified value in the clock stop status (when the “STOP s” instruction is executed). Each peripheral hardware continues the operation set in the peripheral control register in the halt status, and its operation status is determined by the initialized value of the peripheral control register in the clock stop status. For the value to which the peripheral control register is to be initialized, refer to chapter Table 8-1. Peripheral Hardware Functions of Peripheral Control Register. Here is an example: Example When P1C0/SO0 pin of port 1C is specified as output port pin, and P0B3/SI/SO1 pin and P0B2/SCK pins are used for serial interface HLTINT DAT 1000B XTAL DAT 0000B INITFLG P0BBIO3,P0BBIO2 ;<1> SET3 P0B3, P0B2 ;<2> BANK1 CLR1 IRQSIO INITFLG SIOCK1, SIOCK0 INITFLG SIOSEL, NOT SIOHIZ SET1 IPSIO EI ;<3> SET1 SIOTS ;<4> HALT HLTINT ;<5> STOP XTAL In the above example, the P0B3, P0B2 pins output high level in <1> , the condition of serial interface is set in <2> , and serial communication is started in <3>. When the “HALT” instruction is executed in <4>, the halt status is set, but the serial communication continues, and the halt status is released when the interrupt by the serial interface is accepted. If the “STOP” instruction in <5> is executed instead of the “HALT” instruction in <4>, the contents of all the peripheral control registers set in <1>, <2>, and <3> are initialized. Consequently, serial communication is stopped, and all the pins of the port 0B are set in the general-purpose input port mode. 181 µPD17072,17073 Table 19-1. Device Operations in Halt and Clock Stop Statuses Status Hardware peripheral CE pin = high level In halt status In clock stop status CE pin = low level In halt status In clock stop status Program counter Stops at address before HALT instruction Stops at address before HALT instruction Initialized to 0000H and stops System register Retained Retained InitializedNote Peripheral register Retained Retained Retained Timer Normal operation Normal operation Stops PLL frequency synthesizer Normal operation Disabled Stops A/D converter Normal operation Normal operation Stops Normal operation Stops STOP instruction is invalid (“NOP”) BEEP Normal operation Serial interface Normal operation Normal operation Stops Frequency counter Normal operation Normal operation Stops LCD controller/driver Normal operation Normal operation Stops General-purpose I/O port Normal operation Normal operation Input port General-purpose input port Normal operation Normal operation Input port General-purpose output port Normal operation Normal operation Retained Note For the value to which these registers are initialized, refer to 4. DATA MEMORY (RAM), 5. SYSTEM REGISTER (SYSREG) and 8. PERIPHERAL CONTROL REGISTER. 19.5 Note on Processing of Each Pin in Halt and Clock Stop Statuses The halt status is used to reduce the current consumption of the device when, for example, only the watch is to be operated. The clock stop status is used to reduce the current consumption of the device to retain only the contents of the data memory. Therefore, the current consumption must be minimized in the halt and clock stop status. The current consumption may increase depending on the status of each pin and therefore, the points listed in Table 19-2 must be observed. 182 µPD17072,17073 Table 19-2. Pin Status in Halt and Clock Stop Statuses and Notes (1/2) Pin status and note on processing Pin function Pin symbol Port 0B P0B3/SI/SO1 P0B2/SCK P0B1 P0B0 Generalpurpose I/O port Port 0C P0C1 P0C0 Port 0D P0D3/FMIFC/AMIFC P0D2/AMIFC Generalpurpose input port Port 1A P1A3/AD1 P1A2/AD0 P1A1 P1A0 Port 0A P0A3 | P0A0 Generalpurpose output port Port 1B P1B3 | P1B0 Halt status Clock stop status Hold status immediately before halt status. All pins are specified as general-purpose input port pins. At this time, all input ports except port 1A (P1A3/AD1, P1A2/AD0, P1A1, P1A0) do not increase current consumption by noise, even if they are floated. (1) When specified as output pins Current consumption increases if any of these pins is externally pulled down while it outputs high level, or externally pulled up when it outputs low level. (2) When specified as input pins (Except P1A3/AD1, P1A2/AD0, P1A1, P1A0) Current consumption by noise does not increase if any of these pins is floated. (3) Port 1A (P1A3/AD1, P1A2/AD0, P1A1, P1A0) Current consumption increases if these pins externally pulled up when they selected pull-down resistors ON by program. When pull-down resistor OFF is selected, these pins are floated and current consumption by noise increases. (4) P0D3/FMIFC/AMIFC, P0D2/AMIFC When P0D3/FMIFC/AMIFC, P0D2/ AMIFC pins are used for frequency counter, current consumption increases because internal amplifier operates. Initialize frequency counter by program as necessary because it is not automatically disabled even when CE pin is low. Port 1A (P1A3/AD1, P1A2/AD0, P1A1, P1A0) is retained the status before clock stop. (1) When pull-down resistor ON is selected by program: Current consumption increases if these pins externally pulled up. (2) When pull-down resistor OFF is selected by program: These pins are floated and current consumption by noise increases. These ports are specified as generalpurpose output ports. The output contents are retained as is. Therefore, current consumption increases if these ports are externally pulled down while they output high level, or pulled up while they output low level. Port 1C P1C0/SO0 Interrupt INT Current consumption increases by external noise if this pin is floated. CE reset CE Current consumption increases by external noise if this pin is floated. 183 µPD17072,17073 Table 19-2. Pin Status in Halt and Clock Stop Statuses and Notes (2/2) Pin status and note on processing Pin function Pin symbol Halt status Clock stop status LCD segment LCD14 | LCD0 When these pins are used as general-purpose output port pins, the same points as those of the general-purpose output port described above must be observed. All pins are specified as LCD segment signal output pins and output low levels (display off). PLL frequency synthesizer VCOL VCOH EO Current consumption increases when PLL operates. When PLL is disabled, VCOL, VCOH : floated EO : floated When CE pin goes low, PLL is automatically disabled. PLL is disabled. Each pin is as follows: VCOL, VCOH : floated EO : floated Crystal oscillator circuit XIN XOUT Current consumption changes with waveform oscillated by crystal oscillator circuit. The greater the oscillation amplitude, the lower the current consumption. Oscillation amplitude is varied depending on crystal resonator and load capacitor, and therefore must be evaluated. XIN pin is internally pulled down and XOUT pin outputs high level 184 µPD17072,17073 19.6 Device Control Function by CE Pin The CE pin has the following functions by using the input level and rising edge of a signal input from an external source: (1) PLL frequency synthesizer (2) Making clock stop instruction valid or invalid (3) Resets device 19.6.1 Controlling operation of PLL frequency synthesizer The PLL frequency synthesizer can operate only when the CE pin is high. When the CE pin is low, PLL is automatically disabled. When PLL is disabled, the VCOH and VCOL pins are floated, and the EO pin is also floated. The PLL frequency synthesizer can also be disabled through program even when the CE pin is high. 19.6.2 Making clock stop instruction valid or invalid The clock stop instruction (“STOP s”) is valid only when the CE pin is low. The clock stop instruction executed when the CE pin is high is treated as an NOP (no operation) instruction. 19.6.3 Resetting device The device can be reset by raising the CE pin (CE reset). The device can also be reset by turning off supply voltage VDD (power-ON reset). For details, refer to 20. RESET. 185 µPD17072,17073 19.6.4 Inputting signal to CE pin The CE pin does not accept a low- or high-level signal less than 200 µs in order to protect the system from malfunctioning due to noise. The level of the signal input to the CE pin can be detected by using the CE flag of the CE pin status detection. Figure 19-5 shows the relations between the input signal and CE flag. Figure 19-5. Relations between Signal Input to CE Pin and CE Flag H L 1 CE flag 0 CE pin 200 µ s less than 200 µ s 200 µ s less than 200 µ s PLL enabled STOP s invalid (NOP) CE reset PLL disabled STOP s valid PLL disabled STOP s invalid (NOP) CE reset is effected in synchronization with next setting of basic timer 0 carry FF 19.6.5 Configuration and functions of CE pin status detection register The CE pin status detection register detects the level of the signal input to the CE pin. The configuration and functions of this register are illustrated below. Figure 19-6. Configuration of CE Pin Status Detection Register Flag symbol Name CE pin status detection register Address b3 b2 b1 b0 0 0 0 C E (BANK1) 52H Read/ Write R Detects status of CE pin 0 Low level 1 High level Fixed to "0" Power-ON At reset 0 0 0 _ Clock stop _ CE _ Remark –: Determined by status of pin The CE flag does not change even if a low or high level signal less than 200 µs is input. 186 µPD17072,17073 19.7 Low-Speed Mode Function The µPD17073 can slow down the CPU clock when “1” is written to the SYSCK flag of the system clock select register. This function is called a low-speed mode function. The time required to execute one instruction in the low-speed mode is 106.6 µs. However, the instruction that is executed immediately after the SYSCK flag has been set to “1” takes 103.3 µs. By slowing down the CPU clock, the current consumption of the device can be lowered as compared with that during normal operation. Figure 19-7 shows the configuration and function of the system clock select register. Figure 19-7. Configuration of System Clock Select Register Flag symbol Read/ Address Name b3 b2 b1 b0 Write S Y System clock select (BANK1) 0 0 0 S R/W 55H register C K Selects system clock (one instruction execution time) 0 53.3 µ s 1 106.6 µ s Fixed to “0” Power-ON 0 0 At Clock stop reset CE 0 0 R R Remark R: Retained 19.7.1 Releasing low-speed mode The low-speed mode is released when the SYSCK flag is reset to “0” by power-ON reset, or when “0” is written to the SYSCK flag. After the low-speed mode has been released, the CPU clock returns to the normal operation speed (one instruction execution time: 53.3 µs). However, the instruction that is executed immediately after the SYSCK flag has been reset to “0” takes 56.6 µs. 187 µPD17072,17073 20. RESET The reset function is to initialize the device operation. 20.1 Configuration of Reset Block Figure 20-1 shows the configuration of the reset block. The device can be reset in two ways: by means of power-ON reset (or VDD reset) that is effected by applying supply voltage VDD, and CE reset that is effected by using the CE pin. The power-ON reset block consists of a voltage detector circuit that detects the voltage input to the VDD pin, a power failure detector circuit, and a reset control circuit. The CE reset block consists of a circuit that detects the rising of the signal input to the CE pin, and a reset control circuit. Figure 20-1. Configuration of Reset Block XOUT Power failure detector block Timer FF block XIN Divider BTM0CY flag read STOP s instruction R S Basic timer 0 carry Q Basic timer 0 carry disable FF Reset signal VDD Voltage detector circuit CE Rising detector circuit Power-ON clear signal (POC) Reset control circuit Forced halt by basic timer 0 carry RES Peripheral control register, system register, stack, program counter RESET STOP instruction 188 IRES µPD17072,17073 20.2 Reset Function The power-ON reset is effected when supply voltage VDD has risen from a specific level, and the CE reset is effected when the CE pin goes high from low. The power-ON reset is to initialize the program counter, stack, system register, basic timer 0 carry FF and control register, and execute the program from address 0000H. The CE reset is to initialize part of the program counter, stack, system register, and peripheral control register, and execute the program from address 0000H. The main differences between the power-ON reset and CE reset are the contents of the peripheral control register to be initialized, and the operation of the power failure detector circuit, which is to be described in 20.6. The power-ON reset and CE reset are controlled by the reset signals IRES, RES, and RESET that are output from the reset control circuit shown in Figure 20-1. Table 20-1 shows the relations among the IRES, RES, and RESET signals, power-ON reset, and CE reset. The reset control circuit also operates when the clock stop instruction (STOP s) described in 19. STANDBY has been executed. The following 20.3 and 20.4 respectively describe the CE reset and power-ON reset. 20.5 describes the relations between the CE reset and power-ON reset. Table 20-1. Relations between Internal Reset Signal and Each Reset Output signal Internal reset signal At CE reset At powerON reset At clock stop Contents controlled by each reset signal IRES × Forcibly sets device in halt status, which is released by setting basic timer 0 carry FF. RES × Initializes part of peripheral control register RESET Initializes part of program counter, stack, system register, and peripheral control register. 189 µPD17072,17073 20.3 CE Reset The CE reset is effected by making the CE pin high. When the CE pin goes high, the RESET signal is output in synchronization with the rising edge of the next basic timer 0 carry FF setting pulse, and the device is reset. When the CE reset has been effected, part of the program counter, stack, system register, and peripheral control register is initialized to an initial value by the RESET signal, and the program is executed from address 0000H. For the initial value, refer to the description of each register.The operation of the CE reset differs depending on whether the clock stop mode is used or not. This is described in 20.3.1 and 20.3.2. 20.3.3 describes the points to be noted when effecting the CE reset. 20.3.1 CE reset when clock stop mode (STOP s instruction) is not used Figure 20-2 shows the operation. When the clock stop mode (STOP s instruction) is not used, and after the CE pin has gone high, therefore, the RESET signal is output at the rising edge of the basic timer 0 carry FF setting pulse selected at that time (tSET = 125 ms), and reset is effected. Figure 20-2. CE Reset Operation When Clock Stop Mode Is Not Used 5V VDD 0V H CE L H XOUT L Basic timer 0 carry H FF setting pulse L H IRES Reset signals L H RES L H RESET L Normal operation Normal operation CE reset is effected at rising edge of basic timer 0 carry FF setting pulse. If basic timer 0 carry FF setting time tSET = 125 ms, 0 < t < 125 ms during this period because of the rising timing of the CE pin. During this period, the program continues operation. 190 µPD17072,17073 20.3.2 CE reset when clock stop mode (STOP s instruction) is used Figure 22-3 shows the operation. When the clock stop mode is used, the IRES, RES, and RESET signals are output at the point where the “STOP s” instruction has been executed. While the CE pin is low, output of the IRES signal continues; therefore, the forced halt status, which is released by the basic timer 0 carry, is set. However, the device stops operation because the clock is stopped. When the CE pin goes high, the clock stop mode is released and oscillation is started. At this time, the halt status that is released by the basic timer 0 carry FF is set by the IRES signal. After the CE pin has risen, the oscillation stabilization status lasts (for 125 ms or longer). If the basic timer 0 carry FF setting pulse rises after that, the halt status is released, and program execution is started from address 0. Figure 20-3. CE Reset Operation When Clock Stop Mode Is Used 3V VDD 0V H CE L H XOUT L Basic timer 0 carry H FF setting pulse L H IRES Reset signals L H RES L H RESET L Normal operation Clock stop status Halt status 125 ms or more STOP 0000B instruction Clock stop released. Oscillation starts. CE reset Program starts from address 0. 20.3.3 Notes on CE reset Because CE reset is effected regardless of the instruction under execution, the following points (1) and (2) must be noted. (1) Time for executing timer processing such as watch To create a watch program by using the basic timer 0 or basic timer 1, the processing of the program must be completed within specific time. For details, refer to 12.2.5 Notes on using basic timer 0 and 12.3.4 Notes on using basic timer 1. (2) Processing of data or flag used in program Exercise care in rewriting data or flags that cannot be processed with one instruction and whose contents must not be changed even if CE reset is effected, such as security code. Here is an example: 191 µPD17072,17073 Example 1. R1 MEM 0.01H ; 1st digit of input data of security code R2 MEM 0.02H ; 2nd digit of input data of security code R3 MEM 0.03H ; Data of 1st digit when security code is changed R4 MEM 0.04H ; Data of 2nd digit when security code is changed M1 MEM 0.11H ; 1st digit of current security code M2 MEM 0.12H ; 2nd digit of current security code START: Key input processing ; Waits for key input of R1 ← Key A contents ; security code R2 ← Key B contents SET2 CMP, Z SUB R1, M1 SUB R2, M2 SKT1 Z BR ERROR ; Substitutes contents of pressed code into R1 and R2 ; <1> ; Compares security code with input data ; Input data is different from security code MAIN: Key input processing ; Security code rewriting mode R3 ← Key C contents ; Substitutes contents of R4 ← Key D contents ; pressed key into R3 and R4 ST M1, R3 ; <2> ST M2, R4 ; <3> BR MAIN ; Rewrites security code ERROR: Does not operate Suppose the security code is “12H” in this example. Then the contents of the data memory addresses M1 and M2 are “1H” and “2H”, respectively. When the CE reset is effected at this time, the contents of the key input in <1> are compared with the security code “12H”, and if they are the same, the ordinary processing is performed. When the security code is changed by the main processing, the new code is rewritten to M1 and M2 in <2> and <3>. Suppose the security code is changed to “34H”. Then “3H” and “4H” are written to M1 and M2 in <2> and <3>. However, if the CE reset happens to occur when <2> has been executed, the program is started from address 0000H without <3> executed. Consequently, the security code is changed to “32H”, which is not intended, and security cannot be released. In this case, use the program shown in Example 2. 192 µPD17072,17073 Example 2. R1 MEM 0.01H ; 1st digit of input data of security code R2 MEM 0.02H ; 2nd digit of input data of security code R3 MEM 0.03H ; Data of 1st digit when security code is changed R4 MEM 0.04H ; Data of 2nd digit when security code is changed M1 MEM 0.11H ; 1st digit of current security code M2 MEM 0.12H ; 2nd digit of current security code CHANGE FLG 0.13H.0 ; “1” while security code is changed START: Key input processing ; Waits for key input of R1 ← Key A contents ; security code R2 ← Key B contents SKT1 CHANGE BR SECURITY_CHK ST M1, R3 ST M2, R4 CLR1 CHANGE ; Substitutes contents of pressed code into R1 and R2 ; <4> ; If CHANGE flag is 1, ; rewrites M1 and M2 SECURITY_CHK: SET2 CMP, Z SUB R1, M1 SUB R2, M2 SKT1 Z BR ERROR ; <1> ; Compares security code with input data ; Input data is different from security code MAIN: Key input processing ; Security code rewriting mode R3 ← Key C contents ; Substitutes contents of R4 ← Key D contents ; pressed key into R3 and R4 SET1 CHANGE ; <5> ; Set CHANGE to “1” while security code is rewritten ST M1, R3 ; <2> ; Rewrites security code ST M2, R4 ; <3> CLR1 CHANGE BR MAIN ; Sets CHANGE flag to “0” after security code is rewritten ERROR: Does not operate In this example, the CHANGE flag is set to “1” in <5> before the security code is rewritten in <2> and <3>. Therefore, the security code is written again in <4> even if the CE reset is effected in <3>. 193 µPD17072,17073 20.4 Power-ON Reset Power-ON reset is effected by raising the supply voltage VDD of the device from a specific level (called power-ON clear voltage). Power-ON clear voltage is described in 20.4.1. If the supply voltage VDD is lower than the power-ON clear voltage, a power-ON clear signal (POC) is detected from the voltage detector circuit shown in Figure 20-1. When the power-ON clear signal is output, the crystal oscillator circuit is stopped, and the device stops operation. While the power-ON clear signal is output, the IRES, RES, and RESET signals are output. When the supply voltage VDD exceeds the power-ON clear voltage, the power-ON clear signal is turned off, the crystal oscillator starts, and the IRES, RES, and RESET signals are also turned off. At this time, the halt status that is released by the basic timer 0 carry FF is set by the IRES signal. After the powerON clear signal is deasserted, the oscillation stabilization status lasts (for 125 ms or longer). If the basic timer 0 carry FF setting pulse rises after that, the halt status is released, and power-ON reset is effected. This operation is illustrated in Figure 20-4. At power-ON reset, the program counter, stack, system register, and peripheral control register are initialized as soon as the power-ON clear signal has been output. For the power-ON reset while the CPU is operating, refer to 20.4.2. For the power-ON reset in the clock stop status, refer to 20.4.3. For the power-ON reset when supply voltage VDD rises from 0 V, refer to 20.4.4. Figure 20-4. Operation of Power-ON Reset 3V Power-ON clear voltage VDD 0V H CE L H XOUT L Basic timer 0 carry H FF setting pulse Power-ON clear signal L H L H IRES Reset signals L H RES L H RESET L Normal operation Device operation stops Halt status 125 ms or more Power-ON clear released. Power-ON reset Oscillation starts. Program starts from address 0. 194 µPD17072,17073 20.4.1 Power-ON clear voltage The power-ON clear voltage differs as follows, depending on the CPU operating temperature range and operating conditions: TA = 0 to +70 °C : 1.6 V MAX. (when CPU is operating and PLL frequency synthesizer and A/D converter stop) TA = –10 to +70 °C : 1.7 V MAX. (when CPU is operating and PLL frequency synthesizer and A/D converter stop) TA = –20 to +70 °C : 1.8 V MAX. (when CPU, PLL frequency synthesizer, and A/D converter are operating) The above values are the maximum values, and the actual power-ON clear voltage must be in a range that does not exceed these maximum values. The power-ON clear voltage during the CPU operation is the same as that in the clock stop status. In the description below, the power-ON clear voltage is assumed to be 1.8 V. 20.4.2 Power-ON reset during normal operation Figure 20-5 (a) shows the operation. As shown in this figure, the power-ON clear signal is output regardless of the input level of the CE pin when the supply voltage VDD drops below 1.8 V (TA = –20 to +70 °C, when CPU, PLL, A/D are operating), and the device operation is stopped. When the supply voltage VDD rises beyond 1.8 V again, the program starts from address 0000H after a halt status of 125 ms or more. The CPU operation includes when the clock stop instruction is not used, and power-ON clear voltage is 1.8 V during halt status set by the halt instruction. 20.4.3 Power-ON reset in clock stop mode Figure 20-5 (b) shows the operation. As shown in this figure, the power-ON clear signal is output and the device operation is stopped when the supply voltage VDD drops below 1.7 V (TA = –20 to +70 °C, when CPU, PLL, A/D are operating). However, because the clock stop mode is set, the operation of the device seems not to be changed. When the supply voltage VDD rises beyond 1.8 V, the program starts from address 0000H after a halt of 125 ms or more. 20.4.4 Power-ON reset when supply voltage VDD rises from 0 V Figure 20-5 (c) shows the operation. As shown in this figure, the power-ON clear signal is output until the supply voltage VDD rises from 0 V to 1.8 V (TA = –20 to +70 °C, CPU, PLL, A/D are operating). When the supply voltage VDD exceeds the power-ON clear voltage, the crystal oscillator circuit starts operating, and the program starts from address 0000H after a halt of 125 ms or more. 195 µPD17072,17073 Figure 20-5. Power-ON Reset and Supply Voltage VDD (TA = –20 to +70 °C, when CPU, PLL, A/D are operating) (a) During CPU operation (including halt status) 3V Power-ON clear voltage 1.8 V VDD 0V H CE L H XOUT Power-ON clear signal L H L Normal operation Device operation stops Halt status 125 ms or more Power-ON clear released. Power-ON reset Oscillation starts. Program starts from address 0. (b) In clock stop mode 3V 1.8 V 1.7 V VDD Power-ON clear voltage 0V CE H L H XOUT Power-ON clear signal L H L Normal operation Clock stop STOP s instruction Device operation stops Halt status 125 ms or more Power-ON clear released. Power-ON reset Oscillation starts. Program starts from address 0. (c) When supply voltage VDD rises from 0 V 3V 1.8 V Power-ON clear voltage VDD 0V H CE XOUT L H L H Power-ON clear signal L Device operation stops Halt status 125 ms or more Power-ON clear released. Power-ON reset Oscillation starts. Program starts from address 0. 196 µPD17072,17073 20.5 Relations between CE Reset and Power-ON Reset There is a possibility that power-ON reset and CE reset are effected simultaneously when the supply voltage VDD is applied for the first time. The reset operations at this time are described in 20.5.1 through 20.5.3. 20.5.1 When VDD pin and CE pin rises simultaneously Figure 20-6 (a) shows the operation. At this time, the program starts from address 0000H because of power-ON reset. 20.5.2 When CE pin rises during forced halt status of power-ON reset Figure 20-6 (b) shows the operation. At this time, the program starts from address 0000H because of power-ON reset, in the same manner as 20.5.1 above. 20.5.3 When CE pin rises after power-ON reset Figure 20-6 (c) shows the operation. At this time, the program starts from address 0000H because of power-ON reset, and the program starts from address 0000H again at the rising edge of the next basic timer 0 carry FF setting signal because of CE reset. 197 µPD17072,17073 Figure 20-6. Relations between Power-ON Reset and CE Reset (TA = –20 to +70 °C, when CPU, PLL, A/D are operating) (a) When VDD and CE pins rises simultaneously 3V 1.8 V Power-ON clear voltage VDD 0V H CE L Basic timer 0 carry H FF setting pulse L Operation stops Halt status 125 ms or more Normal operation Power-ON reset Program starts. (b) When CE pin rises in halt status 3V 1.8 V Power-ON clear voltage VDD 0V H CE L Basic timer 0 carry FF setting pulse H L Operation stops Halt status 125 ms or more Normal operation Power-ON reset Program starts. (c) When CE pin rises after power-ON reset 3V 1.8 V Power-ON clear voltage VDD 0V H CE L Basic timer 0 carry FF setting pulse H L Operation stops Halt status 125 ms or more Normal operation Power-ON reset Program starts. 198 CE reset Program starts. µPD17072,17073 20.6 Power Failure Detection The power failure detection feature is used to judge, when the device has been reset, whether the reset has been effected by application of supply voltage VDD or by the CE pin. Because the contents of the data memory and output ports are “undefined” on power application, the contents of these are initialized by detecting a power failure. The power failure can be detected by detecting the BTM0CY flag by using a power failure detector circuit. Figure 20-7. Power Failure Detection Flowchart Program starts Power failure detected Not power failure Power failure Initializes data memory and output ports 20.6.1 Power Failure Detector Circuit The power failure detector circuit consists of a voltage detector circuit as shown in Figure 20-1, basic timer 0 carry disable flip-flop that is reset by the output (power-ON clear signal) of the voltage detector circuit, and basic timer 0 carry. The basic timer 0 carry disable FF is set to 1 by the power-ON clear signal, and reset to 0 when an instruction that reads the BTM0CY flag has been executed. While the basic timer 0 carry disable FF is set to 1, the BTM0CY flag is not set to 1. If the power-ON clear signal is output (at power-ON reset), therefore, the program is started with the BTM0CY flag cleared, and setting of the BTM0CY flag is inhibited until an instruction that reads the BTM0CY flag is executed later. Once the instruction that reads the BTM0CY flag has been executed, the BTM0CY flag is set each time the basic timer 0 carry FF setting pulse rises. Therefore, whether power-ON reset (power failure) or CE reset (not power failure) has been effected can be judged by checking the content of the BTM0CY flag, when the device has been reset. That is, if the BTM0CY flag is cleared to 0, power-ON reset has been effected; if the flag is set to 1, CE reset has been effected. The voltage at which a power failure can be detected is the same voltage at which power-ON reset is effected. Figure 20-8 illustrates the status transition of the BTM0CY flag. Figure 20-9 shows the timing chart of Figure 20-8 and the operation of the BTM0CY flag. 199 µPD17072,17073 Figure 20-8. Status Transition of BTM0CY Flag CE = low CE = don't care <1> CE = high VDD = low Operation stops VDD = L → 1.8 VNote <2> Crystal oscillation starts. Forced halt (125 ms or more) <3> Power-ON reset Setting BTM0CY flag inhibited CE = H CE = L <4> <5> Clock stop STOP 0 <7> <6> Normal operation CE = H→L Normal operation Clock stop <9> Crystal oscillation starts. Forced halt (125 ms or more) <11> SKT1 BTM0CY or SKF1 BTM0CY <13> STOP 0 Normal operation Rising of basic timer 0 carry FF setting pulse Normal operation. CE reset wait CE = L→H <12> CE reset <8> CE = L→H <10> SKT1 BTM0CY or SKF1 BTM0CY BTM0CY = 0 <14> CE = H→L <15> Normal operation BTM0CY = 1 CE reset <16> CE = L→H Setting BTM0CY flag enabled CE = L→H Normal operation. CE reset wait Rising of basic timer 0 carry FF setting pulse <17> Crystal oscillation starts. Forced halt (125 ms or more) Note 1.8 V is the maximum value and the actual power-ON clear voltage is in a range that does not exceed this maximum value. For details, refer to 20.4.1 Power-ON clear voltage. 200 µPD17072,17073 Figure 20-9. Operation of BTM0CY Flag (a) When BTM0CY flag is never detected (SKT1 BTM0CY or SKF1 BTM0CY is not executed) 3V VDD CE BTM0CY flag setting pulse BTM0CY 0V H L H L H L <1> Operation in Figure 20-8 <2> <6> <5> <3> <8> <6> <5> <4> <7> <9> <6> <1> <14> <1> <7> STOP 0000 B Timer time changed (b) To detect power failure with BTM0CY flag 3V VDD CE BTM0CY flag setting pulse BTM0CY 0V H L H L H L SKTI instruction <1> <2> <6> <14> <13> <16> <14> <13> <12> <17> Operation in Figure 20-8 <3> <11> <15> Timer time changed BTM0CY = 0 Power failure BTM0CY = 1 Not power failure <15> STOP 0000 B BTM0CY = 1 Not power failure 201 µPD17072,17073 20.6.2 Notes on power failure detection with BTM0CY flag Keep in mind the following points when using the BTM0CY flag for watch counting: (1) Updating watch When creating a watch program by using the basic timer 0, it is necessary to update the watch after a power failure has been detected. This is because watch counting is skipped once because the BTM0CY flag is read when a power failure has been detected, and thus the BTM0CY flag is cleared to 0. (2) Watch updating processing time To update the watch, its processing must be completed before the next basic timer 0 carry FF setting pule rises. This is because CE reset is effected without the watch updating processing completed if the CE pin goes high while the watch updating processing is in progress. For further information on (1) and (2) above, refer to 12.2.5 (3) Adjusting basic timer 0 at CE reset. To perform power failure processing, the following points must be noted. (3) Power failure detection timing Watch counting with the BTM0CY flag must be completed before the next basic timer 0 carry FF setting pulse rises after the BTM0CY flag for power failure detection has been read and the program has been started from address 0000H. This is because, the basic timer 0 carry FF setting time is 125 ms, and if power failure detection is performed 126 ms after the program has been started, the BTM0CY flag is not detected once. For details, refer to 12.2.5 (3) Adjusting basic timer 0 at CE reset. Moreover, power failure detection and initial processing must be completed within the basic timer 0 carry FF setting time, as shown in the example on the next page. This is because, if he CE pin rises and CE reset is effected during power failure detection or initial processing, the processing is interrupted, resulting in troubles. To change the basic timer 0 carry FF setting time in the initial processing, one instruction must be used to change the setting time at the end of the initial processing. 202 µPD17072,17073 Example Program example START: ; Program address 0000H ;<1> Processing at reset ;<2> BANK1 SKT1 BTM0CY BR INITIAL ; Power failure detection BACKUP: ;<3> Watch updating BR MAIN INITIAL: ;<4> Initial processing MAIN: Main processing SKT1 BTM0CY BR MAIN Watch updating BR MAIN Operation example 3V VDD 0V 125 ms H CE L 125 ms BTM0CY flag setting pulse H L <1> <4> < 2 > Power failure detection <1> <3> < 2 > Power failure detection If total processing time of If total processing time of < 1 > + < 4 > is 125 ms or longer, CE reset < 1 > + < 3 > is too long, CE reset is effected. is effected in the middle of processing. CE reset CE reset 203 µPD17072,17073 21. µPD17012 INSTRUCTIONS 21.1 Instruction Set Outline b15 b14–b11 0 BIN. 1 HEX. 0 0 0 0 0 ADD r, m ADD m, #n4 0 0 0 1 1 SUB r, m SUB m, #n4 0 0 1 0 2 ADDC r, m ADDC m, #n4 0 0 1 1 3 SUBC r, m SUBC m, #n4 0 1 0 0 4 AND r, m AND m, #n4 0 1 0 1 5 XOR r, m XOR m, #n4 0 1 1 0 6 OR r, m OR m, #n4 INC MOVT BR CALL RET RETSK EI DI RETI PUSH POP GET PUT RORC STOP HALT NOP AR DBF, @AR @AR @AR 0 1 1 1 7 1 0 0 0 8 LD r, m ST m, r 1 0 0 1 9 SKE m, #n4 SKGE m, #n4 1 0 1 0 A MOV @r, m MOV m, @r 1 0 1 1 B SKNE m, #n4 SKLT m, #n4 1 1 0 0 C BR addr (page 0) CALL addr (page 0) 1 1 0 1 D BR addr (page 1) MOV m, #n4 1 1 1 0 E SKT m, #n 1 1 1 1 F SKF m, #n 204 AR AR DBF, p p, DBF r s h µPD17072,17073 21.2 Legend AR : Address register ASR : Address stack register indicated by stack pointer addr : Program memory address (lower 11 bits) BANK : Bank register CMP : Compare flag CY : Carry flag DBF : Data buffer h : Halt release condition INTEF : Interrupt enable flag INTR : Register automatically saved to stack when interrupt occurs INTSK : Interrupt stack register MP MPE : Data memory row address pointer : Memory pointer enable flag : Data memory address indicated by mR, mC m mR : Data memory row address (higher) mC : Data memory column address (lower) n : Bit position (4 bits) n4 : Immediate data (4 bits) PAGE : Page (bits 11 of program counter) PC : Program counter p : Peripheral address pH : Peripheral address (higher 3 bits) pL : Peripheral address (lower 4 bits) r : General register column address SP : Stack pointer s : Stop release condition (×) : Contents address by × 205 µPD17072,17073 21.3 Instruction List Instruction code Mnemonic Operand OP code Operand r, m (r) ← (r) + (m) 00000 mR mC r m, #n4 (m) ← (m) + n4 10000 mR mC n4 r, m (r) ← (r) + (m) + CY 00010 mR mC r m, #n4 (m) ← (m) + n4 + CY 10010 mR mC n4 AR AR ← AR + 1 00111 000 r, m (r) ← (r) – (m) 00001 mR mC r m, #n4 (m) ← (m) – n4 10001 mR mC n4 r, m (r) ← (r) – (m) – CY 00011 mR mC r m, #n4 (m) ← (m) – n4 – CY 10011 mR mC n4 r, m (r) ← (r) v (m) 00110 mR mC r m, #n4 (m) ← (m) v n4 10110 mR mC n4 r, m (r) ← (r) (m) 00100 mR mC r m, #n4 (m) ← (m) v 10100 mR mC n4 r, m (r) ← (r) v (m) 00101 mR mC r m, #n4 (m) ← (m) v n4 10101 mR mC n4 SKT m, #n CMP ← 0, if (m) v n = n, then skip 11110 mR mC n SKF m, #n CMP ← 0, if (m) v n = 0, then skip 11111 mR mC n SKE m, #n4 (m) –n4, skip if zero 01001 mR mC n4 SKNE m, #n4 (m) –n4, skip if not zero 01011 mR mC n4 SKGE m, #n4 (m) –n4, skip if not borrow 11001 mR mC n4 SKLT m, #n4 (m) –n4, skip if borrow 11011 mR mC n4 RORC r 00111 000 0111 r LD r, m (r) ← (m) 01000 mR mC r ST m, r (m) ← (r) 11000 mR mC r @r, m if MPE = 1: (MP, (r)) ← (m) if MPE = 0: (BANK, mR, (r)) ← (m) 01010 mR mC r m, @r if MPE = 1: (m) ← (MP, (r)) if MPE = 0: (m) ← (BANK, mR, (r)) 11010 mR mC r m, #n4 (m) ← n4 11101 mR mC n4 DBF, @AR SP ← SP –1, ASR ← PC, PC ← AR, DBF ← PC, PC ← ASR, SP ← SP + 1 00111 000 ADD Addition ADDC INC SUB Subtraction SUBC OR Logical operation Operation AND XOR Judgment v Instruction group n4 1001 0000 Compare CY → (r)b3 → (r)b2 → (r)b1 → (r)b0 Rotate Transfer MOV MOVT 206 0001 0000 µPD17072,17073 Instruction group Instruction code Mnemonic Operand OP code AR SP ← SP – 1, ASR ← AR 00111 000 1101 0000 POP AR AR ← ASR, SP ← SP + 1 00111 000 1100 0000 GET DBF, p DBF ← (p) 00111 pH 1011 pL PUT p, DBF (p) ← DBF 00111 pH 1010 pL PC10–0 ← addr, PAGE ← 0 01100 PC10–0 ← addr, PAGE ← 1 01101 @AR PC ← AR 00111 addr SP ← SP – 1, ASR ← PC, PC10–0 ← addr, PAGE ← 0 11100 @AR SP ← SP – 1, ASR ← PC, PC ← AR 00111 000 0101 0000 RET PC ← ASR, SP ← SP + 1 00111 000 1110 0000 RETSK PC ← ASR, SP ← SP + 1 and skip 00111 001 1110 0000 RETI PC ← ASR, INTR ← INTSK, SP ← SP + 1 00111 010 1110 0000 EI INTEF ← 1 00111 000 1111 0000 DI INTEF ← 0 00111 001 1111 0000 addr BR CALL Subroutine Interrupt Others Operand PUSH Transfer Branch Operation addr 000 0100 0000 addr STOP s STOP 00111 010 1111 s HALT h HALT 00111 011 1111 h No operation 00111 100 1111 0000 NOP 21.4 Assembler (AS17K) Embedded Macroinstructions Legend flag n : FLG type symbol < > : Item in < > can be omitted. Mnemonic Embedded Operand Operation n SKTn flag 1, ...flag n if (flag 1) to (flag n) = all “1“, then skip 1≤n≤4 SKFn flag 1, ...flag n if (flag 1) to (flag n) = all “0“, then skip 1≤n≤4 SETn flag 1, ...flag n (flag 1) to (flag n) ← 1 1≤n≤4 CLRn flag 1, ...flag n (flag 1) to (flag n) ← 0 1≤n≤4 NOTn flag 1, ...flag n if (flag n) = “0“, then (flag n) ← 1 if (flag n) = “1“, then (flag n) ← 0 1≤n≤4 INITFLG <NOT> flag 1, ... <<NOT> flag n> if description = NOT flag n, then (flag n) ← 0 if description = flag n, then (flag n) ← 1 1≤n≤4 macro 207 µPD17072,17073 22. µPD17073 RESERVED WORDS 22.1 Data Buffer (DBF) Symbol name Attribute Value R/W Description DBF3 MEM 0.0CH R/W Bits 15-12 of DBF DBF2 MEM 0.0DH R/W Bits 11-8 of DBF DBF1 MEM 0.0EH R/W Bits 7-4 of DBF DBF0 MEM 0.0FH R/W Bits 3-0 of DBF 22.2 System Register (SYSREG) Symbol name Attribute Value R/W Description AR3 MEM 0.74H R AR2 MEM 0.75H R/W Bits 11-8 of address register AR1 MEM 0.76H R/W Bits 7-4 of address register AR0 MEM 0.77H R/W Bits 3-0 of address register WR MEM 0.78H R BANK MEM 0.79H R/W IXH MEM 0.7AH R Index register, high MPH MEM 0.7AH R Memory pointer, high MPE FLG 0.7AH.3 R Memory pointer enable flag IXM MEM 0.7BH R Index register, middle MPL MEM 0.7BH R Memory pointer, low IXL MEM 0.7CH R Index register, low RPH MEM 0.7DH R General register pointer, high RPL MEM 0.7EH R/W General register pointer, low (only lower 1 bit is valid) PSW MEM 0.7FH R/W Program status word BCD FLG 0.7EH.0 R/W BCD operation flag CMP FLG 0.7FH.3 R/W Compare flag CY FLG 0.7FH.2 R/W Carry flag Z FLG 0.7FH.1 R/W Zero flag IXE FLG 0.7FH.0 R 208 Bits 15-12 of address register (fixed to “0”) Window register (fixed to “0”) Bank register (Only lower 1 bit is valid) Index enable flag (fixed to “0”) (fixed to “0”) µPD17072,17073 22.3 LCD Segment Register Symbol name Attribute Value R/W LCDD14 MEM 1.41H R/W LCDD13 MEM 1.42H R/W LCDD12 MEM 1.43H R/W LCDD11 MEM 1.44H R/W LCDD10 MEM 1.45H R/W LCDD9 MEM 1.46H R/W LCDD8 MEM 1.47H R/W LCDD7 MEM 1.48H R/W LCDD6 MEM 1.49H R/W LCDD5 MEM 1.4AH R/W LCDD4 MEM 1.4BH R/W LCDD3 MEM 1.4CH R/W LCDD2 MEM 1.4DH R/W LCDD1 MEM 1.4EH R/W LCDD0 MEM 1.4FH R/W Description LCD segment register 209 µPD17072,17073 22.4 Port Register Symbol name P0A3 Attribute FLG Value 0.70.3 R/W R/W Description Bit 3 of port 0A ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P0A2 FLG 0.70H.2 R/W Bit 2 of port 0A ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P0A1 FLG 0.70H.1 R/W Bit 1 of port 0A ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P0A0 FLG 0.70H.0 R/W Bit 0 of port 0A P0B3 FLG 0.71H.3 R/W Bit 3 of port 0B ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P0B2 FLG 0.71H.2 R/W Bit 2 of port 0B ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P0B1 FLG 0.71H.1 R/W Bit 1 of port 0B ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P0B0 FLG 0.71H.0 R/W Bit 0 of port 0B P0C1 FLG 0.72H.1 R/W Bit 1 of port 0C ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P0C0 FLG 0.72H.0 R/W Bit 0 of port 0C P0D3 FLG 0.73H.3 R/W Bit 3 of port 0D ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P0D2 FLG 0.73H.2 R/W Bit 2 of port 0D P1A3 FLG 1.70H.3 R/W Bit 3 of port 1A ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P1A2 FLG 1.70H.2 R/W Bit 2 of port 1A ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P1A1 FLG 1.70H.1 R/W Bit 1 of port 1A ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P1A0 FLG 1.70H.0 R/W Bit 0 of port 1A P1B3 FLG 1.71H.3 R/W Bit 3 of port 1B ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P1B2 FLG 1.71H.2 R/W Bit 2 of port 1B ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P1B1 FLG 1.71H.1 R/W Bit 1 of port 1B ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P1B0 FLG 1.71H.0 R/W Bit 0 of port 1B P1C0 FLG 1.72H.0 R/W Bit 0 of port 1C 210 µPD17072,17073 22.5 Peripheral Control Register Symbol name ADCON Attribute FLG Value 1.50H.1 R/W R/W Description A/D converter control signal power setting flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– LCDEN FLG 1.50H.0 R/W LCD driver display start flag BTM0CY FLG 1.51H.0 R&Res Basic timer 0 carry FF status detection flag CE FLG 1.52H.0 R P1APLD3 FLG 1.53H.3 R/W CE pin status detection flag P1A3 pin pull-down resistor select flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P1APLD2 FLG 1.53H.2 R/W P1A2 pin pull-down resistor select flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P1APLD1 FLG 1.53H.1 R/W P1A1 pin pull-down resistor select flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P1APLD0 FLG 1.53H.0 R/W P1A0 pin pull-down resistor select flag SP MEM 1.54H R/W Stack pointer SYSCK FLG 1.55H.0 R/W System clock select flag INT FLG 1.56H.2 R/W INT pin status detection flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– BTM1CK FLG 1.56H.1 R/W Basic timer 1 clock select flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– IEG FLG 1.56H.0 R/W INT pin interrupt request detection edge direction select flag IPSIO FLG 1.57H.2 R/W Serial interface interrupt enable flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– IPBTM1 FLG 1.57H.1 R/W Basic timer 1 interrupt enable flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– IP FLG 1.57H.0 R/W INT pin interrupt enable flag IRQ FLG 1.58H.0 R/W INT pin interrupt request detection flag IRQBTM1 FLG 1.59H.0 R/W Basic timer 1 interrupt request detection flag IRQSIO FLG 1.5AH.0 R/W Serial interface interrupt request detection flag BEEP0CK1 FLG 1.5BH.1 R/W BEEP clock select flag –––––––––––––––––––––––––––––––––––––––––––– BEEP0CK0 ADCCH3 FLG 1.5BH.0 R/W FLGQ 1.5CH.3 R A/D converter channel select flag (fixed to “0”) –––––––––––––––––––––––––––––––––––––––––––– ADCCH2 FLG 1.5CH.2 R ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– ADCCH1 FLG 1.5CH.1 R/W A/D converter channel select flag –––––––––––––––––––––––––––––––––––––––––––– ADCCH0 FLG 1.5CH.0 R/W ADCRFSEL3 FLG 1.5DH.3 R/W A/D converter reference voltage setting flag –––––––––––––––––––––––––––––––––––––––––––– ADCRFSEL2 FLG 1.5DH.2 R/W –––––––––––––––––––––––––––––––––––––––––––– ADCRFSEL1 FLG 1.5DH.1 R/W –––––––––––––––––––––––––––––––––––––––––––– ADCRFSEL0 FLG 1.5DH.0 R/W ADCSTRT FLG 1.5EH.0 R/W ADCCMP FLG 1.5FH.0 R SIOSEL FLG 1.60H.2 R/W A/D converter compare start flag A/D converter compare result detection flag Serial in/serial out pin select flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– SIOHIZ FLG 1.60H.1 R/W Serial interface/general-purpose port select flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– SIOTS FLG 1.60H.0 R/W SIOCK3 FLG 1.61H.3 R Serial interface transmit/receive start flag Serial interface I/O clock select flag (fixed to “0”) –––––––––––––––––––––––––––––––––––––––––––– SIOCK2 FLG 1.61H.2 R ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– SIOCK0 FLG 1.61H.1 R/W Serial interface I/O clock select flag –––––––––––––––––––––––––––––––––––––––––––– SIOCK0 FLG 1.61H.0 R/W IFCMD1 FLG 1.62H.3 R/W IF counter mode select flag (10, 11: AMIF) 211 µPD17072,17073 Symbol name IFCMD0 Attribute FLG Value 1.62H.2 R/W R/W Description IF counter mode select flag (00: general-purpose I/O port, 01: FMIF) ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– INCCK1 FLG 1.62H.1 R/W IF counter clock select flag –––––––––––––––––––––––––––––––––––––––––––– IFCCK0 FLG 1.62H.0 R/W IFCG FLG 1.63H.0 R IF counter gate status detection flag (1: open, 0: close) IFCSTRT FLG 1.64H.1 W IF counter count start flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– IFCRES FLG 1.64H.0 W IF counter reset flag PLLMD3 FLG 1.65H.3 R PLL mode select flag (fixed to “0”) –––––––––––––––––––––––––––––––––––––––––––– PLLMD2 FLG 1.65H.2 R ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– PLLMD1 FLG 1.65H.1 R/W PLL mode select flag –––––––––––––––––––––––––––––––––––––––––––– PLLMD0 FLG 1.65H.0 R/W PLLRFCK3 FLG 1.66H.3 R PLL reference frequency select flag (fixed to “0”) ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– PLLRFCK2 FLG 1.66H.2 R/W PLL reference frequency select flag –––––––––––––––––––––––––––––––––––––––––––– PLLRFCK1 FLG 1.66H.1 R/W –––––––––––––––––––––––––––––––––––––––––––– PLLRFCK0 FLG 1.66H.0 R/W PLLR17 FLG 1.67H.3 R/W PLL data flag –––––––––––––––––––––––––––––––––––––––––––– PLLR16 FLG 1.67H.2 R/W –––––––––––––––––––––––––––––––––––––––––––– PLLR15 FLG 1.67H.1 R/W –––––––––––––––––––––––––––––––––––––––––––– PLLR14 FLG 1.67H.0 R/W PLLR13 FLG 1.68H.3 R/W –––––––––––––––––––––––––––––––––––––––––––– PLLR12 FLG 1.68H.2 R/W –––––––––––––––––––––––––––––––––––––––––––– PLLR11 FLG 1.68H.1 R/W –––––––––––––––––––––––––––––––––––––––––––– PLLR10 FLG 1.68H.0 R/W PLLR9 FLG 1.69H.3 R/W –––––––––––––––––––––––––––––––––––––––––––– PLLR8 FLG 1.69H.2 R/W –––––––––––––––––––––––––––––––––––––––––––– PLLR7 FLG 1.69H.1 R/W –––––––––––––––––––––––––––––––––––––––––––– PLLR6 FLG 1.69H.0 R/W PLLR5 FLG 1.6AH.3 R/W –––––––––––––––––––––––––––––––––––––––––––– PLLR4 FLG 1.6AH.2 R/W –––––––––––––––––––––––––––––––––––––––––––– PLLR3 FLG 1.6AH.1 R/W –––––––––––––––––––––––––––––––––––––––––––– PLLR2 FLG 1.6AH.0 R/W PLLR1 FLG 1.6BH.3 R/W PLLPUT FLG 1.6CH.0 W PLLUL FLG 1.6DH.0 P0BBIO3 FLG 1.6EH.3 PLL data set flag R&Res PLL unlock FF flag R/W P0B3 input/output select flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P0BBIO2 FLG 1.6EH.2 R/W P0B2 input/output select flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P0BBIO1 FLG 1.6EH.1 R/W P0B1 input/output select flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P0BBIO0 FLG 1.6EH.0 R/W P0B0 input/output select flag P0DBIO3 FLG 1.6FH.3 R/W P0D3 input/output select flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P0DBIO2 FLG 1.6FH.2 R/W P0D2 input/output select flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P0CBIO1 FLG 1.6FH.1 R/W P0C1 input/output select flag ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– P0CBIO0 212 FLG 1.6FH.0 R/W P0C0 input/output select flag µPD17072,17073 22.6 Peripheral Hardware Register Symbol name Attribute Value R/W Description SIOSFR DAT 03H R/W Serial interface presettable shift register AR DAT 40H R/W Address register of GET/PUT/PUSH/CALL/BR/MOVT instruction IFC DAT 43H R Intermediate frequency (IF) counter data register 22.7 Others Symbol name DBF Attribute DAT Value 0FH Description Fixed operand value of PUT, GET, and MOVT instructions 213 µPD17072,17073 23. ELECTRICAL CHARACTERISTICS Absolute Maximum Ratings (T A = 25 °C) Parameter Supply voltage Input voltage Symbol Rating Unit –0.3 to +4.0 V CE pin –0.3 to VDD +0.6 V Other than CE pin –0.3 to VDD +0.3 V –0.3 to VDD +0.3 V 1 pin –3.0 mA Total of all pins –20.0 mA 1 pin 3.0 mA Total of all pins 20.0 mA VDD VI Output voltage VO Output current, high fOH Output current, low Condition IOL Operating ambient temperature TA –20 to +70 °C Storage temperature Tstg –55 to +125 °C Caution If the absolute maximum rating of even one of the above parameters is exceeded even momentarily, the quality of the product may be degraded. In other words, the absolute maximum ratings specify the values exceeding which the product may be physically damaged. Be sure to use the product with these ratings never exceeded. Recommended Operating Range Parameter Supply voltage Symbol VDD1 Condition With CPU, PLL, and AD operating MIN. TYP. MAX. Unit 1.8 3.0 3.6 V TA = –20 to +70 °C VDD2 Supply voltage rise time 214 trise With CPU operating and TA = –10 to +70 °C 1.7 3.0 3.6 V PLL and AD stopped TA = 0 to +70 °C 1.6 3.0 3.6 V 500 mS VDD: 0 → 1.8 V µPD17072,17073 DC Characteristics (T A = –20 to +70 °C, V DD = 1.8 to 3.6 V) Parameter Supply voltage Supply current Symbol Condition MIN. TYP. MAX. Unit 1.8 3.0 3.6 V VDD1 With CPU, PLL, and AD operating TA = –20 to +70 °C VDD2 With CPU operating, TA = –10 to +70 °C 1.7 3.0 3.6 V and PLL and AD stopped TA = 0 to +70 °C 1.6 3.0 3.6 V IDD1 With CPU and PLL operating Sine wave input to VCOH pin (fIN = 230 MHz, VIN = 0.2 VP-P) VDD = 3 V, TA = 25 °C 6.5 10 mA IDD2 With CPU operating and PLL stopped (IF counter stopped) Sine wave input to XIN pin (fIN = 75 kHz, VIN = VDD) VDD = 3 V, TA = 25 °C 35 45 µA IDD3 With CPU and PLL stopped (with HALT instruction used) Sine wave input to XIN pin (fIN = 75 kHz, VIN = VDD) LCD display OFF, VDD = 3 V, TA = 25 °C 10 18 µA Data retention voltage VDDR On power failure detection Data retention current IDDR When crystal oscillation stopped TA = 25 °C, VDD = 3.0 V Input voltage, high VIH1 CE, INT, P0B0-P0B3, P0C0, P0C1, P0D2, P0D3 0.8 VDD V VIH2 P1A0-P1A3 V VIL1 CE, INT, P0B0-P0B3, P0C0, P0C1, P0D2, P0D3 0.2 VDD V VIL2 P1A0-P1A3 0.05 VDD V IOH1 P0A0-P0A3, P0B0-P0B3, P1B0-P1B3, P0C0, P0C1, P0D2, P0D3, P1C0, BEEP VOH = VDD – 0.5 V –0.5 mA IOH2 EO VOH = VDD – 0.5 V –0.2 mA IOH3 LCD0-LCD14 VOH = VDD – 0.5 V –20 µA IOL1 P0A0-P0A3, P0B0-P0B3, P0C0, P0C1, P0D2, P0D3, P1C0, BEEP VOL = 0.5 V 0.5 mA IOL2 EO VOL = 0.5 V 0.2 mA IOL3 P1B0-P1B3 VOL = 0.5 V 5 µA IOL4 LCD0-LCD14 VOL = 0.5 V 20 µA IIH1 With P1A0-P1A3 pulled down Input voltage, low Output current, high Output current, low Input current, high 1.7 V 3 0.5 VDD 3 30 µA µA VIH = VDD = 1.8 V IIH2 With XIN pulled down µA 40 VIH = VDD = 1.8 V LCD drive voltage VLCD1 With LCD0-LCD14 output open C1 = 0.1 µF, C2 = 0.01 µF 2.8 3.1 3.3 V ±1 µA TA = 25 °C Output off leakage current IL EO 215 µPD17072,17073 AC Characteristics (T A = –20 to +70 °C, V DD = 1.8 to 3.6 V) Parameter Operating frequency Symbol Condition MIN. fIN1 VCOL pin, MF mode Sine wave input, VIN = 0.2 VP-P fIN2 TYP. MAX. Unit 0.3 8 MHz VCOL pin, HF mode Sine wave input, VIN = 0.3 VP-P 5 130 MHz fIN3 VCOH pin, VHF mode Sine wave input, VIN = 0.2 VP-P 40 230 MHz fIN4 AMIFC pin, FMIFC pin, AMIF count mode Sine wave input, VIN = 0.1 VP-P 400 500 kHz fIN5 AMIFC pin, FMIFC pin, AMIF count mode Sine wave input, VIN = 0.15 VP-P 0.4 2 MHz fIN6 FMIFC pin, FMIF count mode Sine wave input, VIN = 0.1 VP-P 10 11 MHz MAX. Unit ±1.5 LSB A/D Converter Characteristics (TA = 25 °C, V DD = 1.8 V) Parameter A/D converter 216 Symbol Condition 4-bit resolution MIN. TYP. µPD17072,17073 24. PACKAGE DRAWINGS 56 PIN PLASTIC QFP (10 10) A B 42 43 29 28 detail of lead end C D S R Q 15 14 56 1 F J G H I P M K M N L NOTE Each lead centerline is located within 0.13 mm (0.005 inch) of its true position (T.P.) at maximum material condition. ITEM A B MILLIMETERS INCHES 12.8±0.4 10.0±0.2 0.504±0.016 0.394±0.008 C 10.0±0.2 0.394±0.008 D 12.8±0.4 0.504±0.016 F 0.8 0.031 G H 0.8 0.30±0.10 0.031 0.012±0.004 I 0.13 0.005 J 0.65 (T.P.) 0.026 (T.P.) K 1.4±0.2 0.055±0.008 L 0.6±0.2 0.024 +0.008 –0.009 M 0.15 +0.10 –0.05 0.006 +0.004 –0.003 N 0.10 0.004 P 1.7 0.067 Q R 0.125±0.075 5°±5° 0.005±0.003 5°±5° S 2.0 MAX. 0.079 MAX. S56GB-65-1A7-3 217 µPD17072,17073 64 PIN PLASTIC TQFP (FINE PITCH) ( 10) A B 48 33 32 49 F 64 17 16 1 G R Q S D C detail of lead end H I M J M P K N L NOTE Each lead centerline is located within 0.10 mm (0.004 inch) of its true position (T.P.) at maximum material condition. ITEM MILLIMETERS INCHES A 12.0±0.2 0.472 +0.009 –0.008 B 10.0±0.2 0.394 +0.008 –0.009 C 10.0±0.2 0.394 +0.008 –0.009 D 12.0±0.2 0.472 +0.009 –0.008 F 1.25 0.049 G 1.25 0.049 H 0.22 +0.055 –0.045 0.009±0.002 I 0.10 0.004 J 0.5 (T.P.) 0.020 (T.P.) K 1.0±0.2 0.039 +0.009 –0.008 L 0.5±0.2 0.020 +0.008 –0.009 M 0.145 +0.055 –0.045 0.006±0.002 N 0.10 0.004 P 1.0±0.1 0.039 +0.005 –0.004 Q 0.1±0.05 0.004±0.002 R 3° +7° –3° 3° +7° –3° S 1.27 MAX. 0.050 MAX. S64GB-50-9EU-1 218 µPD17072,17073 25. RECOMMENDED SOLDERING CONDITIONS Solder the µPD17073 under the following recommended conditions. For the details of the recommended soldering conditions, refer to Information Document Semiconductor Device Mounting Technology Manual (C10535E). For the soldering methods and conditions other than those recommended, consult NEC. Table 25-1. Soldering Conditions for Surface-Mount Type (1) µPD17072GB-×××-1A7: 56-pin plastic QFP (10 × 10 mm, 0.65-mm pitch) µPD17073GB-×××-1A7: 56-pin plastic QFP (10 × 10 mm, 0.65-mm pitch) Soldering Method Soldering Condition Symbol of Recommended Soldering Infrared reflow Package peak temperature: 235 °C, Time: 30 seconds MAX. (210 °C MIN.) Number of times: 2 MAX. IR35-00-2 VPS Package peak temperature: 215 °C, Time: 40 seconds MAX. (200 °C MIN.) Number of times: 2 MAX. VP15-00-2 Wave soldering Soldering bath temperature: 260 °C MAX., Time: 10 seconds MAX., Number of times: 1, Preheating temperature: 120 °C MAX. WS60-00-1 (package surface temperature) Pin partial heating Pin temperature: 300 °C MAX., Time: 3 seconds MAX. (per side of device) — (2) µPD17072GB-×××-9EU: 64-pin plastic TQFP (10 × 10 mm, 0.5-mm pitch) µPD17073GB-×××-9EU: 64-pin plastic TQFP (10 × 10 mm, 0.5-mm pitch) Soldering Method Soldering Condition Symbol of Recommended Soldering Infrared reflow Package peak temperature: 235 °C, Time: 30 seconds MAX. (210 °C MIN.) Number of times: 1, Number of days: 2Note (after that, prebaking at 125 °C for 10 hours is necessary) IR35-102-1 VPS Package peak temperature: 215 °C, Time: 40 seconds MAX. (200 °C MIN.) Number of times: 1, Number of days: 2Note (after that, prebaking at 125 °C for 10 hours is necessary) VP15-102-1 Pin partial heating Pin temperature: 300 °C MAX., Time: 3 seconds (per side of device) — Note The number of days for which the device can be stored after the dry pack is opened, at 25 °C, 65%RH MAX. Caution Do not use two or more soldering methods in combination (except pin partial heating). 219 µPD17072,17073 APPENDIX A. NOTES ON CONNECTING CRYSTAL RESONATOR When connecting a crystal resonator to the µPD17073, connect the part enclosed by dotted line in Figure A-1 below as follows to avoid adverse influence of wiring capacitance: • Keep the wiring length as short as possible. • Do not cross the wiring with any other signal lines. Do not route the wiring in the vicinity of lines through which a high current flows. • The ground of the capacitors of the oscillation circuit must be always at the same potential as GND. Do not ground to a ground pattern through which a high current flows. • Do not extract signals from the oscillation circuit. To connect the capacitors or to adjust the oscillation frequency, keep in mind the following points (1) through (3): (1) If the values of C1 and C2 are too high, the oscillation characteristics may be degraded or the current consumption increases. (2) A trimmer capacitor for oscillation frequency adjustment is generally connected to the XIN pin. Depending on the crystal resonator to be used, however, the oscillation stability may be degraded as a result of connecting a trimmer capacitor to the XIN pin (in this case, connect the trimmer capacitor to the XOUT pin). Therefore, evaluate oscillation by using the crystal resonator to be actually used. (3) Adjust the oscillation frequency while measuring the LCD drive waveform (62.5 Hz) or VCO oscillation frequency. If a probe is connected to the XOUT or XIN pin, accurate adjustment cannot be made due to the capacitance of the probe. Figure A-1. Connecting Crystal Resonator µ PD17073 XOUT X IN 75 kHz crystal resonator C2 220 C1 µPD17072,17073 APPENDIX B. DEVELOPMENT TOOLS The following development tools are available for development of the program of the µPD17073: Hardware Name Outline In-circuit emulator IE-17K, IE-17K-ET, and EMU-17K are in-circuit emulators common to 17K series. [IE-17K, IE-17K-ETNote1, IE-17K and IE-17K-ET are connected to host machine such as PC-9800 series or IBM PC/ATTM EMU-17KNote2] with RS-232-C. EMU-17K is mounted in expansion slot of host machine, PC-9800 series. By using these in-circuit emulators in combination with system evaluation board (SE board) dedicated to each model of microcontroller, they operate as emulators dedicated to that microcontroller. When SIMPLEHOST ®, which is man-machine interface, is used, more sophisticated debugging environment can be created. EMU-17K also has function that allows you to monitor contents of data memory real-time. SE board (SE-17072) SE-17072 is SE board for µPD17072 and 17073. It may be used alone to evaluate system, or in combination with in-circuit emulator for debugging. Emulation probe (EP-17K56GB) EP-17K56GB is an emulation probe for the 17K series 56-pin QFP (10 × 10 mm). By using this emulation probe with the EV-9500GB-56Note 3, the SE board and target system are connected. EP-17K56GB-1: Bend lead package EP-17K56GB-2: Inverted lead package Emulation probe (EP-17K64GB: bend lead package) EP-17K64GB is an emulation probe for the 17K series 64-pin TQFP (10 × 10 mm). By using this emulation probe with the EV-9500GB-64Note 3, the SE board and target system are connected. Conversion adapter (EV-9500GB-56) EV-9500GB-56 is a conversion adapter for a 56-pin QFP (10 × 10 mm). It is used to connect the EP-17K56GB and target system. Conversion adapter (EV-9500GB-64) EV-9500GB-64 is a conversion adapter for a 64-pin TQFP (10 × 10 mm). It is used to connect the EP-17K64GB and target system. Notes 1. Low-cost model: External power supply type 2. This is a product from I.C. For details, contact I.C Corp. ((03) 3447-3793). 3. One EV-9500GB-56 is supplied with the EP-17K56GB. Five EV-9500GB-56 are also available as a set. One EV-9500GB-64 is supplied with the EP-17K64GB. Five EV-9500GB-64 are also available as a set. 221 µPD17072,17073 Software Name Outline 17K-Series Assembler (AS17K) Device File (AS17071) Host Machine AS17K is an assembler that can be commonly used with the 17K series products. To develop the program of the µPD17072 and 17073, AS17K and a device file (AS17071) are used. PC-9800 series AS17071 is a device file for µPD17072 and 17073, and is used with 17K series assembler (AS17K). PC-9800 series IBM PC/AT IBM PC/AT Support SIMPLEHOST is software that Software serves as a man-machine (SIMPLEHOST) interface on WindowsTM when a program is developed with an in-circuit emulator and a personal computer. PC-9800 series IBM PC/AT OS MS-DOSTM PC DOSTM MS-DOS PC DOS MS-DOW Windows PC DOS Remark Supported OS versions are listed below. OS Version MS-DOS Ver. 3.30 to Ver. 5.00ANote PC DOS Ver. 3.1 to Ver. 5.0Note Windows Ver. 3.0 to Ver. 3.1 Note Ver. 5.00/5.00A of MS-DOS and Ver. 5.0 of PC DOS have a task swap function, but it is not supported by this software product. 222 Supply Media Order Code 5"2HD µS5A10AS17K 3.5"2HD µS5A13AS17K 5"2HC µS7B10AS17K 3.5"2HC µS7B13AS17K 5"2HD µS5A10AS17071 3.5"2HD µS5A13AS17071 5"2HC µS7B10AS17071 3.5"2HC µS7B13AS17071 5"2HD µS5A10IE17K 3.5"2HD µS5A13IE17K 5"2HC µS7B10IE17K 3.5"2HC µS7B13IE17K µPD17072,17073 [MEMO] 223 µPD17072,17073 NOTES FOR CMOS DEVICES 1 PRECAUTION AGAINST ESD FOR SEMICONDUCTORS Note: Strong electric field, when exposed to a MOS device, can cause destruction of the gate oxide and ultimately degrade the device operation. Steps must be taken to stop generation of static electricity as much as possible, and quickly dissipate it once, when it has occurred. Environmental control must be adequate. When it is dry, humidifier should be used. It is recommended to avoid using insulators that easily build static electricity. Semiconductor devices must be stored and transported in an anti-static container, static shielding bag or conductive material. All test and measurement tools including work bench and floor should be grounded. The operator should be grounded using wrist strap. Semiconductor devices must not be touched with bare hands. Similar precautions need to be taken for PW boards with semiconductor devices on it. 2 HANDLING OF UNUSED INPUT PINS FOR CMOS Note: No connection for CMOS device inputs can be cause of malfunction. If no connection is provided to the input pins, it is possible that an internal input level may be generated due to noise, etc., hence causing malfunction. CMOS device behave differently than Bipolar or NMOS devices. Input levels of CMOS devices must be fixed high or low by using a pull-up or pull-down circuitry. Each unused pin should be connected to VDD or GND with a resistor, if it is considered to have a possibility of being an output pin. All handling related to the unused pins must be judged device by device and related specifications governing the devices. 3 STATUS BEFORE INITIALIZATION OF MOS DEVICES Note: Power-on does not necessarily define initial status of MOS device. Production process of MOS does not define the initial operation status of the device. Immediately after the power source is turned ON, the devices with reset function have not yet been initialized. Hence, power-on does not guarantee out-pin levels, I/O settings or contents of registers. Device is not initialized until the reset signal is received. Reset operation must be executed immediately after power-on for devices having reset function. 224 µPD17072,17073 Regional Information Some information contained in this document may vary from country to country. Before using any NEC product in your application, please contact the NEC office in your country to obtain a list of authorized representatives and distributors. They will verify: • Device availability • Ordering information • Product release schedule • Availability of related technical literature • Development environment specifications (for example, specifications for third-party tools and components, host computers, power plugs, AC supply voltages, and so forth) • Network requirements In addition, trademarks, registered trademarks, export restrictions, and other legal issues may also vary from country to country. NEC Electronics Inc. (U.S.) NEC Electronics (Germany) GmbH NEC Electronics Hong Kong Ltd. Mountain View, California Tel: 800-366-9782 Fax: 800-729-9288 Benelux Office Eindhoven, The Netherlands Tel: 040-2445845 Fax: 040-2444580 Hong Kong Tel: 2886-9318 Fax: 2886-9022/9044 NEC Electronics (Germany) GmbH Duesseldorf, Germany Tel: 0211-65 03 02 Fax: 0211-65 03 490 NEC Electronics Hong Kong Ltd. France Tel: 01-30-67 58 00 Fax: 01-30-67 58 99 Seoul Branch Seoul, Korea Tel: 02-528-0303 Fax: 02-528-4411 NEC Electronics (France) S.A. NEC Electronics Singapore Pte. Ltd. Spain Office Madrid, Spain Tel: 01-504-2787 Fax: 01-504-2860 United Square, Singapore 1130 Tel: 253-8311 Fax: 250-3583 NEC Electronics (France) S.A. NEC Electronics (UK) Ltd. Milton Keynes, UK Tel: 01908-691-133 Fax: 01908-670-290 NEC Electronics Italiana s.r.1. Milano, Italy Tel: 02-66 75 41 Fax: 02-66 75 42 99 NEC Electronics Taiwan Ltd. NEC Electronics (Germany) GmbH Scandinavia Office Taeby Sweden Tel: 8-63 80 820 Fax: 8-63 80 388 Taipei, Taiwan Tel: 02-719-2377 Fax: 02-719-5951 NEC do Brasil S.A. Sao Paulo-SP, Brasil Tel: 011-889-1680 Fax: 011-889-1689 J96. 3 225 µPD17072,17073 SIMPLEHOST is a registerd trademark of NEC Corporation. PC/AT and PC DOS are trademarks of IBM Corporation. MS-DOS and Windows are trademarks of Microsoft Corporation. The export of this product from Japan is regulated by the Japanese government. To export this product may be prohibited without governmental license, the need for which must be judged by the customer. The export or re-export of this product from a country other than Japan may also be prohibited without a license from that country. Please call an NEC sales representative. No part of this document may be copied or reproduced in any form or by any means without the prior written consent of NEC Corporation. NEC Corporation assumes no responsibility for any errors which may appear in this document. NEC Corporation does not assume any liability for infringement of patents, copyrights or other intellectual property rights of third parties by or arising from use of a device described herein or any other liability arising from use of such device. No license, either express, implied or otherwise, is granted under any patents, copyrights or other intellectual property rights of NEC Corporation or others. While NEC Corporation has been making continuous effort to enhance the reliability of its semiconductor devices, the possibility of defects cannot be eliminated entirely. To minimize risks of damage or injury to persons or property arising from a defect in an NEC semiconductor device, customers must incorporate sufficient safety measures in its design, such as redundancy, fire-containment, and anti-failure features. NEC devices are classified into the following three quality grades: "Standard", "Special", and "Specific". The Specific quality grade applies only to devices developed based on a customer designated "quality assurance program" for a specific application. The recommended applications of a device depend on its quality grade, as indicated below. Customers must check the quality grade of each device before using it in a particular application. Standard: Computers, office equipment, communications equipment, test and measurement equipment, audio and visual equipment, home electronic appliances, machine tools, personal electronic equipment and industrial robots Special: Transportation equipment (automobiles, trains, ships, etc.), traffic control systems, anti-disaster systems, anti-crime systems, safety equipment and medical equipment (not specifically designed for life support) Specific: Aircrafts, aerospace equipment, submersible repeaters, nuclear reactor control systems, life support systems or medical equipment for life support, etc. The quality grade of NEC devices is "Standard" unless otherwise specified in NEC's Data Sheets or Data Books. If customers intend to use NEC devices for applications other than those specified for Standard quality grade, they should contact an NEC sales representative in advance. Anti-radioactive design is not implemented in this product. M4 96.5 226