![]() |
|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
DATA SHEET MOS INTEGRATED CIRCUIT PD17704, 17705, 17707, 17708, 17709 4-BIT SINGLE-CHIP MICROCONTROLLERS WITH DEDICATED HARDWARE FOR DIGITAL TUNING SYSTEM The PD17704, 17705, 17707, 17708, and 17709 are 4-bit single-chip CMOS microcontrollers containing hardware for digital tuning systems. Provided with a wealth of hardware, these microcontrollers are available in many variations of ROM and RAM capacities to support various applications. Therefore, a high-performance, multi-function digital tuning system can be configured with only one chip. In addition, a one-time PROM model, PD17P709, which can be written only once and therefore is ideal for program evaluation and small-scale production of a PD17704, 17705, 17707, 17708, or 17709 system, is also available. FEATURES PD17704 Program memory (ROM) 16K bytes (8192 x 16 bits) 672 x 4 bits PD17705 24K bytes (12288 x 16 bits) PD17707 PD17708 32K bytes (16384 x 16 bits) PD17709 General Purpose data memory (RAM) 1120 x 4 bits 1776 x 4 bits * Instruction execution time 1.78 s (with fX = 4.5-MHz crystal oscillator) * PLL frequency synthesizer Dual modulus prescaler (130 MHz MAX.), programmable divider, phase comparator, charge pump * Abundant peripheral hardware units General-purpose I/O ports, serial interfaces, A/D converter, D/A converter (PWM output), BEEP output, frequency counter * Many interrupts External Internal : 6 sources : 6 sources * Power-ON reset, CE reset, and power failure detection circuit * Supply voltage: VDD = 5 V 10 % Unless otherwise specified, the PD17709 is treated as the representative model in this document. The information in this document is subject to change without notice. Document No. U11624EJ2V0DS00 (2nd edition) Date Published December 1996 N Printed in Japan The mark shows major revised points. (c) 1996 PD17704, 17705, 17707, 17708, 17709 ORDERING INFORMATION Part Number Package 80-pin plastic QFP (14 x 14 mm, 0.65 mm pitch) 80-pin plastic QFP (14 x 14 mm, 0.65 mm pitch) 80-pin plastic QFP (14 x 14 mm, 0.65 mm pitch) 80-pin plastic QFP (14 x 14 mm, 0.65 mm pitch) 80-pin plastic QFP (14 x 14 mm, 0.65 mm pitch) PD17704GC-xxx-3B9 PD17705GC-xxx-3B9 PD17707GC-xxx-3B9 PD17708GC-xxx-3B9 PD17709GC-xxx-3B9 Remark xxx indicates a ROM code number. FUNCTIONAL OUTLINE Part Number Item Program memory (ROM) PD17704 PD17705 PD17707 PD17708 PD17709 16K bytes 24K bytes (12288 x 16 bits) (8192 x 16 bits) 672 x 4 bits 1120 x 4 bits 32K bytes (16384 x 16 bits) 1176 x 4 bits General-purpose data memory (RAM) Instruction execution time General-purpose port 1.78 s (with fX = 4.5-MHz crystal oscillator) * I/O port : 46 pins * Input port : 12 pins * Output port: 4 pins * Address stack : 15 levels * Interrupt stack: 4 levels * DBF stack : 4 levels (can be manipulated via software) * External: 6 sources (falling edge of CE pin, INT0 through INT4) * Internal : 6 sources (timers 0 through 3, serial interfaces 0 and 1) Stack level Interrupt Timer 5 * * * * channels Basic timer (clock: 10, 20, 50, 100 Hz) : 8-bit timer with gate counter (clock: 1 k, 2 k, 10 k, 100 kHz): 8-bit timer (clock: 1 k, 2 k, 10 k, 100 kHz) : 8-bit timer multiplexed with PWM (clock: 440 Hz, 4.4 kHz) : 1 1 2 1 channel channel channels channel A/D converter D/A converter (PWM) 8 bits x 6 channels (hardware mode and software mode selectable) 3 channels (8-bit or 9-bit resolution selectable by software) Output frequency: 4.4 kHz, 440 Hz (with 8-bit PWM selected) 2.2 kHz, 220 Hz (with 9-bit PWM selected) 2 units (3 channels) * 3-wire serial I/O : 2 channels * 2-wire serial I/O/I 2 C bus : 1 channel Division mode * Direct division mode (VCOL pin (MF mode) : 0.5 to 3 MHz) * Pulse swallow mode (VCOL pin (HF mode) : 10 to 40 MHz) (VCOH pin (VHF mode): 60 to 130 MHz) 13 types selectable (1, 1.25, 2.5, 3, 5, 6.25, 9, 10, 12.5, 18, 20, 25, 50 kHz) Two error-out output pins (EO0, EO1) Unlock status detectable by program Serial interface PLL frequency synthesizer Reference frequency Charge pump Phase comparator 2 PD17704, 17705, 17707, 17708, 17709 Part Number Item Frequency counter PD17704 PD17705 PD17707 PD17708 PD17709 * Intermediate frequency (IF) measurement P1C0/FMIFC pin : in FMIF mode 10 to 11 MHz in AMIF mode 0.4 to 0.5 MHz P1C1/AMIFC pin: in AMIF mode 0.4 to 0.5 MHz * External gate width measurement P2A1/FCG1, P2A0/FCG0 pin 2 pins Output frequency: 1 kHz, 3 kHz, 4 kHz, 6.7 kHz (BEEP0 pin) 67 Hz, 200 Hz, 3 kHz, 4 kHz (BEEP1 pin) BEEP output Reset * Power-ON reset (on power application) * Reset by RESET pin * Watchdog timer reset Can be set only once on power application: 65536 instruction, 131072 instruction, or no-use selectable * Stack pointer overflow/underflow reset Can be set only once on power application: interrupt stack or address stack selectable * CE reset (CE pin low high level) CE reset delay timing can be set. * Power failure detection function * Clock stop mode (STOP) * Halt mode (HALT) Standby Supply voltage * PLL operation: VDD = 4.5 to 5.5 V * CPU operation: VDD = 3.5 to 5.5 V 80-pin plastic QFP (14 x 14 mm, 0.65 mm pitch) Package 3 PD17704, 17705, 17707, 17708, 17709 PIN CONFIGURATION (Top View) 80-pin plastic QFP (14 x 14 mm, 0.65 mm pitch) PD17704GC-xxx-3B9 PD17705GC-xxx-3B9 PD17707GC-xxx-3B9 PD17708GC-xxx-3B9 PD17709GC-xxx-3B9 P0B2/SCK1 P0A1/SCK0 P0A3/SDA P0B1/SO1 P0A0/SO0 P0A2/SCL P0B0/SI1 P0B3/SI0 RESET GND0 P2D0 P2D1 P2D2 P0C0 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 INT2 P1A3/INT4 P1A2/INT3 P1A1 P1A0/TM0G P3A3 P3A2 P3A1 P3A0 P3B3 P3B2 P3B1 P3B0 P2A2 P2A1/FCG1 P2A0/FCG0 P1B3 P1B2/PWM2 P1B1/PWM1 P1B0/PWM0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 P0C2 P0C3 P2C0 P2C1 P2C2 P2C3 P3D0 P3D1 P3D2 P3D3 P3C0 P3C1 P3C2 P3C3 P2B0 P2B1 P2B2 P2B3 INT0 INT1 GND2 P0D3/AD3 P0D2/AD2 P0D1/AD1 P0D0/AD0 P1C3/AD5 P1C2/AD4 P1C1/AMIFC P1C0/FMIFC VDD1 VCOL GND1 EO0 EO1 P1D3 P1D2 P1D1/BEEP1 4 P1D0/BEEP0 VCOH TEST P0C1 REG VDD0 XOUT CE XIN PD17704, 17705, 17707, 17708, 17709 PIN NAME AD0-AD5 AMIFC CE EO0, EO1 FCG0, FGC1 FMIFC GND0-GND2 INT0-INT4 P0A0-P0A3 P0B0-P0B3 P0C0-P0C3 P0D0-P0D3 P1A0-P1A3 P1B0-P1B3 P1C0-P1C3 P1D0-P1D3 P2A0-P2A2 P2B0-P2B3 : A/D converter input : AM frequency counter input : Chip enable : Error-out output : Frequency counter gate input : FM frequency counter input : Ground 0 to 2 : External interrupt input : Port 0A : Port 0B : Port 0C : Port 0D : Port 1A : Port 1B : Port 1C : Port 1D : Port 2A : Port 2B P2C0-P2C3 P2D0-P2D2 P3A0-P3A3 P3B0-P3B3 P3C0-P3C3 P3D0-P3D3 REG RESET SCK0, SCK1 SCL SDA SI0, SI1 SO0, SO1 TEST TM0G VCOH VCOL VDD0, VDD1 XIN, XOUT : Port 2C : Port 2D : Port 3A : Port 3B : Port 3C : Port 3D : CPU regulator : Reset input : 3-wire serial clock I/O : 2-wire serial clock I/O : 2-wire serial data I/O : 3-wire serial data input : 3-wire serial data output : Test input : Timer 0 gate input : Local oscillation high input : Local oscillation low input : Power supply : Main clock oscillation BEEP0, BEEP1 : BEEP output PWM0-PWM2 : D/A converter output 5 PD17704, 17705, 17707, 17708, 17709 BLOCK DIAGRAM VCOH PLL RF P0C0-P0C3 P0D0-P0D3 P1A0-P1A3 P1B0-P1B3 P1C0-P1C3 P1D0-P1D3 P2A0-P2A2 P2B0-P2B3 P2C0-P2C3 P2D0-P2D2 P3A0-P3A3 P3B0-P3B3 P3C0-P3C3 P3D0-P3D3 4 4 4 4 4 4 P0A0-P0A3 P0B0-P0B3 4 4 VCOL EO0 EO1 SO0/P0A0 SCK0/P0A1 RAM 672 x 4 bits ( PD17704, 17705) 1120 x 4 bits ( PD17707, 17708) 1776 x 4 bits ( PD17709) SYSREG Serial Interface0 SCL/P0A2 SDA/P0A3 SI0/P0B3 SCK1/P0B2 Port 3 4 4 3 4 4 4 4 Serial Interface1 ALU BEEP Instruction Decoder Interrupt Control ROM 8192 x 16 bits ( PD17704) 12288 x 16 bits ( PD17705, 17707) 16384 x 16 bits ( PD17708, 17709) SO1/P0B1 SI1/P0B0 BEEP0/P1D0 BEEP1/P1D1 INT0 INT1 INT2 INT3/P1A2 INT4/P1A3 FCG0/P2A0 Frequency Counter FCG1/P2A1 FMIFC/P1C0 AMIFC/P1C1 AD0/P0D0 AD1/P0D1 AD2/P0D2 AD3/P0D3 AD4/P1C2 AD5/P1C3 PWM0/P1B0 PWM1/P1B1 PWM2/P1B2 8-bit Timer3 CPU Peripheral D/A Converter Stack 8-bit Timer2 XIN XOUT CE Reset RESET VDD0, VDD1 GND0-GND2 VCPU Regulator REG 8-bit Timer1 A/D Converter Program Counter 8-bit Timer0 Gate Counter TM0G/P1A0 OSC Basic Timer 6 PD17704, 17705, 17707, 17708, 17709 TABLE OF CONTESNTS 1. PIN FUNCTIONS .............................................................................................................................. 1.1 Pin Function List .................................................................................................................. 1.2 Equivalent Circuits of Pins .................................................................................................. 1.3 Connections of Unused Pins .............................................................................................. 1.4 Cautions on Using CE, INT0 through INT4, and RESET Pins .......................................... 1.5 Cautions on Using TEST Pin ............................................................................................... 2. PROGRAM MEMORY (ROM) .......................................................................................................... 2.1 Outline of Program Memory ................................................................................................ 2.2 Program Memory .................................................................................................................. 2.3 Program Counter .................................................................................................................. 2.4 Flow of Program ................................................................................................................... 2.5 Cautions on Using Program Memory ................................................................................ 3. ADDRESS STACK (ASK) ................................................................................................................ 3.1 Outline of Address Stack ..................................................................................................... 3.2 Address Stack Register (ASR) ............................................................................................ 3.3 Stack Pointer (SP) ................................................................................................................ 3.4 Operation of Address Stack ................................................................................................ 3.5 Cautions on Using Address Stack ...................................................................................... 4. DATA MEMORY (RAM) ................................................................................................................... 4.1 Outline of Data Memory ....................................................................................................... 4.2 Configuration and Function of Data Memory ................................................................... 4.3 Data Memory Addressing .................................................................................................... 4.4 Cautions on Using Data Memory ........................................................................................ 5. SYSTEM REGISTERS (SYSREG) ................................................................................................... 5.1 Outline of System Registers ............................................................................................... 5.2 System Register List ............................................................................................................ 5.3 Address Register (AR) ......................................................................................................... 5.4 Window Register (WR) ......................................................................................................... 5.5 Bank Register (BANK) ......................................................................................................... 5.6 Index Register (IX) and Data Memory Row Address Pointer (MP: memory pointer) .... 5.7 General Register Pointer (RP) ............................................................................................. 5.8 Program Status Word (PSWORD) ....................................................................................... 6. GENERAL REGISTER (GR) ............................................................................................................ 6.1 Outline of General Register ................................................................................................. 6.2 General Register .................................................................................................................. 6.3 Generating Address of General Register by Each Instruction ........................................ 6.4 Cautions on Using General Register ................................................................................. 11 11 16 21 23 23 24 24 25 26 26 29 30 30 30 32 33 34 35 35 38 42 43 44 44 45 46 48 49 50 52 54 56 56 56 57 57 7 PD17704, 17705, 17707, 17708, 17709 7. ALU (Arithmetic Logic Unit) BLOCK ............................................................................................. 7.1 Outline of ALU Block .......................................................................................................... 7.2 Configuration and Function of Each Block ....................................................................... 7.3 ALU Processing Instruction List ......................................................................................... 7.4 Cautions on Using ALU ....................................................................................................... 8. REGISTER FILE (RF) ........................................................................................................................ 8.1 Outline of Register File ........................................................................................................ 8.2 Configuration and Function of Register File .................................................................... 8.3 Control Registers ................................................................................................................. 8.4 Port Input/Output Selection Registers .............................................................................. 8.5 Cautions on Using Register File ......................................................................................... 9. DATA BUFFER (DBF) ....................................................................................................................... 9.1 Outline of Data Buffer .......................................................................................................... 9.2 Data Buffer ............................................................................................................................ 9.3 Relationships between Peripheral Hardware and Data Buffer ........................................ 9.4 Cautions on Using Data Buffer ........................................................................................... 10. DATA BUFFER STACK ................................................................................................................... 10.1 Outline of Data Buffer Stack ................................................................................................ 10.2 Data Buffer Stack Register .................................................................................................. 10.3 Data Buffer Stack Pointer .................................................................................................... 10.4 Operation of Data Buffer Stack ........................................................................................... 10.5 Using Data Buffer Stack ...................................................................................................... 10.6 Cautions on Using Data Buffer Stack ................................................................................ 58 58 59 59 63 64 64 65 66 78 84 85 85 86 87 90 91 91 91 93 94 95 95 11. GENERAL-PURPOSE PORT ........................................................................................................... 96 11.1 Outline of General-purpose Port ......................................................................................... 96 11.2 General-Purpose I/O Port (P0A, P0B, P0C, P1D, P2A, P2B, P2C, P2D, P3A, P3B, P3C, P3D) .............................................................................................................................. 99 11.3 General-Purpose Input Port (P0D, P1A, P1C) ................................................................... 113 11.4 General-Purpose Output Port (P1B) .................................................................................. 116 12. INTERRUPT ..................................................................................................................................... 117 12.1 Outline of Interrupt Block .................................................................................................... 117 12.2 Interrupt Control Block ........................................................................................................ 119 12.3 Interrupt Stack Register....................................................................................................... 133 12.4 Stack Pointer, Address Stack Registers, and Program Counter .................................... 137 12.5 Interrupt Enable Flip-Flop (INTE) ........................................................................................ 137 12.6 Accepting Interrupt .............................................................................................................. 138 12.7 Operations after Interrupt Has Been Accepted ................................................................ 143 12.8 Returning from Interrupt Routine ....................................................................................... 143 12.9 External Interrupts (CE and INT0 through INT4 pins) ...................................................... 144 12.10 Internal Interrupts ................................................................................................................ 147 13. TIMERS ............................................................................................................................................ 148 13.1 Outline of Timers .................................................................................................................. 148 8 PD17704, 17705, 17707, 17708, 17709 13.2 13.3 13.4 13.5 13.6 Basic Timer 0 ........................................................................................................................ 150 Timer 0 .................................................................................................................................. 163 Timer 1 .................................................................................................................................. 172 Timer 2 .................................................................................................................................. 179 Timer 3 .................................................................................................................................. 186 14. A/D CONVERTER ............................................................................................................................ 193 14.1 Outline of A/D Converter ..................................................................................................... 193 14.2 Input Selection Block ........................................................................................................... 194 14.3 Compare Voltage Generation and Compare Blocks ........................................................ 196 14.4 Comparison Timing Chart ................................................................................................... 199 14.5 Using A/D Converter ............................................................................................................ 200 14.6 Cautions on Using A/D Converter ...................................................................................... 201 14.7 Status at Reset ..................................................................................................................... 201 15. D/A CONVERTER (PWM mode) ...................................................................................................... 202 15.1 Outline of D/A Converter ..................................................................................................... 202 15.2 PWM Clock Selection Register ........................................................................................... 203 15.3 PWM Output Selection Block .............................................................................................. 204 15.4 Duty Setting Block ............................................................................................................... 207 15.5 Clock Generation Block ....................................................................................................... 211 15.6 D/A Converter Output Wave ................................................................................................ 211 15.7 Example of Using D/A Converter ........................................................................................ 214 15.8 Status at Reset ..................................................................................................................... 215 16. SERIAL INTERFACES ..................................................................................................................... 216 16.1 Outline of Serial Interfaces .................................................................................................. 216 16.2 Serial Interface 0 .................................................................................................................. 217 16.3 Serial Interface 1 .................................................................................................................. 245 17. PLL FREQUENCY SYNTHESIZER .................................................................................................. 255 17.1 Outline of PLL Frequency Synthesizer.............................................................................. 255 17.2 Input Selection Block and Programmable Divider ........................................................... 256 17.3 Reference Frequency Generator ......................................................................................... 260 17.4 Phase Comparator (-DET), Charge Pump, and Unlock FF ............................................. 262 17.5 PLL Disabled Status ............................................................................................................ 266 17.6 Using PLL Frequency Synthesizer ..................................................................................... 267 17.7 Status at Reset ..................................................................................................................... 271 18. FREQUENCY COUNTER ................................................................................................................. 272 18.1 Outline of Frequency Counter ............................................................................................. 272 18.2 Input/Output Selection Block and Gate Time Control Block ........................................... 273 18.3 Start/Stop Control Block and IF Counter .......................................................................... 276 18.4 Using IF Counter .................................................................................................................. 283 18.5 Using External Gate Counter .............................................................................................. 285 18.6 Status at Reset ..................................................................................................................... 286 9 PD17704, 17705, 17707, 17708, 17709 19. BEEP ................................................................................................................................................ 287 19.1 Outline of BEEP .................................................................................................................... 287 19.2 I/O Selection Block and Output Selection Block .............................................................. 288 19.3 Clock Selection Block and Clock Generation Block ........................................................ 290 19.4 Output Waveform of BEEP .................................................................................................. 291 19.5 Status at Reset ..................................................................................................................... 291 20. STANDBY ........................................................................................................................................ 292 20.1 Outline of Standby Function ............................................................................................... 292 20.2 Halt Function ........................................................................................................................ 293 20.3 Clock Stop Function ............................................................................................................ 299 20.4 Device Operation in Halt and Clock Stop Status .............................................................. 301 20.5 Cautions on Processing of Each Pin in Halt and Clock Stop Status .............................. 301 20.6 Device Operation Control Function of CE Pin .................................................................. 303 21. RESET .............................................................................................................................................. 306 21.1 Outline of Reset .................................................................................................................... 306 21.2 CE Reset ............................................................................................................................... 307 21.3 Power-ON Reset ................................................................................................................... 313 21.4 Relationship between CE Reset and Power-ON Reset .................................................... 316 21.5 Reset by RESET Pin ............................................................................................................. 320 21.6 WDT&SP Reset ..................................................................................................................... 321 21.7 Power Failure Detection ...................................................................................................... 327 22. INSTRUCTION SET ......................................................................................................................... 332 22.1 Outline of Instruction Set .................................................................................................... 332 22.2 Legend .................................................................................................................................. 333 22.3 Instruction List ..................................................................................................................... 334 22.4 Assembler (RA17K) Embedded Macro Instruction .......................................................... 336 23. RESERVED SYMBOLS ................................................................................................................... 337 23.1 Data Buffer (DBF) ................................................................................................................. 337 23.2 System Registers (SYSREG) ............................................................................................... 337 23.3 Port Registers ....................................................................................................................... 338 23.4 Register File (Control Registers) ........................................................................................ 340 23.5 Peripheral Hardware Registers ........................................................................................... 345 23.6 Others .................................................................................................................................... 345 24. ELECTRICAL CHARACTERISTICS ................................................................................................ 346 25. PACKAGE DRAWING ..................................................................................................................... 349 26. RECOMMENDED SOLDERING CONDITIONS .............................................................................. 350 APPENDIX A. CAUTIONS ON CONNECTING CRYSTAL RESONATOR ........................................... 351 APPENDIX B. DEVELOPMENT TOOLS ............................................................................................... 352 10 PD17704, 17705, 17707, 17708, 17709 1. PIN FUNCTIONS 1.1 Pin Function List Pin No. 1 41 42 2 3 4 5 Symbol INT2 INT1 INT0 P1A3/INT4 P1A2/INT3 P1A1 P1A0/TM0G Function Edge-detectable vectored interrupt input pins. Rising or falling edge can be specified. Output Form - Port 1A multiplexed with external interrupt request signal input and event signal input pins. * P1A3 through P1A0 * 4-bit input port * INT4, INT3 * Edge-detectable vectored interrupt * TM0G * Input for gate of 8-bit timer 0 At reset Power-ON reset Input (P1A3 through P1A0) WDT&SP reset Input (P1A3 through P1A0) CE reset Retained Retained With clock stopped - 6 | 9 P3A3 | P3A0 4-bit I/O port. Can be set in input or output mode in 4-bit units. At reset Power-ON reset Input WDT&SP reset Input CE reset Retained Retained With clock stopped CMOS push-pull 10 | 13 P3B3 | P3B0 4-bit I/O port. Can be set in input or output mode in 4-bit units. At reset Power-ON reset Input WDT&SP reset Input CE reset Retained Retained With clock stopped CMOS push-pull 14 15 16 P2A2 P2A1/FCG1 P2A0/FCG0 Port 2A multiplexed with external gate counter input pins. * P2A2 through P2A0 * 3-bit I/O port * Can be set in input or output mode in 1-bit units. * FCG1, FCG0 * Input for external gate counter At reset Power-ON reset Input (P2A2 through P2A0) WDT&SP reset Input (P2A2 through P2A0) CE reset Retained (P2A2 through P2A0) Retained (P2A2 through P2A0) With clock stopped CMOS push-pull 11 PD17704, 17705, 17707, 17708, 17709 Pin No. 17 18 | 20 Symbol P1B3 P1B2/PWM2 | P1B0/PWM0 Function Port 1B multiplexed with D/A converter output pins. * P1B3 through P1B0 * 4-bit output port * PWM2 through P2M0 * 8- or 9-bit D/A converter output At reset Power-ON reset Outputs low level (P1B3 through P1B0) 21 33 75 22 | 25 GND2 GND1 GND0 P0D3/AD3 | P0D0/AD0 Ground WDT&SP reset Outputs low level (P1B3 through P1B0) CE reset Retained Retained (P1B3 through P1B0) - With clock stopped Output Form N-ch open-drain (12 V) Port 0D multiplexed with A/D converter input pins * P0D3 through P0D0 * 4-bit input port * Can be connected with pull-down resistor in 1-bit units. * AD3 through AD0 * Analog input of A/D converter with 8-bit resolution At reset Power-ON reset Input with pull-down resistor (P0D3 through P0D0) WDT&SP reset Input with pull-down resistor (P0D3 through P0D0) CE reset Retained Retained With clock stopped - 26 27 28 29 P1C3/AD5 P1C2/AD4 P1C1/AMIFC P1C0/FMIFC Port 1C multiplexed with A/D converter input and IF counter input pins. * P1C3 through P1C0 * 4-bit input port * AD5, AD4 * Analog input to A/D converter with 8-bit resolution * FMIFC, AMIFC * Input to frequency counter At reset Power-ON reset Input (P1C3 through P1C0) WDT&SP reset Input (P1C3 through P1C0) CE reset * P1C3/AD5, P1C2/AD4 retained * P1C1/AMIFC, P1C0/FMIFC input (P1C1, P1C0) * P1C3/AD5, P1C2/AD4 retained * P1C1/AMIFC, P1C0/FMIFC input (P1C1, P1C0) With clock stopped - 12 PD17704, 17705, 17707, 17708, 17709 Pin No. 30 79 Symbol VDD1 VDD0 Function Power supply. Supply the same voltage to these pins. * With CPU and peripheral function operating: 4.5 to 5.5 V * With CPU operating : 3.5 to 5.5 V * With clock stopped : 2.2 to 5.5 V PLL local oscillation (VCO) frequency input. * VCOH * Active with VHF mode selected by program; otherwise, pulled down. * VCOL * Active with HF or MW mode selected by program; otherwise, pulled down. Because the input of these pins goes into an AC amplifier, cut the DC component of the input signal with a capacitor. 34 35 EO0 EO1 Output from charge pump of PLL frequency synthesizer. Outputs the divided frequency of local oscillation and the result of comparison of the phase difference of reference frequency. At reset Power-ON reset High-impedance output 36 TEST WDT&SP reset High-impedance output CE reset High-impendance output High-impedance output - With clock stopped CMOS 3-state Output Form - 31 32 VCOH VCOL - Test input pin. Be sure to connect this pin to GND. Port 1D and BEEP output. * P1D3 through P1D0 * 4-bit I/O port * Can be set in input or output mode in 1-bit units. * BEEP1, BEEP0 * BEEP output At reset Power-ON reset Input (P1D3 through P1D0) WDT&SP reset Input (P1D3 through P1D0) CE reset Retained (P1D3 through P1D0) Retained (P1D3 through P1D0) With clock stopped 37 38 39 40 P1D3 P1D2 P1D1/BEEP1 P1D0/BEEP0 CMOS push-pull 43 | 46 P2B3 | P2B0 4-bit I/O Port. Can be set in input or output mode in 1-bit units. At reset Power-ON reset Input WDT&SP reset Input CE reset Retained Retained With clock stopped CMOS push-pull 47 | 50 P3C3 | P3C0 4-bit I/O Port. Can be set in input or output mode in 4-bit units. At reset Power-ON reset Input WDT&SP reset Input CE reset Retained Retained With clock stopped CMOS push-pull 13 PD17704, 17705, 17707, 17708, 17709 Pin No. 51 | 54 Symbol P3D3 | P3D0 Function 4-bit I/O Port. Can be set in input or output mode in 4-bit units. At reset Power-ON reset Input 55 | 58 P2C3 | P2C0 WDT&SP reset Input CE reset Retained Retained CMOS push-pull With clock stopped CE reset Retained Retained CMOS push-pull With clock stopped CE reset Retained Retained N-ch open-drain CMOS push-pull With clock stopped Output Form CMOS push-pull 4-bit I/O Port. Can be set in input or output mode in 4-bit units. At reset Power-ON reset Input WDT&SP reset Input 59 | 62 P0C3 | P0C0 4-bit I/O Port. Can be set in input or output mode in 4-bit units. At reset Power-ON reset Input WDT&SP reset Input 63 64 65 66 67 68 69 70 P0A3/DSA P0A2/SCL P0A1/SCK0 P0A0/SO0 P0B3/SI0 P0B2/SCK1 P0B1/SO1 P0B0/SI1 Ports P0A and P0B are multiplexed with I/O of serial interface. * P0A3 through P0A0 * 4-bit I/O port * Can be set in input or output mode in 1-bit units. * P0B3 through P0B0 * 4-bit I/O port * Can be set in input or output mode in 1-bit units. * SDA, SCL * Serial data and serial clock I/O of serial interface 0 in 2-wire serial I/O or I 2 C bus mode * SCK0, SO0, SI0 * Serial clock I/O, serial data output, and serial data input of serial interface 0 in 3-wire serial I/O mode * SCK1, SO1, SI1 * Serial clock I/O, serial data output, serial data input of serial interface 1 in 3-wire serial I/O mode At reset Power-ON reset Input P0A3 through P0A0, P0B3 through P0B0 WDT&SP reset Input P0A3 through P0A0, P0B3 through P0B0 CE reset Retained P0A3 through P0A0, P0B3 through P0B0 Retained P0A3 through P0A0, P0B3 through P0B0 With clock stopped 71 | 73 P2D2 | P2D0 3-bit I/O port. Can be set in input or output mode in 1-bit units. At reset Power-ON reset Input WDT&SP reset Input CE reset Retained Retained With clock stopped CMOS push-pull 14 PD17704, 17705, 17707, 17708, 17709 Pin No. 74 Symbol REG Function CPU regulator. Connect this pin to GND via 0.1-F capacitor. Ground pins of crystal resonator. Output Form - 76 77 78 XOUT XIN CE - Device operation-selection, CE reset, and interrupt signal input pin. * Device operation-select When CE is high, PLL frequency synthesizer can operate. When CE is low, PLL frequency synthesizer is automatically disabled internally. * CE reset When CE goes high, device is reset at rising edge of internal basic timer setting pulse. This pin also has reset timing delay function. * Interrupt Vectored interrupt occurs at falling edge of this pin. Reset input - 80 RESET - 15 PD17704, 17705, 17707, 17708, 17709 1.2 Equivalent Circuits of Pins (1) P0A (P0A1/SCK0, P0A0/SO0) P0B (P0B3/SI0, P0B2/SCK1, P0B1/SO1, P0B0/SI1) P0C (P0C3, P0C2, P0C1, P0C0) P1D (P1D3, P1D2, P1D1/BEEP1, P1D0/BEEP0) P2A (P2A2, P2A1/FCG1, P2A0/FCG0) P2B (P2B3, P2B2, P2B1, P2B0) P2C (P2C3, P2C2, P2C1, P2C0) P2D (P2D2, P2D1, P2D0) P3A (P3A3, P3A2, P3A1, P3A0) P3B (P3B3, P3B2, P3B1, P3B0) P3C (P3C3, P3C2, P3C1, P3C0) P3D (P3D3, P3D2, P3D1, P3D0) VDD (I/O) CKSTOPNote VDD Note This is an internal signal that is output when the clock stop instruction is executed, and its circuit is designed not to increase the current consumption due to noise even if it is floated. 16 PD17704, 17705, 17707, 17708, 17709 (2) P0A (P0A3/SDA, P0A2/SCL) (I/O) VDD CKSTOPNote Note This is an internal signal that is output when the clock stop instruction is executed, and its circuit is designed not to increase the current consumption due to noise even if it is floated. (3) P1B (P1B3, P1B2/PWM2, P1B1/PWM1, P1B0/PWM0) (output) (4) P0D (P0D3/AD3, P0D2/AD2, P0D1/AD1, P0D0/AD0) (input) A/D converter VDD CKSTOPNote P0DPLD flag High-ON resistance Note This is an internal signal that is output when the clock stop instruction is executed, and its circuit is designed not to increase the current consumption due to noise even if it is floated. 17 PD17704, 17705, 17707, 17708, 17709 (5) P1A (P1A1) (input) VDD CKSTOPNote Note This is an internal signal output on execution of the clock stop instruction, and its circuit is designed not to increase the current consumption due to noise even if the pin is floated. (6) P1C (P1C3/AD5, P1C2/AD4) (input) VDD A/D converter CKSTOPNote Note This is an internal signal output on execution of the clock stop instruction, and its circuit is designed not to increase the current consumption due to noise even if the pin is floated. (7) P1C (P1C1/AMIFC, P1C0/FMIFC) (input) VDD General-purpose port CKSTOPNote VDD High-ON resistance VDD Frequency counter Note This is an internal signal output on execution of the clock stop instruction, and its circuit is designed not to increase the current consumption due to noise even if the pin is floated. 18 PD17704, 17705, 17707, 17708, 17709 (8) CE RESET INT0, INT1, INT2 P1A (P1A3/INT4, P1A2/INT3, P1A0/TM0G) VDD (Schmitt trigger input) (9) XOUT (output), XIN (input) VDD High-ON resistance VDD XIN Internal clock High-ON resistance XOUT (10) EO1, EO0 (output) VDD DWN UP 19 PD17704, 17705, 17707, 17708, 17709 (11) VCOH, VCOL (Input) VDD High-ON resistance VDD High-ON resistance 20 PD17704, 17705, 17707, 17708, 17709 1.3 Connections of Unused Pins It is recommended to connect unused pins as follows: Table 1-1. Connections of Unused Pins (1/2) Pin Name Port pin P0D3/AD3-P0D0/AD0 P1C3/AD5 P1C2/AD4 P1C1/AMIFC Note 2 P1C0/FMIFC Note 2 P1A3/INT4 P1A2/INT3 P1A1 P1A0/TM0G P1B3 P1B2/PWM2-P1B0/PWM0 P0A3/SDA P0A2/SCL P0A1/SCK0 P0A0/SO0 P0B3/SI0 P0B2/SCK1 P0B1/SO1 P0B0/SI1 P0C3-P0C0 P1D3 P1D2 P1D1/BEEP1 P1D0/BEEP0 P2A2 P2A1/FCG1 P2A0/FCG0 P2B3-P2B0 P2C3-P2C0 P2D2-P2D0 N-ch open-drain output I/O Note 3 Set in general-purpose input port mode by software and individually connect to VDD or GND via resistor Note 1 . Set to low-level output by software and then open. Set in port mode and individually connect to VDD or GND via resistor Note 1 . Individually connect to GND via resistor Note 1 . I/O Mode Input Recommended Connections of Unused Pins Individually connect to GND via resistor Note 1 . Notes 1. If a pin is externally pulled up (connected to VDD via resistor) or pulled down (connected to GND via resistor) with a high resistance, the pin almost enters a high-impedance state, increasing the current (through-current) consumption of the port. Generally, the resistance of a pull-up or pulldown resistor is several 10 k, though it depends on the application circuit. 2. Do not set these pins as AMIFC and FMIFC pins; otherwise, the current consumption will increase. 3. The I/O ports are set in the general-purpose I/O port mode at power-ON reset, when reset by the RESET pin, or when reset due to overflow or underflow of the watchdog timer or the stack. 21 PD17704, 17705, 17707, 17708, 17709 Table 1-1. Connections of Unused Pins (2/2) Pin Name Port pin P3A3-P3A0 P3B3-P3B0 P3C3-P3C0 P3D3-P3D0 Pins other than port pins CE EO1 EO0 INT0-INT2 RESET TEST VCOH VCOL Input Input Input - Individually connect to GND via resistorNote 1 . Connect to VDD via resistor Note 1 . Directly connect to GND. Disable PLL via software and open. Input Output Connect to VDD via resistor Note 1 . Open I/O Mode I/O Note 2 Recommended Connections of Unused Pins Set in general-purpose input port mode by software and individually connect to VDD or GND via resistor Note 1 . Notes 1. If a pin is externally pulled up (connected to VDD via resistor) or pulled down (connected to GND via resistor) with a high resistance, the pin almost enters a high-impedance state, increasing the current (through-current) consumption of the port. Generally, the resistance of a pull-up or pulldown resistor is several 10 k, though it depends on the application circuit. 2. The I/O ports are set in the general-purpose input port mode at power-ON reset, when reset by the RESET pin, or when reset due to overflow or underflow of the watchdog timer or the stack. 22 PD17704, 17705, 17707, 17708, 17709 1.4 Cautions on Using CE, INT0 through INT4, and RESET Pins The CE, INT0 through INT4, and RESET pins have a function to set a test mode in which the internal operations of the PD17709 are tested (IC test), in addition to the functions listed in 1.1 Pin Function List. When a voltage exceeding VDD is applied to any of these pins, the device is set in the test mode. If a noise exceeding VDD is superimposed during normal operation, therefore, the test mode is set by mistake, hindering the normal operation. Especially if the wiring length of pins is too long, noise is superimposed on these pins. In consequence, the above problem occurs. Therefore, keep the wiring length as short as possible to prevent noise from being superimposed. noise. * Connect a diode with low VF between a pin and VDD. VDD VDD If superimposition of noise is unavoidable, connect an external component as illustrated below to suppress the * Connect a capacitor between a pin and VDD. Diode with low VF VDD VDD CE, INT0-INT4, RESET CE, INT0-INT4, RESET 1.5 Cautions on Using TEST Pin When VDD is applied to the TEST pin, the device is set in the test mode. Therefore, be sure to keep the wiring length of this pin as short as possible, and directly connect it to the GND pin. If the wiring length between the TEST pin and GND pin is too long, or if external noise is superimposed on the TEST pin, generating a potential difference between the TEST pin and GND pin, your program may not run normally. GND TEST Short 23 PD17704, 17705, 17707, 17708, 17709 2. PROGRAM MEMORY (ROM) 2.1 Outline of Program Memory Figure 2-1 outlines the program memory. As shown in this figure, the addresses of the program memory are specified by the program counter. The program memory has the following two major functions. * To store programs * To store constant data Figure 2-1. Outline of Program Memory Program counter Instruction ... Constant data ... 24 ... ... Address specification Program memory PD17704, 17705, 17707, 17708, 17709 2.2 Program Memory Figure 2-2 shows the configuration of the program memory. As shown in this figure, the PD17704 has 16K bytes (8192 x 16 bits) of program memory, the PD17707 has 24K bytes (12288 x 16 bits), and the PD17708 and 17709 have 32K bytes (16384 x 16 bits). Therefore, the program memory addresses of the PD17704 are 0000H through 1FFFH, those of the PD17705, 17707 are 0000H through 2FFFH, and those of the PD17708 and 17709 are 0000H through 3FFFH. Because all "instructions" are "one-word instructions", one instruction can be stored to 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 Address 0 0 0 0 H Reset start address 0 0 0 1 H Serial interface 1 interrupt vector 0 0 0 2 H Serial interface 0 interrupt vector 0 0 0 3 H Timer 3 interrupt vector 0 0 0 4 H Timer 2 interrupt vector 0 0 0 5 H Timer 1 interrupt vector 0 0 0 6 H Timer 0 interrupt vector 0 0 0 7 H INT4 pin interrupt vector 0 0 0 8 H INT3 pin interrupt vector 0 0 0 9 H INT2 pin interrupt vector 0 0 0 A H INT1 pin interrupt vector 0 0 0 B H INT0 pin interrupt vector 0 0 0 C H Falling edge interrupt vector of CE pin 0 7 FFH Page 1 0 FFFH Page 2 1 7 FFH Page 3 1 FFFH 2000H ( PD17704) Page 0 CALL addr instruction subroutine entry address Segment 0 BR addr instruction branch address MOVT DBF, @AR instruction table reference address Page 0 CALL addr instruction subroutine entry address BR @AR instruction branch address CALL @AR instruction subroutine entry address Page 1 2 FFFH ( PD17705, 17707) Segment 1 BR addr instruction (system segment) branch address Page 2 Page 3 3 FFFH ( PD17708, 17709) 16 bits 25 PD17704, 17705, 17707, 17708, 17709 2.3 Program Counter 2.3.1 Configuration of program counter Figure 2-3 shows the configuration of the program counter. As shown in this figure, the program counter consists of a 13-bit binary counter and a 1-bit segment register (SGR). Bits 11 and 12 of the program counter indicate a page. The program counter specifies an address of the program memory. Figure 2-3. Configuration of Program Counter SGR PC12 PC11 PC10 PC9 PC8 PC7 PC6 PC5 PC4 PC3 PC2 PC1 PC0 Page PC 2.3.2 Segment register (SGR) The segment register specifies a segment of the program memory. Table 2-1 shows the relationships between the segment register and program memory. The segment register is set only when the SYSCAL entry instruction is executed. Table 2-1. Relationships between Segment Register and Program Memory Value of Segment Register 0 1 Segment of Program Memory Segment 0 Segment 1 2.4 Flow of Program The flow of the program is controlled by the program counter that specifies an address of the program memory. The program flow when each instruction is executed is described below. Figure 2-5 shows the value that is set to the program counter when each instruction is executed. Table 2-2 shows the vector address when an interrupt is accepted. 2.4.1 Branch instruction (1) Direct branch ("BR addr") The branch destination address of the direct branch instruction is in the same segment of the program memory. In other words, a branch cannot be executed exceeding a segment. (2) Indirect branch ("BR @AR") The branch destination addresses of the indirect branch instruction are all the addresses of the program memory, i.e., addresses 0000H through 1FFFH for the PD17704, addresses 0000H through 2FFFH for the PD17705, 17707, and 0000H through 3FFFH for the PD17708 and 17709. For further information, also refer to 5.3 Address Register (AR). 26 PD17704, 17705, 17707, 17708, 17709 2.4.2 Subroutine (1) Direct subroutine call ("CALL addr") The first address of a subroutine that can be called by the direct subroutine instruction is in page 0 of each segment (addresses 0000H through 07FFH). (2) Indirect subroutine call (CALL @AR) The first addresses of a subroutine that can be called by the indirect subroutine call instruction are all the addresses of the program memory, i.e., addresses 000H through 1FFFH for the PD17704, addresses 0000H through 2FFFH for the PD17705, 17707, and 0000H through 3FFFH for the PD17708 and 17709. For further information, also refer to 5.3 Address Register (AR). 2.4.3 Table reference The addresses that can be referenced by the table reference instruction ("MOVT DBF, @AR") are all the addresses of the program memory, i.e., addresses 0000H through 1FFFH for the PD17704, addresses 0000H through 2FFFH for the PD17705, 17707, and 0000H through 3FFFH for the PD17708 and 17709. For further information, also refer to 5.3 Address Register (AR) and 9.2.2 Table reference instruction (MOVT, DBF, @AR). 2.4.4 System call The first address of a subroutine that can be called by the system call instruction ("SYSCAL entry") is the first 16 steps of each block (block 0 to 7) in page 0 of segment 1 (system segment). Figure 2-4. Outline of System Call Instruction Segment 0 00000H 02000H Block 0 0 2 0FFH 02100H Block 1 0 2 1FFH 02200H Block 2 Page 0 (16 bits x 2K steps) 0 2 2FFH . . . . 02700H Block 7 0 0 7FFH 00800H Page 1 0 0FFFH 01000H Page 2 0 1 7FFH 01800H Page 3 0 1FFFH (16 bits x 8K steps) 0 3FFFH (16 bits x 8K steps) 0 3 7FFH 03800H Page 3 0 2FFFH 03000H Page 2 0 2 7FFH 02800H Page 1 Area where entry address of system segment can be specified 0 2 0 0FH Segment 1 (system segment) 02000H Block 0 of segment 1 Entry address of SYSCAL instruction 27 PD17704, 17705, 17707, 17708, 17709 Figure 2-5. Value of Program Counter Upon Execution of Instruction Program counter Instruction BR addr Page 0 Page 1 Page 2 Page 3 CALL addr Retained Retained Contents of Program Counter (PC) SGR b12 0 0 1 1 0 b11 0 1 0 Operand of instruction (addr) 1 0 Operand of instruction (addr) b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 SYSCAL entry 1 BR @AR CALL @AR Contents of address register MOVT DBF, @AR RET RETSK RETI Other instructions (including skip instruction) When interrupt is accepted 0 Power-ON reset, watchdog timer reset, 0 RESET pin, CE reset entryH : high-order 3 bits of entry entryL : low-order 4 bits of entry 0 0 0 0 0 0 0 0 0 0 0 0 0 Vector address of each interrupt Retained 0 0 entryH 0 0 0 0 entryL Contents of address stack register (ASR) (return address) specified by stack pointer (SP) Increment Table 2-2. Interrupt Vector Address Order 1 2 3 4 5 6 7 8 9 10 11 12 Internal/External External External External External External External Internal Internal Internal Internal Internal Internal Interrupt Source Falling edge of CE pin INT0 pin INT1 pin INT2 pin INT3 pin INT4 pin Timer 0 Timer 1 Timer 2 Timer 3 Serial interface 0 Serial interface 1 Vector Address 00CH 00BH 00AH 009H 008H 007H 006H 005H 004H 003H 002H 001H 28 PD17704, 17705, 17707, 17708, 17709 2.5 Cautions on Using Program Memory 2.5.1 Last address in each segment The segment register is not connected to the binary counter. Therefore, address 0000H of segment 0 is specified next to address 1FFFH, which is the last address of segment 0. To specify between segments, a dedicated instruction such as an indirect branch, indirect subroutine call, or system call instruction is used. 29 PD17704, 17705, 17707, 17708, 17709 3. ADDRESS STACK (ASK) 3.1 Outline of Address Stack Figure 3-1 outlines the address stack. The address stack consists of a stack pointer and address stack registers. The address of an address stack register is specified by the stack pointer. The address stack saves a return address when a subroutine call instruction is executed or when an interrupt is accepted. The address stack is also used when the table reference instruction is executed. Figure 3-1. Outline of Address Stack Stack pointer Address specification Address stack register 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 sixteen 16-bit registers ASR0 through ASR15. Actually, however, it consists of fifteen 16-bit registers (ASR0 through ASR14) because no register is allocated to ASR15. The address stack saves a return address when a subroutine is called, when an interrupt is accepted, and when the table reference instruction is executed. 30 PD17704, 17705, 17707, 17708, 17709 Figure 3-2. Configuration of Address Stack Register Stack pointer (SP) Bit b3 b2 b1 b0 0H Address Address stack register (ASR) Bit b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 SP3 SP2 SP1 SP0 ASR0 1H ASR1 2H ASR2 3H ASR3 4H ASR4 5H ASR5 6H ASR6 7H ASR7 8H ASR8 9H ASR9 AH ASR10 BH ASR11 CH ASR12 DH ASR13 EH ASR14 FH ASR15 (Undefined) Cannot be used 31 PD17704, 17705, 17707, 17708, 17709 3.3 Stack Pointer (SP) 3.3.1 Configuration and function of stack pointer Figure 3-3 shows the configuration and functions of the stack pointer. The stack pointer consists of a 4-bit binary counter. It specifies the address of an address stack register. A value can be directly read from or written to the stack pointer by using a register manipulation instruction. Figure 3-3. Configuration and Function of Stack Pointer Name Flag symbol b3 b2 b1 b0 Stack pointer (SP) 01H R/W Address Read/Write ( ( ( ( ( S P 3 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 ( S P 2 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 ( S P 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 1 ( S P 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 Specifies address of address stack register (ASR) Address 0 (ASR0) Address 1 (ASR1) Address 2 (ASR2) Address 3 (ASR3) Address 4 (ASR4) Address 5 (ASR5) Address 6 (ASR6) Address 7 (ASR7) Address 8 (ASR8) Address 9 (ASR9) Address 10 (ASR10) Address 11 (ASR11) Address 12 (ASR12) Address 13 (ASR13) Address 14 (ASR14) Setting prohibited At reset Power-ON reset WDT&SP reset CE reset Clock stop Retained Power-ON reset : Reset by RESET pin up on power application WDT&SP reset : Reset by watchdog timer and stack pointer CE reset Clock stop : CE reset : Upon execution of clock stop instruction 32 PD17704, 17705, 17707, 17708, 17709 3.4 Operation of Address Stack 3.4.1 Subroutine call instruction ("CALL addr", "CALL @AR") and return instruction ("RET", "RETSK") When a subroutine call instruction is executed, the value of the stack pointer is decremented by one, and the return address is stored to an address stack register specified by the stack pointer. When the return instruction is executed, the contents of the address stack register (return address) specified by the stack pointer are 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 incremented by one, and the return address is stored to an address stack register specified by the stack pointer. Next, the contents of the program memory specified by the address register are read to the data buffer, the contents of the address stack register (return value) specified by the stack pointer are restored to the program counter, and the value of the stack pointer is incremented by one. 3.4.3 When interrupt is accepted and on execution of return instruction ("RETI") When an interrupt is accepted, the value of the stack pointer is decremented by one, and the return address is stored to an address stack register specified by the stack pointer. When the return instruction is executed, the contents of an address stack register (return value) specified by the stack pointer are restored to the program counter, and the value of the stack pointer is incremented by one. 3.4.4 Address stack manipulation instruction ("PUSH AR", "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 an address stack register specified by the stack pointer. When the "POP" instruction is executed, the contents of an 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.4.5 System call instruction ("SYSCAL entry") and return instruction ("RET", "RETSK") When the "SYSCAL entry" instruction is executed, the value of the stack pointer is decremented by one, and the return address and the value of the segment register are stored to an address stack register specified by the stack pointer. When the return instruction is executed, the contents of an address stack register (return value) specified by the stack pointer are restored to the program counter and segment register, and the value of the stack pointer is incremented by one. 33 PD17704, 17705, 17707, 17708, 17709 3.5 Cautions on Using Address Stack 3.5.1 Nesting level and operation on overflow The value of address stack register (ASR15) is "undefined" when the value of the stack pointer is 0FH. Accordingly, if a subroutine call or system call exceeding 15 levels, or an interrupt is used without manipulating the stack, execution returns to an "undefined" address. 3.5.2 Reset on detection of overflow or underflow of address stack Whether the device is reset on detection of overflow or underflow of the address stack can be specified by program. At reset, the program is started from address 0, and some control registers are initialized. This reset function is valid at power-ON reset or reset by the RESET pin. For details, refer to 21. RESET. 34 PD17704, 17705, 17707, 17708, 17709 4. DATA MEMORY (RAM) 4.1 Outline of Data Memory Figure 4-1 outlines the data memory. As shown in the figure, system registers, a data buffer, port registers, and port input/output selection registers are located on the data memory. The data memory stores data, transfers data with the peripheral hardware or ports, and controls the CPU. Figure 4-1. Outline of Data Memory (1/3) (a) PD17709 Peripheral hardware Data transfer Column address 0 0 1 Row address 1 2 3 4 5 6 7 8 9 A B C D E F Data buffer 2 3 4 5 6 7 Port registers Port registers Port registers Port registers BANK0 BANK1 BANK2 BANK3 BANK4 ... Data memory ... .. BANK14 BANK15Note System registers Data transfer Ports Note Port input/output selection registers are allocated to addresses 60H through 6FH of BANK 15. 35 PD17704, 17705, 17707, 17708, 17709 Figure 4-1. Outline of Data Memory (2/3) (b) PD17707, 17708 Peripheral hardware Data transfer Column address 0 0 1 Row address 1 2 3 4 5 6 7 8 9 A B C D E F Data buffer 2 3 4 5 6 7 Port registers Port registers Port registers Port registers BANK0 BANK1 BANK2 BANK3 BANK4 ... ... Data memory .. BANK9 BANK15Note System registers Data transfer Ports Note Port input/output selection registers are allocated to addresses 60H through 6FH of BANK 15. Cautions 1. The PD17707 and 17708 do not have BANKs 10 through 14. 2. Nothing is allocated to addresses 00H through 5FH of BANK15. 36 PD17704, 17705, 17707, 17708, 17709 Figure 4-1. Outline of Data Memory (3/3) (c) PD17704, 17705 Peripheral hardware Data transfer Column address 0 0 1 Row address 2 3 4 5 6 7 Port registers Port registers Port registers Port registers BANK0 BANK1 BANK2 BANK3 BANK4 BANK5 BANK15Note System registers Data memory 1 2 3 4 5 6 7 8 9 A B C D E F Data buffer Data transfer Ports Note Port input/output selection registers are allocated to addresses 60H through 6FH of BANK 15. Cautions 1. The PD17704 and 17705 do not have BANKs 6 through 14. 2. Nothing is allocated to addresses 00H through 5FH of BANK15. 37 PD17704, 17705, 17707, 17708, 17709 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 several banks with each bank made up of a total of 128 nibbles with 7H row addresses and 0FH column addresses. The data memory can be divided into five functional blocks. Each block is described in 4.2.1 through 4.2.5 below. The contents of the data memory can be operated on, compared, judged, and transferred in 4-bit units with a single data memory manipulation instruction. 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. Because the system registers are allocated to all banks, the same system registers exist at addresses 74H through 7FH of any bank. 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 BANK 0. For details, refer to 9. DATA BUFFER (DBF). 4.2.3 Port registers The port registers are allocated to addresses 70H through 73H of BANKs 0 through 3. For details, refer to 11. GENERAL-PURPOSE PORTS. 4.2.4 Port input/output selection registers Port input/output selection registers are allocated to addresses 60H through 6FH of BANK15. For details, refer to 8.4 Port Input/Output Selection Register. 4.2.5 General-purpose data memory The general-purpose data memory is allocated to the addresses of the data memory excluding those of the system registers, port registers, and port input/output selection registers. (a) PD17709 The general-purpose data memory of the PD17709 consists of a total of 1776 nibbles of the 112 nibbles each of BANKs 0 through 15 (BANK15 only has 96 nibbles). (b) PD17707, 17708 The general-purpose data memory of the PD17707 and 17708 consists of a total of 1120 nibbles of the 112 nibbles each of BANKs 0 through 9. (c) PD17704, 17705 The general-purpose data memory of the PD17704 and 17705 consists of a total of 672 nibbles of the 112 nibbles each of BANKs 0 through 5. 38 PD17704, 17705, 17707, 17708, 17709 Figure 4-2. Configuration of Data Memory (1/3) (a) PD17709 BANK0 Column address 0 1 2 3 4 5 6 7 8 9 ABCDE F 0 1 2 3 4 5 6 7 0 1 Column address 0123456789ABCDEF Data buffer Row address Row address Data memory 2 3 4 5 6 7 Port register System registers (SYSREG)Note General registers BANK0 BANK1 BANK2 BANK14 BANK15 System registers Row address Row address Row address ... Example Address 51H of BANK 0 b3 b2 b1 b0 BANK1-BANK3 Column address 0123456789ABCDEF 0 1 2 3 4 5 6 7 Port register System registers (SYSREG)Note BANK4-BANK14 Column address 0123456789ABCDEF 0 1 2 3 4 5 6 7 Fixed to 0 System registers (SYSREG)Note BANK15 Column address 0123456789ABCDEF 0 1 2 3 4 5 6 7 Port input/output selection registers Fixed to 0 System registers (SYSREG)Note Note An identical system register exists. 39 PD17704, 17705, 17707, 17708, 17709 Figure 4-2. Configuration of Data Memory (2/3) (b) PD17707, 17708 BANK0 Column address 0 1 2 3 4 5 6 7 8 9 ABCDE F 0 1 2 3 4 5 6 7 0 1 Row address Data memory 2 3 4 5 6 7 Port register System registers (SYSREG)Note General registers Row address Column address 0123456789ABCDEF Data buffer BANK0 BANK1 BANK2 Row address Row address Row address Note An identical system register exists. Cautions 1. The PD17707 and 17708 do not have BANKs 10 through 14. 2. Nothing is allocated to addresses 00H through 5FH of BANK15. ... BANK9 BANK15 System registers Example Address 51H of BANK 0 b3 b2 b1 b0 BANK1-BANK3 Column address 0123456789ABCDEF 0 1 2 3 4 5 6 7 Port register System registers (SYSREG)Note BANK4-BANK9 Column address 0123456789ABCDEF 0 1 2 3 4 5 6 7 Fixed to 0 System registers (SYSREG)Note BANK15 Column address 0123456789ABCDEF 0 1 2 3 4 5 6 7 Port input/output selection registers Fixed to 0 System registers (SYSREG)Note Nothing is allocated 40 PD17704, 17705, 17707, 17708, 17709 Figure 4-2. Configuration of Data Memory (3/3) (c) PD17704, 17705 BANK0 Column address 0 1 2 3 4 5 6 7 8 9 ABCDE F 0 1 2 3 4 5 6 7 0 1 Row address Row address Column address 0123456789ABCDEF Data buffer Data memory 2 3 4 5 6 7 Port register System registers (SYSREG)Note General registers BANK0 BANK1 BANK2 ... BANK5 BANK15 System registers BANK1-BANK3 Column address 0123456789ABCDEF Row address Example Address 51H of BANK 0 b3 b2 b1 b0 0 1 2 3 4 5 6 7 Port register System registers (SYSREG)Note BANK4, BANK5 Column address 0123456789ABCDEF 0 1 Row address 2 3 4 5 6 7 Fixed to 0 System registers (SYSREG)Note BANK15 Column address 0123456789ABCDEF 0 1 Row address 2 3 4 5 6 7 Port input/output selection registers Fixed to 0 System registers (SYSREG)Note Note An identical system register exists. Cautions 1. The PD17704 and 17705 do not have BANKs 6 through 14. 2. Nothing is allocated to addresses 00H through 5FH of BANK15. 41 PD17704, 17705, 17707, 17708, 17709 Table 4-1. Data Memory Manipulation Instructions Function Operation Add Instruction ADD ADDC SUB SUBC AND OR XOR SKE SKGE SKLT SKNE MOV LD ST SKT SKF Subtract Logic Compare Transfer Judge 4.3 Data Memory Addressing Figure 4-3 shows address specification of the data memory. An address of the data memory is specified by a bank, row address, and column address. A row address and a column address are directly specified by a data memory manipulation instruction. However, a bank is specified by the contents of a bank register. For the details of the bank register, refer to 5. SYSTEM REGISTER (SYSREG). Figure 4-3. Address Specification of Data Memory Bank b3 Data memory address Bank register Instruction operand b2 b1 b0 Row address b2 b1 b0 Column address b3 b2 b1 b0 42 PD17704, 17705, 17707, 17708, 17709 4.4 Cautions on Using Data Memory 4.4.1 At power-ON reset The contents of the general-purpose data memory are "undefined" at power-ON reset. Initialize the data memory as necessary. 4.4.2 Cautions on data memory not provided If a data memory manipulation instruction that reads the data memory is executed to a data memory address not provided, undefined data is read. Nothing is changed even if data is written to such an address. 43 PD17704, 17705, 17707, 17708, 17709 5. SYSTEM REGISTERS (SYSREG) 5.1 Outline of System Registers Figure 5-1 shows the location of the system registers on the data memory and their outline. As shown in the figure, the system registers are allocated to addresses 74H through 7FH of all the banks of the data memory. Therefore, identical system registers exist at addresses 74H through 7FH of any bank. Because the system registers are located on the data memory, they can be manipulated by all data memory manipulation instructions. Seven types of system registers are available depending on function. Figure 5-1. Location and Outline of System Registers on Data Memory Column address 0 0 1 1 2 3 4 5 6 7 8 9 A B C D E F Row address 2 3 4 5 6 7 BANK0 BANK1 BANK2 Data memory Remark The PD17704 and 17705 do not have the BANKs 6 through 14. The PD17707 and 17708 do not have BANKs 10 through 14. Address Name 74H 75H 76H 77H 78H Window register (WR) 79H Bank register (BANK) 7AH 7BH Index register (IX) Data memory row address pointer (MP) Function Controls program memory address Transfers Specifies Modifies address of data memory Specifies data with register file bank of data memory address of general register 7CH 7DH 7EH 7FH ... ... BANK14 BANK15 System register Address register (AR) General register Program pointer (RP) status word (PSWORD) Controls operation 44 PD17704, 17705, 17707, 17708, 17709 5.2 System Register List Figure 5-2 shows the configurations of the system registers. Figure 5-2. Configuration of System Registers Address Name 74H 75H 76H 77H 78H 79H 7AH 7BH 7CH 7DH 7EH 7FH System registers Address register (AR) Window register (WR) Bank register Index register (IX) General register Program pointer (RP) status word (PSWORD) (BANK) Data memory row address pointer (MP) Symbol AR3 AR2 AR1 AR0 WR BANK IXH MPH IXM MPL IXL RPH RPL PSW Bit Data 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 b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 M P0 E (MP) (IX) (RP) BCCZ I CMY DP X E 45 PD17704, 17705, 17707, 17708, 17709 5.3 Address Register (AR) 5.3.1 Configuration of address register Figure 5-3 shows the configuration of the address register. As shown in the figure, the address register consists of 16 bits of system register addresses 74H through 77H (AR3 through AR0). Figure 5-3. Configuration of Address Register Address Name Symbol Bit Data b3 74H 75H 76H 77H Address register (AR) AR3 b2 b1 b0 b3 AR2 b2 b1 b0 b3 AR1 b2 b1 b0 b3 AR0 b2 b1 b0 M S B L S B Power-ON reset WDT&SP reset CE reset Clock stop 0 0 0 Retained 0 0 0 Retained 0 0 0 Retained 0 0 0 Retained At reset Power-ON reset : Reset by RESET pin on power application WDT&SP reset : Reset by watchdog timer and stack pointer CE reset Clock stop : CE reset : On execution of clock stop instruction 46 PD17704, 17705, 17707, 17708, 17709 5.3.2 Function of address register The address register specifies a program memory address when the table reference instruction ("MOVT DBF, @AR"), stack manipulation instruction ("PUSH AR", "POP AR"), indirect branch instruction ("BR @AR"), or indirect subroutine call instruction ("CALL @AR") is executed. A dedicated instruction ("INC AR") is available that can increment the contents of the address instruction by one. The following paragraphs (1) through (5) describe the operation of the address register when the respective instructions are executed. (1) Table reference instruction ("MOVT DBF, @AR") When the table reference instruction is executed, the constant data (16 bits) of a program memory address specified by the contents of the address register are read to the data buffer. The constant data that can be specified by the address register is stored to address 0000H to 1FFFH in the case of PD17704, address 0000H to 2FFFH in the case of the PD17705 and 17707, and address 0000H to 3FFFH in the case of the PD17708 and 17709. (2) Stack manipulation instruction ("PUSH AR", "POP AR") When the "PUSH AR" instruction is executed, the value of the stack pointer is decremented by one, and the contents of the address register (AR) are transferred to an address stack register specified by the stack pointer whose value has been decremented by one. When the "POP AR" instruction is executed, the contents of an 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) Indirect branch instruction ("BR @AR") When this instruction is executed, the program branches to a program memory address specified by the contents of the address register. The branch address that can be specified by the address register is 0000H to 1FFFH in the case of PD17704, 0000H to 2FFFH in the case of the PD17705 and 17707, and 0000H to 3FFFH in the case of the PD17705 and 17708 and 17709. (4) Indirect subroutine call instruction ("CALL @AR") The subroutine at a program memory address specified by the contents of the address register can be called. The first address of the subroutine that can be specified by the address register is 0000H to 1FFFH in the case of the PD17704, 0000H to 2FFFH in the case of the PD17705 and 17707, and 0000H to 3FFFH in the case of the PD17708 and 17709. (5) Address register increment instruction ("INC AR") This instruction increments the contents of the address register by one. 5.3.3 Address register and data buffer The address register can transfer data as part of the peripheral hardware via the data buffer. For details, refer to 9. DATA BUFFER (DBF). 47 PD17704, 17705, 17707, 17708, 17709 5.3.4 Cautions on Using Address Register Because the address register is configured in 16 bits, it can specify an address up to FFFFH. However, the program memory exists at addresses 0000H to 1FFFH in the case of PD17704, 0000H to 2FFFH in the case of the PD17705 and 17707 and 0000H to 3FFFH in the case of the PD17708 and 17709. Therefore, the maximum value that can be set to the address register of the PD17704 is address 1FFFH. In the case of the PD17705 and 17707, it is address 2FFFH. In the case of the PD17708 and 17709, it is address 3FFFH. 5.4 Window Register (WR) 5.4.1 Configuration of window register Figure 5-4 shows the configuration of the window register. As shown in the figure, the window register consists of 4 bits of system register address 78H (WR). Figure 5-4. Configuration of Window Register Address Name 78H Window register (WR) Symbol Bit Data b3 WR b2 b1 b0 M S B L S B Power-ON reset WDT&SP reset CE reset Clock stop Undefined Retained 5.4.2 Function of window register The window register is used to transfer data with the register file (RF) to be described later. Data transfer between the window register and register file is manipulated by using dedicated instructions "PEEK WR, rf" and "POKE, rf WR" (rf: address of register file). The following paragraphs (1) and (2) describe the operation of the window register when these instructions are executed. For further information, also refer to 8. REGISTER FILE (RF). (1) "PEEK WR, rf" instruction When this instruction is executed, the contents of the register file addressed by "rf" are transferred to the window register. (2) "POKE rf, WR" instruction When this instruction is executed, the contents of the window register are transferred to the register file addressed by "rf". 48 At reset PD17704, 17705, 17707, 17708, 17709 5.5 Bank Register (BANK) 5.5.1 Configuration of bank register Figure 5-5 shows the configuration of the bank register. As shown in the figure, the bank register consists of 4 bits of system register address 79H (BANK). Figure 5-5. Configuration of Bank Register Address Name 79H Bank register (BANK) Symbol Bit Data b3 M S B Power-ON reset WDT&SP reset CE reset Clock stop 0 0 0 Retained BANK b2 b1 b0 L S B 5.5.2 Function of bank register The bank register specifies a bank of the data memory. Table 5-1 shows the relationships between the value of the bank register and a bank of the data memory that is specified. Because the bank register is one of the system registers, its contents can be rewritten regardless of the bank currently specified. When manipulating a bank register, therefore, the status of the bank at that time is irrelevant. Table 5-1. Data Memory Bank Specification Bank Register (BANK) b3 0 0 0 0 0 0 0 0 b2 0 0 0 0 1 1 1 1 b1 0 0 1 1 0 0 1 1 b0 0 1 0 1 0 1 0 1 BANK0 BANK1 BANK2 BANK3 BANK4 BANK5 BANK6Note BANK7 Note Bank of Data Memory At reset Bank Register (BANK) b3 1 1 1 1 1 1 1 1 b2 0 0 0 0 1 1 1 1 b1 0 0 1 1 0 0 1 1 b0 0 1 0 1 0 1 0 1 Bank of Data Memory BANK8Note BANK9Note BANK10Note BANK11Note BANK12Note BANK13Note BANK14Note BANK15 Note Do not set BANKs 6 through 14 in the PD17704 and 17705, and BANKs 10 through 14 in the PD17707 and 17708 because these banks are not provided. Caution The area to which the data memory is allocated differs depending on the model. For details, refer to Figure 4-2 Configuration of Data Memory. 49 PD17704, 17705, 17707, 17708, 17709 5.6 Index Register (IX) and Data Memory Row Address Pointer (MP: memory pointer) 5.6.1 Configuration of index register and data memory row address pointer Figure 5-6 shows the configuration of the index register and data memory row address pointer. As shown in the figure, the index register consists of an index register (IX) made up of 11 bits (the low-order 3 bits (IXH) of system register address 7AH, and 7BH and 7CH (IXM, IXL)) and an index enable flag (IXE) at the lowest bit position of 7FH (PSW). The data memory row address pointer (memory pointer) consists of a data memory row address pointer (MP) that is made up of 7 bits of the low-order 3 bits of 7AH (MPH) and 7BH (MPL), and a data memory row address pointer enable flag (memory pointer enable flag: MPE) at the lowest bit position of 7AH (MPH). In other words, the high-order 7 bits of the index register are shared with the data memory row address pointer Figure 5-6. Configuration of Index Register and Data Memory Row Address Pointer Address Name 7AH 7BH Index register (IX) 7CH 7EH 7FH Program status word (PSWORD) Memory pointer (MP) Symbol IXH MPH Bit Data M P E b3 b2 M S B M S B MP 0 0 0 Retained 0 0 0 Retained Power-ON reset WDT&SP reset CE reset Clock stop R: retained IX L S B 0 0 0 Retained b1 b0 b3 IXM MPL b2 b1 b0 b3 b2 b1 b0 L S B b3 b2 b1 IXL PSW b0 b3 b2 b1 b0 I X E At reset 0 0 0 R 50 PD17704, 17705, 17707, 17708, 17709 5.6.2 Functions of index register and data memory row address pointer The index register and data memory row address pointer modify the addresses of the data memory. The following paragraphs (1) and (2) describe their functions. A dedicated instruction ("INC IX") that increments the value of the index register by one is available. For the details of address modification, refer to 7. ALU (Arithmetic Logic Unit) BLOCK. (1) Index register (IX) When a data memory manipulation instruction is executed, the data memory address is modified by the contents of the index register. This modification, however, is valid only when the IXE flag is set to 1. To modify the address, the bank, row address, and column address of the data memory are ORed with the contents of the index register, and the instruction is executed to a data memory address (called real address) specified by the result of this OR operation. All data memory manipulation instructions are subject to address modification by the index register. The following instructions, however, are not subject to address modification by the index register. INC INX MOVT PUSH POP PEEK POKE GET PUT BR BR AR IX DBF, @AR AR AR WR,rf rf,WR DBF,p p, DBF addr @AR RORC CALL CALL RET RETSK RETI EI DI STOP s HALT h NOP r addr @AR (2) Data memory row address pointer (MP) When the general register indirect transfer instruction ("MOV @r,m" or "MOV m,@r") is executed, the indirect transfer destination address is modified. This modification, however, is valid only when the MPE flag is set to 1. To modify the address, the bank and row address at the indirect transfer destination are replaced by the contents of the data memory row address pointer. Instructions other than the general register indirect transfer instruction are not subject to address modification. (3) Index register increment instruction ("INC IX") This instruction increments the contents of the index register by one. Because the index register is configured of 10 bits, its contents are incremented to "000H" if the "INC IX" instruction is executed when the contents of the index register are "3FFH". 51 PD17704, 17705, 17707, 17708, 17709 5.7 General Register Pointer (RP) 5.7.1 Configuration of General Register Pointer Figure 5-7 shows the configuration of the general register pointer. As shown in the figure, the general register pointer consists of 7 bits including 4 bits of system register address 7DH (RPH) and the high-order 3 bits of address 7EH (RPL). Figure 5-7. Configuration of General Register Pointer Address Name 7DH General register pointer (RP) 7EH Symbol Bit Data b3 RPH b2 b1 b0 b3 RPL b2 b1 b0 M S B L S B B C D Power-ON reset WDT&SP reset CE reset Clock stop 0 0 0 Retained 0 0 0 At reset Retained 52 PD17704, 17705, 17707, 17708, 17709 5.7.2 Function of general register pointer The general register pointer specifies a general register on the data memory. Figure 5-8 shows the addresses of the general registers specified by the general register pointer. As shown in the figure, a bank is specified by the high-order 4 bits (RPH: address 7DH) of the general register pointer, and a row address is specified by the low-order 3 bits (RPL: address 7EH). Because the valid number of bits of the general register pointer is 7, all the row addresses (0H through 7FH) of all the banks can be specified as general registers. For the details of the operation of the general register, refer to 6. GENERAL REGISTER (GR). Figure 5-8. Address of General Register Specified by General Register Pointer General register pointer (RP) RPH b3 RPL b0 b3 b2 b1 b2 b1 b0 M S B L S B B C D Specifies row address of each bank Specifies bank Bank 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 1 BANK0 Row address 0H 1H 2H 3H 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 0 1 0 1 BANK15 4H 5H 6H 7H Remark The PD17704 and 17705 do not have BANKs 6 through 14. The PD17707 and 17708 do not have BANKs 10 through 14. Caution The area to which the data memory is allocated differs depending on the model. For details, refer to Figure 4-2 Configuration of Data Memory. 5.7.3 Cautions on using general register pointer The lowest bit of address 7EH (RPL) of the general register pointer is allocated as the BCD flag of the program status word. When rewriting RPL, therefore, pay attention to the value of the BCD flag. 53 PD17704, 17705, 17707, 17708, 17709 5.8 Program Status Word (PSWORD) 5.8.1 Configuration of program status word Figure 5-9 shows the configuration of the program status word. As shown in the figure, th program status word consists of a total of 5 bits including the lowest bit of system register address 7EH (RPL) and 4 bits of address 7FH (PSW). Each bit of the program status word has its own function. The 5 bits of the program status word are BCD flag (BCD), compare flag (CMP), carry flag (CY), zero flag (Z), and index enable flag (IXE). Figure 5-9. Configuration of Program Status Word Address Name 7EH 7FH Program status word (PSWORD) Symbol Bit Data b3 RPL b2 b1 b0 B C D b3 C M P PSW b2 C Y b1 Z b0 I X E At reset Power-ON reset WDT&SP reset CE reset Clock stop 0 0 0 Retained 0 0 0 Retained 54 PD17704, 17705, 17707, 17708, 17709 5.8.2 Function of program status word The program status word is a register that sets the conditions under which the ALU (Arithmetic Logic Unit) executes an operation or data transfer, or indicates the result of an operation. 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. Outline of Function of Each Flag of Program Status Word (RP) Program Status Word (PSWORD) RPL b3 b2 b1 b0 B C D b3 C M P PSW b2 C Y b1 Z b0 I X E Flag Name Index enable flag (IXE) Function Modifies address of data memory when data memory manipulation instruction is exeuted. 0 : Does not modify 1 : Modifies Zero flag (Z) Indicates result of arithmetic operation is zero. Status of this flag differs depending on contents of compare flag. Carry flag (CY) Indicates occurrence of carry or borrow as result of execution of addition or subtraction instruction. This flag is reset to 0 if no carry or borrow occurs. It is set to 1 if carry or borrow occurs. This flag is also used as shift bit of "RORC r" instruction. Compare flag (CMP) Indicates whether result of arithmetic operation is stored to data memory or general register. 0 : Stores result. 1 : Does not store result. BCD flag (BCD) Indicates whether arithmetic operation is performed in decimal or binary. 0 : Binary operation 1 : Decimla operation 5.8.3 Cautions on using program status word When an arithmetic operation (addition or subtraction) is executed to the program status word, the "result" of the arithmetic operation is stored. For example, even if an operation that generates a carry is executed, if the result of the operation is 0000B, 0000B is stored to the PSW. 55 PD17704, 17705, 17707, 17708, 17709 6. GENERAL REGISTER (GR) 6.1 Outline of General Register Figure 6-1 outlines the general register. As shown in the figure, the general register is specified in the data memory by the general register pointer. The bank and row address of the general register are specified by the general register pointer. The general register is used to transfer or operate data between data memory addresses. Figure 6-1. Outline of General Register Column address Data memory General register pointer Row address General register Transfer, operation BANK0 BANK1 BANK2 Remark The PD17704 and 17705 do not have BANKs 6 through 14. The PD17707 and 17708 do not have BANKs 10 through 14. BANK14 BANK15 System register 6.2 General Register The general register consists of 16 nibbles (16 x 4 bis) of the same row address on the data memory. For the range of the banks and row addresses that can be specified by the general register pointer as a general register, refer to 5.7 General Register Pointer (RP). The 16 nibbles of the same row address specified as a general register operate or transfer data with the data memory by a single instruction. In other words, operation or data transfer between data memory addresses can be executed by a single instruction. The general register can be controlled by the data memory manipulation instruction, like the other data memory areas. 56 PD17704, 17705, 17707, 17708, 17709 6.3 Generating Address of General Register by Each Instruction The following sections 6.3.1 and 6.3.2 explain how the address of the general register is generated when each instruction is executed. For the details of the operation of each instruction, refer to 7. ALU (Arithmetic Logic Unit) BLOCK. 6.3.1 Add ("ADD r, m", "ADDC r, m") , subtract ("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"), and rotation ("RORC r") instructions Table 6-1 shows the address of the general register specified by operand "r" of an instruction. Operand "r" of an instruction specifies only a column address. Table 6-1. Generating Address of General Register Bank b3 General register address b2 b1 b0 Row address b2 b1 b0 Column address b3 b2 r b1 b0 Contents of general register pointer 6.3.2 Indirect transfer ("MOV @r, m", "MOV m, @r") instruction Table 6-2 shows a general register address specified by instruction operand "r" and an indirect transfer address specified by "@r". Table 6-2. Generating Address of General Register Bank b3 General register address Contents of general register pointer Indirect transfer address Same as data memory Contents of "r" r b2 b1 b0 Row address b2 b1 b0 Column address b3 b2 b1 b0 6.4 Cautions on Using General Register 6.4.1 Row address of general register Because the row address of the general register is specified by the general register pointer, the currently specified bank may differ from the bank of the general register. 6.4.2 Operation between general register and immediate data No instruction is available that executes an operation between the general register and immediate data. To execute an operation between the general register and immediate data, the general register must be treated as a data memory area. 57 PD17704, 17705, 17707, 17708, 17709 7. ALU (Arithmetic Logic Unit) BLOCK 7.1 Outline of ALU Block Figure 7-1 outlines the ALU block. As shown in the figure, the ALU block consists of an ALU, temporary registers A and B, program status word, decimal adjustment circuit, and memory address control circuit. The ALU operates on, judges, compares, rotates, and transfers 4-bit data in the data memory. Figure 7-1. Outline of ALU Block Data bus Address control Temporary register A Temporary register B Program status word Index modification memory pointer Carry/borrow/zero detection/decimal/storage specification ALU * Arithmetic operation * Logical operation * Bit judgment * Comparison * Rotation * Transfer Data memory Decimal adjustment 58 PD17704, 17705, 17707, 17708, 17709 7.2 Configuration and Function of Each Block 7.2.1 ALU The ALU performs arithmetic operation, logical operation, bit judgment, comparison, rotation, and transfer of 4-bit data according to instructions specified by the program. 7.2.2 Temporay registers A and B Temporary registers A and B temporarily store 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 operation of and stores the status of the ALU. For further information on the program status word, also refer to 5.8 Program Status Word (PSWORD). 7.2.4 Decimal adjustment circuit The decimal adjustment circuit converts the result of an arithmetic operation into a decimal number if the BCD flag of the program status word is set to "1" during arthmetic operations. 7.2.5 Address control circuit The address control circuit specifies an address of the data memory. At this time, address modification by the index register and data memory row address pointer is also controlled. 7.3 ALU Processing Instruction List Table 7-1 lists the ALU operations when each instruction is executed. Table 7-2 shows how data memory addresses are modified by the index register and data memory row address pointer. Table 7-3 shows decimal adjustment data when a decimal operation is performed. 59 PD17704, 17705, 17707, 17708, 17709 Table 7-1. List of ALU Processing Instruction Operations ALU Function Instruction Difference in Operation Depending on Program Status Word (PSWORD) Value of Value of BCD flag CMP flag ADD r, m m, #n4 ADDC r, m m, #n4 Subtract SUB r, m m, #n4 SUBC r, m m, #n4 Logical operation AND OR r, m 1 1 1 0 0 1 0 0 Operation Operation of CY flag Set if carry or borrow occurs; Operation of Z flag Address Modification Index Memory pointer Add Stores result of binary operation Set if result of operation is 0000B; otherwise, reset Modifies Does not modify Does not store result otherwise, reset Retains status if result of operation of binary operation Stores result of decimal operation Does not store result of decimal operation is 0000B; otherwise, reset Set if result of operation is 0000B; otherwise, reset Retains status if result of operation is 0000B; otherwise, reset Retains previous Retains previous status status Modifies Does not modify Don't care Don't care Not affected m, #n4 (retained) (retained) r, m m, #n4 XOR r, m m, #n4 Judge SKT SKF m, #n m, #n Don't care Don't care Not affected (retained) (reset) Retains previous Retains previous status status Retains previous Retains previous status status Modifies Does not modify Modifies Does not modify Compare SKE m, #n4 Don't care Don't care Not affected SKNE m, #n4 (retained) (retained) SKGE m, #n4 SKLT Transfer LD ST MOV m, #n4 r, m m, r m, #n4 @r, m m, @r Rotate RORC r Don't care Don't care Not affected (retained) (retained) Don't care Don't care Not affected (retained) (retained) Retains previous Retains previous status status Modifies Does not modify Modifies Value of b0 of general register Retains previous status Does not Does not modify modify 60 PD17704, 17705, 17707, 17708, 17709 Table 7-2. Modification of Data Memory Address and Indirect Transfer Address by Index Register and Data Memory Row Address Pointer IXE MPE General Register Address Specified by "r" Bank Row address Column address Data Memory Address Specified by "m" Bank Row address Column address Indirect Transfer Address Specified by "@r" Bank Row address Column address b3 b2 b1 b0 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 b2 b1 b0 b3 b2 b1 b0 0 0 RP r BANK m BANK mR (r) 0 1 ditto ditto MP (r) 1 0 ditto BANK Logical IX m OR BANK Logical IXH, IXM mR OR (r) 1 1 ditto ditto MP (r) BANK IX IXE IXH IXM IXL m mR mC MP r RP (X) : bank register : index register : index enable flag : bits 10 through 8 of index register : bits 7 through 4 of index register : bits 3 through 0 of index register : data memory address indicated by mR, mC : data memory row address (high-order) : data memory column address (low-order) : data memory row address pointer : general register column address : general register pointer : contents addressed by X X: direct address such as "m" and "r" MPE : memory pointer enable flag 61 PD17704, 17705, 17707, 17708, 17709 Table 7-3. Decimal Adjustment Data Operation Hexadecimal Addition Result 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 CY 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Operation result 0000B 0001B 0010B 0011B 0100B 0101B 0110B 0111B 1000B 1001B 1010B 1011B 1100B 1101B 1110B 1111B 0000B 0001B 0010B 0011B 0100B 0101B 0110B 0111B 1000B 1001B 1010B 1011B 1100B 1101B 1110B 1111B Decimal Addition CY 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Operation result 0000B 0001B 0010B 0011B 0100B 0101B 0110B 0111B 1000B 1001B 0000B 0001B 0010B 0011B 0100B 0101B 0110B 0111B 1000B 1001B 1110B 1111B 1100B 1101B 1110B 1111B 1100B 1101B 1010B 1011B 1100B 1101B Operation Hexadecimal Addition Result 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 CY 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Operation result 0000B 0001B 0010B 0011B 0100B 0101B 0110B 0111B 1000B 1001B 1010B 1011B 1100B 1101B 1110B 1111B 0000B 0001B 0010B 0011B 0100B 0101B 0110B 0111B 1000B 1001B 1010B 1011B 1100B 1101B 1110B 1111B Decimal Addition CY 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Operation result 0000B 0001B 0010B 0011B 0100B 0101B 0110B 0111B 1000B 1001B 1100B 1101B 1110B 1111B 1100B 1101B 1110B 1111B 1100B 1101B 1110B 1111B 0000B 0001B 0010B 0011B 0100B 0101B 0110B 0111B 1000B 1001B Remark Decimal adjustment is not correctly carried out in the shaded area in the above table. 62 PD17704, 17705, 17707, 17708, 17709 7.4 Cautions on Using ALU 7.4.1 Cautions on execution operation to program status word If an arithmetic operation is executed to the program status word, the result of the operation is stored to the program status word. The CY and Z flags in the program status word are usually set or reset by the result of the arithmetic operation. If an arithmetic operation is executed to the program status word itself, the result of the operation is stored to the program status word, and consequently, it cannot be judged whether a carry or borrow occurs or whether the result of the operation is zero. If the CMP flag is set, however, the result of the operation is not stored to the program status word. Therefore, the CY and Z flags are set or reset normally. 7.4.2 Cautions on executing decimal operation The decimal operation can be executed only when the result of the operation falls within the following ranges: (1) Result of addition : 0 to 19 in decimal (2) Result of subtraction: 0 to 9 or -10 to -1 in decimal If a decimal operation is executed exceeding or falling below the above ranges, the result is a value greater than 1010B (0AH). 63 PD17704, 17705, 17707, 17708, 17709 8. REGISTER FILE (RF) 8.1 Outline of Register File Figure 8-1 outlines the register file. As shown in the figure, the rgister file consists of the control registers existing on a space different from the data memory, and a portion overlapping the data memory. The control registers set conditions of the peripheral hardware units. The data on the register file can be read or written via window register. Figure 8-1. Outline of Register File Register file 0 Control register (on separate space from data memory) Peripheral hardware 1 2 Row address 3 4 (Same space as data memory) Data manipulation via window register 5 6 7 System register Window register 64 PD17704, 17705, 17707, 17708, 17709 8.2 Configuration and Function of Register File Figure 8-2 shows the configuration of the register file and the relationships between the register file and data memory. The register file is assigned addresses in 4-bit units, like the data memory, and consists of a total of 128 nibbles with row addresses 0H through 7FH and column addresses 0H through 0FH. Addresses 00H through 3FH are control registers that sets the conditions of the peripheral hardware units. Addresses 40H through 7FH overlap the data memory. In other words, addresses 40H through 7FH of the register file are addresses 40H through 7FH of the currently-selected bank of data memory. Because addresses 40H through 7FH of the register file overlap the same addresses of the data memory, these addresses of the register file can be manipulated in the same manner as the data memory, except that the addresses of the register file can also be manipulated by using register file manipulation instructions ("PEEK WR, rf" and "POKE rf, WR"). Note, however, that addresses 60H through 6FH of BANK15 are assigned port input/output selection registers (for details refer to 8.4 Port Input/Output Selection Registers). Figure 8-2. Configuration of Register File and Relationship with Data Memory Column address 0 0 1 1 2 3 4 5 6 7 8 9 A B C D E F Row address 2 3 4 5 6 7 BANK0 BANK1 BANK2 Data memory Port input/output selection registers System registers 0 1 2 3 Register file Control registers Remark The PD17704 and 17705 do not have BANKs 6 through 14. The PD17707 and 17708 do not have BANKs 10 through 14. BANK14 BANK15 65 PD17704, 17705, 17707, 17708, 17709 8.2.1 Register file manipulation instructions ("PEEK WR, rf", "POKE rf, WR") Data is read from or written to the register file via the window register of the system registers, by using the following instructions. (1) "PEEK WR, rf" Reads data of the register file addressed by "rf" to the window register. (2) "POKE rf, WR" Writes the data of the window register to the register file addressed by "rf". 8.3 Control Registers Figure 8-3 shows the configuration of the control registers. As shown in the figure, the control registers consist of a total of 64 nibbles (64 x 4 bits) of addresses 00H through 3FH of the register file. Of these 64 nibbles, however, only 53 nibbles are actually used. The remaining 11 nibbles are unused registers and prohibited from being written or read. Each control register has an attribute of 1 nibble that identifies four types of registers: 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 a read-only (R and R&Reset) register. An "undefined" value is read if a write-only (W) register is read. Among the 4-bit data in 1 nibble, the bit fixed to "0" is always "0" when it is read, and is also "0" when it is written. The 11 nibbles of unused registers are undefined when their contents are read, and nothing changes even when they are written. Table 8-1 lists the peripheral hardware control functions of the control registers. 66 PD17704, 17705, 17707, 17708, 17709 [MEMO] 67 PD17704, 17705, 17707, 17708, 17709 Figure 8-3. Configuration of Control Registers (1/2) Column Address Row Address Item 0 1 Stack pointer 2 Watchdog timer clock selection 3 Watchdog 4 Data buffer 5 Stack overflow/ 6 CE reset timer carry counter I S P R E S A S P R E S C E C N T 3 C E C N T 2 C E C N T 1 C0 E C N T 0 7 MOVT bit selection 0 (8)Note Name timer counter stack pointer underflow reset reset selection Symbol 0 SSSS PPPP 3210 ) ) ) ) 0W D T C K 1 W D T C K 0 W0 D T R E S 0 0 0 0 0 0 D B F S P 1 ) D B F S P 0 ) 0M O V T S E L 1 R/W M O V T S E L 0 ( ( ( ( ( ( Read/ Write 1 (9) Note R/W R/W W & Reset R R/W R/W Name PLL mode selection PLL reference frequency selection PLL unlock FF BEEP/general -purpose port pin function selection BEEP clock selection Watchdog timer/stack pointer reset status detection Basic timer 0 carry Symbol P 0 P P P P L LLLL L LLLL S MMRR C DDFF N 10CC KK F 32 Read/ Write 2 (A)Note Name FCG channel selection Symbol 0 0 F C G C H 1 R/W P L L R F C K 1 P0 L L R F C K 0 0 0P0 L L U L 0B E E P 1 S E L R/W B E E P 0 S E L B E E P 1 C K 1 B E E P 1 C K 0 B E E P 0 C K 1 B E E P 0 C K 0 0 0 0W0 D T C Y 0 0B T M 0 C Y R/W R&Reset R/W R&Reset R&Reset IF counter gate status detection 0 0 I F C G O S T T IF counter mode selection I F C M D 1 I F C M D 0 I F C C K 1 IF counter control A/D converter A/D converter channel selection mode selection PWM clock selection PWM/generalpurpose port pin function selection F0 C G C H 0 I0 F C C K 0 0 I F C S T R T W I 0AAA0AAA0P0P0PPP W DDD W WWW F DDD CCC M M MMM C CCC MSC B C 210 CCC R DTM I K SSS HHH E TP T EEE 210 S LLL R/W R/W R R/W R/W Read/ Write 3 (B) Note R/W R R/W Name Serial interface 1 interrupt request 0 0 0 Serial interface 0 interrupt request 0 0 I0 R Q S I O 0 Timer 3 interrupt request 0 0 I0 R Q T M 3 Timer 2 interrupt request 0 0 I R Q T M 2 Symbol I0 R Q S I O 1 Read/ Write R/W R/W R/W R/W Note ( ) indicates an address that is used when the assembler is used. 68 PD17704, 17705, 17707, 17708, 17709 Figure 8-3. Configuration of Control Register (2/2) 8 System register interrupt stack pointer 9 A Serial I/O0 wait status judgment 0 0 B Serial I/O0 clock selection C Serial I/O0 interrupt mode selection 0 S I O 0 I M D 1 S I O 0 I M D 0 D Serial I/O0 status detection S I O 0 S F 8 S I O 0 S F 9 R S B S T T S B B S Y S B A C K S I O 0 N W T E Serial I/O0 wait control F Serial I/O0 mode selection 0 S Y S R S P 2 S Y S R S P 1 S Y S R S P 0 0S0SSS0 I BII O MOO 0 D00 W CC S KK T 10 T R R/W S I O 0 W R Q 1 S I O 0 W R Q 0 SSSS IBII O OO 0 00 C MT H SX Basic timer 0 clock selection 0 0B T M 0 C K 1 R/W B T M 0 C K 0 Timer 3 control T0TTTT M MMMM 3 3322 S ERER E NENE L S S Timer 1 interrupt request 0 0 0 I0 R Q T M 1 ( ) R R/W R/W ( ) ( ) R/W R/W R/W Serial I/O1 mode selection S I O 1 T S S I O 1 H I Z S I O 1 C K 1 Interrupt edge selection 1 Interrupt edge selection 2 SIIII0III IENEN EEE OGTGT GGG 14433 210 C S S K E E 0 L L R/W R/W R/W Timer 2 counter clock selection T M 2 C K 1 T M 2 C K 0 Timer 1 counter clock selection T M 1 E N T M 1 R E S T M 1 C K 1 T M 1 C K 0 Timer 0 counter clock selection T M 0 E N T M 0 R E S T M 0 C K 1 T M 0 C K 0 Timer 0 mode selection T M 0 O V F T M 0 G C E G T M 0 G O E G Interrupt enable 1 Interrupt enable 2 Interrupt enable 3 TIIII MPPPP 0SSTT M I I MM DOO32 10 I P T M 1 IIIIIII PPPPPPP T43210C M E 0 R/W R/W R/W R/W R/W R/W R/W Timer 0 interrupt request 0 0 II RN QT T4 M 0 INT4 pin interrupt request 0 0 INT3 pin interrupt request II0 RN QT 43 0 INT2 pin interrupt request II0 RN QT 32 0 INT1 pin interrupt request II0 RN QT 21 0 INT0 pin interrupt request II0 RN QT 10 0 CE pin interrupt request IC0CI ER RE CQ Q NC 0 TE S T T R R / W R/W R/W R/W R/W R/W R/W 69 PD17704, 17705, 17707, 17708, 17709 Table 8-1. Peripheral Hardware Control Functions of Control Registers (1/8) Peripheral Hardware Name Control Register Address Read/ b3 Peripheral Hardware Control Function Function Set value At Reset Power- WDT ON & SP reset F F CE reset Clock Stop b2 Write Symbol b1 b0 Stack Stack pointer 01H R/W (SP3) (SP2) (SP1) (SP0) Interrupt stack pointer of system register 08H R 0 (SYSRSP2) (SYSRSP1) (SYSRSP0) Data buffer stack pointer 04H R 0 0 (DBFSP1) (DBFSP0) Stack overflow/ underflow reset selection 05H R/W 0 0 ISPRES Selects interrupt stack overflow/underflow reset (can be set only once following power application) ASPRES Selects address stack overflow/underflow reset (can be set only once following power application) Watchdog Watchdog timer timer clock selection 02H R/W 0 0 WDTCK1 WDTCK0 Watchdog timer counter reset 03H W& WDTRES 0 Not used set only once following power application) 0 Selects clock of watchdog timer (can be 0 1 reset F Retained 5 5 5 Retained Fixed to "0" 0 0 0 Retained Detects nesting level of data buffer stack Fixed to "0" 0 0 1 1 Level 0 Level 1 Level 2 Level 3 0 1 0 1 3 Retained Retained Retained Reset prohibited Reset valid Fixed to "0" 3 Retained Retained Retained 0 65536 instruction 1 1 Setting prohibited 0 1 131072 instruction 1 Resets watchdog timer counter Fixed to "0" Invalid Reset if written Undefined Undefined Undefined Undefined Reset 0 0 0 WDT&SP reset status detection 16H R& 0 0 1 Retained Retained Reset 0 0 WDTCY Detects resetting of watchdog timer/stack pointer No reset request Reset request 70 PD17704, 17705, 17707, 17708, 17709 Table 8-1. Peripheral Hardware Control Functions of Control Registers (2/8) Peripheral Hardware Name Control Register Address Read/ b3 Peripheral Hardware Control Function Function Set value At Reset Power- WDT ON & SP reset Retained Retained Clock CE reset Stop b2 Write Symbol b1 b0 CE CE reset timer carry counter 06H R/W CECNT3 CECNT2 CECNT1 CECNT0 MOVT bit selection 07H R/W 0 0 MOVTSEL1 Sets bit transferred by MOVT (transferred 00 16-bit MOVTSEL0 to DBF1, 0 during 8-bit transfer) Serial Serial I/O0 wait 0AH R 0 0 0 SIO0WSTT Judges wait status of serial interface 0 Serial I/O0 clock selection 0BH R/W 0 SBMD Fixed to "0" Selects operation mode of I 2C bus during slave transmission SIO0CK1 SIO0CK0 Serial I/O0 interrupt mode selection 0CH R/W 0 0 SIO0IMD1 SIO0IMD0 Serial I/O0 status detection 0DH R SIO0SF8 SIO0SF9 SBSTT Detects number of clocks (I 2C SBBSY bus mode) Sets interrupt condition of serial interface 0 Detects clock counter 0 7th clock 0 0 Sets number of CE reset timer 0: Setting prohibited carry counts 1 reset 1 1: 1 count 2: 2 counts 3: 3 counts 4: 4 counts 5: 5 counts 6: 6 counts 7: 7 counts 8: 8 counts 9: 9 counts A: 10 counts B: 11 counts C: 12 counts D: 13 counts E: 14 counts F: 15 coounts 1 Fixed to "0" 0 0 0 Retained 0 High-order transfer 8-bit transfer 01 1 1 Low-order 8-bit transfer 0 Fixed to "0" 0 0 0 0 interface status judgment During wait During serial communication 0 0 0 0 Continues processing 0 93.75 kHz 0 0 375 kHz 1 Reception mode is set automatically 1 281.25 kHz 0 1 46.875 kHz 1 Sets internal clck of serial interface 0 Fixed to "0" 0 0 0 0 0 8th clock 1 1 7th clock after start condition 0 1 Stop condition 1 Set at 8th clock Set at 9th clock Set from start condition to 9th clock Set from start condition to stop condition 0 0 0 0 Detects start condition (I 2C bus mode) Serial I/O0 wait control 0EH R/W SBACK Sets and detects acknowledge Sets and detects 0, 1 (I 2C bus mode) Enabled 0 No wait 0 0 0 0 0 SIO0NWT Enables wait Cleared SIO0WRQ1 Sets wait mode SIO0WRQ0 0 1 1 Data Acknowledge Address wait wait wait 1 0 1 71 PD17704, 17705, 17707, 17708, 17709 Table 8-1. Peripheral Hardware Control Functions of Control Registers (3/8) Peripheral Hardware Name Control Register Address Read/ b3 Peripheral Hardware Control Function Function Set value At Reset Power- WDT ON & SP reset 0 0 CE reset Clock Stop b2 Write Symbol b1 b0 Serial Serial I/O0 0FH R/W SIO0CH SB SIO0MS SIO0TX Serial I/O1 mode selection 1DH R/W SIO1TS SIO1HIZ Sets master/slave Sets transfer direction Starts or stops operation Sets status of P0B1/SO1 pin Selects serial I/O0 mode 0 Not used 0 0 0 I 2C mode 1 1 2-wire mode 0 1 1 3-wire mode 1 reset 0 0 interface mode selection Slave operation Master operation Reception Transmission 0 0 0 0 Stops operation Starts operation General-purpose I/O port Serial data output pin 1 375.00 kHz 0 1 46.875 kHz 1 SIO1CK1 SIO1CK0 PLL frequency synthesizer Sets I/O clock 0 External clock 0 0 187.50 kHz 1 PLL mode selection 10H R/W PLLSCNF 0 PLLMD1 PLLMD0 Sets low-order bits of swallow counter Lowest bit is 0 Lowest bit is 1 U 0 U 0 R 0 R 0 Fixed to "0" Sets division mode of PLL 0 Disabled 0 0 MF 1 1 VHF 0 1 HF 1 PLL reference frequency selection 11H R/W PLLRFCK3 Sets reference frequency of PLL 0: 1.25 kHz 1: 2.5 kHz 2: 5 kHz PLLRFCK2 PLLRFCK1 PLLRFCK0 3: 10 kHz 4: 6.25 kHz 5: 12.5 kHz 6: 25 kHz 7: 50 kHz 8: 3 kHz 9: 9 kHz A: 18 kHz B: Setting prohibited C: 1 kHz D: 20 kHz E: Setting prohibited F: PLL disabled F F F F PLL unlcok FF 12H R& 0 Fixed to "0" Undefined Undefined Retained Retained Reset 0 0 PLLUL BEEP BEEP/generalpurpose port pin function selection 13H R/W 0 0 BEEP1SEL Selects function of P1D1/BEEP1 pin General-purpose BEEP0SEL Selects function of P1D0/BEEP0 pin BEEP clock selection 14H R/W I/O port 0 3 kHz 1 0 3 kHz 1 1 200 Hz 0 1 4 kHz 0 1 67 Hz 1 1 6.7 kHz 1 Detects status of unlock FF Fixed to "0" Locked Unclocked 0 0 0 0 BEEP BEEP1CK1 Sets output frequency of BEEP1 0 4 kHz BEEP1CK0 0 BEEP0CK1 Sets output frequency of BEEP0 0 BEEP0CK0 1 kHz 0 0 0 0 0 U: Undefined R: Retained 72 PD17704, 17705, 17707, 17708, 17709 Table 8-1. Peripheral Hardware Control Functions of Control Registers (4/8) Peripheral Hardware Name Control Register Address Read/ b3 Peripheral Hardware Control Function Function Set value At Reset Power- WDT ON & SP reset Retained Clock CE reset Stop b2 Write Symbol b1 b0 Timer Basic timer 0 carry 17H R& 0 Fixed to "0" 0 1 reset 0 1 Retained Reset 0 0 BTM0CY Detects basic timer 0 carry FF Fixed to "0" FF reset FF set 0 0 Retained Retained Basic timer 0 clock selection 18H R/W 0 0 BTM0CK1 BTM0CK0 Selects clock of basic timer 0 0 10 Hz 0 0 20 Hz 1 1 50 Hz 0 1 100 Hz 1 Timer 3 control 28H R/W TM3SEL 0 TM3EN TM3RES Selects timer 3 and D/A converter D/A converter Fixed to "0" Starts or stops timer 3 counter Resets timer 3 counter Starts or stops timer 2 counter Resets timer 2 counter Sets basic clock of timer 2 counter Starts or stops timer 1 counter Resets timer 1 counter Sets basic clock of timer 1 counter Starts or stops timer 0 counter Resets timer 0 counter Sets basic clock of timer 0 counter Detects timer 0 overflow Sets edge of gate close input signal Stops Not affected Stops Not affected 0 0 100 kHz 10 kHz 0 1 Timer 3 0 0 Retained 0 Starts Reset Starts Reset 1 2 kHz 0 1 1 kHz 1 Timer 2 counter 29H clock selection R/W TM2EN TM2RES TM2CK1 TM2CK0 0 0 Retained 0 Timer 1 counter 2AH clock selection R/W TM1EN TM1RES TM1CK1 TM1CK0 Stops Not affected 0 0 100 kHz 10 kHz 0 1 Starts Reset 1 2 kHz 0 1 1 kHz 1 0 0 Retained 0 Timer 0 counter 2BH clock selection R/W TM0EN TM0RES TM0CK1 TM0CK0 Stops Not affected 0 0 100 kHz 10 kHz 0 1 Starts Reset 1 2 kHz 0 1 1 kHz 1 0 0 Retained 0 Timer 0 mode selection 2CH R/W TM0OVF TM0GCEG No overflow Rising edge Overflow Falling edge 0 0 Retained 0 TM0GOEG Sets edge of gate open input signal TM0MD Selects modulo counter/gate counter of timer 0 Modulo counter Gate counter 73 PD17704, 17705, 17707, 17708, 17709 Table 8-1. Peripheral Hardware Control Functions of Control Registers (5/8) Peripheral Hardware Name Control Register Address Read/ b3 Peripheral Hardware Control Function Function Set value At Reset Power- WDT ON & SP reset 0 CE reset Clock Stop b2 Write Symbol b1 b0 Interrupt Interrupt edge selection 1 INT4SEL 1EH R/W IEG4 Sets interrupt issuance edge (INT4 pin) Sets interrupt request flag of P1A3/INT4 pin IEG3 Sets interrupt issuance edge (INT3 pin) INT3SEL Sets interrupt request flag of P1A2/INT3 pin Interrupt edge selection 2 1FH R/W 0 IEG2 Fixed to "0" Sets interrupt issuance edge (INT2 pin) IEG1 Sets interrupt issuance edge (INT1 pin) IEG0 Sets interrupt issuance edge (INT0 pin) Interrupt enable 1 2DH R/W IPSIO1 Enables serial interface 1 interrupt IPSIO0 Enables serial interface 0 interrupt IPTM3 IPTM2 Interrupt enable 2 2EH R/W IPTM1 IPTM0 IP4 IP3 Interrupt enable 3 2FH R/W IP2 IP1 IP0 IPCE Serial interface 1 34H interrupt request R/W 0 0 0 IRQSIO1 Detects serial interface 1 interrupt request Enables timer 3 interrupt Enables timer 2 interrupt Enables timer 1 interrupt Enables timer 0 interrupt Enables INT4 pin interrupt Enables INT3 pin interrupt Enables INT2 pin interrupt Enables INT1 pin interrupt Enables INT0 pin interrupt Enables CE pin interrupt Fixed to "0" 0 Rising edge 1 Falling edge reset 0 Retained Retained Enables Disables setting of flag setting of flag Rising edge Falling edge Enables Disables setting of flag setting of flag 0 Rising edge Falling edge 0 Retained Retained Disables interrupt Enables interrupt 0 0 Retained Retained Disables interrupt Enables interrupt 0 0 Retained Retained Disables interrupt Enables interrupt 0 0 Retained Retained 0 0 Retained Retained No interrupt request Interrupt request 74 PD17704, 17705, 17707, 17708, 17709 Table 8-1. Peripheral Hardware Control Functions of Control Registers (6/8) Peripheral Hardware Name Control Register Address Read/ b3 Peripheral Hardware Control Function Function Set value At Reset Power- WDT ON & SP reset 0 CE reset Clock Stop b2 Write Symbol b1 b0 Interrupt Serial interface 0 interrupt request 35H R/W 0 0 0 IRQSIO0 Detects serial interface 0 interrupt request Timer 3 interrupt request 36H R/W 0 0 0 IRQTM3 Timer 2 interrupt request 37H R/W 0 0 0 IRQTM2 Timer 1 interrupt request 38H R/W 0 0 0 IRQTM1 Timer 0 interrupt request 39H R/W 0 0 0 IRQTM0 INT4 pin interrupt request 3AH R/W INT4 0 0 IRQ4 INT3 pin interrupt request 3BH R/W INT3 0 0 IRQ3 INT2 pin interrupt request 3CH R/W INT2 0 0 IRQ2 INT1 pin interrupt request 3DH R/W INT1 0 0 IRQ1 Fixed to "0" Fixed to "0" 0 1 reset 0 Retained Retained No interrupt request Interrupt request 0 0 Retained Retained Detects timer 3 interrupt request No interrupt request Interrupt request Fixed to "0" 0 0 Retained Retained Detects timer 2 interrupt request No interrupt request Interrupt request Fixed to "0" 0 0 Retained Retained Detects timer 1 interrupt request No interrupt request Interrupt request Fixed to "0" 0 0 Retained Retained Detects timer 0 interrupt request No interrupt request Interrupt request Detects INT4 pin status Fixed to "0" Low level High level U 0 U 0 U U Retained Retained Detects INT4 pin interrupt request No interrupt request Interrupt request Detects INT3 pin status Fixed to "0" Low level High level U 0 U 0 U U Retained Retained Detects INT3 pin interrupt request No interrupt request Interrupt request Detects INT2 pin status Fixed to "0" Low level High level U 0 U 0 U U Retained Retained Detects INT2 pin interrupt request No interrupt request Interrupt request Detects INT1 pin status Fixed to "0" Low level High level U 0 U 0 U U Retained Retained Detects INT1 pin interrupt request No interrupt request Interrupt request U: Undefined 75 PD17704, 17705, 17707, 17708, 17709 Table 8-1. Peripheral Hardware Control Functions of Control Registers (7/8) Peripheral Hardware Name Control Register Address Read/ b3 Peripheral Hardware Control Function Function Set value At Reset Power- WDT ON & SP reset U 0 U CE reset Clock Stop b2 Write Symbol b1 b0 Interrupt INT0 pin interrupt request 3EH R/W INT0 0 0 IRQ0 CE pin interrupt 3FH request R CE 0 Detects INT0 pin status Fixed to "0" 0 Low level 1 High level reset U 0 U Retained Retained Detects INT0 pin interrupt request No interrupt request Interrupt request Detects CE pin status Fixed to "0" Stops Operates 0 0 0 0 R 0 R 0 Low level High level U 0 U 0 U 0 U 0 CECNTSTT Detects CE reset counter status R/W IF counter FCG channel selection 20H R/W IRQCE 0 0 FCGCH1 FCGCH0 IF counter gate status detection 21H R 0 0 0 IFCGOSTT Detects IF counter gate status IF counter mode selection 22H R/W IFCMD1 IFCMD0 IFCCK1 IFCCK0 IF counter control 23H W 0 0 IFCSTRT IFCRES A/D A/D converter 24H R/W 0 ADCCH2 ADCCH1 ADCCH0 A/D converter mode selection 25H R/W 0 ADCMD Fixed to "0" Selects comparison mode of A/D converter R ADCSTT Detects operating status of A/D converter ADCCMP Detects comparison result of A/D converter Starts or stops IF counter Resets IF counter data Fixed to "0" Sets IF counter gate time and FCG count frequency Fixed to "0" Sets IF counter mode 0 FCG 0 Detects CE pin interrupt request No interrupt request Interrupt request Fixed to "0" Sets pin to be used as FCG 0 FCG not used 0 0 FCG0 pin 1 1 FCG1 pin 0 1 Setting prohibited 1 Fixed to "0" 0 0 0 0 Closed 0 AMIFC 1 Open 1 FMIFC 0 1 AMIFC2 1 0 0 0 0 0 0 1 1 1ms, 4 ms, 8 ms, Open, 1 kHz 100 kHz 900 kHz Setting prohibited 0 1 0 1 0 0 0 0 Nothing affected Starts counter Nothing affected Starts counter 0 1: P0D0/AD0 pin 2: P0D1/AD1pin 3: P0D2/AD2 pin 4: P0D3/AD3 pin 5: P1C2/AD4 pin 6: P1C3/AD5 pin 7: Setting prohibited 0 Retained Retained converter channel selection Selects pin used for A/D converter 0: A/D converter not used 0 Software mode Hardware mode 0 0 0 Retained Retained Conversion ends Converting 0 0 VADCREF > VADCIN VADCREF < VADCIN 0 Retained U: Undefined R: Retained 76 PD17704, 17705, 17707, 17708, 17709 Table 8-1. Peripheral Hardware Control Functions of Control Registers (8/8) Peripheral Hardware Name Control Register Address Read/ b3 Peripheral Hardware Control Function Function Set value At Reset Power- WDT ON & SP reset 0 Retained Clock CE reset Stop b2 Write Symbol b1 b0 D/A PWM clock 26H R/W 0 PWMBIT Fixed to "0" Selects number of bits of PWM counter 0 PWMCK Fixed to "0" Selects output clock of timer 3 0 1 reset 0 0 converter selection 8 bits 9 bits 4.4 kHz (8)/ 2.2 kHz (9) 440 Hz (8)/ 220 Hz (9) 0 0 Retained PWM/generalpurpose port pin function selection 27H R/W 0 PWM2SEL PWM1SEL PWM0SEL Fixed to "0" Selects function of P1B2/PWM2 pin General-purpose D/A converter Selects function of P1B1/PWM1 pin Selects function of P1B0/PWM0 pin output port 0 77 PD17704, 17705, 17707, 17708, 17709 8.4 Port Input/Output Selection Registers Figure 8-4 shows the configuration of the port input/output selection registers. As shown in this figure, the port input/output select registers consist of a total of 16 nibbles (16 x 4 bits) at addresses 60H through 6FH of BANK 15 of the data memory. Table 8-2 lists the control functions of the port input/output selection registers. 78 PD17704, 17705, 17707, 17708, 17709 [MEMO] 79 PD17704, 17705, 17707, 17708, 17709 Figure 8-4. Configuration of Port Input/Output Selection Registers (1/2) (BANK15) Column Address Row Address Item Name 0 1 2 3 4 5 6 7 Port 0D pull-down resistor selection Group I/O selection Symbol PPPPPPPP 0 00 0 3 33 3 DDDDDCBA 6 PPPPGGGG L 3 Read/ Write LL 21 R/W L 0 R/W I I I I DDDDOOOO 80 PD17704, 17705, 17707, 17708, 17709 Figure 8-4. Configuration of Port Input/Output Selection Registers (2/2) 8 9 A B C D E F Port 2D bit Port 2C bit Port 2B bit Port 2A bit Port 1D bit Port 0C bit Port 0B bit Port 0A bit I/O selection I/O selection I/O selection I/O selection I/O selection I/O selection I/O selection I/O selection 0PPPPPPPPPPP 22 2 2 22 22 22 2 DDDCCCCBBBB BBBBBBBBBBB I I I 0 I 3 I I I I I I I 0 OOOOOOOOOOO 21 R/W 21 R/W 03 21 R/W 0PPPPPPPPPPPPPPPPPPP 22 2 1 11 1 0 00 00 00 0 0 00 0 AAADDDDCCCCBBBBAAAA BBBBBBBBBBBBBBBBBBB I I I 0 I 3 I I I 0 I 3 I I I I I I I 0 I 3 I I I 0 OOOOOOOOOOOOOOOOOOO 21 R/W 21 R/W 21 R/W 03 21 R/W 21 R/W 81 PD17704, 17705, 17707, 17708, 17709 Table 8-2. Control Functions of Port Input/Output Selection Registers (1/2) Peripheral Hardware Port Input/Output Selection Register Name Address Read/ b3 Control Function Function Set value At Reset Power- WDT ON & SP reset 0 CE reset Clock Stop b2 (BANK15) Write Symbol b1 b0 Input/ output port Port 0D pulldown resistor selection 66H R/W P0DPLD3 P0DPLD2 P0DPLD1 P0DPLD0 Group I/O selection 67H R/W P3DGIO P3CGIO P3BGIO P3AGIO Port 2D bit I/O selection 68H R/W 0 P2DBIO2 P2DBIO1 P2DBIO0 Port 2C bit I/O selection 69H R/W P2CBIO3 P2CBIO2 P2CBIO1 P2CBIO0 Port 2B bit I/O selection 6AH R/W P2BBIO3 P2BBIO2 P2BBIO1 P2BBIO0 Port 2A bit I/O selection 6BH R/W 0 P2ABIO2 P2ABIO1 P2ABIO0 Port 1D bit I/O selection 6CH R/W P1DBIO3 P1DBIO2 P1DBIO1 P1DBIO0 Port 0C bit I/O selection 6DH R/W P0CBIO3 P0CBIO2 P0CBIO1 P0CBIO0 Port 0B bit I/O selection 6EH R/W P0BBIO3 P0BBIO2 P0BBIO1 P0BBIO0 Selects pull-down resistor of P0D3 pin 0 Pull-down 1 Pull-down reset 0 Retained Retained Selects pull-down resistor of P0D2 pin resistor used resistor not used Selects pull-down resistor of P0D1 pin Selects pull-down resistor of P0D0 pin Selects input/output of port 3D Selects input/output of port 3C Selects input/output of port 3B Selects input/output of port 3A Fixed to "0" Selects input/output of port P2D2 Selects input/output of port P2D1 Selects input/output of port P2D0 Selects input/output of port P2C3 Selects input/output of port P2C2 Selects input/output of port P2C1 Selects input/output of port P2C0 Selects input/output of port P2B3 Selects input/output of port P2B2 Selects input/output of port P2B1 Selects input/output of port P2B0 Fixed to "0" Selects input/output of port P2A2 Selects input/output of port P2A1 Selects input/output of port P2A0 Selects input/output of port P1D3 Selects input/output of port P1D2 Selects input/output of port P1D1 Selects input/output of port P1D0 Selects input/output of port P0C3 Selects input/output of port P0C2 Selects input/output of port P0C1 Selects input/output of port P0C0 Selects input/output of port P0B3 Selects input/output of port P0B2 Selects input/output of port P0B1 Selects input/output of port P0B0 Input Output 0 0 Retained Retained 0 Input Output 0 Retained Retained Input Output 0 0 Retained Retained Input Output 0 0 Retained Retained 0 Input Output 0 Retained Retained Input Output 0 0 Retained Retained Input Output 0 0 Retained Retained Input Output 0 0 Retained Retained 82 PD17704, 17705, 17707, 17708, 17709 Table 8-2. Control Functions of Port Input/Output Selection Registers (2/2) Peripheral Hardware Port Input/Output Selection Register Name Address Read/ b3 Control Function Function Set value At Reset Power- WDT ON & SP reset 0 CE reset Clock Stop b2 (BANK15) Write Symbol b1 b0 Input/ output port Port 0A bit I/O selection 6FH R/W P0ABIO3 P0ABIO2 P0ABIO1 P0ABIO0 Selects input/output of port P0A3 Selects input/output of port P0A2 Selects input/output of port P0A1 Selects input/output of port P0A0 0 Input 1 Output reset 0 Retained Retained 83 PD17704, 17705, 17707, 17708, 17709 8.5 Cautions on Using Register File Keep in mind the following points (1) through (3) when using the write-only (W), read-only (R), and unused registers of the control registers (addresses 00H through 3FH of the register file). (1) An "undefined value" is read if a write-only register is read. (2) Nothing is affected even if a read-only register is written. (3) An "undefined value" is read if an unused register is read. Nor is anything affected if this register is written. 84 PD17704, 17705, 17707, 17708, 17709 9. DATA BUFFER (DBF) 9.1 Outline of Data Buffer Figure 9-1 outlines the data buffer. The data buffer is located on the data memory and has the following two functions. * Reads constant data on the program memory (table reference) * Transfers data with the peripheral hardware units Figure 9-1. Outline of Data Buffr Data buffer Data write (PUT) Table reference (MOVT) Data read (GET) Peripheral hardware Constant data Program memory 85 PD17704, 17705, 17707, 17708, 17709 9.2 Data Buffer 9.2.1 Configuration of data buffer Figure 9-2 shows the configuration of the data buffer. As shown in the figure, the data buffer consists of a total of 16 bits of addresses 0CH through 0FH of BANK 0 on the data memory. The 16-bit data is configured with bit 3 of address 0CH as the MSB and bit 0 of address 0FH as the LSB. Because the data buffer is located on the data memory, it can be manipulated by all data memory manipulation instructions. Figure 9-2. Configuration of Data Buffer Column address 0 0 1 Row address 2 3 4 5 6 7 BANK0 BANK1 BANK2 Data memory 1 2 3 4 5 6 7 8 9 A B C D E F Data buffer (DBF) BANK14 BANK15 System register Remark The PD17704 and 17705 do not have BANKs 6 through 14. The PD17707 and 17705 do not have BANKs 6 through 14. Data memory Address Bit Data buffer Bit Signal Data M S B 0CH 0DH 0EH 0FH b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 DBF3 DBF2 DBF1 DBF0 Data L S B 86 PD17704, 17705, 17707, 17708, 17709 9.2.2 Table reference instruction ("MOVT DBF, @AR") This instruction moves the contents of the program memory addressed by the contents of the address register to the data buffer. The number of bits transferred by the table reference instruction can be specified by MOVT selection register (address 07H) of the control registers. When 8-bit data is transferred, it is read to DBF1 and 0. When the table reference instruction is used, one stack level is used. All the addresses of the program memory can be referenced by the table reference instruction. 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 a peripheral register addressed by "p" to the data buffer. (2) PUT p, DBF Sets the data of the data buffer to a peripheral register addressed by "p". 9.3 Relationships between Peripheral Hardware and Data Buffer Table 9-1 shows the relationships between the peripheral hardware and the data buffer. 87 PD17704, 17705, 17707, 17708, 17709 Table 9-1. Relationships between Peripheral Hardware and Data Buffer (1/2) Peripheral Hardware Peripheral Register Transferring Data with Data Buffer Name Symbol Peripheral address Execution of PUT/GET instruction PUT/GET I/O bit Actual bit A/D converter A/D converter reference voltage setting register Presettable shift register 0 Presettable shift register 1 Timer 0 modulo register Timer 0 counter ADCR 02H 8 8 Serial interface Serial interface 0 Serial interface 1 Timer 0 SIO0SFR SIO1SFR TM0M TM0C TM1M TM1C TM2M TM2C AR DBFSTK PLLR IFC PWMR0 PWMR1 PWMR2 TM3M 03H 04H 1AH 1BH 1CH 1DH 1EH 1FH 40H 41H 42H 43H 44H 45H 46H PUT/GET 8 8 PUT/GET GET PUT/GET GET PUT/GET GET PUT/GET PUT/GET PUT/GET GET PUT/GET 8 8 8 8 8 8 16 16 16 16 16 8 8 8 8 8 8 16 16 16 16 9 Timer 1 Timer 1 modulo register Timer 1 counter Timer 2 Timer 2 modulo register Timer 2 counter Address register Data buffer stack PLL frequency synthesizerNote Address register DBF stack PLL data register IF counter data register PWM data register 0 PWM data register 1 PWM data register 2 Timer 3 modulo register Frequency counter D/A converter (PWM output) P1B0/PWM0 pin P1B1/PWM1 pin P1B2/PWM2 pin Timer 3 PUT/GET 16 9 8 Note The programmable counter of the PLL frequency synthesizer is configured of 17 bits, of which the highorder 16 bits indicate the PLL data register (PLLR) and the low-order bits are allocated to the PLLSCNF flag (the third bit of address 10H). For details, refer to 17. PLL FREQUENCY SYNTHESIZER. 88 PD17704, 17705, 17707, 17708, 17709 Table 9-1. Relationships between Peripheral Hardware and Data Buffer (2/2) At Reset Power-ON WDT&SP reset reset CE reset 0Note Clock Stop Function 0 0 0Note Sets compare voltage VADCREF of A/D converter Sets serial-out data and reads serial-in data Undefined Undefined Undefined Undefined FF 0 FF 0 FF 0 0 FF 0 FF 0 FF 0 0 Retained Retained Retained Retained Retained Retained 0 FF 0 FF 0 FF 0 Retained Retained Retained 0 1FF Sets modulo register value of timer 0 Reads count value of timer 0 counter Sets modulo register value of timer 1 Reads count value of timer 1 counter Sets modulo register value of timer 2 Reads count value of timer 2 counter Transfers data with address register Saves data of data buffer Sets division value (N value) of PLL Reads count value of frequency counter Sets duty of output signal of D/A converter Undefined Undefined Retained Undefined Undefined Retained 0 1FF 0 1FF 0 Retained Sets duty of output signal of D/A converter (multiplexed with modulo register of timer 3) Sets modulo register value of timer 3 Note Value in hardare mode. "Retained" in software mode. 89 PD17704, 17705, 17707, 17708, 17709 9.4 Cautions on Using Data Buffer Keep the following points in mind concerning the unused peripheral addresses, write-only peripheral register (PUT only), and read-only peripheral register (GET only) when transferring data with the peripheral hardware via data buffer. * An "undefined value" is read if a write-only register is read. * Nothing is affected even if a read-only register is written. * An "undefined value" is read if an unused address is read. Nor is anything affected if this address is written. 90 PD17704, 17705, 17707, 17708, 17709 10. DATA BUFFER STACK 10.1 Outline of Data Buffer Stack Figure 10-1 outlines the data buffer stack. As shown in the figure, the data buffer stack consists of a data buffer stack pointer and data buffer stack registers. The data buffer stack saves or restores the contents of the data buffer when the "PUT" or "GET" instruction is executed. Therefore, the contents of the data buffer can be saved by one instruction when an interrupt is accepted. Figure 10-1. Outline of Data Buffer Stack DBF Data buffer stack pointer Address specification Data buffer stack registers 10.2 Data Buffer Stack Register Figure 10-2 shows the configuration of the data buffer stack registers. As shown in the figure, the data buffer stack registers consist of four 16-bit registers. The contents of the data buffer are saved by executing the "PUT" instruction, and the saved data is restored by executing the "GET" instruction. The data buffer contents can be successively saved up to 4 levels. 91 PD17704, 17705, 17707, 17708, 17709 Figure 10-2. Configuration of Data Buffer Stack Register Data buffer DBF3 DBF2 DBF1 DBF0 Transfer data GET 16 bits PUT Name Symbol Address Bit Data Data buffer stack register DBFSTK 41H b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 Valid data Saves contents of data buffer up to 4 levels 92 PD17704, 17705, 17707, 17708, 17709 10.3 Data Buffer Stack Pointer The data buffer stack pointer detects the multiplexing level of the data buffer stack registers. When the "PUT" instruction is executed to the data buffer stack, the value of the data buffer stack pointer is incremented by one; when the "GET" instruction is executed, the value of the pointer is decremented by one. The data buffer stack pointer can be only read and cannot be written. The configuration and function of the data buffer stack pointer are illustrated below. Name Flag symbol b3 b2 b1 b0 Address Read/Write Data buffer stack pointer 0 0 D B F S P 1 D B F S P 0 04H R Detects multiplexing level of data buffer stack 0 0 1 1 0 1 0 1 Level 0 Level 1 Level 2 Level 3 Fixed to "0" Power-ON reset WDT&SP reset CE reset Clock stop 0 0 0 0 0 0 0 0 At reset Retained 93 PD17704, 17705, 17707, 17708, 17709 10.4 Operation of Data Buffer Stack Figure 10-3 shows the operation of the data buffer stack. As shown in the figure, when the PUT instruction is executed, the contents of the data buffer are transferred to a data buffer stack register specified by the stack pointer, and the stack pointer is incremented by one. When the GET instruction is executed, the contents of a data buffer stack register specified by the stack pointer are transferred to the data buffer, and the stack pointer is decremented by one. Therefore, note that the value of the stack pointer is set to 1 if data has been written once because its initial value is 0, and that the stack pointer is set to 0 when data has been written four times. Note that when writing (PUT) exceeding four levels, the first data are discarded. Figure 10-3. Operation of Data Buffer Stack (a) If writing does not exceed level 4 0 1 2 3 Undefined Undefined Undefined Undefined A Undefined Undefined Undefined A B Undefined Undefined A B Undefined Undefined A B Undefined Undefined VDD PUT PUT GET GET (b) If writing exceeds level 4 0 1 2 3 A Undefined Undefined Undefined A B Undefined Undefined A B C Undefined A B C D E B C D E B C D E B C D PUT PUT PUT PUT PUT GET GET 94 PD17704, 17705, 17707, 17708, 17709 10.5 Using Data Buffer Stack A program example is shown below. Example To save the contents of the data buffer and address register by using INT0 interrupt routine (the contents of the data buffer and address register are not automatically saved when an interrupt occurs). START: BR INITIAL ; Reset address ; Interrupt vector address NOP ; SI01 NOP ; SI00 NOP ; TM3 NOP ; TM2 NOP ; TM1 NOP ; TM0 NOP ; INT4 NOP ; INT3 NOP ; INT2 NOP ; INT1 BR INTINT0 ; INT0 NOP ; Down edge of CE INTINT0: PUT GET PUT DBFSTK, DBF ; ; DBF, AR ; DBFSTK, DBF ; ; Saves contents of DBF to first level of data buffer stack (DBFSTK) Transfers contents of address register (AR) to DBF Saves contents of AR to second level of data buffer stack Processing B ; INT0 interrupt processing GET DBF, DBFSTK ; Restores second level of data buffer stack to data buffer, PUT AR, DBF ; and restores contents of data buffer to address register GET DBF, DBFSTK ; Restores first level of data buffer stack to data buffer EI RETI INITIAL: SET1 IP0 EI LOOP: Processing A BR END LOOP 10.6 Cautions on Using Data Buffer Stack The contents of the data buffer stack are not automatically saved when an interrupt is accepted, and therefore, must be saved by software. Even when a bank of the data memory other than BANK0 is specified, the contents of the data buffer (existing in BANK0) can be saved or restored by using the "PUT" and "GET" instructions. 95 PD17704, 17705, 17707, 17708, 17709 11. GENERAL-PURPOSE PORT The general-purpose ports output high-level, low-level, or floating signals to external circuits, and read highlevel or low-level signals from external circuits. 11.1 Outline of General-purpose Port Table 11-1 shows the relationships between each port and port register. The general-prupose ports are classified into I/O, input, and output ports. The I/O ports are further subclassified into bit I/O ports that can be set in the input or output mode in 1-bit (1-pin) units, and group I/O ports that can be set in the input or output mode in 4-bit (4-pin) units. The inut or output mode of each I/O port is specified by the port input/output selection registers (addresses 60H through 6FH) of BANK15. Table 11-1. Relationships between Port (Pin) and Port Register (1/3) Port No. Pin Symbol I/O Bank Data Setting Method Port register (data memory) Address Symbol Bit symbol (reserved word) b3 b2 b1 b0 I/O (bit I/O) 71H P0B b3 b2 b1 b0 I/O (bit I/O) 72H P0C b3 b2 b1 b0 Input 73H P0D b3 b2 b1 b0 P0A3 P0A2 P0A1 P0A0 P0B3 P0B2 P0B1 P0B0 P0C3 P0C2 P0C1 P0C0 P0D3 P0D2 P0D1 P0D0 Port 0A 63 64 65 66 P0A3 P0A2 P0A1 P0A0 P0B3 P0B2 P0B1 P0B0 P0C3 P0C2 P0C1 P0C0 P0D3 P0D2 P0D1 P0D0 I/O (bit I/O) BANK0 70H P0A Port 0B 67 68 69 70 Port 0C 59 60 61 62 Port 0D 22 23 24 25 96 PD17704, 17705, 17707, 17708, 17709 Table 11-1. Relationships between Port (Pin) and Port Register (2/3) Port No. Pin Symbol I/O Bank Data Setting Method Port register (data memory) Address Symbol Bit symbol (reserved word) b3 b2 b1 b0 Output 71H P1B b3 b2 b1 b0 Input 72H P1C b3 b2 b1 b0 I/O (bit I/O) 73H P1D b3 b2 b1 b0 I/O (bit I/O) P2A2 P2A1 P2A0 P2B3 P2B2 P2B1 P2B0 P2C3 P2C2 P2C1 P2C0 I/O (bit I/O) P2D2 P2D1 P2D0 73H P2D I/O (bit I/O) 72H P2C I/O (bit I/O) 71H P2B BANK2 70H P2A b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 b3 b2 b1 b0 P1A3 P1A2 P1A1 P1A0 P1B3 P1B2 P1B1 P1B0 P1C3 P1C2 P1C1 P1C0 P1D3 P1D2 P1D1 P1D0 - P2A2 P2A1 P2A0 P2B3 P2B2 P2B1 P2B0 P2C3 P2C2 P2C1 P2C0 - P2D2 P2D1 P2D0 Port 1A 2 3 4 5 P1A3 P1A2 P1A1 P1A0 P1B3 P1B2 P1B1 P1B0 P1C3 P1C2 P1C1 P1C0 P1D3 P1D2 P1D1 P1D0 Input BANK1 70H P1A Port 1B 17 18 19 20 Port 1C 26 27 28 29 Port 1D 37 38 39 40 Port 2A No pin 14 15 16 Port 2B 43 44 45 46 Port 2C 55 56 57 58 Port 2D No pin 71 72 73 97 PD17704, 17705, 17707, 17708, 17709 Table 11-1. Relationships between Port (Pin) and Port Register (3/3) Port No. Pin Symbol I/O Bank Data Setting Method Port register (data memory) Address Symbol Bit symbol (reserved word) b3 b2 b1 b0 I/O (group I/O) 71H P3B b3 b2 b1 b0 I/O (group I/O) 72H P3C b3 b2 b1 b0 I/O (group I/O) 73H P3D b3 b2 b1 b0 - BANK4 | BANK15 Note 70H-73H - P3A3 P3A2 P3A1 P3A0 P3B3 P3B2 P3B1 P3B0 P3C3 P3C2 P3C1 P3C0 P3D3 P3D2 P3D1 P3D0 Port 3A 6 7 8 9 P3A3 P3A2 P3A1 P3A0 P3B3 P3B2 P3B1 P3B0 P3C3 P3C2 P3C1 P3C0 P3D3 P3D2 P3D1 P3D0 I/O (group I/O) BANK3 70H P3A Port 3B 10 11 12 13 Port 3C 47 48 49 50 Port 3D 51 52 53 54 - No pin Fixed to "0" Note The PD17704 and 17705 do not have BANKs 6 through 14. PD17707 and 17708 do not have BANKs 10 through 14. 98 PD17704, 17705, 17707, 17708, 17709 11.2 General-Purpose I/O Port (P0A, P0B, P0C, P1D, P2A, P2B, P2C, P2D, P3A, P3B, P3C, P3D) 11.2.1 Configuration of I/O port The following paragraphs (1) and (2) show the configuration of the I/O ports. (1) P0A (P0A1, P0A0) P0B (P0B3, P0B2, P0B1, P0B0) P0C (P0C3, P0C2, P0C1, P0C0) P1D (P1D3, P1D2, P1D1, P1D0) P2A (P2A2, P2A1, P2A0) P2B (P2B3, P2B2, P2B1, P2B0) P2C (P2C3, P2C2, P2C1, P2C0) P2D (P2D2, P2D1, P2D0) P3A (P3A3, P3A2, P3A1, P3A0) P3B (P3B3, P3B2, P3B1, P3B0) P3C (P3C3, P3C2, P3C1, P3C0) P3D (P3D3, P3D2, P3D1, P3D0) VDD I/O selection flag Output latch Write instruction Port register (1 bit) VDD 1 0 Read instruction CKSTOP Note Note This is an internal signal that is output when the clock stop instruction is executed, and this circuit is designed not to increase the current consumption due to noise even if it is floated. 99 PD17704, 17705, 17707, 17708, 17709 (2) P0A (P0A3, P0A2) I/O selection flag Output latch Write instruction Port register (1 bit) VDD Read instruction CKSTOP Note Note This is an internal signal that is output when the clock stop instruction is executed, and this circuit is designed not to increase the current consumption due to noise even if it is floated. 11.2.2 Using I/O port The input or output mode of the I/O ports is set by I/O selection register P0A, P0B, P0C, P1D, P2A, P2B, P2C, P2D, P3A, P3B, P3C, or P3D of the control registers. Because P0A, P0B, P0C, P1D, P2A, P2B, P2C, and P2D are bit I/O ports, they can be set in the input or output mode in 1-bit units. P3A, P3B, P3C, and P3D are group I/O ports, and therefore they are set in the input or output mode in 4bit units. Setting the output data of or reading the input data of a port is carried out by executing an instruction that writes data to or reads data from the port. 11.2.3 shows the configuration of the I/O selection register of each port. 11.2.4 and 11.2.5 describe how each port is used as an input or output port. 11.2.6 describes the points to be noted when using the I/O ports. 100 PD17704, 17705, 17707, 17708, 17709 11.2.3 I/O port I/O selection register The following I/O selection registers of the I/O ports are available. * Port 0A bit I/O selection register * Port 0B bit I/O selection register * Port 0C bit I/O selection register * Port 1D bit I/O selection register * Port 2A bit I/O selection register * Port 2B bit I/O selection register * Port 2C bit I/O selection register * Port 2D bit I/O selection register * Group I/O selection registers (port 3A, port 3B, port 3C, port 3D) Each I/O selection register sets the input or output mode of the corresponding port pin. The following paragraphs (1) through (9) descibe the configuration and functions of the above I/O selection registers. 101 PD17704, 17705, 17707, 17708, 17709 (1) Port 0A bit I/O selection register Name Flag symbol b3 b2 b1 b0 Address Read/Write Port 0A bit I/O selection P 0 A B I P 0 A B I P 0 A B I P 0 A B I (BANK15) 6FH R/W OO 3 2 OO 1 0 Sets input/output mode of port 0 1 Sets P0A0 pin in input mode Sets P0A0 pin in output mode Sets input/output mode of port 0 1 Sets P0A1 pin in input mode Sets P0A1 pin in output mode Sets input/output mode of port 0 1 Sets P0A2 pin in input mode Sets P0A2 pin in output mode Sets input/output mode of port 0 1 Power-ON reset At reset Sets P0A3 pin in input mode Sets P0A3 pin in output mode 0 0 0 0 0 0 0 0 WDT&SP reset CE reset Retained Retained Clock stop 102 PD17704, 17705, 17707, 17708, 17709 (2) Port 0B bit I/O selection register Name Flag symbol b3 b2 b1 b0 Address Read/Write Port 0B bit I/O selection P 0 B B I P 0 B B I P 0 B B I P 0 B B I (BANK15) 6EH R/W OO 3 2 OO 1 0 Sets input/output mode of port 0 1 Sets P0B0 pin in input mode Sets P0B0 pin in output mode Sets input/output mode of port 0 1 Sets P0B1 pin in input mode Sets P0B1 pin in output mode Sets input/output mode of port 0 1 Sets P0B2 pin in input mode Sets P0B2 pin in output mode Sets input/output mode of port 0 1 Power-ON reset At reset Sets P0B3 pin in input mode Sets P0B3 pin in output mode 0 0 0 0 0 0 0 0 WDT&SP reset CE reset Retained Retained Clock stop 103 PD17704, 17705, 17707, 17708, 17709 (3) Port 0C bit I/O selection register Name Flag symbol b3 b2 b1 b0 Address Read/Write Port 0C bit I/O selection P 0 C B I P 0 C B I P 0 C B I P 0 C B I (BANK15) 6DH R/W OO 3 2 OO 1 0 Sets input/output mode of port 0 1 Sets P0C0 pin in input mode Sets P0C0 pin in output mode Sets input/output mode of port 0 1 Sets P0C1 pin in input mode Sets P0C1 pin in output mode Sets input/output mode of port 0 1 Sets P0C2 pin in input mode Sets P0C2 pin in output mode Sets input/output mode of port 0 1 Power-ON reset At reset Sets P0C3 pin in input mode Sets P0C3 pin in output mode 0 0 0 0 0 0 0 0 WDT&SP reset CE reset Retained Retained Clock stop 104 PD17704, 17705, 17707, 17708, 17709 (4) Port 1D bit I/O selection register Name Flag symbol b3 b2 b1 b0 Address Read/Write Port 1D bit I/O selection P 1 D B I P 1 D B I P 1 D B I P 1 D B I (BANK15) 6CH R/W OO 3 2 OO 1 0 Sets input/output mode of port 0 1 Sets P1D0 pin in input mode Sets P1D0 pin in output mode Sets input/output mode of port 0 1 Sets P1D1 pin in input mode Sets P1D1 pin in output mode Sets input/output mode of port 0 1 Sets P1D2 pin in input mode Sets P1D2 pin in output mode Sets input/output mode of port 0 1 Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 Sets P1D3 pin in input mode Sets P1D3 pin in output mode At reset Retained Retained Clock stop 105 PD17704, 17705, 17707, 17708, 17709 (5) Port 2A bit I/O selection register Name Flag symbol b3 b2 b1 b0 Address Read/Write Port 2A bit I/O selection 0 P 2 A B I O 2 P 2 A B I P 2 A B I (BANK15) 6BH R/W OO 1 0 Sets input/output mode of port 0 1 Sets P2A0 pin in input mode Sets P2A0 pin in output mode Sets input/output mode of port 0 1 Sets P2A1 pin in input mode Sets P2A1 pin in output mode Sets input/output mode of port 0 1 Sets P2A2 pin in input mode Sets P2A2 pin in output mode Fixed to "0" Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 At reset Retained Retained Clock stop 106 PD17704, 17705, 17707, 17708, 17709 (6) Port 2B bit I/O selection register Name Flag symbol b3 b2 b1 b0 Address Read/Write Port 2B bit I/O selection P 2 B B I P 2 B B I P 2 B B I P 2 B B I (BANK15) 6AH R/W OO 3 2 OO 1 0 Sets input/output mode of port 0 1 Sets P2B0 pin in input mode Sets P2B0 pin in output mode Sets input/output mode of port 0 1 Sets P2B1 pin in input mode Sets P2B1 pin in output mode Sets input/output mode of port 0 1 Sets P2B2 pin in input mode Sets P2B2 pin in output mode Sets input/output mode of port 0 1 Power-ON reset 0 0 0 0 0 0 0 0 Sets P2B3 pin in input mode Sets P2B3 pin in output mode At reset WDT&SP reset CE reset Retained Retained Clock stop 107 PD17704, 17705, 17707, 17708, 17709 (7) Port 2C bit I/O selection register Name Flag symbol b3 b2 b1 b0 Address Read/Write Port 2C bit I/O selection P 2 C B I P 2 C B I P 2 C B I P 2 C B I (BANK15) 69H R/W OO 3 2 OO 1 0 Sets input/output mode of port 0 1 Sets P2C0 pin in input mode Sets P2C0 pin in output mode Sets input/output mode of port 0 1 Sets P2C1 pin in input mode Sets P2C1 pin in output mode Sets input/output mode of port 0 1 Sets P2C2 pin in input mode Sets P2C2 pin in output mode Sets input/output mode of port 0 1 Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 Sets P2C3 pin in input mode Sets P2C3 pin in output mode At reset Retained Retained Clock stop 108 PD17704, 17705, 17707, 17708, 17709 (8) Port 2D bit I/O selection register Name Flag symbol b3 b2 b1 b0 Address Read/Write Port 2D bit I/O selection 0 P 2 D B I O 2 P 2 D B I P 2 D B I (BANK15) 68H R/W OO 1 0 Sets input/output mode of port 0 1 Sets P2D0 pin in input mode Sets P2D0 pin in output mode Sets input/output mode of port 0 1 Sets P2D1 pin in input mode Sets P2D1 pin in output mode Sets input/output mode of port 0 1 Sets P2D2 pin in input mode Sets P2D2 pin in output mode Fixed to "0" Power-ON reset At reset 0 0 0 0 0 0 0 WDT&SP reset CE reset Retained Retained Clock stop 109 PD17704, 17705, 17707, 17708, 17709 (9) Group I/O selection register (ports 3A, 3B, 3C, 3D) Name Flag symbol b3 b2 b1 b0 Address Read/Write Group I/O selection P 3 D P 3 C P 3 B P 3 A (BANK15) 67H R/W GG I I GG I I OO OO Sets input/output mode of port 0 1 Sets P3A0 through P3A3 pins in input mode Sets P3A0 through P3A3 pins in output mode Sets input/output mode of port 0 1 Sets P3B0 through P3B3 pins in input mode Sets P3B0 through P3B3 pins in output mode Sets input/output mode of port 0 1 Sets P3C0 through P3C3 pins in input mode Sets P3C0 through P3C3 pins in output mode Sets input/output mode of port 0 1 Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 Sets P3D0 through P3D3 pins in input mode Sets P3D0 through P3D3 pins in output mode At reset Retained Retained Clock stop 110 PD17704, 17705, 17707, 17708, 17709 11.2.4 When using I/O port as input port The port pin to be set in the input mode is selected by the I/O selection register corresponding to the port. Ports P0A, P0B, P0C, P1D, P2A, P2B, P2C, and P2D can be set in the input or output mode in 1-bit units. P3A, P3B, P3C, and P3D can be set in the input or output mode in 4-bit units. The pin set in the input mode is floated (Hi-Z) and waits for input of an external signal. The input data is read by executing a read instruction (such as SKT) to the port register corresponding to the port pin. "1" is read from the port register when a high level is input to the corresponding port pin; when a low level is input to the port pin, "0" is read from the register. When a write instruction (such as MOV) is executed to the port register corresponding to the pin set in the input mode, the contents of the output latch are rewritten. 11.2.5 When using I/O port as output port The port pin to be set in the output mode is selected by the I/O selection register corresponding to the port. Ports P0A, P0B, P0C, P1D, P2A, P2B, P2C, and P2D can be set in the input or output mode in 1-bit units. P3A, P3B, P3C, and P3D can be set in the input or output mode in 4-bit units. 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) to the port register corresponding to the port pin. Write "1" to the port register to output a high level to the port pin; write "0" to output a low level. The port pin can be also floated (Hi-Z) if it is set in the input mode. If a read instruction (such as SKT) is executed to the port register corresponding to a port pin set in the output mode, the contents of the output latch are read. Note, however, that the contents of the output latch of the P0A3 and P0A2 pins may differ from the read contents because the status of these pins are read as are (refer to 11.2.6). 11.2.6 Cautions on using I/O port (P0A3 and P0A2 pins) When using the P0A3 and P0A2 pins in the output mode, the contents of the output latch may be rewritten as shown in the example below. Example To set the P0A3 and P0A2 pins in the output mode BANK15 INITFLG P0ABI03, P0ABI02, NOT P0ABI01, NOT P0ABI00 ; Sets P0A3 and P0A2 pins in output mode INITFLG P0A3, P0A2, NOT P0A1, NOT P0A0 ; <1> CLR1 AND P0A3 .MF.P0A3 SHR 4, #.DF.(NOT P0A3 AND 0FH) ; Outputs low level to P0A3 pin MACRO EXTEND ; Outputs high level to P0A3 and P0A2 pins If the P0A2 pin is externally made low when the instruction in the above example <1> is executed, the contents of the output latch of the P0A2 pin are rewritten to "0" by the CLR1 instruction. In other words, if an instruction that reads the contents of port register P0A is executed while the P0A3 or P0A2 pin is set in the output mode, the contents of the output latch are rewritten to the pin level at that time, regardless of the previous status. 111 PD17704, 17705, 17707, 17708, 17709 11.2.7 Status of I/O port at reset (1) At power-ON reset All the I/O ports are set in the input mode. The contents of the output latch are reset to "0". (2) At WDT&SP reset All the I/O ports are set in the input mode. The contents of the output latch are reset to "0". (3) At CE reset The setting of the input or output mode is retained. The contents of the output latch are also retained. (4) On execution of clock stop instruction The setting of the input or output mode is retained. The contents of the output latch are also retained. (5) In halt status The previous status is retained. 112 PD17704, 17705, 17707, 17708, 17709 11.3 General-Purpose Input Port (P0D, P1A, P1C) 11.3.1 Configuration of input port The following paragraphs (1) and (2) show the configuration of the input port. (1) P0D (P0D3, P0D2, P0D1, P0D0) Write instruction To A/D converter VDD Port register (1 bit) Input latch Read instruction CKSTOP Note High-ON resistance P0DPLD flag Note This is an internal signal output on execution of the clock stop instruction, and its circuit is designed not to increase the current consumption due to noise even if the pin is floated. (2) P1A (P1A3, P1A2, P1A1, P1A0) P1C (P1C3, P1C2, P1C1, P1C0) To frequency counter or A/D converter Write instruction VDD Port register (1 bit) Read instruction CKSTOP Note Note This is an internal signal output on execution of the clock stop instruction, and its circuit is designed not to increase the current consumption due to noise even if the pin is floated. (Except P1A3, P1A2, P1A0) 113 PD17704, 17705, 17707, 17708, 17709 11.3.2 Using input port The input data is read by executing a read instruction (such as SKT) to the port register corresponding to the port pin. "1" is read from the port register when a high level is input to the corresponding port pin; when a low level is input to the port pin, "0" is read from the register. Nothing is affected even if a write instruction (such as MOV) is executed to the port register. P0D has a pull-down resistor that can be connected or disconnected by software in 1-bit units. The pull-down resistor is connected when "0" is written to the corresponding bit of the port 0D pull-down resistor selection register. When "1" is written to the corresponding bit of this register, the pull-down resistor is disconnected. 11.3.3 Port 0D pull-down resistor selection register The port 0D pull-down resistor selection register specifies whether a pull-down resistor is connected to P0D3 through P0D0 pins. The configuration and function of this register are illustrated below. * Port 0D pull-down resistor selection register Name Flag symbol b3 b2 b1 b0 Address Read/Write Port 0D pull-down resistor selection P 0 D P L D 3 P 0 D P L D 2 P 0 D P L D 1 P 0 D P L D 0 (BANK15) 66H R/W Selects pull-down resistor of P0D0 pin 0 1 Connects pull-down resistor to P0D0 pin Disconnects pull-down resistor from P0D0 pin Selects pull-down resistor of P0D1 pin 0 1 Connects pull-down resistor to P0D1 pin Disconnects pull-down resistor from P0D1 pin Selects pull-down resistor of P0D2 pin 0 1 Connects pull-down resistor to P0D2 pin Disconnects pull-down resistor from P0D2 pin Selects pull-down resistor of P0D3 pin 0 1 Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 Connects pull-down resistor to P0D3 pin Disconnects pull-down resistor from P0D3 pin At reset Retained Retained Clock stop 114 PD17704, 17705, 17707, 17708, 17709 11.3.4 Status of input port at reset (1) At power-ON reset All the input ports are set in the input mode. All the pull-down resistors of P0D are connected. (2) At WDT&SP reset All the input ports are set in the input mode. All the pull-down resistors of P0D are connected. (3) At CE reset The input ports are set in the input mode. The pull-down resistors of P0D retain the previous status. (4) On execution of clock stop instruction The input ports are set in the input mode. The pull-down resistors of P0D retain the previous status. (5) In halt status The previous status is retained. 115 PD17704, 17705, 17707, 17708, 17709 11.4 General-Purpose Output Port (P1B) 11.4.1 Configuration of output port The configuration of the output port is shown below. (1) P1B (P1B3, P1B2, P1B1, P1B0) Output latch Write instruction Port register (1 bit) Read instruction 11.4.2 Using output port The output port outputs the contents of the output latch to each pin. The output data is set by executing a write instruction (such as MOV) to the port register corresponding to the port pin. Write "1" to the port register to output a high level to the port pin; write "0" to output a low level. However, because P1B is an N-ch open-drain output port, it is floated when it outputs a high level. Therefore, an external pull-up resistor must be connected to this port. If a read instruction (such as SKT) is executed to the port register, the contents of the output latch are read. 11.4.3 Status of output port at reset (1) At power-ON reset The contents of the output latch are output. The contents of the output latch are reset to "0". (2) At WDT&SP reset The contents of the output latch are output. The contents of the output latch are reset to "0". (3) At CE reset The contents of the output latch are output. The contents of the output latch are retained. (4) On execution of clock stop instruction The contents of the output latch are output. The contents of the output latch are retained. (5) In halt status The contents of the output latch are output. The contents of the output latch are retained. 116 PD17704, 17705, 17707, 17708, 17709 12. INTERRUPT 12.1 Outline of Interrupt Block Figure 12-1 outlines the interrupt block. As shown in the figure, the interrupt block temporarily stops the currently executed program and branches execution to a vector address in response to an interrupt request output by a peripheral hardware unit. The interrupt block consists of an "interrupt request servicing block" corresponding to each peripheral hardware unit, "interrupt enable flip-flop" that enables all interrupts, "stack pointer" that is controlled when an interrupt is accepted, "address stack registers", "program counter", and "interrupt stack". The "interrupt control block" of each peripheral hardware unit consists of an "interrupt request flag (IRQ xxx)" that detects the corresponding interrupt request, "interrupt enable flag (IPxxx)" that enables the interrupt, and "vector address generator (VAG)" that specifies a vector address when the interrupt is accepted. The PD17709 has the following 12 types of maskable interrupts. * CE pin falling edge interrupt * INT0 through INT4 interrupts * Timer 0 through timer 3 interrupts * Serial interface 0 and serial interface 1 interrupts When an interrupt is accepted, execution branches to a predetermined address, and the interrupt is serviced. 117 PD17704, 17705, 17707, 17708, 17709 Figure 12-1. Outline of Interrupt Block Interrupt control block IPSIO1 flag Serial interface 1 IRQSIO1 flag Vector address generator 01H Stack pointer Address stack registers Program counter IPSIO0 flag Serial interface 0 IRQSIO0 flag Vector address generator 02H System registers IPTM3 flag Timer 3 IRQTM3 flag Vector address generator 03H Pointer Interrupt stack IPTM2 flag Timer 2 IRQTM2 flag Vector address generator 04H IPTM1 flag Timer 1 IRQTM1 flag Vector address generator 05H IPTM0 flag Timer 0 IRQTM0 flag Vector address generator 06H IP4 flag INT4 pin IRQINT4 flag Vector address generator 07H IP3 flag INT3 pin IRQINT3 flag Vector address generator 08H IP2 flag INT2 pin IRQINT2 flag Vector address generator 09H IP1 flag INT1 pin IRQINT1 flag Vector address generator 0AH IP0 flag INT0 pin IRQINT0 flag Vector address generator 0BH IPCE flag CE pin falling IRQCE flag Vector address generator 0CH DI, EI instruction Interrupt enable flip-flop 118 PD17704, 17705, 17707, 17708, 17709 12.2 Interrupt Control Block An interrupt control block is provided for each peripheral hardware unit. This block detects issuance of an interrupt request, enables the interrupt, and generates a vector address when the interrupt is accepted. 12.2.1 Configuration and function of interrupt request flag (IRQxxx) Each interrupt request flag is set to 1 when an interrupt request is issued by the corresponding peripheral hardware unit, and is reset to 0 when the interrupt is accepted. Writing the interrupt request flag to "1" via a window register is equivalent to issuance of the interrupt request. By detecting the interrupt request flag when an interrupt is not enabled, issuance status of each interrupt request can be detected. Once the interrupt request flag has been set, it is not reset until the corresponding interrupt is accepted, or until "0" is written to the flag via a window register. Even if two or more interrupt requests are issued at the same time, the interrupt request flag corresponding to the interrupt that has not been accepted is not reset. Figures 12-2 through 12-13 show the configuration and function of the respective interrupt request registers. Figure 12-2. Configuration of Serial Interface 1 Interrupt Request Register Name Flag symbol b3 b2 b1 b0 Serial interface 1 interrupt request 0 0 0 I R Q S I O 1 34H R/W Address Read/Write Indicates interrupt request issuance status of serial interface 1 0 1 Interrupt request not issued Interrupt request issued Fixed to "0" Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 R R At reset Clock stop R: Retained 119 PD17704, 17705, 17707, 17708, 17709 Figure 12-3. Configuration of Serial Interface 0 Interrupt Request Register Name Flag symbol b3 b2 b1 b0 Serial interface 0 interrupt request 0 0 0 I R Q S I O 0 35H R/W Address Read/Write Indicates interrupt request issuance status of serial interface 0 0 1 Interrupt request not issued Interrupt request issued Fixed to "0" Power-ON reset 0 0 0 0 0 R R At reset WDT&SP reset CE reset Clock stop R: Retained Figure 12-4. Configuration of Timer 3 Interrupt Request Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Timer 3 interrupt request 0 0 0 I R Q T M 3 36H R/W Indicates interrupt request issuance status of timer 3 0 1 Interrupt request not issued Interrupt request issued Fixed to "0" Power-ON reset 0 0 0 0 0 R R At reset WDT&SP reset CE reset Clock stop R: Retained 120 PD17704, 17705, 17707, 17708, 17709 Figure 12-5. Configuration of Timer 2 Interrupt Request Register Name Flag symbol b3 b2 b1 b0 Timer 2 interrupt request 0 0 0 I R Q T M 2 37H R/W Address Read/Write Indicates interrupt request issuance status of timer 2 0 1 Interrupt request not issued Interrupt request issued Fixed to "0" Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 R R At reset Clock stop R: Retained Figure 12-6. Configuration of Timer 1 Interrupt Request Register Name Flag symbol b3 b2 b1 b0 Timer 1 interrupt request 0 0 0 I R Q T M 1 38H R/W Address Read/Write Indicates interrupt request issuance status of timer 1 0 1 Interrupt request not issued Interrupt request issued Fixed to "0" Power-ON reset WDT&SP reset CE reset Clock stop R: Retained 0 0 0 0 0 R R At reset 121 PD17704, 17705, 17707, 17708, 17709 Figure 12-7. Configuration of Timer 0 Interrupt Request Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Timer 0 interrupt request 0 0 0 I R Q T M 0 39H R/W Indicates interrupt request issuance status of timer 0 0 1 Interrupt request not issued Interrupt request issued Fixed to "0" Power-ON reset WDT&SP reset CE reset Clock stop R: Retained 0 0 0 0 0 R R 122 At reset PD17704, 17705, 17707, 17708, 17709 Figure 12-8. Configuration of INT4 Pin Interrupt Request Register Name Flag symbol b3 b2 b1 b0 Address Read/Write INT4 pin interrupt request I N T 4 0 0 I R Q 4 3AH R/W Indicates interrupt request issuance status of INT4 pin 0 1 Interrupt request not issued Interrupt request issued Fixed to "0" Detects status of INT4 pin 0 1 Power-ON reset At reset WDT&SP reset CE reset U U U U 0 0 0 0 R R Low level is input High level is input Clock stop U: Undefined, R : Retained 123 PD17704, 17705, 17707, 17708, 17709 Figure 12-9. Configuration of INT3 Pin Interrupt Request Register Name Flag symbol b3 b2 b1 b0 Address Read/Write INT3 pin interrupt request I N T 3 0 0 I R Q 3 3BH R/W Indicates interrupt request issuance status of INT3 pin 0 1 Interrupt request not issued Interrupt request issued Fixed to "0" Detects status of INT3 pin 0 1 Power-ON reset WDT&SP reset CE reset U U U U 0 0 0 0 R R Low level is input High level is input 124 At reset Clock stop U: Undefined, R : Retained PD17704, 17705, 17707, 17708, 17709 Figure 12-10. Configuration of INT2 Pin Interrupt Request Register Name Flag symbol b3 b2 b1 b0 Address Read/Write INT2 pin interrupt request I N T 2 0 0 I R Q 2 3CH R/W Indicates interrupt request issuance status of INT2 pin 0 1 Interrupt request not issued Interrupt request issued Fixed to "0" Detects status of INT2 pin 0 1 Power-ON reset WDT&SP reset CE reset U U U U 0 0 0 0 R R Low level is input High level is input At reset Clock stop U: Undefined, R : Retained 125 PD17704, 17705, 17707, 17708, 17709 Figure 12-11. Configuration of INT1 Pin Interrupt Request Register Name Flag symbol b3 b2 b1 b0 Address Read/Write INT1 pin interrupt request I N T 1 0 0 I R Q 1 3DH R/W Indicates interrupt request issuance status of INT1 pin 0 1 Interrupt request not issued Interrupt request issued Fixed to "0" Detects status of INT1 pin 0 1 Power-ON reset WDT&SP reset CE reset U U U U 0 0 0 0 R R Low level is input High level is input 126 At reset Clock stop U: Undefined, R: Retained PD17704, 17705, 17707, 17708, 17709 Figure 12-12. Configuration of INT0 Pin Interrupt Request Register Name Flag symbol b3 b2 b1 b0 Address Read/Write INT0 pin interrupt request I N T 0 0 0 I R Q 0 3EH R/W Indicates interrupt request issuance status of INT0 pin 0 1 Interrupt request not issued Interrupt request issued Fixed to "0" Detects status of INT0 pin 0 1 Power-ON reset U U U U 0 0 0 0 R R Low level is input High level is input At reset WDT&SP reset CE reset Clock stop U: Undefined, R: Retained 127 PD17704, 17705, 17707, 17708, 17709 Figure 12-13. Configuration of CE Pin Interrupt Request Register Name Flag symbol b3 b2 b1 b0 Address Read/Write CE pin interrupt request C E 0 C E C N T S T T I R Q C E 3FH R/W Indicates interrupt request issuance status of CE pin 0 1 Interrupt request not issued Interrupt request issued Detects status of CE reset counter 0 1 Stops Operates Fixed to "0" Detects status of CE pin 0 1 Low level is input High level is input Power-ON reset At reset WDT&SP reset CE reset U U U U 0 0 0 0 0 0 0 R R Clock stop U : Undefined, R : Retained 128 PD17704, 17705, 17707, 17708, 17709 12.2.2 Function and configuration of interrupt request flag (IPxxx) Each interrupt request flag enables the interrupt of the corresponding peripheral hardware unit. In order for an interrupt to be accepted, all the following conditions must be satisfied. * The interrupt must be enabled by the corresponding interrupt request flag. * The interrupt request must be issued by the corresponding interrupt request flag. * The EI instruction (which enables all interrupts) must be executed. The interrupt enable flags are located on the interrupt enable register on the register file. Figures 12-14 through 12-16 show the configuration and function of each interrupt enable register. Figure 12-14. Configuration of Interrupt Enable Register 1 Name Flag symbol b3 b2 b1 b0 Address Read/Write Interrupt enable 1 I P S I I P S I I P T I P T 2DH R/W MM 3 2 OO 1 0 Enables or disables timer 2 interrupt 0 1 Disables Enables Enables or disables timer 3 interrupt 0 1 Disables Enables Enables or disables serial interface 0 interrupt 0 1 Disables Enables Enables or disables serial interface 1 interrupt 0 1 Disables Enables At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 Retained Retained Clock stop 129 PD17704, 17705, 17707, 17708, 17709 Figure 12-15. Configuration of Interrupt Enable Register 2 Name Flag symbol b3 b2 b1 b0 Interrupt enable 2 I P T I P T I P 4 I P 3 2EH R/W Address Read/Write MM 1 0 Enables or disables INT3 pin interrupt 0 1 Disables Enables Enables or disables INT4 pin interrupt 0 1 Disables Enables Enables or disables timer 0 interrupt 0 1 Disables Enables Enables or disables timer 1 interrupt 0 1 Disables Enables At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 Retained Retained Clock stop 130 PD17704, 17705, 17707, 17708, 17709 Figure 12-16. Configuration of Interrupt Enable Register 3 Name Flag symbol b3 b2 b1 b0 Address Read/Write Interrupt enable 3 I P 2 I P 1 I P 0 I P C E 2FH R/W Enables or disables CE pin interrupt 0 1 Disables Enables Enables or disables INT0 pin interrupt 0 1 Disables Enables Enables or disables INT1 pin interrupt 0 1 Disables Enables Enables or disables INT2 pin interrupt 0 1 Disables Enables At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 Retained Retained Clock stop 131 PD17704, 17705, 17707, 17708, 17709 12.2.3 Vector address generator (VAG) The vector address generator generates a branch address (vector address) of the program memory corresponding to an interrupt source that has been accepted from the corresponding peripheral hardware. Table 12-1 shows the vector addresses of the respective interrupt sources. Table 12-1. Interrupt Sources and Vector Addresses Interrupt Source Falling edge of CE pin INT0 pin INT1 pin INT2 pin INT3 pin INT4 pin Timer 0 Timer 1 Timer 2 Timer 3 Serial interface 0 Serial interface 1 Vector Address 00CH 00BH 00AH 009H 008H 007H 006H 005H 004H 003H 002H 001H 132 PD17704, 17705, 17707, 17708, 17709 12.3 Interrupt Stack Register 12.3.1 Configuration and function of interrupt stack register Figure 12-17 shows the configuration of the interrupt stack register. The interrupt stack register saves the contents of the following system registers (except the address register (AR)) when an interrupt is accepted. * Window register (WR) * Bank register (BANK) * Index register (IX) * General pointer (RP) * Program status word (PSWORD) When an interrupt is accepted and the contents of the above system registers are saved to the interrupt stack, the contents of the above system registers, except the window register, are reset to "0". The interrupt stack can save the contents of the above system registers at up to four levels. Therefore, interrupts can be nested up to four levels. The contents of the interrupt stack register are restored to the system registers when the interrupt return (RETI) instruction is executed. The contents of the interrupt stack register are undefined at power-ON reset. The previous contents are retained at CE reset and on execution of the clock stop instruction. Figure 12-17. Configuration of Interrupt Stack Register Interrupt stack pointer of system register Interrupt stack register (INTSK) Name Window stack WRSK Bank stack BANKSK Index stack H IXHSK Index stack M IXHSK Index stack L IXHSK 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 0H 1H 2H 3H 4H 5H Undefined INTSK1 INTSK2 INTSK3 INTSK4 Pointer stack H RPHSK Pointer stack L RPLSK Status stack PSWSK Bit b3 b2 b1 b0 0 S Y S S P 2 S Y S S P 1 S Y S S P 0 Address Undefined 133 PD17704, 17705, 17707, 17708, 17709 12.3.2 Interrupt stack pointer of system register The interrupt stack pointer of the system register detects the nesting level of interrupts. The interrupt stack pointer can be only read and cannot be written. The configuration and function of the interrupt stack pointer are illustrated below. Name Flag symbol b3 b2 b1 b0 ) ) ) Address Read/Write Interrupt stack pointer of system registers 0 S Y S R S P 2 ( S Y S R S P 1 ( S Y S R S P 0 ( 08H R Detects level of interrupt stack of system registers 0 0 0 0 1 1 0 0 1 1 0 0 0 1 0 1 0 1 Use prohibited 4 levels (INTSK1) 3 levels (INTSK2) 2 levels (INTSK3) 1 level (INTSK4) 0 level Fixed to "0" At reset Power-ON reset WDT&SP reset CE reset 0 1 1 1 0 0 0 1 1 1 Clock stop Retained 134 PD17704, 17705, 17707, 17708, 17709 12.3.3 Interrupt stack operation Figure 12-8 shows the operation of the interrupt stack. When nested interrupts exceeding four levels are accepted, since the contents saved first are discarded they therefore must be saved by the program. Figure 12-18. Operation of Interrupt Stack (1/2) (a) Where interrupt nesting level is 4 or less Undefined Undefined Undefined Undefined Main routine MAIN Undefined Undefined Undefined Interrupt A A MAIN Undefined Undefined Interrupt B MAIN A B RETI RETI Undefined Undefined Undefined Undefined MAIN Undefined Undefined Undefined A MAIN Undefined Undefined 135 PD17704, 17705, 17707, 17708, 17709 Figure 12-18. Operation of Interrupt Stack (2/2) (b) Where interrupt nesting level is 5 or more Undefined Undefined MAIN Undefined Undefined Undefined A MAIN Undefined Undefined Interrupt C C B A MAIN Interrupt D D C B A Interrupt E Main routine Interrupt A MAIN A B D E Interrupt level 1 Interrupt level 2 Interrupt level 4 Interrupt level 5 System reset Caution The system is reset when an interrupt of level 5 is accepted. However, the ISPRES flag, which resets the non-maskable interrupt if the interrupt stack overflows or underflows, must be set to "1". This flag is "1" after system reset, and can then be written only once. 136 PD17704, 17705, 17707, 17708, 17709 12.4 Stack Pointer, Address Stack Registers, and Program Counter The address stack registers save a return address when execution returns from an interrupt routine. The stack pointer specifies the address of an address stack register. When an interrupt is accepted, the value of the stack pointer is decremented by one, and the value of the program counter at that time is saved to an address stack register specified by the stack pointer. Next, the interrupt routine is executed. When the interrupt return (RETI) instruction is executed after that, the contents of an 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. For further information, also refer to 3. ADDRESS STACK (ASK). 12.5 Interrupt Enable Flip-Flop (INTE) The interrupt enable flip-flop enables or disables the 12 types of maskable 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 instructions EI (to set) and DI (to reset). The EI instruction sets this flip-flop when the instruction next to EI is executed, and the DI instruction resets the flip-flop while it is being executed. When an interrupt is accepted, this flip-flop is automatically reset. This flip-flop is also reset at power-ON reset, at a reset by the RESET pin, at a watchdog timer, overflow or underflow of the stack, and at CE reset. The flip-flop retains the previous status on execution of the clock stop instruction. 137 PD17704, 17705, 17707, 17708, 17709 12.6 Accepting Interrupt 12.6.1 Accepting interrupt and priority The following operations are performed before an interrupt is accepted. (1) Each peripheral hardware unit outputs an interrupt request signal to the corresponding interrupt request block if a given interrupt condition (for example, input of the falling signal to the INT0 pin) is satisfied. (2) When each interrupt request block accepts an interrupt request signal from the corresponding peripheral hardware unit, it sets the corresponding interrupt request flag (for example, IRQ0 flag if it is the INT0 pin that has issued the interrupt request) to "1". (3) The interrupt enable flag corresponding to each interrupt request flag (for example, IP0 flag if the interrupt request flag is IRQ0) is set to "1" when each interrupt request flag is set to "1", and each interrupt request block 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 is set to "1" by the EI instruction, and reset to "0" by the DI instruction. If "1" is output by each interrupt request processing block while the interrupt enable flip-flop is set to "1", the interrupt is accepted. As shown in Figure 12-1, the output of the interrupt enable flip-flop is input to each interrupt request block via an AND circuit when an interrupt is accepted. The signal input to each interrupt request block causes the interrupt request flag corresponding to each interrupt request flag to be reset to "0" and the vector address corresponding to each interrupt to be output. If the interrupt request block outputs "1" at this time, the interrupt accept signal is not transferred to the next stage. If two or more interrupt requests are issued at the same time, therefore, the interrupts are accepted according to the priority shown in Table 12-2. Unless the interrupt request enable flag is set to "1", the corresponding interrupt is not accepted. Therefore, by resetting the interrupt enable flag to "0", the interrupt with a high hardware priority can be disabled. Table 12-2. Interrupt Priority Interrupt Source Falling edge of CE pin INT0 pin INT1 pin INT2 pin INT3 pin INT4 pin Timer 0 Timer 1 Timer 2 Timer 3 Serial interface 0 Serial interface 1 Priority 1 2 3 4 5 6 7 8 9 10 11 12 138 PD17704, 17705, 17707, 17708, 17709 12.6.2 Timing chart when interrupt is accepted The timing charts in Figure 12-19 illustrate the operations performed when an interrupt or interrupts are accepted. Figure 12-19 (1) is the timing chart when one interrupt is accepted. (a) in (1) is the timing chart where the interrupt request flag is set to "1" after all the others, and (b) is the timing chart where the interrupt enable flag is set to "1" after all the others. In either case, the interrupt is accepted when the interrupt request flag, interrupt enable-flip flop, and interrupt enable flag all have been set to "1". If the flag or flip-flop that has been set last is set in the first instruction cycle of the "MOVT DBF, @AR" instruction or by an instruction that satisfies a given skip condition, the interrupt is accepted in the second instruction cycle of the "MOVT DBF, @AR" instruction or after the instruction that is skipped (this instruction is treated as NOP) has been executed. The interrupt enable flip-flop is set in the instruction cycle next to that in which the EI instruction is executed. Therefore, the interrupt is accepted after the instruction next to the EI instruction has been executed even when the interrupt request flag is set in the execution cycle of the EI instruction. (2) in Figure 12-19 is the timing chart where two or more interrupts are used. When two or more interrupts are used, the interrupts are accepted according to the hardware priority if all the interrupt enable flags are set. However, the hardware priority can be changed by setting the interrupt enable flags by the program. "Instruction cycle" shown in Figure 12-19 is a special cycle in which the interrupt request flag is reset, a vector address is specified, and the contents of the program counter are saved after an interrupt has been accepted. It takes 1.78 s, which is equivalent to one instruction execution time, to be completed. For details, refer to 12.7 Operation after Interrupt Has Been Accepted. 139 PD17704, 17705, 17707, 17708, 17709 Figure 12-19. Timing Charts When Interrupt Is Accepted (1/3) (1) When one interrupt (e.g., rising of INT0 pin) is used (a) If there is no interrupt mask time by the interrupt flag (IPxxx) <1> If a normal instruction which is not "MOVT" or an instruction that satisfies a skip condition is executed when interrupt is accepted Instruction EI POKE MOV WR, #0010B INTPM3, WR Normal Interrupt instruction cycle INTE INT0 pin IRQ0 flag IP0 flag 1 instruction cycle 1.78 s INT0 pin interrupt accepted Interrupt enable period INT0 pin interrupt service <2> If "MOVT" or an instruction that satisfies a skip condition is executed when interrupt is accepted Instruction EI MOV POKE WR, #0010B INTPM3, WR MOVT DBF, @AR or skip instruction Interrupt cycle INTE INT0 pin IRQ0 flag IP0 flag 1 instruction cycle 1.78 s INT0 pin interrupt accepted Interrupt enable period INT0 pin interrupt service 140 PD17704, 17705, 17707, 17708, 17709 Figure 12-19. Timing Charts When Interrupt Is Accepted (2/3) (b) If interrupt is kept pending by the interrupt enable flag Instruction EI Interrupt MOV POKE cycle WR, #0010B INTPM3, WR INTE INT0 pin IRQ0 flag IP0 flag INT0 pin interrupt pending period INT0 pin interrupt service INT0 pin interrupt accepted (2) If two or more interrupts (e.g., INT0 pin and INT1 pin) are used (a) Hardware priority Instruction MOV POKE WR, #0110B INTPM3, WR INTE INT0 pin IRQ0 flag INT1 pin IRQ1 flag IP0 flag IP1 flag EI Interrupt cycle EI Interrupt cycle INT0 pin interrupt pending period INT0 pin interrupt service INT1 pin interrupt service INT1 pin interrupt pending period INT0 pin interrupt accepted INT1 pin interrupt accepted 141 PD17704, 17705, 17707, 17708, 17709 Figure 12-19. Timing Charts When Interrupt Is Accepted (3/3) (b) Software priority Instruction MOV POKE WR, #0100B INTPM3, WR INTE INT0 pin IRQ0 flag INT1 pin IRQ1 flag IP0 flag IP1 flag EI Interrupt MOV POKE cycle WR, #0110B INTPM3, WR EI Interrupt cycle INT1 pin interrupt pending period INT1 pin interrupt service INT0 pin interrupt service INT0 pin interrupt pending period INT1 pin interrupt accepted INT0 pin interrupt accepted 142 PD17704, 17705, 17707, 17708, 17709 12.7 Operations after Interrupt Has Been Accepted When an interrupt is accepted, the following operations are sequentially performed automatically. (1) The interrupt enable flip-flop and the interrupt request flag corresponding to the accepted interrupt request are reset to "0". As a result, the other interrupts are disabled. (2) The contents of the stack pointer are decremented by one. (3) The contents of the program counter are saved to an address stack register specified by the stack pointer. At this time, the contents of the program counter are the program memory address after the address at which the interrupt has been accepted. For example, if a branch instruction is executed when the interrupt has been accepted, the contents of the program counter are the branch destination address. If a subroutine call instruction is executed, the contents of the program counter are the call destination address. If the skip condition of a skip instruction is satisfied, the next instruction is executed as NOP and then the interrupt is accepted. Consequently, the contents of the program counter are the address after that of the instruction that is skipped. (4) The contents of the system registers (except the address register) are saved to the interrupt stack. (5) The contents of the vector address generator corresponding to the interrupt that has been accepted are transferred to the program counter. In other words, execution branches to the interrupt routine. The operations (1) through (5) above require the time of one special instruction cycle (1.78 s) in which normal instruction execution is not performed. This instruction cycle is called an "interrupt cycle". In other words, the time of one instruction cycle (1.78 s) is required after an interrupt has been accepted until execution branches to the corresponding vector address. 12.8 Returning from Interrupt Routine The interrupt return (RETI) instruction is used to return from an interrupt routine to the processing during which an interrupt was accepted. When the RETI instruction is executed, the following operations are sequentially performed automatically. (1) The contents of an 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 system registers. (3) The contents of the stack pointer are incremented by one. The operations (1) through (3) above require one instruction cycle (1.78 s) in which the RETI instruction is executed. The only difference between the RETI instruction and the RET and RETSK instructions, which are subroutine return instructions, is the restoration of the bank register and index register in step (2) above. 143 PD17704, 17705, 17707, 17708, 17709 12.9 External Interrupts (CE and INT0 through INT4 pins) 12.9.1 Outline of external interrupts Figure 19-20 outlines the external interrupts. As shown in the figure, external interrupt requests are issued at the rising or falling edges of signals input to the INT0 through INT4 pins, and at the falling edge of the CE pin. Whether an interrupt request is issued at the rising or falling edge of an INT pin is independently specified by the program. The INT0 through INT4 and CE pins are Schmitt trigger input pins to prevent malfunctioning due to noise. These pins do not accept a pulse input of less than 100 ns. Figure 12-20. Outline of External Interrupts Interrupt control block INT0 flag IEG0 flag INT0 Schmitt trigger INT1 flag Edge detection block IRQ0 flag IEG1 flag INT1 Schmitt trigger INT2 flag Edge detection block IRQ1 flag IEG2 flag INT2 Schmitt trigger INT3 flag Edge detection block IRQ2 flag IEG3 flag INT3 Schmitt trigger Edge detection block IRQ3 flag INT3SEL INT4 flag IEG4 flag INT4 Schmitt trigger Edge detection block IRQ4 flag INT4SEL CE flag CE Schmitt trigger Edge detection block IRQCE flag 144 PD17704, 17705, 17707, 17708, 17709 12.9.2 Edge detection block The edge detection block specifies the valid edge (rising or falling edge) of an input signal that issues the interrupt request of INT0 to INT4 pins, by using an interrupt edge selection register. Figure 12-21 shows the configuration and function of the interrupt edge selection register. Figure 12-21. Configuration of Interrupt Edge Selection Register (1/2) Name Flag symbol b3 b2 b1 b0 Address Read/Write Interrupt edge selection 1 I E G 4 I N T 4 S E L I E G 3 I N T 3 S E L 1EH R/W Selects function of P1A2/INT3 pin 0 1 Interrupt pin (edge detection cricuit operates) General-purpose port pin (edge detection cricuit stops) Selects input edge to issue interrupt request (INT3 pin) 0 1 Rising edge Falling edge Selects function of P1A3/INT4 pin 0 1 Interrupt pin (edge detection cricuit operates) General-purpose port pin (edge detection cricuit stops) Selects input edge to issue interrupt request (INT4 pin) 0 1 Rising edge Falling edge At resat Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 Retained Retained Clock stop Caution The external input delays about 100 ns. 145 PD17704, 17705, 17707, 17708, 17709 Figure 12-21. Configuration of Interrupt Edge Selection Register (2/2) Name Flag symbol b3 b2 b1 b0 Interrupt edge selection 2 0 I E G 2 I E I E 1FH R/W Address Read/Write GG 1 0 Selects input edge to issue interrupt request (INT0 pin) 0 1 Rising edge Falling edge Selects input edge to issue interrupt request (INT1 pin) 0 1 Rising edge Falling edge Selects input edge to issue interrupt request (INT2 pin) 0 1 Rising edge Falling edge Fixed to "0" At resat Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 Retained Retained Clock stop Caution The external input is delayed about 100 ns. Note that an interrupt request signal may be issued at the time when the interrupt request issuance edge is switched by the interrupt edge selection flags (IEG0 through IEG4). As indicated in the table 12-3, for example, if the IEG0 flag is set to "1" (falling edge), the high level is input from the INT0 pin and the IEG0 flag is reset to "0", the edge detection circuit judges that the rising edge is input and an interrupt request is issued. 146 PD17704, 17705, 17707, 17708, 17709 Table 12-3. Issuance of Interrupt Request by Changing IEG Flag Changes in IEG0 through IEG4 Flags Status of INT0 through INT4 Pins 1 0 Low level High level Low level High level Issuance of Interrupt Request Not issued Issued Issued Not issued Status of Interrupt Request Flag Retains previous status Set to "1" Set to "1" Retains previous status (Falling) (Rising) 0 1 (Rising) (Falling) 12.9.3 Interrupt control block The signal levels that are input to the INT0 through INT4 pins can be detected by using the INT0 through INT4 flags. Because these flags are reset independently of interrupts, when the interrupt function is not used the INT0 through INT2 pins can be used as a 3-bit input port, and P1A2/INT3 and P1A3/INT4 pins can be used as a 2bit general-purpose input port. If the interrupts are not enabled, these ports can be used as general-purpose port pins whose rising or falling edge can be detected by reading the corresponding interrupt request flags. At this time, however, the interrupt request flags are not automatically reset and must be reset by the program. For further information, also refer to 12.2.1 Configuration and function of interrupt request flag (IRQxxx). 12.10 Internal Interrupts The following six internal interrupts are available. * Timer 0 * Timer 1 * Timer 2 * Timer 3 * Serial interface 0 * Serial interface 1 12.10.1 Timer 0, timer 1, timer 2, and timer 3 interrupts Interrupt requests are issued at fixed intervals. For details, refer to 13. TIMER. 12.10.2 Serial interface 0 and serial interface 1 interrupts Interrupt requests can be issued at the end of a serial output or serial input operation. For details, refer to 16. SERIAL INTERFACE. 147 PD17704, 17705, 17707, 17708, 17709 13. TIMERS Timers are used to manage the program execution time. 13.1 Outline of Timers Figure 13-1 outlines the timers. The following five timers are available. * Basic timer 0 * Timer 0 * Timer 1 * Timer 2 * Timer 3 Basic timer 0 detects the status of a flip-flop that is set at fixed time intervals in software. Timers 0 through 3 are modulo timers and can use interrupts. Basic timer 0 can also be used to detect a power failure. Timer 3 is multiplexed with the D/A converter. The clock of each timer is created by dividing the system clock (4.5 MHz). Figure 13-1. Outline of Timers (1/2) (1) Basic timer 0 4.5 MHz Clock selection Flip-flop BTM0CY flag (2) Timer 0 Overflow Interrupt control TM0G Gate control Coincidence detection 4.5 MHz Clock selection Start/stop 8-bit counter Modulo register (3) Timer 1 4.5 MHz Clock selection Start/stop 8-bit counter Coincidence detection Interrupt control Modulo register 148 PD17704, 17705, 17707, 17708, 17709 Figure 13-1. Outline of Timers (2/2) (4) Timer 2 4.5 MHz Clock selection Start/stop 8-bit counter Coincidence detection Interrupt control Modulo register (5) Timer 3 4.5 MHz Clock divider Start/stop 8-bit counter or 9-bit counter Coincidence detection Interrupt control Modulo register Multiplexed whih D/A converter 149 PD17704, 17705, 17707, 17708, 17709 13.2 Basic Timer 0 13.2.1 Outline of basic timer 0 Figure 13-2 outlines basic timer 0. Basic timer 0 is used as a timer by detecting in software the BTM0CY flag that is set at fixed intervals (100, 50, 20, or 10 ms). If the BTM0CY flag is read first after power-ON reset, "0" is always read. After that, the flag is set to "1" at fixed intervals. If the CE pin goes high, CE reset is effected in synchronization with the timing at which the BTM0CY flag is set next. Therefore, a power failure can be detected by reading the content of the BTM0CY flag at system reset (powerON reset or CE reset). For the details of power failure detection, refer to 21. RESET. Figure 13-2. Outline of Basic Timer 0 Clock selection block BTM0CK0 flag BTM0CK1 flag 4.5 MHz Divider Selector Flip-flop BTM0CY flag Remarks 1. BTM0CK1 and BTM0CK0 (bits 1 and 0 of basic timer 0 clock selection register: refer to Figure 13-3) set the time intervals at which the BTM0CY flag is set. 2. BTM0CY (bit 0 of basic timer 0 carry register: refer to Figure 13-4) detects the status of the flip-flop. 150 PD17704, 17705, 17707, 17708, 17709 13.2.2 Clock selection block The clock selection block divides the system clock (4.5 MHz) and sets the time interval at which the BTM0CY flag is to be set, by using the BTM0CK0 and BTM0CK1 flags. Figure 13-3 shows the configuration of the basic timer 0 clock selection register. Figure 13-3. Configuration of Basic Timer 0 Clock Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Basic timer 0 clock selection 0 0 B T B T 18H R/W MM 0 C K 1 0 C K 0 Sets time interval at which BTM0CY flag is set 0 0 1 1 0 1 0 1 10 Hz (100 ms) 20 Hz (50 ms) 50 Hz (20 ms) 100 Hz (10 ms) Fixed to "0" At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 Retained Retained Clock stop 151 PD17704, 17705, 17707, 17708, 17709 13.2.3 Flip-flop and BTM0CY flag The flip-flop is set at fixed intervals and its status is detected by the BTM0CY flag of the basic timer 0 carry register. When the BTM0CY flag is read, it is reset to "0" (Read & Reset). The BTM0CY flag is "0" at power-ON reset, and is "1" at CE reset and on execution of the clock stop instruction. Therefore, this flag can be used to detect a power failure. The BTM0CY flag is not set after power application until an instruction that reads it is executed. Once the read instruction has been executed, the flag is set at fixed intervals. Figure 13-4 shows the configuration of the basic timer 0 carry register. Figure 13-4. Configuration of Basic Timer 0 Carry Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Basic timer 0 carry 0 0 0 B T M 0 C Y 17H R & Reset Detects status of flip-flop 0 1 Flip-flop is not set Flip-flop is set Fixed to "0" At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 R 1 R Clock stop R: Retained 152 PD17704, 17705, 17707, 17708, 17709 13.2.4 Example of using basic timer 0 An example of a program using basic timer 0 is shown below. This program executes processing A every 1 second. Example CLR2 MOV LOOP: SKT1 BR ADD SKE BR MOV BTM0CK1, BTM0CK0 ; Sets BTM0CY flag setting pulse to 10 Hz (100 ms) M1, #0 BTM0CY NEXT M1, #1 M1, #0AH NEXT M1, #0 ; Branches to NEXT if BTM0CY flag is "0" ; Adds 1 to M1 ; Executes processing A if M1 is "10" (1 second has elapsed) Processing A NEXT: Processing B BR LOOP ; Executes processing B and branches to LOOP 153 PD17704, 17705, 17707, 17708, 17709 13.2.5 Errors of basic timer 0 Errors of basic timer 0 include an error due to the detection time of the BTM0CY flag, and an error that occurs when the time interval at which the BTM0CY flag is to be set is changed. The following paragraphs (1) and (2) describe each error. (1) Error due to detection time of BTM0CY flag The time to detect the BTM0CY flag must be shorter than the time at which the BTM0CY flag is set (refer to 13.2.6 Notes on using basic timer 0). Where the time interval at which the BTM0CY flag is detected is tCHECK and the time interval at which the flag is set is tSET (100, 50, 20, or 10 ms), tCHECK and tSET must relate as follows. tCHECK < tSET At this time, the error of the timer when the BTM0CY flag is detected is as follows, as shown in Figure 13-5. 0 < Error < tSET Figure 13-5. Error of Basic Timer 0 due to Detection Time of BTM0CY Flag H L tSET 1 BTM0CY flag 0 tCHECK1 SKT1 BTM0CY <1> SKT1 BTM0CY <2> tCHECK2 SKT1 BTM0CY <3> tCHECK3 SKT1 BTM0CY <4> BTM0CY flag setting pulse As shown in Figure 13-5, the timer is updated because BTM0CY flag is "1" when it is detected in step <2>. When the flag is detected next in step <3>, it is "0". Therefore, the timer is not updated until the flag is detected again in <4>. This means that the timer is extended by the time of tCHECK3. 154 PD17704, 17705, 17707, 17708, 17709 (2) Error when time interval to set BTM0CY flag is changed The BTM0CK1 and BTM0CK0 flags set the time of the BTM0CY flag. As described in 13.2.2, four types of timer time-setting pulses can be selected: 10 Hz, 20 Hz, 50 Hz, and 100 Hz. At this time, these four pulses operate independently. If the timer time-setting pulse is changed by using the BTM0CK1 and BTM0CK0 flags, an error occurs as described in the example below. Example ; <1> INTIFLG NOT BTM0CK1, NOT BTM0CK0 ; Sets BTM0CY flag setting pulse to 10 Hz (100 ms) Processing A ; <2> INITFLG BTM0CK1, NOT BTM0CK0 ; Sets BTM0CY flag setting pulse to 50 Hz (20 ms) Processing A ; <3> INITFLG NOT BTM0CK1, NOT BTM0CK0 ; Sets BTM0CY flag setting pulse to 10 Hz (100 ms) At this time, the BTM0CY flag setting pulse is changed as shown in Figure 13-6. Figure 13-6. Changing BTM0CY Flag Setting Pulse H Internal pulse 10 HZ L Internal pulse H 50 HZ L BTM0CY flag H setting pulse L 1 BTM0CY flag 0 SKT1 BTM0CY <1> <2> <3> As shown in Figure 13-6, if the BTM0CY flag setting time is changed and the new pulse falls, the BTM0CY flag retains the previous status (<2> in the figure). If the new pulse rises, however, the BTM0CY flag is set to "1" (<3> in the figure). Although changing the pulse setting between 10 Hz (100 ms) and 50 Hz (20 ms) is described in this example, the same applies to changing the pulse in respect to 20 Hz (50 ms) and 100 Hz (10 ms). 155 PD17704, 17705, 17707, 17708, 17709 Therefore, as shown in Figure 13-7, the error of the time until the BTM0CY flag is first set after the BTM0CY flag setting time has been changed is as follows: -tSET < Error < tCHECK tSET : new setting time of BTM0CY flag tCHECK : time to detect BTM0CY flag Phase differences are provided among the internal pules of 10, 20, 50, and 100 Hz. Because these phase differences are shorter than the newly set pulse time, they are included in the above error. Figure 13-7. Timer Error When BTM0CY Flag Setting Time Is Changed from A to B H Internal pulse A L H Internal pulse B L tSET BTM0CY flag setting pulse H L H BTM0CY flag L SKT1 BTM0CY Intrinsic timer time Actual timer time Time changed An error of -tSET occurs if BTM0CY flag is detected immediately after the timer time has been changed because the flag then becomes "1". tCHECK Intrinsic timer time Actual timer time Time changed An error of tCHECK occurs if the timer time is changed immediately after BTM0CY flag has been detected because the flag is then reset once. tSET 156 PD17704, 17705, 17707, 17708, 17709 13.2.6 Cautions on using basic timer 0 (1) BTM0CY flag detection time interval Keep the time to detect the BTM0CY flag shorter than the time at which the BTM0CY flag is set. This is because, if the time of processing B is longer than the time interval at which the BTM0CY flag is set as shown in Figure 13-8, setting of the BTM0CY flag is overlooked. Figure 13-8. BTM0CY Flag Detection and BTM0CY Flag BTM0CY flag setting pulse H L tSET <1> 1 BTM0CY flag 0 SKT1 BTM0CY SKT1 BTM0CY Processing A Processing B SKT1 BTM0CY <2> <3> <4> <5> Because execution time of processing B takes too long after detection of BTM0CY flag that has been set to "1" in <2>, BTM0CY flag that is set to "1" in <3> cannot be detected. (2) Timer updating processing time and BTM0CY flag detection time interval As described in (1) above, time interval tSET at which the BTM0CY flag is detected must be shorter than the time for which to set the BTM0CY flag. At this time, even if the time interval at which the BTM0CY flag is detected is short, if the updating processing time of the timer is long the processing of the timer may not be executed normally at CE reset. Therefore, the following condition must be satisfied. tCHECK + tTIMER < tSET tCHECK : time to detect BTM0CY flag tTIMER : timer updating processing time tSET : time to set BTM0CY flag An example is given below. 157 PD17704, 17705, 17707, 17708, 17709 Example Example of timer updating processing and BTM0CY flag detection time interval START: CLR2 BTIMER: ; <1> SKT1 BR BTM0CK1, BTM0CK0 ; Sets BTM0CY flag setting pulse to 10 Hz (100 ms) BTM0CY AAA ; Updates timer if BTM0CY flag is "1" Timer updating BR AAA: Processing A BR BTIMER BTIMER The timing chart of the above program is shown below. H CE pin L BTM0CY flag setting pulse H L tSET 1 BTM0CY flag 0 BTM0CY detection interval tCHECK Timer updating processing tTIMER If this timer updating processing time is too long, CE reset is effected during processing. <1> SKT1 BTM0CY <2> SKT1 BTM0CY CE reset (3) Compensating basic timer 0 carry at CE reset Next, an example of compensating the timer at CE reset is described below. As shown in the example below, the timer must be compensated at CE reset "if the BTM0CY flag is used for power failure detection and if the BTM0CY flag is used for a watch timer". The BTM0CY flag is reset (to 0) first on power application (power-ON reset), and is disabled from being set until it is read once by the "PEEK" instruction. If the CE pin goes high, CE reset is effected in synchronization with the rising edge of the BTM0CY flag setting pulse. At this time, the BTM0CY flag is set (to 1) and the timer is started. By detecting the status of the BTM0CY flag at system reset (power-ON reset or CE reset), therefore, it can be identified whether a power-ON reset or CE reset has been effected (power failure detection). That is, power-ON reset has been effected if the flag is "0", and CE reset has been effected if it is "1". At this time, the watch timer must continue operating even if CE reset has been effected. However, because the BTM0CY flag is reset to 0 when it is read to detect a power failure, the set status (1) of the BTM0CY flag is overlooked once. If the delay function of CE reset is used, the value set to the CE reset timer carry counter (control register address 06H) is overlooked. Consequently, the watch timer must be updated if CE reset is identified by means of power failure detection. For the details of power failure detection, refer to 21. RESET. 158 PD17704, 17705, 17707, 17708, 17709 Example Example of compensating timer at CE reset (to detect power failure and update watch timer using BTM0CY flag) START: Processing A ; <1> SKT1 BR BACKUP: ; <2> ; Program address 0000H BTM0CY INITIAL ; Embedded macro ; Tests BTM0CY flag ; if "0", branches to INITIAL (power failure detection) 100-ms watch updating ; Compensates watch timer because of backup (CE reset) ; Initial value "1" is stored as CE reset timer carry ; counter value LOOP: ; <3> Processing B SKF1 BR BR INITIAL: CLR2 BTM0CK1, BTM0CK0 ; Embedded macro ; Because power failure (power-ON reset) occurs, ; sets setting time of BTM0CY flag to 100 ms, and ; executes processing C Processing C BR LOOP BTM0CY BACKUP LOOP : While performing processing B, ; tests BTM0CY flag and updates watch timer Figure 13-9 shows the timing chart of the above program. 159 PD17704, 17705, 17707, 17708, 17709 Figure 13-9. Timing Chart VDD 5V 0V CE BTM0CY flag setting pulse (10 Hz) H L H L 1 0 Program processing Program instruction A <1> C <3> B <3> Watch UP B B <3> <3> B B <3> <3> Watch UP B B <3> <3> B A <1> B B <3> <3> Watch UP BTM0CY flag Power-ON reset Start from address 0 Application of supply voltage CE reset Watch UP Start from address 0 BTM0CY flag detected Updates watch timer because setting of BTM0CY flag (to 1) is detected Point B Point C Point D Point E Point A As shown in Figure 13-9, the program is started from address 0000H because the internal 10-Hz pulse rises when supply voltage VDD is first applied. When the BTM0CY flag is detected at point A, it is judged that the BTM0CY flag is reset (to 0) and that a power failure (power-ON reset) has occurred because the power has just been applied. Therefore, "processing C" is executed, and the BTM0CY flag setting pulse is set to 100 ms. Because the content of the BTM0CY flag is read once at point A, the BTM0CY flag will be set to 1 every 100 ms. Next, even if the CE pin goes low at point B and high at point C, the program counts up the watch timer while executing "processing B", unless the clock stop instruction is executed. At point C, because the CE pin goes high, CE reset is effected at point D at which the BTM0CY flag setting pulse rises next time, and the program is started from address 0000H. When the BTM0CY flag is detected at point E at this time, it is set to 1. Therefore, this is judged to be a back up (CE reset). As is evident from the above figure, unless the watch is updated by 100 ms at point E, the watch is delayed by 100 ms each time CE reset is effected. If processing A takes longer than 100 ms when a power failure is detected at point E, the setting of the BTM0CY flag is overlooked two times. Therefore, processing A must be completed within 100 ms. The above description also applies when the BTM0CY flag setting pulse is set to 50, 20, or 10 ms. Therefore, the BTM0CY flag must be detected for power failure detection within the BTM0CY flag setting time after the program has been started from address 0000H. 160 PD17704, 17705, 17707, 17708, 17709 (4) If BTM0CY flag is detected at the same time as CE reset As described in (3) above, CE reset is effected as soon as the BTM0CY flag is set to 1. If the instruction that reads the BTM0CY flag happens to be executed at the same time as CE reset at this time, the BTM0CY flag reading instruction takes precedence. Therefore, if the next setting the BTM0CY flag (rising of BTM0CY flag setting pulse) after the CE pin has gone high coincides with execution of the BTM0CY flag reading instruction, CE reset is effected at "the next timing at which the BTM0CY flag is set". This operation is illustrated in Figure 13-10. Figure 13-10. Operation When CE Reset Coincides with BTM0CY Flag Reading Instruction H CE pin L H BTM0CY flag setting pulse L 1 BTM0CY flag 0 SKT1 BTM0CY SKT1 BTM0CY CE reset BTM0CY flag setting pulse H L 1 BTM0CY flag 0 Instruction SKT1 BTM0CY (PEEK ***) (SKT ***) Embedded macro PEEK WR, . MF. BTM0CY SHR 4 SKT WR, #. DF. BTM0CY AND 000FH 1.78 s If BTM0CY flag is read at this time, CE reset is effected delayed once. Originally, program is started from address 0000H here. However, CE reset is not effected because it happens to coincide with program that reads BTM0CY flag. Consequently, if the BTM0CY flag detection time interval coincides with the BTM0CY flag setting time in a program that cyclically detects the BTM0CY flag, CE reset is never effected. Therefore, the following point must be noted. Because one instruction cycle is 1.78 s (1/562.5 kHz), a program that detects the BTM0CY flag once, say, every 1125 instructions, reads the BTM0CY flag every 1.78 s x 1125 = 2 ms. Because the timer time setting pulse is 100 ms at this time, if setting and detection of the BTM0CY flag coincide once, CE reset is never effected. 161 PD17704, 17705, 17707, 17708, 17709 Therefore, do not create a cyclic program that satisfies the following condition. tSET x 1125 X = n (n: natural number) tSET : B TM0CY flag setting time X : Cycle X step of instruction that reads BTM0CY flag An example of a program that satisfies the above condition is shown below. Do not create such a program. Example Processing A CLR2 LOOP: ; <1> SKT1 BR AAA: 1121 steps BR BBB: 1121 steps BR LOOP LOOP BTM0CY BBB ; Embedded macro BTM0CK1, BTM0CK0 ; Embedded macro ; Sets BTM0CY flag setting pulse to 100 ms Because the BTM0CY flag reading instruction in <1> is repeatedly executed every 1125 instruction in this example, CE reset is not effected if the BTM0CY flag happens to be set at the timing of instruction in <1>. 162 PD17704, 17705, 17707, 17708, 17709 13.3 Timer 0 13.3.1 Outline of timer 0 Figure 13-11 shows the outline of timer 0. The timer 0 is used as timer (modulo mode) by comparing the count value with the previously set value after the basic clock (100 kHz, 10 kHz, 2 kHz, and 1 kHz) has counted by the 8-bit counter. The pulse width of the signal input from the TM0G pin can be measured (external gate counter). Figure 13-11. Outlines Timer 0 TM0CK1 flag TM0CK0 flag DBF 8 4.5 MHz Clock selection TM0GCEG flag TM0GOEG flag Start/stop Timer 0 counter (TM0C) Overflow TM0RES flag TM0OVF flag P1A0/TM0G Gate control TM0MD flag TM0MD flag Coincidence detection circuit Sets IRQTM0 flag Timer 0 modulo register (TM0M) 8 DBF Gate closed Remarks 1. TM0CK1 and TM0CK0 (bits 1 and 0 of timer 0 counter clock selection register: refer to Figure 13-13) set a basic clock frequency. 2. TM0MD (bit 0 of timer 0 mode selection register: refer to Figure 13-14) selects the modulo counter and gate counter. 3. TM0GOEG (bit 1 of timer 0 mode selection register: refer to Figure 13-14) sets the open edge of an external gate. 4. TM0GCEG (bit 2 of timer 0 mode selection register: refer to Figure 13-14) sets the close edge of an external gate. 5. TM0OVF (bit 3 of timer 0 mode selection register: refer to Figure 13-14) detects an overflow of timer 0 counter. 6. TM0RES (bit 2 of timer 0 counter clock selection register: refer to Figure 13-13) resets timer 0 counter. 163 PD17704, 17705, 17707, 17708, 17709 13.3.2 Clock selection, start/stop control, and gate control blocks Figure 13-12 shows the configuration of these blocks. The clock selection block selects a basic clock to operate timer 0 counter. Four types of basic clocks can be selected by using the TM0CK1 and TM0CK0 flags. Figure 13-13 shows the configuration and function of each flag. The start/stop block controls the TM0MD flag and open/close signal from the gate control block, and starts or stops the basic clock to be input to timer 0 counter by the TM0EN flag. The gate control block sets the opening or closing conditions of the gate. It sets whether the gate is opened or closed by a rising or falling of the input signal, by using the TM0GOEG and TM0GCEG flags. This block also issues an interrupt request when the closing condition of the gate is detected. Figure 13-14 shows the configuration and function of each flag. Figure 13-12. Configuration of Clock Selection, Start/Stop Control, and Gate Control Blocks Clock selection TM0CK1 TM0CK0 Divider 4.5 MHz 10 kHz 2 kHz 1 kHz Selector 100 kHz Timer 0 counter Start/stop TM0EN flag TM0MD flag TM0MD flag Gate control TM0GOEG TM0GCEG P1A0/TM0G Edge detection Open/ close Timer 0 interrupt 164 PD17704, 17705, 17707, 17708, 17709 Figure 13-13. Configuration of Timer 0 Counter Clock Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Timer 0 counter clock selection T T T T 2BH R/W MM 0 E N 0 R E S MM 0 C K 1 0 C K 0 Sets basic clock of timer 0 counter 0 0 1 1 0 1 0 1 100 kHz (10 s) 10 kHz (100 s) 2 kHz (500 s) 1 kHz (1 ms) Resets timer 0 counter 0 1 Does not change Resets counter Starts or stops timer 0 0 1 Stops Starts At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 Retained 0 0 0 0 Clock stop Caution When the TM0RES flag is read, 0 is always read. 165 PD17704, 17705, 17707, 17708, 17709 13.3.3 Count block The count block counts the basic clock with an 8-bit timer 0 counter, reads the count value, and issues an interrupt request if the value of the timer 0 modulo register coincides with its value. Timer 0 counter can be reset by the TM0RES flag. The TM0OVF flag can detect an overflow of the counter. When an overflow occurs, an interrupt request can be issued. The value of the timer 0 counter can be read via data buffer. The value of the timer 0 modulo register can be written or read via data buffer. Figure 13-14 shows the configuration of the timer 0 mode selection register. Figure 13-15 shows the configuration of the timer 0 counter. Figure 13-16 shows the configuration of the timer 0 modulo register. Figure 13-14. Configuration of Timer 0 Mode Selection Register Name Flag symbol b3 b2 b1 b0 Timer 0 mode selection T T T T 2CH R/W Address Read/Write MM 0 0 MM 0 0 OG V F C E G GM OD E G Selects modulo counter or gate counter of timer 0 0 1 Modulo counter Gate counter Specifies edge of gate open input signal 0 1 Rising edge Falling edge Specifies edge of gate close input signal 0 1 Rising edge Falling edge Detects timer 0 overflow 0 1 No overflow Overflow At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 Retained 0 0 0 0 Clock stop 166 PD17704, 17705, 17707, 17708, 17709 Figure 13-15. Configuration of Timer 0 Counter Data buffer DBF3 Don't care DBF2 Don't care Transfer data GET 8 bits PUT must not be executed Name Symbol Address Bit Data Valid data Timer 0 counter TM0C 1BH b7 b6 b5 b4 b3 b2 b1 b0 DBF1 DBF0 Reads count value of timer 0 0 * Modulo mode Reset if count value of timer 0 coincides with value of modulo counter. * External gate mode 0FFH Resets counting to 00H if overflow occurs At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Retained 0 0 0 0 0 0 0 0 Clock stop 167 PD17704, 17705, 17707, 17708, 17709 Figure 13-16. Configuration of Timer 0 Modulo Register Data buffer DBF3 Don't care DBF2 Don't care Transfer data GET 8 bits PUT Name Symbol Address Bit Data Valid data Timer 0 modulo register TM0M 1AH b7 b6 b5 b4 b3 b2 b1 b0 DBF1 DBF0 Sets modulo data of timer 0 0 * Modulo mode Issues interrupt request when value of modulo counter coincides with count value of timer 0. * External gate mode Does not issue interrupt request when value of modulo 0FFH counter coincides with count value of timer 0. At reset Power-ON reset WDT&SP reset CE reset 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Retained 1 1 1 1 1 1 1 1 Clock stop 168 PD17704, 17705, 17707, 17708, 17709 13.3.4 Example of using timer 0 (1) Modulo counter mode The modulo counter mode is used for time management by generating timer 0 interrupt at fixed intervals. An example of a program is shown below. This program executes processing B every 500 s. TM0DATA START: BR INITIAL ; Interrupt vector address NOP NOP NOP NOP NOP BR INT_TM0 NOP NOP NOP NOP NOP NOP INITIAL: INITFLG ; CLR1 MOV MOV PUT SET1 EI SET1 LOOP: Processing A BR INT_TM0: Processing B EI RETI ; Timer 0 interrupt service LOOP NOT TM0EN, TM0RES, NOT TM0CK1, NOT TM0CK0 (Stop) , (Reset) , (Basic clock = 10 s) TM0MD ; Modulo mode DBF0, #(TM0MDATA SHR 0) AND 0FH DBF1, #(TM0MDATA SHR 4) AND 0FH TM0M, DBF ; Sets count data IPTM0 ; Enables timer 0 interrupt TM0EN ; Starts timer 0 ; Reset address ; ; ; ; ; ; ; ; ; ; ; ; SIO1 SIO0 TM3 TM2 TM1 TM0 INT4 INT3 INT2 INT1 INT0 Down edge of CE DAT 0032H ; MODULO DATA = 50 ; Return 169 PD17704, 17705, 17707, 17708, 17709 (2) Gate counter mode The gate counter mode is used to count the width of a pulse input to the TM0G pin. An example of a program is shown below. In this program example, the width of the pulse input to the TM0G pin is counted from the falling edge to the falling edge. If the pulse width is 800 to 1200 s, processing C is executed; otherwise, processing B is executed. If the pulse width is 2560 s or more, processing D is executed. TM0800 TM01200 START: BR INITIAL ; Interrupt vector address NOP NOP NOP NOP NOP BR INT_TM0 NOP NOP NOP NOP NOP NOP INITIAL: INITFLG ; INITFLG ; SET1 SET1 EI LOOP: Processing A BR INT_TM0: PUT GET INITFLG SKT1 BR DBFSTK, DBF DBF, TM0C TM0EN, TM0RES TM0OVF AAA ; Saves data buffer ; Detects overflow status (2560 s or more?) LOOP NOT TM0EN, TM0RES, NOT TM0CK1, NOT TM0CK0 (Stop) , (Reset) , (Basic clock = 10 s) TM0GCEG , TM0GOEG , TM0MD (Falling close), (Falling open), (Gate counter) TM0EN ; START IPTM0 ; Enables timer 0 interrupt ; Reset address ; ; ; ; ; ; ; ; ; ; ; ; SIO1 SIO0 TM3 TM2 TM1 TM0 INT4 INT3 INT2 INT1 INT0 Down edge of CE DAT DAT 0050H 0078H ; Count data = 80 ; Count data = 120 Processing D BR AAA: SUB SUBC SKF1 BR SUB DBF0, #TM0800 AND 0FH DBF1, #TM0800 SHR4 AND 0FH CY ; 800 s or more? BBB DBF0, #TM01200 AND 0FH EI_RETI 170 PD17704, 17705, 17707, 17708, 17709 SUBC SKT1 BR DBF1, #TM01200 SHR4 AND 0FH CY ; 1200 s or more? BBB Processing C BR BBB: Processing B EI_RETI: GET EI RETI END 13.3.5 Error of timer 0 Timer 0 has an error of up to 1 basic clock in the following cases. (1) On starting/stopping counter The counter is started or stopped by ANDing the open/close condition of the gate and TM0EN flag setting condition. Therefore, an error of 0 to +1 clocks occurs when the gate is opened or the TM0EN flag is set, and an error of -1 to 0 clocks occurs when the gate is closed or the flag is reset. In all, an error of 1 count occurs. (2) On resetting counter operation An error of 0 to +1 clocks occurs when the counter is reset. (3) On selecting basic clock during counter operation An error of 0 to +1 clocks of the newly selected clock occurs. 13.3.6 Cautions on using timer 0 Timer 0 interrupt may occur simultaneously with the other timer interrupts and CE reset. If it is necessary to update the timer at CE reset, do not use timer 0, use basic timer 0 instead. DBF, DBFSTK ; Restores data buffer ; Return EI_RETI 171 PD17704, 17705, 17707, 17708, 17709 13.4 Timer 1 13.4.1 Outline of timer 1 Figure 13-17 outlines timer 1. Timer 1 counts the basic clock (100, 10, 2, or 1 kHz) with an 8-bit counter, and compares the count value with a value set in advance. Figure 13-17. Outline of Timer 1 TM1CK1 flag TM1CK0 flag Interrupt control DBF 4.5 MHz Clock selection Start/stop TM1EN flag Timre 1 counter (TM1C) TM1RES flag Coincidence detection circuit Timer 1 IRQTM1 flag Timer 1 modulo register (TM1M) DBF Remarks 1. TM1CK1 and TM1CK0 (bits 1 and 0 of timer 1 counter clock selection register: refer to Figure 13-18) set the basic clock frequency. 2. TM1EN (bit 3 of timer 1 counter clock selection register: refer to Figure 13-18) starts or stops timer 1. 3. TM1RES (bit 2 of timer 1 counter clock selection register: refer to Figure 13-18) resets timer 1 counter. 172 PD17704, 17705, 17707, 17708, 17709 13.4.2 Clock selection and start/stop control blocks The clock selection block selects a basic clock to operate timer 1 counter. Four types of basic clocks can be selected by using the TM1CK1 and TM1CK0 flags. The start/stop block starts or stops the basic clock input to timer 1 by using the TM1EN flag. Figure 13-18 shows the configuration and function of each flag. 13.4.3 Count block The count block counts the basic clock with timer 1 counter, reads the count value, and issues an interrupt request when its count value coincides with the value of the timer 1 modulo register. The timer 1 counter can be reset by the TM1RES flag. The timer 1 counter is automatically reset when its value coincides with the value of the timer 1 modulo register. The value of the timer 1 counter can be read via data buffer. Data can be written to the value of the timer 1 modulo register via data buffer. Figure 13-18 shows the configuration of timer 1 counter clock selection register. Figure 13-19 shows the configuration of the timer 1 counter. Figure 13-20 shows the configuration of the timer 1 modulo register. 173 PD17704, 17705, 17707, 17708, 17709 Figure 13-18. Configuration of Timer 1 Counter Clock Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Timer 1 counter clock selection T T T T 2AH R/W MM 1 E N 1 R E S MM 1 C K 1 1 C K 0 Sets basic clock of timer 1 counter 0 0 1 1 0 1 0 1 100 kHz (10 s) 10 kHz (100 s) 2 kHz (500 s) 1 kHz (1 ms) Resets timer 1 counter (valid on writing) 0 1 Does not change Resets counter Starts or stops timer 1 0 1 Stops Starts Power-On reset At reset 0 0 0 0 0 0 0 0 WDT&SP reset CE reset Retained 0 0 0 0 Clock stop Caution When the TM1RES flag is read, 0 is always read. 174 PD17704, 17705, 17707, 17708, 17709 Figure 13-19. Configuration of Timer 1 Counter Data buffer DBF3 Don't care DBF2 Don't care Transfer data GET 8 bits PUT must not be executed Name Symbol Address Bit Data Valid data Timer 1 counter TM1C 1DH b7 b6 b5 b4 b3 b2 b1 b0 DBF1 DBF0 Reads count value of timer 1 0 x Count value 0FFH Power-ON reset At reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 WDT&SP reset CE reset Retained 0 0 0 0 0 0 0 0 Clock stop 175 PD17704, 17705, 17707, 17708, 17709 Figure 13-20. Configuration of Timer 1 Modulo Register Data buffer DBF3 Don't care DBF2 Don't care Transfer data GET 8 bits PUT Name Symbol Address Bit Data Valid data Timer 1 modulo register TM1M 1CH b7 b6 b5 b4 b3 b2 b1 b0 DBF1 DBF0 Sets modulo data of timer 1 0 1 Setting prohibited x Modulo counter value 0FFH At reset Power-ON reset WDT&SP reset CE reset 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Retained 1 1 1 1 1 1 1 1 Clock stop 176 PD17704, 17705, 17707, 17708, 17709 13.4.4 Example of using timer 1 (1) Modulo timer The modulo timer is used for time management by generating timer 1 interrupt at fixed intervals. An example of a program is shown below. This program executes processing B every 500 s. TM1DATA START: BR INITIAL ; Interrupt vector address NOP NOP NOP NOP BR INT_TM1 NOP NOP NOP NOP NOP NOP NOP INITIAL: INITFLG ; MOV MOV PUT SET1 SET1 EI LOOP: Processing A BR INT_TM1: PUT DBFSTK, DBF ; Saves data buffer LOOP NOT TM1EN, TM1RES, NOT TM1CK1, NOT TM1CK0 (Stop) , (Reset) , (Basic clock = 10 s) DBF0, #TM1DATA DBF1, #TM1DATA SHR4 AND 0FH TM1, DBF TM1EN ; START IPTM1 ; Enables timer 1 interrupt ; Reset address ; ; ; ; ; ; ; ; ; ; ; ; SIO1 SIO0 TM3 TM2 TM1 TM0 INT4 INT3 INT2 INT1 INT0 Down edge of CE DAT 0032H ; Count data = 50 Processing B GET EI RETI END DBF, DBFSTK ; Return 177 PD17704, 17705, 17707, 17708, 17709 13.4.5 Error of timer 1 Timer 1 has an error of up to 1 basic clock in the following cases. (1) On starting/stopping counter The counter is started or stopped by setting the TM1EN flag. Therefore, an error of 0 to +1 clocks occurs when the TM1EN flag is set, and an error of -1 to 0 clocks occurs when the flag is reset. In all, an error of 1 count occurs. (2) On resetting counter operation An error of 0 to +1 clocks occurs when the counter is reset. (3) On selecting basic clock during counter operation An error of 0 to +1 clocks of the newly selected clock occurs. 13.4.6 Cautions on using timer 1 Timer 1 interrupt may occur simultaneously with the other timer interrupts and CE reset. If it is necessary to update the timer at CE reset, do not use timer 1, use basic timer 0 instead. 178 PD17704, 17705, 17707, 17708, 17709 13.5 Timer 2 13.5.1 Outline of timer 2 Figure 13-21 outlines timer 2. Timer 2 counts the basic clock (100, 10, 2, or 1 kHz) with an 8-bit counter, and compares the count value with a value set in advance. Figure 13-21. Outline of Timer 2 TM2CK1 flag TM2CK0 flag Interrupt control DBF 4.5 MHz Clock selection Start/stop TM2EN flag Timer 2 counter (TM2C) TM2RES flag Coincidence detection circuit Timer 2 IRQTM2 flag Timer 2 modulo register (TM2M) DBF Remarks 1. TM2CK1 and TM2CK0 (bits 1 and 0 of timer 2 counter clock selection register: refer to Figure 13-22) set the basic clock frequency. 2. TM2EN (bit 3 of timer 2 counter clock selection register: refer to Figure 13-22) starts or stops timer 2. 3. TM2RES (bit 2 of timer 2 counter clock selection register: refer to Figure 13-22) resets timer 2 counter. 179 PD17704, 17705, 17707, 17708, 17709 13.5.2 Clock selection and start/stop control blocks The clock selection block selects a basic clock to operate timer 2 counter. Four types of basic clocks can be selected by using the TM2CK1 and TM2CK0 flags. The start/stop block starts or stops the basic clock input to timer 2 by using the TM2EN flag. Figure 13-22 shows the configuration and function of each flag. 13.5.3 Count block The count block counts the basic clock with timer 2 counter, reads the count value, and issues an interrupt request when its count value coincides with the value of the timer 2 modulo register. The timer 2 counter can be reset by the TM2RES flag. The timer 2 counter is automatically reset when its value coincides with the value of the timer 2 modulo register. The value of the timer 2 counter can be read via data buffer. Data can be written to the value of the timer 2 modulo register via data buffer. Figure 13-22 shows the configuration of timer 2 counter clock selection register. Figure 13-23 shows the configuration of the timer 2 counter. Figure 13-24 shows the configuration of the timer 2 modulo register. 180 PD17704, 17705, 17707, 17708, 17709 Figure 13-22. Configuration of Timer 2 Counter Clock Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Timer 2 counter clock selection T T T T 29H R/W MM 2 E N 2 R E S MM 2 C K 1 2 C K 0 Sets basic clock of timer 2 counter 0 0 1 1 0 1 0 1 100 kHz (10 s) 10 kHz (100 s) 2 kHz (500 s) 1 kHz (1 ms) Resets timer 2 counter (valid on writing) 0 1 Does not change Resets counter Starts or stops timer 2 0 1 Stops Starts At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 Retained 0 0 0 0 Clock stop Caution When the TM2RES flag is read, 0 is always read. 181 PD17704, 17705, 17707, 17708, 17709 Figure 13-23. Configuration of Timer 2 Counter Data buffer DBF3 Don't care DBF2 Don't care Transfer data GET 8 bits PUT must not be executed Name Symbol Address Bit Data Valid data Timer 2 counter TM2C 1FH b7 b6 b5 b4 b3 b2 b1 b0 DBF1 DBF0 Reads count value of timer 2 0 x Count value 0FFH Power-ON reset At reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 WDT&SP reset CE reset Retained 0 0 0 0 0 0 0 0 Clock stop 182 PD17704, 17705, 17707, 17708, 17709 Figure 13-24. Configuration of Timer 2 Modulo Register Data buffer DBF3 Don't care DBF2 Don't care Transfer data GET 8 bits PUT Name Symbol Address Bit Data Valid data Timer 2 modulo register TM2M 1EH b7 b6 b5 b4 b3 b2 b1 b0 DBF1 DBF0 Sets modulo data of timer 2 0 1 Setting prohibited x Modulo counter value 0FFH At reset Power-On reset WDT&SP reset CE reset 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Retained 1 1 1 1 1 1 1 1 Clock stop 183 PD17704, 17705, 17707, 17708, 17709 13.5.4 Example of using timer 2 (1) Modulo timer The modulo timer is used for time management by generating a timer 2 interrupt at fixed intervals. An example of a program is shown below. This program executes processing B every 500 s. TM2DATA START: BR INITIAL ; Interrupt vector address NOP NOP NOP BR INT_TM2 NOP NOP NOP NOP NOP NOP NOP NOP INITIAL: INITFLG ; MOV MOV PUT SET1 SET1 EI LOOP: Processing A BR INT_TM2: PUT INITFLG DBFSTK, DBF TM2EN, TM2RES ; Saves data buffer ; Resets and starts LOOP NOT TM2EN, TM2RES, NOT TM2CK1, NOT TM2CK0 (Stop) , (Reset) , (Basic clock = 10 s) DBF0, #TM2DATA DBF1, #TM2DATA SHR4 AND 0FH TM2, DBF TM2EN ; START IPTM2 ; Enables timer 2 interrupt ; Reset address ; ; ; ; ; ; ; ; ; ; ; ; SIO1 SIO0 TM3 TM2 TM1 TM0 INT4 INT3 INT2 INT1 INT0 Down edge of CE DAT 0032H ; Count data = 50 Processing B GET EI RETI END DBF, DBFSTK ; Return 184 PD17704, 17705, 17707, 17708, 17709 13.5.5 Error of timer 2 Timer 2 has an error of up to 1 basic clock in the following cases. (1) On starting/stopping counter The counter is started or stopped by setting the TM2EN flag. Therefore, an error of 0 to +1 clocks occurs when the TM2EN flag is set, and an error of -1 to 0 clocks occurs when the flag is reset. In all, an error of 1 count occurs. (2) On resetting counter operation An error of 0 to +1 clocks occurs when the counter is reset. (3) On selecting basic clock during counter operation An error of 0 to +1 clocks of the newly selected clock occurs. 13.5.6 Cautions on using timer 2 Timer 2 interrupt may occur simultaneously with the other timer interrupts and CE reset. If it is necessary to update the timer at CE reset, do not use timer 2, use basic timer 0 instead. 185 PD17704, 17705, 17707, 17708, 17709 13.6 Timer 3 13.6.1 Outline of timer 3 Figure 13-25 outlines timer 3. Timer 3 counts the basic clock (1.125 MHz or 112.5 kHz selectable) with an 8-bit counter Note , and compares the count value with a value set in advance. Because timer 3 is multiplexed with a D/A converter, all the three D/A converter pins are automatically set in the general-purpose port mode when timer 3 is used. Note A 9-bit or 8-bit counter can be selected for the D/A converter, but the 8-bit counter is automatically selected when the timer function is selected. Figure 13-25. Outline of Timer 3 Interrupt control PWMCK flag TM3EN flag TM3SEL flag 4.5 MHz Clock selection Start/stop Timer 3 counter (TM3C) TM3RES flag IRQTM3 flag Coincidence detection circuit Timer 3 modulo register (TM3M) DBF Remarks 1. PWMCK (bit 0 of PWM clock selection register: refer to Figure 13-26) selects the output frequency of timer 3. 2. TM3SEL (bit 3 of timer 3 control register: refer to Figure 13-27) selects timer 3 or D/A converter. 3. TM3EN (bit 1 of timer 3 control register: refer to Figure 13-27) starts or stops counting by timer 3. 4. TM3RES (bit 0 of timer 3 control register: refer to Figure 13-27) controls resetting of timer 3 counter. 186 PD17704, 17705, 17707, 17708, 17709 13.6.2 Clock selection block The clock of timer 3 is selected by the PWMCK flag of the PWM clock selection register. Figure 13-26 shows the configuration of the flag. Figure 13-26. Configuration of PWM Clock Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write PWM clock selection 0 P W M B I T 0 P W M C K 26H R/W Selects output frequency of timer 3 0 1 4.4 kHz (8 bits)/2.2 kHz (9 bits) 440 Hz (8 bits)/220 Hz (9 bits) Fixed to "0" Selects number of bits of PWM counter 0 1 8 bits 9 bits Fixed to "0" At reset Power-ON reset WDT&SP reset CE reset 0 0 0 R 0 0 0 0 R 0 Clock stop R:Retained 187 PD17704, 17705, 17707, 17708, 17709 13.6.3 Start/stop control block The start/stop block starts or stops the basic clock to be input to timer 3 counter by using the TM3EN flag. To control timer 3, timer 3 must be selected by the TM3SEL flag. Figure 13-27 shows the configuration of each flag. Figure 13-27. Configuration of Timer 3 Control Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Timer 3 control T M 3 S E L 0 T T 28H R/W MM 3 E N 3 R E S Resets counter 0 1 Dose not change Resets Starts or stops counter 0 1 Stop Starts Fixed to "0" Selects timer 3 or D/A converter 0 1 D/A converter (PWM output) Timer 3 Power-ON reset At reset WDT&SP reset CE reset 0 0 R 0 0 0 0 0 0 Retained 0 0 Clock stop R:Retained 188 PD17704, 17705, 17707, 17708, 17709 13.6.4 Count block The count block counts the basic clock with timer 3 and issues an interrupt request when the count value of timer 3 coincides with the value of the timer 3 modulo register. Timer 3 counter can be reset by the TM3RES flag. Because the PWM data register 2 (PWMR2) and timer 3 modulo register (TM3M) are multiplexed, these registers cannot be used at the same time. When timer 3 is used, the PWM data register 1 (PWMR1) and PWM data register 0 (PWMR0) can be used as 9-bit data latches (refer to 15. D/A CONVERTER (PWM mode)). Figure 13-28. Configuration of Timer 3 Modulo Register Data buffer DBF3 DBF2 DBF1 DBF0 Transfer data GET 16 bits PUT Name Symbol Address Bit Data Timer 3 modulo register TM3M 46H b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 0 0 0 0 0 0 0 Valid data Note Sets modulo data of timer 3 0 x Modulo counter value 1FFH Fixed to "0" Power-ON reset At reset 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 WDT&SP reset CE reset Retained 1 1 1 1 1 1 1 1 1 Clock stop Note This register is multiplexed with the PWM data register. 189 PD17704, 17705, 17707, 17708, 17709 13.6.5 Example of using timer 3 An example of a program using timer 3 (multiplexed with PWM) is given below. This program executes processing B every 888 s. TM3DATA START: BR INITIAL ; Interrupt vector address NOP NOP BR INT_TM3 NOP NOP NOP NOP NOP NOP NOP NOP NOP INITIAL: INITFLG ; INITFLG ; INITFLG ; MOV MOV PUT SET1 SET1 EI LOOP: Processing A BR INT_TM3: PUT DBFSTK, DBF ; Saves data buffer LOOP NOT PWMSEL2 , NOT PWMSEL1 , NOT PWMSEL0 (General-purpose port), (General-purpose port), (General-purpose port) NOT PWMBIT, PWMCK ( 8BIT ), (440 Hz) TM3SEL , NOT TM3EN, TM3RES (Timer 3 mode), (Stop) , (Reset) DBF0, #TM3DATA DBF1, #TM3DATA SHR4 AND 0FH TM3M, DBF TM3EN ; START IPTM3 ; Enables timer 3 interrupt ; Reset address ; ; ; ; ; ; ; ; ; ; ; ; SIO1 SIO0 TM3 TM2 TM1 TM0 INT4 INT3 INT2 INT1 INT0 Down edge of CE DAT 0064H ; Count data = 100 Processing B GET EI RETI END DBF, DBFSTK ; Return 190 PD17704, 17705, 17707, 17708, 17709 13.6.6 Error of timer 3 Timer 3 has an error of up to 1 basic clock in the following cases. (1) On starting/stopping counter The counter is started or stopped by setting the TM3EN flag. Therefore, an error of 0 to +1 clocks occurs when the TM3EN flag is set, and an error of -1 to 0 clocks occurs when the flag is reset. In all, an error of 1 count occurs. (2) On resetting counter operation An error of 0 to +1 clocks occurs when the counter is reset. (3) On selecting basic clock during counter operation An error of 0 to +1 clocks of the newly selected clock occurs. 13.6.7 Cautions on using timer 3 Timer 3 interrupt may occur simultaneously with the other timer interrupts and CE reset. If it is necessary to update the timer at CE reset, do not use timer 3, use basic timer 0 instead. When timer 3 is used, the three output port pins multiplexed with the D/A converter pins, P1B2/PWM2 through P1B0/PWM0, are automatically set in the general-purpose output port mode. 191 PD17704, 17705, 17707, 17708, 17709 13.6.8 Status at reset (1) At power-ON reset The P1B2/PWM2 through P1B0/PWM0 pins are set in the general-purpose output port mode. The output value is "low level". The value of each PWM data register (including the timer 3 modulo register) is "1FFH". (2) At WDT&SP reset The P1B2/PWM2 through P1B0/PWM0 pins are set in the general-purpose output port mode. The output value is "low level". The value of each PWM data register (including the timer 3 modulo register) is "1FFH". (3) On execution of clock stop instruction The P1B2/PWM2 through P1B0/PWM0 pins are set in the general-purpose output port mode. The output value is the "previous contents of the output latch". The value of each PWM data register (including the timer 3 modulo register) is "1FFH". (4) At CE reset The previous status is retained. That is, if the D/A converter is being used, the PWM output is retained as is. If timer 3 is being used, counting continues. While timer 3 is being used, the DI status is set (in which all interrupts are disabled). (5) In halt status The previous status is retained. That is, if the D/A converter is being used, the PWM output is retained as is. If timer 3 is being used, counting continues. 192 PD17704, 17705, 17707, 17708, 17709 14. A/D CONVERTER 14.1 Outline of A/D Converter Figure 14-1 outlines the A/D converter. The A/D converter converts an analog voltage input to the AD5 to AD0 pins into an 8-bit digital signal. Two modes can be selected by using the ADCMD flag: software mode and hardware mode. In the software mode, a voltage input to a pin is compared with an internal reference voltage, and the result of the comparison is detected by the ADCCMP flag. By judging this result in software and by sequentially selecting reference voltages, the A/D converter can be used as a successive approximation A/D converter. In the hardware mode, reference voltages are automatically selected, and the input voltage is directly detected as 8-bit digital data. Figure 14-1. Outline of A/D Converter ADCCH2 flag ADCCH1 flag ADCCH0 flag P1C3/AD5 P1C2/AD4 P0D3/AD3 P0D2/AD2 P0D1/AD1 P0D0/AD0 Compare block DBF ADCSTT flag ADCCMP flag Input selection block Compare voltage generation block R-string D/A converter Start/stop control block ADCMD flag Remarks 1. ADCCH2 through ADCCH0 (bits 2 through 0 of A/D converter channel selection register: refer to Figure 14-3) select pins used for the A/D converter. 2. ADCCMP (bit 0 of A/D converter mode selection register: refer to Figure 14-5) detects the result of comparison. 3. ADCSTT (bit 1 of A/D converter mode selection register: refer to Figure 14-5) detects the operating status. 4. ADCMD (bit 2 of A/D converter mode selection register: refer to Figure 14-5) selects software or hardware mode. 193 PD17704, 17705, 17707, 17708, 17709 14.2 Input Selection Block Figure 14-2 shows the configuration of the input selection block. The input selection block selects a pin to be used by using the ADCCH2 through ADCCH0 flags. Only one pin can be used for the A/D converter. When one of the P0D0/AD0 through P0D3/AD3, P1C2/AD4, and P1C3/ AD5 pins is selected, the other five pins are forcibly set in the input port mode. The P0D0/AD0 through P0D3/AD3 pins can be connected to a pull-down resistor if so specified by the P0DPL0 through P0DPLD3 flags. To use the P0D0/AD0 through P0D3/AD3 pins for the A/D converter, therefore, disconnect their pull-down resistors to correctly detect an external input analog voltage. Figure 14-3 shows the configuration of the A/D converter channel selection register. Figure 14-2. Configuration of Input Selection Block ADCCH2 ADCCH1 ADCCH0 Selector P1C3/AD5 P1C2/AD4 P0D3/AD3 P0D2/AD2 P0D1/AD1 P0D0/AD0 Compare block VADCIN Each I/O port 194 PD17704, 17705, 17707, 17708, 17709 Figure 14-3. Configuration of A/D Converter Channel Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write A/D converter channel selection 0 A D C C H 2 A D C C H 1 A D C C H 0 24H R/W Selects pin used for A/D converter 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 A/D converter not used (general-purpose input port) P0D0/AD0 pin P0D1/AD1 pin P0D2/AD2 pin P0D3/AD3 pin P1C2/AD4 pin P1C3/AD5 pin Setting prohibited Fixed to "0" At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 Retained Retained Clock stop 195 PD17704, 17705, 17707, 17708, 17709 14.3 Compare Voltage Generation and Compare Blocks Figure 14-4 shows the configuration of the compare voltage generation block and compare block. The compare voltage generation block switches a tap decoder according to the 8-bit data set to the A/D converter reference voltage setting register and generates 256 different of compare voltages V ADCREF. In other words, this block is an R-string D/A converter. The supply voltage to this R-string D/A converter is the same as the supply voltage VDD of the device. The compare block compares voltage VADCIN input from a pin with compare voltage VADCREF. Comparison can be made in two modes, software mode and hardware mode, which can be selected by the ADCMD flag. In the software mode, a compare voltage is set to the A/D converter reference voltage setting register by software, and one set compare voltage is compared with the input voltage, and the result of the comparison is detected by the ADCCMP flag. In the hardware mode, once comparison has been started, the hardware automatically changes the value of the A/D converter reference voltage setting register. On completion of the comparison, the value of the A/D converter reference voltage setting register is read and is loaded as an 8-bit data. Figures 14-5 and 14-6 show the configuration of each flag and A/D converter reference voltage setting register. Figure 14-4. Configuration of Compare Voltage Generation and Compare Blocks 1/2 VDD VADCIN DBF VADCREF 2 pF - Comparator + ADCCMP flag A/D converter reference voltage setting register (ADCR) Tap decoder 0 1 2 254 255 VDD 1 R 2 R R 3 R 2 Soft/hard, start/stop control block ADCSTT flag ADCMD flag 196 PD17704, 17705, 17707, 17708, 17709 Figure 14-5. Configuration of A/D Converter Mode Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write A/D converter mode selection 0 A D C M D A D C S T T A D C C M P 25H R/W Detects result of comparison by A/D converter 0 1 VADCIN < VADCREF VADCIN > VADCREF Detects operating status of A/D converter in hardware mode 0 1 End of conversion Conversion in progress Selects compare mode of A/D converter and starts or stops A/D converter 0 1 Software modeNote 1 Hardware modeNote 2 Fixed to "0" Power-ON reser At reset WDT&SP reser CE reser 0 0 0 R R 0 0 0 0 0 0 0 R Clock stop R:Retained Notes 1. A/D conversion under execution is stopped if "0" is written to this bit. 2. A/D operation is started in the hardware mode when "1" is written to this bit. In the software mode, operation is started as soon as data has been written (by the PUT instruction) to the A/D converter reference voltage setting register (ADCR). 197 PD17704, 17705, 17707, 17708, 17709 Figure 14-6. Configuration of A/D Converter Reference Voltage Setting Register Data buffer DBF3 Don't care DBF2 Don't care Transfer data GET 8 bits PUT Name Symbol Address Bit Data Valid data A/D converter reference volfage setting register ADCR 02H b7 b6 b5 b4 b3 b2 b1 b0 DBF1 DBF0 Sets or reads compare voltage VADCREF of A/D converter * In software mode: Sets compare voltage * In hardware mode: Reads result of comparison 0 VADCREF = 0 V x VADCREF = FFH x-0.5 256 xVDD (V) At reset Power-ON reset WDT&SP reset CE reset Retained Note 0 0 Clock stop RetainedNote Note "0" in the hardware mode. 198 PD17704, 17705, 17707, 17708, 17709 14.4 Comparison Timing Chart 14.4.1 In software mode Comparison is completed three instructions after data has been set (by the PUT instruction) to the A/D converter reference voltage setting register (ADCR). Figure 14-7 shows the timing chart. Figure 14-7. Timing Chart of Comparison by A/D Converter Instruction cycle PUT ADCR, DBF 1 2 3 Comparison starts Sample & hold ADCSTT fiag "0" ADCCMP fiag Result of comparison 14.4.2 In hardware mode When the ADCMD flag is set to "1", A/D conversion is started. The ADCSTT flag is set to "1", and comparison is completed after 17 instructions have been executed. At this time, the ADCSTT flag is reset to "0" after 15 instructions have been executed after the ADCMD flag was set to "1". This is because execution time of two instructions is required to judge the status of the ADCSTT flag. For details, also refer to 14.5 Using A/D Converter. Figure 14-8 shows the timing chart. Figure 14-8. Timing Chart of Comparison by A/D Converter Instruction cycle 1 2 3 15 16 17 Sample & hold ADCSTT flag A/D converter 1st Reference voltage setting register ADCMD flag (=1) set. Comparison starts End of comparison 8th Result of comparison 199 PD17704, 17705, 17707, 17708, 17709 14.5 Using A/D Converter 14.5.1 Software mode The software mode is convenient for comparing one compare voltage. An example of a program in this mode is shown below. Example To compare input voltage VADCIN of AD0 pin with compare voltage VADCREF (127.5/256 VDD), and branch to AAA if VADCIN < VADCREF, or to BBB if VADCIN > VADCREF ADCR7 ADCR6 ADCR5 ADCR4 ADCR3 ADCR2 ADCR1 ADCR0 BANK15 INITFLG BANK0 INITFLG CLR1 INITFLG INITFLG PUT NOP NOP NOP SKT1 BR BR FLG FLG FLG FLG FLG FLG FLG FLG 0.0EH.3 ; Defines each bit of DBF as ADCR data setting flag 0.0EH.2 0.0EH.1 0.0EH.0 0.0EH.3 0.0EH.2 0.0EH.1 0.0EH.0 NOT P0DPLD3, NOT P0DPLD2, NOT P0DPLD1, P0DPLD0 NOT ADCCH2, NOT ADCCH1, ADCCH0 ADCMD ADCR7, NOT ADCR6, NOT ADCR5, NOT ADCR4 NOT ADCR3, NOT ADCR2, NOT ADCR1, NOT ADCR0 ADCR, DBF ; Disconnects pull-down resistor of P0D0 pin ; ; ; ; ; ; ; ; ; Selects AD0 pin for A/D converter Sets software mode Sets compare voltage VADCREF Waits for duration of three instructions ADCCMP AAA BBB Judges result of comparison 14.5.2 Hardware mode Here is a program example: Example To detect the value of analog input roltage VADCIN of AD0 pin. BANK15 INITFLG NOT P0DPLD3, NOT P0DPLD2, NOT P0DPLD1, P0DPLD0 ; Disconnects pull-down resistor of P0D0 pin BANK0 INITFLG NOT ADCCH2, NOT ADCCH1, ADCCH0 ; Selects AD0 pin for A/D converter SET1 ADCMD ; Sets hardware mode and starts conversion LOOP: SKT1 ADCSTT ; Detects end of A/D conversion ; Embedded macro instruction ;PEEK WR, .MF. ADCSTT SHR4 AND 0FH ;SKT1 WR,#.DF.ADCSTT AND 0FH BR LOOP GET DBF,ADCR ; Conversion in progress ; Stores result of conversion to DBF 200 PD17704, 17705, 17707, 17708, 17709 14.6 Cautions on Using A/D Converter 14.6.1 Cautions on selecting A/D converter pin When one of the P0D0/AD0 through P0D3/AD3, P1C2/AD4, and P1C3/AD5 pins is selected, the other five pins are forcibly set in the input port mode. The P0D0/AD0 through P0D3/AD3 pins can be connected to a pulldown resistor if so specified by the P0DPL0 through P0DPLD3 flags in bank 15. To use the P0D0/AD0 through P0D3/AD3 pins for the A/D converter, therefore, disconnect their pull-down resistors to correctly detect an external input analog voltage. 14.7 Status at Reset 14.7.1 At power-ON reset All the P0D0/AD0 through P0D3/AD3, P1C2/AD4, and P1C3/AD5 pins are set in the general-purpose input port mode. The P0D0 through P0D3 pins are connected with a pull-down resistor. 14.7.2 At WDT&SP reset All the P0D0/AD0 through P0D3/AD3, P1C2/AD4, and P1C3/AD5 pins are set in the general-purpose input port mode. The P0D0 through P0D3 pins are connected with a pull-down resistor. 14.7.3 At CE reset The status of the pin selected for the A/D converter is retained as is. The previous status of the pull-down resistor of the P0D0 through P0D3 pins is retained. 14.7.4 On execution of clock stop instruction The status of the pin selected for the A/D converter is retained as is. The previous status of the pull-down resistor of the P0D0 through P0D3 pins is retained. 14.7.5 In halt status The status of the pin selected for the A/D converter is retained as is. The previous status of the pull-down resistor of the P0D0 through P0D3 pins is retained. 201 PD17704, 17705, 17707, 17708, 17709 15. D/A CONVERTER (PWM mode) 15.1 Outline of D/A Converter Figure 15-1 outlines the D/A converter. The D/A converter outputs a signal whose duty factor is varied by means of PWM (Pulse Width Modulation). By connecting an external lowpass filter to the D/A converter, a digital signal can be converted into an analog signal. Each pin of the D/A converter can output a variable-duty signal independently of the others. Whether an 8-bit counter or 9-bit counter is used for the D/A converter can be specified by software. When the 8-bit counter is selected, two output frequencies, 4.4 kHz and 440 Hz can be selected, and the duty factor of the output signal can be varied in 256 steps. When the 9-bit counter is selected, two output frequencies, 2.2 kHz and 220 Hz, can be selected, and the duty factor can be varied in 512 steps. When the D/A converter is not used, it can be used as timer 3, which counts the basic clock (1.125 or 0.1125 MHz) with an 8-bit counter. For the details of timer 3, refer to 13. TIMER 3. Figure 15-1. Outline of D/A Converter Duty setting block Multiplexed with timer 3 DBF DBF DBF TM3SEL flag PWM0SEL flag P1B0/PWM0 Output selection block PWM1SEL flag P1B1/PWM1 Output selection block PWM2SEL flag RES P1B2/PWM2 Output selection block 9-bit or 8-bit counter PWMBIT Clock generation block PWMCK TM3RES flag PWM data register 0 (PWMR0) PWM data register 1 (PWMR1) PWM data register 2 (PWMR2) Comparator Comparator Comparator IRQTM3 fPWM Remarks 1. 2. 3. 4. 5. PWM2SEL through PWM0SEL (bits 2 through 0 of PWM/general-purpose port pin function selection register: refer to Figure 15-4) select a general-purpose output port of D/A converter. PWMBIT (bit 2 of PWM clock selection register: refer to Figure 15-2) selects the number of bits (8 or 9 bits) of the PWM counter. PWMCK (bit 0 of PWM clock selection register: refer to Figure 15-2) selects the output frequency of PWM timer. TM3SEL (bit 3 of timer 3 control register: refer to Figure 15-5) selects timer 3 or D/A converter. TM3RES (bit 0 of timer 3 control register: refer to Figure 15-5) controls resetting of timer 3 counter. 202 PD17704, 17705, 17707, 17708, 17709 15.2 PWM Clock Selection Register The PWM clock selection register specifies whether the PWM counter is used as an 8-bit counter or 9-bit counter when the D/A converter is used for PWM output. Figure 15-2 shows the configuration of the PWM clock selection register. Figure 15-2. Configuration of PWM Clock Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write PWM clock selection 0 P W M B I T 0 P W M C K 26H R/W Selects output frequency of timer 3 0 1 4.4 kHz (8 bits) /2.2 kHz (9 bits) 440 Hz (8 bits) /220 Hz (9 bits) Fixed to "0" Selects number of bits of PWM counter 0 1 8 bits 9 bits Fixed to "0" At reset Power-ON reset WDT&SP reset CE reset 0 0 0 R 0 0 0 0 R 0 Clock stop R: Retained 203 PD17704, 17705, 17707, 17708, 17709 15.3 PWM Output Selection Block The output selection block specifies whether each output pin of the D/A converter is used for the D/A converter or as a general-purpose output port, by using the PWM2SEL through PWM0SEL flags of the PWM/general-purpose port pin function selection register. Figure 15-3 shows the configuration of the output selection block, and Figure 15-4 shows the configuration of the PWM/general-purpose port pin function selection register. Each pin can be changed between the D/A converter mode and general-purpose output port mode independently of the others. Because each output pin is an N-ch open-drain output pin, an external pull-up resistor is necessary. When the D/A converter is used as timer 3, the P1B2/PWM2 through P1B0/PWM0 pins are automatically set in the general-purpose output port mode, regardless of the values set to the PWM2SEL through PWM0SEL flags. Figure 15-3. Configuration of Output Selection Block PWM2SEL through PWM0SEL flags TM3SEL Each output pin 1 0 Output latch Comparator output 204 PD17704, 17705, 17707, 17708, 17709 Figure 15-4. Configuration of PWM/General-Purpose Port Pin Function Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write PWM/general-purpose port pin function selection 0 P P P 27H R/W WWW M 2 S E L MM 1 S E L 0 S E L Selects function of P1B0/PWM0 pin 0 1 General-purpose output port D/A converter Selects function of P1B1/PWM1 pin 0 1 General-purpose output port D/A converter Selects function of P1B2/PWM2 pin 0 1 General-purpose output port D/A converter Fixed to "0" At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 Retained 0 0 0 Clock stop 205 PD17704, 17705, 17707, 17708, 17709 Figure 15-5. Configuration of Timer 3 Control Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Timer 3 control T M 3 S E L 0 T T 28H R/W MM 3 E N 3 R E S Resets counter 0 1 Does not change Resets Starts or stops counter 0 1 Stops Starts Fixed to "0" Selects timer 3 or D/A converter 0 1 D/A converter (PWM output) Timer 3 At reset Power-ON reset WDT&SP reset CE reset 0 0 R 0 0 0 0 0 0 Retained 0 0 Clock stop R: Retained 206 PD17704, 17705, 17707, 17708, 17709 15.4 Duty Setting Block 15.4.1 PWM duty with 8-bit counter selected The duty setting block compares the value set to each PWM data register (PWMR2 to PWMR0) with the value of the basic clock counted by each 8-bit counter. If the value of the PWM data register is greater, the block outputs a high level. If the value of the PWM data register is less, it outputs a low level. Where the value set to the PWM data register is "x", therefore, the duty factor can be calculated by the following expression. x + 0.25 256 Duty: D = x 100% Remark 0.25 is an offset, and a high level is output even where x = 0. Data is set to each PWM data register for each pin via data buffer (DBF). However, the same basic clock, PWM counter, and output frequency must be selected for each pin. This means that each pin cannot output a duty factor of a different cycle independently of the others. Because the basic clock frequency is 1.125 or 0.1125 MHz, the frequency and cycle of the output signal can be calculated as follows. (1) Where output frequency is 4.4 kHz and basic clock frequency is 1.125 MHz 1.125 MHz 256 256 1.125 MHz Frequency: f = = 4.3945 kHz Cycle: T= = 227.56 s (2) Where output frequency is 440 Hz and basic clock frequency is 0.1125 MHz 0.1125 MHz 256 256 0.1125 MHz Frequency: f = = 439.45 Hz Cycle: T= = 2.2756 ms Because the duty setting register of the PWM data registers and timer 3 modulo register are the same register, they cannot be used at the same time. When timer 3 is used, PWM data registers 1 and 0 can be used as 8-bit data latches. 207 PD17704, 17705, 17707, 17708, 17709 Figure 15-6. Configuration of PWM Data Registers (with 8-bit counter selected) Data buffer DBF3 DBF2 DBF1 DBF0 Transfer data GET 16 bits PUT Name Symbol Address Bit Data PWM data register 2Note PWMR2 46H b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 0 0 0 0 0 0 0 0 Valid data GET PUT Name Symbol Address Bit Data PWM data register 1 PWMR1 45H b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 0 0 0 0 0 0 0 0 Valid data GET PUT Name Symbol Address Bit Data PWM data register 0 PWMR0 44H b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 0 0 0 0 0 0 0 0 Valid data Sets PWM output duty of each pin 0 x Duty: D = x+0.25 256 x 100 % FFH Fixed to "0" At reset Power-ON reset WDT&SP reset CE reset 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Retained 1 1 1 1 1 1 1 1 Clock stop Note This register is multiplexed with timer 3 modulo register. 208 PD17704, 17705, 17707, 17708, 17709 15.4.2 PWM duty with 9-bit counter selected The duty setting block compares the value set to each PWM data register (PWMR2 to PWMR0) with the value of the basic clock counted by each 9-bit counter. If the value of the PWM data register is greater, the block outputs a high level. If the value of the PWM data register is less, it outputs a low level. Where the value set to the PWM data register is "x", therefore, the duty factor can be calculated by the following expression. x + 0.25 512 Duty: D = x 100% Remark 0.25 is an offset, and a high level is output even where x = 0. Data is set to each PWM data register for each pin via data buffer (DBF). However, the same basic clock, PWM counter, and output frequency must be selected for each pin. This means that each pin cannot output a duty factor of a different cycle independently of the others. Because the basic clock frequency is 1.125 or 0.1125 MHz, the frequency and cycle of the output signal can be calculated as follows. (1) Where output frequency is 2.2 kHz and basic clock frequency is 1.125 MHz 1.125 MHz 512 512 1.125 MHz Frequency: f = = 2.197 kHz Cycle: T= = 455.11 s (2) Where output frequency is 220 Hz and basic clock frequency is 0.1125 MHz 0.1125 MHz 512 512 0.1125 MHz Frequency: f = = 219.73 Hz Cycle: T= = 4.5511 ms Because the duty setting register of the PWM data registers and timer 3 modulo register are the same register, they cannot be used at the same time. When timer 3 is used, PWM data registers 1 and 0 can be used as 8-bit data latches. 209 PD17704, 17705, 17707, 17708, 17709 Figure 15-7. Configuration of PWM Data Registers (with 9-bit counter selected) Data buffer DBF3 DBF2 DBF1 DBF0 Transfer data GET 16 bits PUT Name Symbol Address Bit Data PWM data register 2 PWMR2 46H b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 0 0 0 0 0 0 0 Valid data GET PUT Name Symbol Address Bit Data PWM data register 1 PWMR1 45H b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 0 0 0 0 0 0 0 Valid data GET PUT Name Symbol Address Bit Data PWM data register 0 PWMR0 44H b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 0 0 0 0 0 0 0 Valid data Note Sets PWM output duty of each pin 0 x Duty: D = x+0.25 512 x 100 % 1FFH Fixed to "0" Power-On reset At reset WDT&SP reset CE reset 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Retained 1 1 1 1 1 1 1 1 1 Clock stop Note This register is multiplexed with timer 3 modulo register. 210 PD17704, 17705, 17707, 17708, 17709 15.5 Clock Generation Block The clock generation block outputs a basic clock to set the duty factor of each output signal. Two output frequencies, 1.125 MHz and 112.5 kHz, can be selected. 15.6 D/A Converter Output Wave (1) shows the relationship between the duty factor and output wave. (2) shows the output wave of each pin. Each output pin has a phase different from the others. (1) Duty and output wave (a) With 8-bit counter and 4.4 kHz selected x=0 x=1 x=2 ......... 222 ns 888 ns 888 ns x = 255 227.56 s 667 ns (b) With 8-bit counter and 440 Hz selected x=0 x=1 x=2 2.22 s 8.88 s 8.88 s ......... x = 255 2.2756 ms 6.67 s 211 PD17704, 17705, 17707, 17708, 17709 (c) With 9-bit counter and 2.2 kHz selected x=0 x=1 x=2 ......... 222 ns 888 ns 888 ns x = 511 455.11 s 667 ns (d) With 9-bit counter and 220 Hz selected x=0 x=1 x=2 2.22 s 8.88 s 8.88 s ......... x = 511 4.5511 ms 6.67 s (2) Each pin and output wave (a) With 8-bit counter and 4.4 kHz selected PWM0 (x = 0) 222 ns PWM1 (x = 0) 222 ns PWM2 (x = 0) 222 ns 227.56 s 227.56 s 227.56 s 212 PD17704, 17705, 17707, 17708, 17709 (b) With 8-bit counter and 440 Hz selected PWM0 (x = 0) 2.22 s PWM1 (x = 0) 2.22 s PWM2 (x = 0) 2.22 s 2.2756 ms 2.2756 ms 2.2756 ms (c) With 9-bit counter and 2.2 kHz selected PWM0 (x = 0) 222 ns PWM1 (x = 0) 222 ns PWM2 (x = 0) 222 ns 455.11 s 455.11 s 455.11 s (d) With 9-bit counter and 220 Hz selected PWM0 (x = 0) 2.22 s PWM1 (x = 0) 2.22 s PWM2 (x = 0) 2.22 s 4.5511 ms 4.5511 ms 4.5511 ms 213 PD17704, 17705, 17707, 17708, 17709 15.7 Example of Using D/A Converter An example of a program using the D/A converter is shown below. Example This program increments the duty factor of the PWM1 pin every 1 second. PWM1DATA DAT INITIAL: INITFLG ; INITFLG ; LOOP0: BANK1 CLR1 BANK0 CLR1 MOV MOV MOV SET1 LOOP1: PUT GET2 PWM1R, DBF TM3RES, TM3EN ; Resets and starts counter TM3SEL ; Selects D/A converter P1B1 NOT PWM2SEL, NOT PWM1SEL, NOT PWM0SEL (General-purpose port), (General-purpose port), (General-purpose port) 0000H PWMBIT , NOT PWMCK (9-bit counter), (1.125 MHz) DBF2, #PWM1DATA SHR 8 AND 0FH DBF1, #PWM1DATA SHR 4 AND 0FH DBF0, #PWM1DATA AND 0FH PWM1SEL ; Sets PWM1/P1B1 pin in PWM output port mode ; Duty: 0.25/512 to 511.25/512 (PWM output) Waits for 1 second GET ADD ADDC ADDC SKGE BR LOOP2: BANK1 SET1 BANK0 CLR1 PWM1SEL ; Sets PWM1/P1B1 pin in general-purpose output port mode P1B1 DBF, PWM1R DBF0, #1 DBF1, #0 DBF2, #1 DBF2, #2 LOOP1 ; Port outputs high level Waits for 1 second BR LOOP0 214 PD17704, 17705, 17707, 17708, 17709 15.8 Status at Reset 15.8.1 At power-ON reset The P1B0/PWM0 through P1B2/PWM2 pins are set in the general-purpose output port mode. The output value is "low level". The value of each PWM data register (including the timer 3 modulo register) is "1FFH". 15.8.2 At WDT&SP reset The P1B0/PWM0 through P1B2/PWM2 pins are set in the general-purpose output port mode. The output value is "low level". The value of each PWM data register (including the timer 3 modulo register) is "1FFH". 15.8.3 At CE reset The P1B0/PWM2 through P1B2/PWM2 pins retain the previous status. That is, if the D/A converter is being used, the PWM output is retained as is. If timer 3 is being used, counting continues. 15.8.4 On execution of clock stop instruction The P1B0/PWM0 through P1B2/PWM2 pins are set in the general-purpose output port mode. The output value is the "previous contents of the output latch". The value of each PWM data register (including the timer 3 modulo register) is "1FFH". 15.8.5 In halt status The P1B0/PWM0 through P1B2/PWM2 pins retain the previous status. That is, if the D/A converter is being used, the PWM output is retained as is. If timer 3 is being used, counting continues. 215 PD17704, 17705, 17707, 17708, 17709 16. SERIAL INTERFACES 16.1 Outline of Serial Interfaces Figure 16-1 outlines the serial interfaces. Table 16-1 classifies the serial interfaces and shows their communication modes. As shown in Figure 16-1, two serial interfaces, 0 (SIO0) and 1 (SIO1), are available. Serial interfaces 0 and 1 can be used at the same time. Serial interface 0 can be used in two modes: 2-wire and 3-wire modes. In the 2-wire mode, two pins, SDA and SCL, are used. In the 3-wire mode, three pins, SCK0, SO0, and SI0, are used. In the 2-wire mode, two communication modes, I2C bus and serial I/O modes, can be selected. Serial interface 1 can be used only in 3-wire mode, and uses three pins, SCK1, SO1, and SI1. The communication mode is the serial I/O mode. Figure 16-1. Outline of Serial Interfaces SDA/P0A3 SCL/P0A2 SCK0/P0A1 SO0/P0A0 SI0/P0B3 I/O control Presettable shift register 0 (SIO0SFR) Clock control block 4.5 MHz Interrupt control block IRQSIO0 flag Serial interface 0 SCK1/P0B2 SO1/P0B1 SI1/P0B0 I/O control Presettable shift register 1 (SIO1SFR) Clock control block 4.5 MHz IRQSIO1 flag Serial interface 1 216 PD17704, 17705, 17707, 17708, 17709 Table 16-1. Classification and Communication Modes of Serial Interfaces Number of Communication Lines 2 lines (2-wire) Channel Communication Mode I2C bus Serial I/O Pins Used Serial interface 0 P0A3/SDA P0A2/SCL P0A1/SCK0 P0A0/SO0 P0B3/SI0 3 lines (3-wire) Serial I/O Serial interface 1 3 lines (3-wire) Serial I/O P0B2/SCK1 P0B1/SO1 P0B0/SI1 16.2 Serial Interface 0 16.2.1 Outline of serial interface 0 Figure 16-2 outlines the serial interface 0. Serial interface 0 can be used in 2-wire I2C bus or serial I/O mode, or 3-wire serial I/O mode. Figure 16-2. Outline of Serial Interface 0 SIO0CH flag SB flag SIO0MS flag SIO0CK0, 1 flag Wait signal SCL/P0A2 Clock I/O control block SCK0/P0A1 Clock control block 4.5 MHz Wait control block Count values 8, 9 SBSTT, SBBSY flag Start/stop detection block SDA/P0A3 SO0/P0A0 SI0/P0B3 Data I/O control block OUT Presettable shift register 0 (SIO0SFR) IN Interrupt control block SIO0WSTT flag SIO0WRQ0, 1 flag SIO0NWT flag Clock counter SIO0CH flag SB flag SIO0TX flag SIO0SF8, 9 flag SIO0IMD0, 1 flag Serial date ACK Acknowledge control block SBACK flag 217 PD17704, 17705, 17707, 17708, 17709 Remarks 1. 2. 3. 4. 5. 6. 7. 8. 9. SIO0CH and SB (bits 3 and 2 of serial I/O0 mode selection register: refer to Figure 16-3) select the mode of serial I/O0. SIO0MS (bit 1 of serial I/O0 mode selection register: refer to Figure 16-3) select a master or slave. SIO0TX (bit 0 of serial I/O0 mode selection register: Figure 16-3) selects reception or transmission. SIO0CK1 and SIO0CK0 (bits 1 and 0 of serial I/O0 clock selection register: refer to Figure 16-4) select an internal shift clock frequency. SIO0WRQ1 and SIO0WRQ0 (bits 1 and 0 of serial I/O0 wait control register: refer to Figure 16-7) set wait conditions for communication. SIO0NWT (bit 2 of serial I/O0 wait control register: refer to Figure 16-7) starts communication. SIO0SF9 and SIO0SF8 (bits 2 and 3 of serial I/O0 status detection register: refer to Figure 16-5) detect a clock counter. SBSTT and SBBSY (bits 1 and 0 of serial I/O0 status detection register: refer to Figure 16-5) detect the start and stop conditions, and clock counter in the I2C bus mode. SIO0IMD1 and SIO0IMD0 (bits 1 and 0 of serial I/O0 interrupt mode selection register: refer to Figure 16-9) set interrupt timing. 10. SBACK (bit 3 of serial I/O0 wait control register: refer to Figure 16-7) reads or sets acknowledge data. 11. SIO0WSTT (bit 0 of serial I/O0 wait status judge register: refer to Figure 16-8) detects serial communication status. 16.2.2 Clock I/O control block and data I/O control block The clock I/O control block and data I/O control block control the communication mode (I2C bus or serial I/O mode), the number of pins used (2-wire or 3-wire mode), and transmission or reception operation of serial interface 0. The 2-wire or 3-wire mode, and I2C bus or serial I/O mode are selected by using the SIO0CH and SB flags. The SIO0MS flag selects the internal clock (master) or external clock (slave) operation, and the SIO0TX flag selects reception (RX) or transmission (TX). Each flag is allocated to the serial I/O0 mode selection register. Figure 16-3 shows the configuration of the serial I/O0 mode selection register. Table 16-2 shows the set status of each pin. As shown in this table, flags that set the input or output mode of each pin must also be manipulated in addition to the control flags of the serial interface, in order to set each pin. 218 PD17704, 17705, 17707, 17708, 17709 Figure 16-3. Configuration of Serial I/O0 Mode Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Serial I/O0 mode selsction S I O 0 C H S B S I S I 0FH R/W OO 0 M 0 T SX Sets serial I/O of SDA/P0A3 pin (2-wire) and SO0/P0A0 pin (3-wire) (selects reception RX or transmission TX ) 2-wire (SDA/P0A3 pin) 0 1 Serial input (Hi-Z) Serial output : TX : RX 3-wire (SO0/P0A0 pin) General-purpose port Serial output : TX Sets direction of shift clock I C bus mode 0 1 2 Serial I/O mode Slave operation (external clock input) External clock input Master operation (internal clock output) Internal clock output Sets mode of serial I/O0 0 0 1 1 0 1 0 1 Serial I/O0 not used I2C bus mode 2-wire serial I/O mode 3-wire serial I/O mode At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Clock stop 219 PD17704, 17705, 17707, 17708, 17709 Table 16-2. Status of Each Pin Set by Control Flag Each Flag S I O 0 C H 1 S B Communication mode S I O 0 M S Clock direction S I O 0 T X 0 Serial I/O Pin name P 0 A B I O 3 0 1 0 1 P0A2/SCL 0 1 0 1 P0A1/SCK0 P0A0/SO0 P0B3/SI0 0 1 I2C bus 0 Input (reception) Output (transmission) P0A2/SCL P0A3/SDA 0 1 0 1 0 1 0 1 P0A1/SCK0 P0A0/SO0 P0B3/SI0 1 1 3-wire serial I/O 0 External (slave) Internal (master) 0 General-purpose port Output (transmission) P0B3/SI0 P0A0/SO0 P0A3/SDA P0A2/SCL P0A1/SCK0 0 1 0 1 P 0 A B I O 2 P 0 A B I O 1 Pin P 0 A B I O 0 P 0 A B I O 0 Pin setting status 0 2-wire serial I/O Input (reception) Output (transmission) P0A3/SDA Serial input General-purpose output port Serial output 1 0 External (slave) (internal) (master) External clock General-purpose output port Internal clock 1 General-purpose I/O port General-purpose I/O port General-purpose I/O port Serial input General-purpose output port Serial output 1 0 External (slave) Internal (master) External clock General-purpose output port Internal clock 1 General-purpose I/O port General-purpose I/O port General-purpose I/O port General-purpose I/O port General-purpose I/O port External clock General-purpose output port Internal clock 1 0 1 0 1 0 1 General-purpose input port General-purpose output port Serial output 1 Serial input General-purpose output port General-purpose input port General-purpose output port 0 0 Not used as serial I/O0 P0A0-P0A3, P0B3 0 1 0 1 0 1 0 1 0 1 220 PD17704, 17705, 17707, 17708, 17709 16.2.3 Clock control block The clock control block controls generation of a clock when the internal clock is used (master operation) and clock output timing. The frequency fSC of the internal clock is set by the SIO0CK1 and SIO0CK0 flags of the serial I/O0 clock selection register. Figure 16-4 shows the configuration of the serial I/O0 clock selection register. The shift clock output from the clock control block is valid only for the master operation (SIO0MS flag = 1). For the clock generation timing, refer to the description of each communication mode. Figure 16-4. Configuration of Serial I/O0 Clock Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Serial I/O0 clock selection 0 S B M D S I S I 0BH R/W OO 0 C K 1 0 C K 0 Selects internal shift clock frequency fSC of serial interface 0 0 0 1 1 0 1 0 1 93.75 kHz 375.00 kHz 281.25 kHz 46.875 kHz Selects operation mode during slave transmission of I2C bus 0 1 Continues processing Slave reception mode is set automatically if acknowledge signal is not received (fixed to "1" when serial I/O is selected) Fixed to "0" At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 0 0 0 0 0 Clock stop 221 PD17704, 17705, 17707, 17708, 17709 16.2.4 Clock counter and start/stop detection block The clock counter is a wrap-around counter that counts the rising edges of the clock. Because this counter directly reads the status of the clock pin, whether the clock is an internal clock or external clock cannot be identified. The contents of the clock counter can be detected via the SIO0SF8 and SIO0SF9 flags of the serial I/O0 status detection register, but cannot be directly read by program. The start/stop detection block detects the start and stop conditions when the I2C bus mode is used. The start and stop conditions are detected by the SBSTT and SBBSY flags of the serial I/O0 status detection register. Figure 18-5 shows the configuration of the serial I/O0 status detection register. For the operation and timing chart of the clock counter, refer to the description of each communication mode. 222 PD17704, 17705, 17707, 17708, 17709 Figure 16-5. Configuration of Serial I/O0 Status Detection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Serial I/O0 status detection S I S I S B S T T S B B S Y 0DH R OO 0 S F 8 0 S F 9 Detects start /stop condition of I2C bus mode I2C bus mode 0 1 Detects stop condition Detects start condition Serial I/O mode Retains "0" Detects start condition and clock counter in I2C bus mode I2C bus mode 0 Detects rising of clock when value of clock counter is "9" 1 Detects start condition Serial I/O mode Retains "0" Detects clock counter I2C bus mode 0 Detects rising of clock when value of clock counter is next to "9" 1 Value of clock counter is "9" Serial I/O mode Retains "0" Detects clock counter I C bus mode 0 1 2 Serial I/O mode Detects rising of clock when value of clock counter is next to "8" Value of clock counter is "8" At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Clock stop 223 PD17704, 17705, 17707, 17708, 17709 16.2.5 Presettable shift register 0 Presettable shift register 0 is an 8-bit shift register that writes serial out data and reads serial in data. This register writes or reads data via data buffer. It outputs the contents of the most significant bit (MSB) from the serial data I/O pin in synchronization with the falling edge of the shift clock (during transmission operation), and reads data to the least significant bit (LSB) in synchronization with the rising edge of the serial clock. Figure 16-6 shows the configuration of the presettable shift register 0. Figure 16-6. Configuration of Presettable Shift Register 0 Data buffer DBF3 Don't care DBF2 Don't care DBF1 DBF0 Transfer data GETNote 8 PUTNote Peripheral register Name Presettable shift register 0 b7 M S B b6 b5 b4 b3 b2 b1 b0 Symbol Peripheral register L S SIO0SFR B Valid data 03H Sets serial out data and reads serial in data D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 Serial out Serial in Note Data may be destroyed if the PUT or GET instruction is executed during serial communication. For details, refer to 16.2.10 Causions on setting and reading data. 224 PD17704, 17705, 17707, 17708, 17709 16.2.6 Wait control block and acknowledge control block The wait control block keeps communication waiting or releases communication from the wait status. The condition under which communication is kept waiting is set by the SIO0WRQ0 and 1 flags (bits 0 and 1 of serial I/O0 wait control register). Serial communication is started when the SIO0NWT flag (bit 2 of serial I/O0 wait control register) is set (released from the wait status). The communication status can be detected by the SIO0NWT flag. When "0" is written to the SIO0NWT flag while communication is released from the wait status, the wait status is set. This is called forced wait status. The acknowledge control block outputs and detects an acknowledge signal in the I2C bus mode. An acknowledge signal is set and read by the SBACK flag (bit 3 of serial I/O0 wait control register). Figure 16-7 shows the configuration of the serial I/O0 wait control register. Figure 16-8 shows the configuration of the serial I/O0 wait status judge register. 225 PD17704, 17705, 17707, 17708, 17709 Figure 16-7. Configuration of Serial I/O0 Wait Control Register Name Flag symbol b3 b2 b1 b0 Serial I/O0 wait control S B A C K S I O 0 N W T S I S I 0EH R/W Address Read/Write OO 0 0 WW R R QQ 1 0 Sets wait condition Name 0 0 0 1 No wait Data wait I C bus mode Does not wait Waits at falling edge of shift clocks when value of clock counter is "8" 1 0 Acknowledge wait Waits at falling edge of shift clock when value of clock counter is "9" 1 1 Address wait Waits at falling edge of clock when value of clock counter is "8" after detection of start condition Wait at rising edge of shift clock when value of clock counter is "8" Setting prohibited 2 Serial I/O mode Sets wait and detects wait status When flag is written 0 Forced wait When flag is read Waits under condition of SIO0WRQ0 and 1 flags 1 Releases wait status (serial communication starts) Sets and detects acknowledge signal in I2C bus mode I2C bus mode Reception (SIO0TX = 0) 0 Transmission (SIO0TX = 1) Retains "0" Serial I/O mode Serial communication in progress Outputs "0" as Detects acknowledge acknowledge of slave (acknowledge is "0" ) 1 Outputs "1" as Detects acknowledge acknowledge of slave (acknowledge is "1" ) At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Clock stop 226 PD17704, 17705, 17707, 17708, 17709 Figure 16-8. Configuration of Serial I/O0 Wait Status Judge Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Serial I/O0 wait status judge 0 0 0 S I O 0 W S T T 0AH R Detects serial communication status 0 1 Waiting or requesting wait by slave Serial communication in progress Fixed to "0" At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 Clock stop Caution If a slave outputs a wait request while the master is operating, "0" is detected on the SIO0WSTT flag. The SIO0NWT flag retains the status of 1. 227 PD17704, 17705, 17707, 17708, 17709 16.2.7 Interrupt control block The interrupt control block sets a condition under which an interrupt request is issued by the serial I/O0 interrupt mode selection register. When the interrupt request issuance condition is satisfied, the IRQSIO0 flag is set. Change the interrupt request issuance condition while communication is in the wait status. If it is changed after communication has been released from the wait status, an interrupt request may be issued as soon as the condition has been changed. Figure 16-9 shows the configuration of the serial I/O0 interrupt mode selection register. Figure 16-9. Configuration of Serial I/O0 Interrupt Mode Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Serial I/O0 interrupt mode selection 0 0 S I S I 0CH R/W OO 0 I 0 I MM D 1 D 0 Sets interrupt request issuance condition I C bus mode 0 0 Rising edge of shift clock when value of clock counter reaches "7" 0 1 Rising edge of shift clock when value of clock counter reaches "8" 1 0 Rising edge of shift clock when value of clock counter reaches "7" after detection of start condition Note 3 1 1 When stop condition is detected Note 4 2 Serial I/O mode Rising edge of shift clock when value of clock counter reaches "7" Note 1 Rising edge of shift clock when value of clock counter reaches "8" Note 2 Interrupt request is not issued Fixed to "0" At reset Power-ON reset WDT & SP reset CE reset 0 0 0 0 0 0 0 0 0 0 Clock stop Notes 1. An interrupt request is issued if this mode is set when the value of the clock counter is "7". 2. An interrupt request is issued if this mode is set when the value of the clock counter is "8". 3. An interrupt request is issued if this mode is set when the SBSTT flag = 1 and the value of the clock counter is "7". 4. An interrupt request is issued if this mode is set after the stop condition has been issued. 228 PD17704, 17705, 17707, 17708, 17709 16.2.8 I2C bus mode (1) Outline of I2C bus mode In the I2C bus mode, communication is carried out with two pins, SCL and SDA. The features of the I2C bus mode are as follows. * Communication can be controlled under the start/stop conditions and by the acknowledge signal for the ninth clock. * Communication can be kept waiting by externally fixing the clock to low level with an N-ch open-drain pin. (2) Timing chart Figure 16-10 shows the timing chart. Figure 16-10. Timing Chart in I2C Bus Mode Start condition Shift clock Serial data 1 2 3 7 8 9 Stop condition D7 D6 D5 D1 D0 ACK Clock counter SIO0NWT SIO0WSTT SIO0SF8 SIO0SF9 SBSTT SBBSY 0 1 2 6 7 8 9 0 <1> <2> <3> <4> INT <9> <10> <5> <11> <6> <7> <8> <12> <1> Initial status (general-purpose input port) <2> Generates start condition by general-purpose I/O port <3> Sets transmission status of master <4> Releases wait <5> Wait timing when data wait status is set <6> Wait timing when acknowledge wait status is set <7> Sets general-purpose I/O port (releases serial operation mode) <8> Generates stop condition by general-purpose I/O port <9> Issues interrupt request when value of clock counter first reaches 7 after detection of start condition <10> Issues interrupt request when value of clock counter reaches 7 <11> Issues interrupt request when value of clock counter reaches 8 <12> Issues interrupt request after stop condition is detected 229 PD17704, 17705, 17707, 17708, 17709 (3) Operation of clock counter The value of the clock counter is incremented from the initial value "0" each time the rising of the clock pin has been detected. In the I2C bus mode, the value of the clock counter returns to "0" after it has reached "9", and the clock counter continues counting. In the serial I/O mode, the value of the clock counter returns to "0" after it has reached "8", and the clock counter continues counting. The clock counter is also reset in the following cases. * At reset (power-ON reset, WDT&SP reset, CE reset) * On execution of clock stop instruction * On detection of start condition * If communication mode is changed from I2C bus mode to 2-wire or 3-wire serial I/O mode (4) Wait operation and cautions When the wait status is released, serial data is output (during transmission operation), and the wait status is kept released until a condition (wait condition) set by the SIO0WRQ0 and 1 flags is satisfied. When the wait condition is satisfied, the shift clock pin is made low, and the operations of the clock counter and presettable shift register 0 are stopped. If the forced wait status is specified while the wait status is released, the forced wait status is set at the falling of the clock next to the one at which "0" has been written to the SIO0NWT flag. Nothing is changed even if the wait status is released again after the wait status has been released once. If the forced wait status is set in the wait status, one pulse of the shift clock is output. In the I2C bus mode, do not set data wait conditions (SIOWRQ0 = 1, WIO0WRQ1 = 0) successively. This is because, if the data wait condition is set two times in succession and the wait status is released, the wait status is set as soon as the wait status has been released the second time. While the device is operating as the master and if the level of the shift clock output pin is forcibly made low externally while the pin outputs a high level (this is called a wait request by slave), the master is placed in the wait status. If this happens, the master resumes its operation when the wait request by the slave has been cleared. (5) Interrupt request issuance timing Interrupt request issuance timing can be selected by the SIO0IMD0 and 1 flags. (6) Acknowledge block and its operation The acknowledge block operates only in the I2C bus mode. This block is used to output an acknowledge signal during a reception operation, or to detect an acknowledge signal during a transmission operation. During reception, the content of the SBACK flag is output to the serial data pin at the falling edge of the shift clock when the value of the clock counter is "8". Once data has been set to the SBACK flag during reception, the value of the data is retained. During transmission, the status of the serial data pin is read to the SBACK flag at the rising edge of the shift clock when the value of the clock counter reaches "9" Figure 16-11 shows the acknowledge signal output and input operations. During reception, set the acknowledge signal (setting of the SBACK flag) as soon as the wait status has been released (by setting the SIO0NWT flag). 230 PD17704, 17705, 17707, 17708, 17709 This is because, even if only the SBACK flag is set, the SIO0NWT flag is also set because it is in the register at the same address. If the wait status is set at this time, the wait status is released and one pulse of the shift clock is output. Figure 16-11. Acknowledge Output and Input Operations (a) During reception Shift clock 7 8 9 Data Hi-Z (D1) Hi-Z (D0) SBACK output Hi-Z Data input Acknowledge output At this time, wait status must be released at the same time. (b) During transmission Shift clock 7 8 9 ACK at reception side Data D1 output Data output D0 output Acknowledge input 231 PD17704, 17705, 17707, 17708, 17709 (7) Shift clock generation timing in I2C bus mode (a) On releasing wait status from initial status The initial status is the point where the master operation in the I2C bus mode is selected. In the wait status, a low level is output to the shift clock pin. Figure 16-12. Shift Clock Generation Timing in I2C Bus Mode (1/5) Shift clock 1:1 Wait period 1/fSC Initialization Wait released (b) During wait operation <1> Wait status under condition of SIO0WRQ0 and SIO0WRQ1 flags (normal operation) Figure 16-12. Shift Clock Generation Timing in I2C Bus Mode (2/5) Shift clock Wait released status Wait period 1/fSC Wait under condition of SIO0WRQ1 and SIO0WRQ0 Wait released <2> If forced wait status is set in wait status Nothing is affected. 232 PD17704, 17705, 17707, 17708, 17709 <3> If forced wait status is set after wait status has been released In this case, the wait status is set at the next falling edge of the clock after the one at which the forced wait status was set. When the forced wait status was set, however, the clock counter and presettable shift register 0 stop operating. If the forced wait status is set while the clock pin is low, the clock counter and presettable shift register 0 operate by 1 pulse. Because the internal clock counter and shift register do not operate at this time, communication may not be performed normally even if the wait status is released again. Figure 16-12. Shift Clock Generation Timing in I2C Bus Mode (3/5) Shift clock Wait released status Wait pending Wait period 1/fSC Forced wait set by SIO0NWT Shift clock Wait pending Wait released Wait period 1/fSC Forced wait set by SIO0NWT Wait released <4> If wait status is released after wait status has been released Nothing is affected. <5> If wait request is made by slave after wait status has been released At this time, the clock is output 0 to 3.3 s after the wait request by the slave has been cleared. The value of T in the figure below is as follows: fSC 93.75 kHz 375.00 kHz 281.25 kHz 46.875 kHz 666 ns 222 ns 222 ns 666 ns T 233 PD17704, 17705, 17707, 17708, 17709 Figure 16-12. Shift Clock Generation Timing in I2C Bus Mode (4/5) Shift clock Wait released status Wait request by slave 1/fSC 0-3.3 s Wait request by slave cleared Shift clock T Wait request by slave T 0-3.3 s Wait request by slave cleared (c) During slave (external clock) operation When the slave operation is specified the first time after application of supply voltage VDD, the SCK pin waits for input of an external clock and the output pin goes into a high-impedance state. If the SCL pin is externally made low at this time, it continues outputting a low level until the wait status is released next time. Figure 16-12. Shift Clock Generation Timing in I2C Bus Mode (5/5) Shift clock I/O port Wait period (originally, Hi-Z) Wait released period Slave is set Wait released (8) Start and stop conditions, and operations of SBSTT and SBBSY flags The start/stop condition recognition timing is shown in Figure 16-13. The SBSTT and SBBSY flags operate only in the I2C bus mode. By detecting these flags, communication status of the other stations can be detected. These flags operate regardless of whether the device operates as the master or slave, whether it performs reception or transmission, and whether communication is in the wait status or released from the wait status. These flags are "0" in the serial I/O mode. For the operations of the SBSTT and SBBSY flags, refer to Figure 16-10 Timing Chart in I2C Bus Mode. 234 PD17704, 17705, 17707, 17708, 17709 Figure 16-13. Start/Stop Condition Recognition Timing (a) Start condition recognition timing H Shift clock pin L H Serial data pin L H SBSTT L SBBSY H L About 1 s Start condition is assumed if shift clock pin goes high about 1 s after serial data pin has gone low. Detects falling of serial data pin (b) Stop condition recognition timing H Shift clock pin L H Serial data pin L H SBSTT L H L About 1 s Stop condition is assumed if shift clock pin goes high about 1 s after serial data pin has gone high. SBBSY Detects rising of serial data pin 235 PD17704, 17705, 17707, 17708, 17709 16.2.9 Serial I/O mode (1) Outline of serial I/O mode In the serial I/O mode, communication is carried out by using two pins, SCL and SDA, or three pins, SCK0, SO0, and SI0. (2) Timing chart Figure 16-14 shows the timing chart in the serial I/O mode. Figure 16-14. Timing Chart in Serial I/O Mode Shift clock 1 2 3 7 8 1 Serial data La D7 D6 D5 D1 D0 D7 Clock counter SIO0NWT SIO0WSTT SIO0SF8 SIO0SF9 SBSTT SBBSY <1> 0 1 2 6 7 8 0 1 "0" "0" "0" <2> <3> INT<6> <7> <4> <5> <1> Initial status (general-purpose input port) <2> Sets transmission status of master <3> Releases wait status <4> Wait timing when data wait status is set <5> Releases wait status again <6> Issues interrupt request when value of clock counter is 7 <7> Issues interrupt request when value of clock counter is 8 236 PD17704, 17705, 17707, 17708, 17709 (3) Operation of clock counter The value of the clock counter is incremented from the initial value "0" each time the rising of the clock pin has been detected. The value of the clock counter returns to "0" after it has reached "8", and the clock counter continues counting. The clock counter is also reset in the following cases. * At reset (power-ON reset, WDT&SP reset, CE reset) * On execution of clock stop instruction * If data is written to serial I/O0 wait control register * If communication mode is changed from 2-wire or 3-wire serial I/O mode to I2C bus mode (4) Wait operation and Cautions When the wait status is released, serial data is output (during transmission operation) at the falling of the next clock, and the wait status is kept released until a condition (wait condition) set by the SIO0WRQ0 and 1 flags is satisfied. When the wait condition is satisfied, the shift clock pin is made high, and the operations of the clock counter and presettable shift register 0 are stopped. The value of the presettable shift register 0 cannot be read correctly if it is read while the wait status is released and while the shift clock pin is high. Correct data cannot be written to the presettable shift register 0 while the wait status is released and while the shift clock pin is low. If the forced wait status is specified while the wait status is released, the forced wait status is set as soon as "0" has been written to the SIO0NWT flag. The clock output wave is not affected even if the wait status is released again when it has been already released once. Note, however, that the clock counter is reset. (5) Interrupt request issuance timing Interrupt request issuance timing can be selected by the SIO0IMD0 and 1 flags. For details, refer to 16.2.7 Interrupt control block. (6) Acknowledge block and its operation The acknowledge block operates only in the I2 C bus mode. (7) Shift clock generation timing in serial I/O mode (a) On releasing wait status from initial status The initial status is the status when the internal clock operation in the serial I/O mode has been selected. In the wait status, a high level is output to the shift clock pin. 237 PD17704, 17705, 17707, 17708, 17709 Figure 16-15. Shift Clock Generation Timing in Serial I/O Mode (1/4) Shift clock 1:1 Wait period 1/fSC Initialization Wait released (b) When wait operation is performed <1> If wait status is set under condition specified by SIO0WRQ0 and SIO0WRQ1 flags (normal operation) Figure 16-15. Shift Clock Generation Timing in Serial I/O Mode (2/4) Shift clock Wait released status Wait period 1/fSC Wait by SIO0WRQ1 and SIO0WRQ0 Wait released <2> If forced wait is set in wait status Figure 16-15. Shift Clock Generation Timing in Serial I/O Mode (3/4) Shift clock Wait period Wait period Forced wait set by SIO0NWT 238 PD17704, 17705, 17707, 17708, 17709 <3> If forced wait is set after wait status has been released Figure 16-15. Shift Clock Generation Timing in Serial I/O Mode (4/4) a b Wait released status Wait period 1/fSC Forced wait by SIO0NWT Wait released a + b = 1/2fSC a b Wait released status Wait period 1/fSC Forced wait by SIO0NWT Wait released a + b = 1/2fSC <4> If wait status is released when it has been already released once The clock output waveform is not affected. However, note that the clock counter is reset. (8) Operations of SBSTT and SBBSY flags The SBSTT and SBBSY flags operate only in the I2C bus mode. These flags remain "0" in the serial I/O mode. 239 PD17704, 17705, 17707, 17708, 17709 16.2.10 Cautions on setting and reading data Data is set to the presettable shift register 0 by using the "PUT SIO0SFR, DBF" instruction. To read the data of this register, the "GET DBF, SIO0SFR" instruction is used. Set or read data of the register in the wait status. If the wait status is released, data may not be correctly set or read depending on the status of the shift clock pin. The following table shows the data setting and reading timing, and points to be noted. Table 16-3. Reading and Writing Data of Presettable Shift Register 0 and Cautions Status on Execution of PUT/GET Wait status Read (GET) Write (PUT) Status of Shift Clock Pin * I2C bus mode: fixed to low * Serial I/O mode: fixed to high Normal read Normal write Outputs contents of MSB when wait status is released next time (during transmission) Clock H L 1 Data 0 I2C Bus Mode Serial I/O Mode Normal read Normal write Outputs contents of MSB when wait status is released next time and shift clock pin goes low (during transmission) Clock H L 1 Data 0 MSB MSB PUT SIO0SFR, DBF Wait released PUT SIO0SFR, DBF Wait released Wait released status Read (GET) High level Cannot be read normally Contents of SIO0SFR are lost Cannot be read normally Contents of SIO0SFR are lost Normal read Normal write Outputs contents of MSB when PUT instruction is executed. Clock counter is not reset Low level Write (PUT) High level Normal read Normal write Outputs contents of MSB at falling of clock next to one at which PUT instruction has been executed. Clock counter is not reset H L 1 Data 0 Clock Clock MSB H L 1 Data 0 MSB PUT SIO0SFR, DBF PUT SIO0SFR, DBF Low level Cannot be read normally Contents of SIO0SFR are lost Cannot be read normally Contents of SIO0SFR are lost 240 PD17704, 17705, 17707, 17708, 17709 16.2.11 Operation of serial interface 0 Tables 16-4 through 16-6 outlines the operations in each communication mode. Table 16-4. Outline of Operation in I2C Bus Mode Operation Mode Slave operation (SIO0MS = 0) Reception Item Status of each pin SDA/P0A3 (SIO0TX = 0) When P0ABIO3 = 0 Floating Waits for input of external data When P0ABIO3 = 1 General-purpose output port Outputs content of output latch SCL/P0A2 When P0ABIO2 = 0 Floating Waits for input of external data When P0ABIO2 = 1 General-purpose output port Outputs content of output latch Clock counter Operation of presettable shift register 0 Output Incremented at rising of SCL pin Not output Shifted from MSB each time SCL falls and is output Not output Shifted from MSB each time SCL falls and is output Transmission (SIO0TX = 1) Outputs contents of SIO0SFR at falling of external clock regardless of P0ABIO3 I2C Bus Mode Master operation (SIO0MS = 1) Reception (SIO0TX = 0) When P0ABIO3 = 0 Floating Waits for input of external data When P0ABIO3 = 1 General-purpose output port Outputs content of output latch Outputs internal clock regardless of P0ABIO2 Transmission (SIO0TX = 1) Outputs contents of SIO0SFR at falling of internal clock regardless of P0ABIO3 --------------------------------------------------------------------------------- Input Wait operation In wait status Shifted from LSB each time SCL rise and is input SCL and SDA pins are floated SCL pin is floated and SDA pin retains its status SCL pin outputs low level and SDA pin is floated SCL pin outputs low level and SDA pin retains its status --------------------------------------------------------------------------------- Wait released SCL pin is floated and waits for input of external clock. SCL pin is floated and waits for input of external clock. SCL pin outputs internal clock. SDA pin is floated and waits for external data ACK output at falling of 8th clock SCL pin outputs internal clock. SDA pin outputs data each time SCL pin falls SDA pin is floated and SDA pin outputs data waits for external data Acknowledge ACK output at falling of 8th clock each time SCL pin falls ACK input at rising of 9th clock ACK input at rising of 9th clock 241 PD17704, 17705, 17707, 17708, 17709 Table 16-5. Outline of Operation in 2-Wire Serial I/O Mode Operation Mode 2-Wire Serial I/O Mode Slave operation (SIO0MS = 0) Reception Item Status of each pin SDA/P0A3 (SIO0TX = 0) When P0ABIO3 = 0 Floating Waits for input of external data When P0ABIO3 = 1 General-purpose output port Outputs contents of output latch SCL/P0A2 When P0ABIO2 = 0 Floating Waits for input of external data When P0ABIO2 = 1 General-purpose output port Outputs contents of output latch Clock counter Operation of presettable shift register 0 Output Incremented at rising of SCL pin Not output Shifted from MSB each time SCL falls and is output Not output Shifted from MSB each time SCL falls and is output Transmission (SIO0TX = 1) Outputs contents of SIO0SFR at falling of external clock regardless of P0ABIO3 Master operation (SIO0MS = 1) Reception (SIO0TX = 0) When P0ABIO3 = 0 Floating Waits for input of external data When P0ABIO3 = 1 General-purpose output port Outputs contents of output latch Outputs internal clock regardless of P0ABIO2 Transmission (SIO0TX = 1) Outputs contents of SIO0SFR at falling of internal clock regardless of P0ABIO3 --------------------------------------------------------------------------------- Input Wait operation In wait status Shifted from LSB each time SCL rise and is input SCL and SDA pins are floated SCL pin is floated and SDA pin retains its status SCL pin outputs high level and SDA pin is floated SCL pin outputs high level and SDA pin retains its status --------------------------------------------------------------------------------- Wait released SCL pin is floated and waits for input of external clock. SCL pin is floated and waits for input of external clock. SCL pin outputs internal clock. SCL pin outputs internal clock. SDA pin is floated and SDA pin outputs data waits for external data each time SCL pin falls SDA pin is floated and SDA pin outputs data waits for external data each time SCL pin falls 242 PD17704, 17705, 17707, 17708, 17709 Table 16-6. Outline of Operation in 3-Wire Serial I/O Mode Operation Mode 3-Wire Serial I/O Mode Slave operation (SIO0MS = 0) Reception Item Status of each pin SCK0/P0A1 (SIO0TX = 0) When P0ABIO1 = 0 Floating Waits for input of external data When P0ABIO1 = 1 General-purpose output port Outputs contents of output latch SO0/P0A0 When P0ABIO0 = 0 General-purpose input port Floating When P0ABIO0 = 1 General-purpose output port Outputs contents of output latch SI0/P0B3 When P0BBIO3 = 0 Floating Waits for input of external data When P0BBIO3 = 1 General-purpose output port Outputs contents of output latch Clock counter Operation of presettable shift register 0 Output Incremented at rising of SCK0 pin Not output Shifted from MSB each time SCK0 falls and is output Not output Shifted from MSB each time SCK0 falls and is output Outputs contents of SIO0SFR at falling edge of external clock regardless of P0ABIO0 When P0ABIO0 = 0 General-purpose input port Floating When P0ABIO0 = 1 General-purpose output port Outputs contents of output latch Outputs contents of SIO0SFR at falling edge of internal clock regardless of P0ABIO0 Transmission (SIO0TX = 1) Master operation (SIO0MS = 1) Reception (SIO0TX = 0) Transmission (SIO0TX = 1) Outputs internal clock regardless of P0ABIO1 --------------------------------------------------------------------------------- Input Wait operation In wait status Shifted from LSB each time SCK0 falls and is input SCK0 pin is floated. SO0 pin as generalpurpose port. SI0 pin is floated SCK0 pin is floated. SC0 pin retains its status. SI0 pin is floated SCK0 pin outputs high SCK0 pin outputs high level SO0 pin as generalpurpose port. SI0 pin is floated level. SO0 pin retains its status. SI0 pin is floated SCK0 pin is floated and waits for input of external clock. SO0 pin outputs data. SI0 pin is floated and waits for input of external data --------------------------------------------------------------------------------- Wait released SCK0 pin is floated and waits for input of external clock. SO0 pin as generalpurpose port. SI0 pin is floated and waits for input of external data SCK0 pin is floated and waits for input of external clock. SO0 pin outputs data. SI0 pin is floated and waits for input of external data SCK0 pin is floated and waits for input of external clock. SO0 pin as generalpurpose port. SI0 pin is floated and waits for input of external data 243 PD17704, 17705, 17707, 17708, 17709 16.2.12 Status of serial interface 0 at reset (1) At power-ON reset Each pin is set in the general-purpose input port mode. The contents of presettable shift register 0 are undefined. (2) At WDT&SP reset Each pin is set in the general-purpose input port mode. The contents of presettable shift register 0 are undefined. (3) On execution of clock stop instruction Each pin is set in the general-purpose I/O port mode and remains in the previous input or output mode. The contents of presettable shift register 0 are undefined. (4) At CE reset Each pin is set in the general-purpose I/O port mode and remains in the previous input or output mode. The contents of presettable shift register 0 are undefined. (5) In halt status Each pin retains its set status. Output of the internal clock is stopped in the status where the HALT instruction is executed. When an external clock is used, the operation continues even if the HALT instruction is executed. Presettable shift register 0 retains the previous value. 244 PD17704, 17705, 17707, 17708, 17709 16.3 Serial Interface 1 16.3.1 Outline of serial interface 1 Figure 16-16 outlines the serial interface 1. Serial interface 1 is used in the 3-wire serial I/O mode. Figure 16-16. Outline of Serial Interface 1 SIO1CK0 and 1 flags Wait signal Clock I/O control block SCK1/P0B2 SIO1TS flag Clock control block 4.5 MHz Wait control block Clock counter Count value: 8 SIO1HIZ flag IRQSIO1 flag SO1/P0B1 Data I/O control block SI1/P0B0 OUT Presettable shift register 1 (SIO1SFR) IN Remarks 1. 2. 3. SIO1CK1 and SIO1CK0 (bits 1 and 0 of serial I/O1 mode selection register: refer to Figure 16-17) select a shift clock. SIO1TS (bit 3 of serial I/O1 mode selection register: refer to Figure 16-17) starts or stops communication operation. SIO1HIZ (bit 2 of serial I/O1 mode selection register: refer to Figure 16-17) selects the function of the SO1/P0B1 pin. 16.3.2 Clock I/O control block and data I/O control block The clock I/O control block and data I/O control block control the transmission or reception operation of serial interface 1 and selects a shift clock. The internal clock (master) or external clock (slave) operation is selected by the SIO1CK0 and 1 flags. The SIO1HIZ flag selects whether the SO1 pin is used as a serial data output pin. The flags that control the clock I/O control block and data I/O control block are allocated to the serial I/O1 mode selection register. Figure 16-17 shows the configuration and function of the serial I/O1 mode selection register. Table 16-7 shows the set status of each pin. As shown in this table, flags that set the input or output mode of each pin must also be manipulated in addition to the control flags of the serial interface, in order to set each pin . 245 PD17704, 17705, 17707, 17708, 17709 Figure 16-17. Configuration of Serial I/O1 Mode Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Serial I/O1 mode selection S I S I S I S I 1DH R/W OO 1 T S 1 H I Z OO 1 C K 1 1 C K 0 Selects shift clock of serial interface 1 0 0 1 1 0 1 0 1 External clock input 187.50 kHz 375.00 kHz 46.875 kHz Selects function of P0B1/SO1 pin 0 1 General-purpose I/O port Serail data output pin Start or stops operation of serial communication 0 1 Stops (wait status) Starts At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Clock stop 16.3.3 Clock counter The clock counter is a wrap-around counter that counts the rising edges of the clock. Because this counter directly reads the status of the clock pin, whether the clock is an internal clock or external clock cannot be identified. The contents of the clock counter cannot be directly read by software. 246 PD17704, 17705, 17707, 17708, 17709 Table 16-7. Status of Each Pin Set by Control Flag Each Flag Communication mode S I O 1 H I Z 3-wire serial I/O 0 1 Internal clock 1 Setting of SIO1 pin S I O 1 C K 1 0 S I O 1 C K 0 0 External clock SCK1/P0B2 Clock setting Pin name P 0 B B I O 2 0 P 0 B B I O 1 P 0 B B I O 0 Pin Set status of pin Wait: General-purpose input port Wait released: External clock input Wait: General-purpose output port Wait released: General-purpose output port 1 0 0 General-purpose input port 1 1 1 Wait: High-level output Wait released: Internal clock output 0 Generalpurpose port SO1/P0B1 0 1 0 1 General-purpose input port General-purpose output port General-purpose input port Serial data output 0 1 Serial data intput General-purpose output port 1 Serial output SI1/P0B0 247 PD17704, 17705, 17707, 17708, 17709 16.3.4 Presettable shift register 1 Presettable shift register 1 is an 8-bit shift register that writes serial out data and reads serial in data. This register writes or reads data via data buffer. It outputs the contents of the most significant bit (MSB) from the serial data I/O pin in synchronization with the falling edge of the shift clock (during transmission operation), and reads data to the least significant bit (LSB) in synchronization with the rising edge of the serial clock. Figure 16-18 shows the configuration of the presettable shift register 1. Figure 16-18. Configuration of Presettable Shift Register 1 Data buffer DBF3 Don't care DBF2 Don't care Transfer data GETNote 8 PUTNote DBF1 DBF0 Peripheral register Name Presettable shift register 1 b7 b6 b5 b4 b3 b2 b1 b0 Symbol M S B Valid data L SIO1SFR S B Peripheral register 04H Sets serial out data and reads serial in data D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 Serial out Serial in Note Data may be destroyed if the PUT or GET instruction is executed during serial communication. For details, refer to 16.3.7 Cautions on setting and reading data. 16.3.5 Wait control block The wait control block keeps communication waiting or releases communication from the wait status. Serial communication is started when communication is released from the wait status by using the SIO1TS flag of the serial I/O1 mode selection register. Communication is set in the wait status eight clocks after the wait status has been released and communication has been started. The communication status can be detected by using the SIO1TS flag. To do so, detect the status of the SIO1TS flag after setting this flag to "1". If "0" is written to the SIO1TS flag when communication is released from the wait status, the wait status is set. This wait status is called forced wait status. For the configuration of the serial I/O1 mode selection register, refer to Figure 16-17. 248 PD17704, 17705, 17707, 17708, 17709 16.3.6 Operation of serial interface 1 (1) Timing chart Figure 16-19 shows the timing chart. Figure 16-19. Timing Chart of Serial Interface 1 Shift clock 1 2 3 7 8 1 Serial data La D7 D6 D5 D1 D0 D7 Clock counter SIO1TS 0 1 2 6 7 8 0 1 <1> <2> <3> INT <5> <4> <1> Initial status (general-purpose input port) <2> Sets transmission status of master/releases wait status <3> Wait timing <4> Releases wait status again <5> Interrupt issuance timing (2) Operation of clock counter The value of the clock counter is incremented from the initial value "0" each time the rising of the clock pin has been detected. The value of the clock counter returns to "0" after it has reached "8", and the clock counter continues counting. The clock counter is also reset in the following cases. * At reset (power-ON reset, WDT&SP reset, CE reset) * On execution of clock stop instruction * If "0" is written to SIO1TS flag (3) Wait operation and cautions When the wait status is released, serial data is output (during transmission operation) at the falling of the next clock, and the wait status is released at the eighth clock. After eight clocks have been output, the shift clock pin is made high, and the operations of the clock counter and presettable shift register 1 are stopped. The value of the presettable shift register 1 cannot be read correctly if it is read while the wait status is released and while the shift clock pin is high. Correct data cannot be written to the presettable shift register 1 while the wait status is released and while the shift clock pin is low. If the forced wait status is specified while the wait status is released, the forced wait status is set as soon as "0" has been written to the SIO1TS flag, and the clock counter is reset. 249 PD17704, 17705, 17707, 17708, 17709 (4) Interrupt request issuance timing An interrupt request is issued at the rising of the shift clock when the value of the clock counter is "8". (5) Shift clock generation timing (a) On releasing wait status from initial status The initial status is the status when the P0B2/SCK1 pin is set in the output mode and the internal clock operation is selected. In 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. Figure 16-20. Shift Clock Generation Timing of Serial Interface 1 (1/4) Shift clock 1:1 Wait status 1/fSC Initialization Wait released (b) When wait operation is performed (normal operation) <1> If wait status is set at the 8th clock (normal operation) Figure 16-20. Shift Clock Generation Timing of Serial Interface 1 (2/4) Shift clock Wait release period Wait period 1/fSC Wait Wait released 250 PD17704, 17705, 17707, 17708, 17709 <2> If forced wait is set in wait status Figure 16-20. Shift Clock Generation Timing of Serial Interface 1 (3/4) Shif clock Wait period Wait period Forced wait set by SIO1TS <3> If forced wait is set after wait status has been released Note that the clock counter is reset. Figure 16-20. Shift Clock Generation Timing of Serial Interface 1 (4/4) a Shift clock Wait released status Wait status b 1/fSC Forced wait by SIO1TS Wait released a + b = 1/2fSC a Shift clock Wait released status Wait status b 1/fSC Forced wait by SIO1TS Wait released a + b = 1/2fSC <4> If wait status is released when it has been already released The clock output waveform is not affected. The clock counter is not reset. 251 PD17704, 17705, 17707, 17708, 17709 16.3.7 Cautions on setting and reading data Data is set to the presettable shift register 1 by using the "PUT SIO1SFR, DBF" instruction. To read the data of this register, the "GET DBF, SIO1SFR" instruction is used. Set or read data of the register in the wait status. If the wait status is released, data may not be correctly set or read depending on the status of the shift clock pin. The following table shows the data setting and reading timing, and points to be noted. Table 16-8. Reading and Writing Data of Presettable Shift Register and Cautions Status on Execution of PUT/GET Wait status Read (GET) Write (PUT) Status of Shift Clock Pin * External clock: floating * Internal clock: output latch (always high) H Clock L 1 Data 0 MSB Serial I/O Mode Normal write Normal write Outputs contents of MSB when wait status is released next time and shift clock pin falls (during transmission) PUT SIO1SFR, DBF Wait released Wait released status Read (GET) High level Cannot be read normally Contents of SIO1SFR are lost Low level Write (PUT) High level Normal write Normal write Outputs contents of MSB at which PUT instruction has been executed. Clock counter is not reset H Clock L 1 Data 0 MSB PUT SIO1SFR, DBF Low level Cannot be read normally Contents of SIO1SFR are lost 252 PD17704, 17705, 17707, 17708, 17709 16.3.8 Operation mode and operation of each part Tables 16-9 outlines the operations of the 3-wire serial I/O mode. Table 16-9. Outline of Operation of Serial Interface 1 Operation Mode Slave operation Item Status of each pin P0B2/SCK1 (SIO1CK1 = SIO1CK0 = 0) During wait (SIO1TS = 0) When P0BBIO2 = 0 Floating General-purpose input port When P0BBIO2 = 1 General-purpose output port Outputs contents of output latch P0B1/SO1 SIO1HIZ = 0 Wait released (SIO1TS = 1) When P0BBIO2 = 0 Floating Waits for input of external clock When P0BBIO2 = 1 General-purpose output port Outputs contents of output latch SIO1HIZ = 1 SIO1HIZ = 0 SIO1HIZ = 1 3-Wire Serial I/O Mode Master operation (SIO1CK1 = SIO1CK0 = other than 0) During wait (SIO1TS = 0) When P0BBIO2 = 0 Floating General-purpose input port When P0BBIO2 = 1 General-purpose output port Outputs high level Wait released (SIO1TS = 1) When P0BBIO2 = 0 Floating General-purpose input port When P0BBIO2 = 1 Outputs internal clock ------------------------------------------------------------------------- ------------------------------------------------------------------------- When P0BBIO1 = 0 Floating General-purpose input port When P0BBIO1 = 1 General-purpose output port Outputs contents of output latch P0B0/SI1 When P0BBIO0 = 0 Floating When P0BBIO1 = 0 Floating General-purpose input port When P0BBIO1 = 1 Outputs data When P0BBIO1 = 0 Floating General-purpose input port When P0BBIO1 = 1 General-purpose output port Outputs contents of output latch When P0BBIO1 = 0 Floating General-purpose input port When P0BBIO1 = 1 Outputs data Waits for input of serial data When P0BBIO0 = 1 General-purpose output port Outputs contents of output latch Clock counter Operation of presettable shift register 1 Output Incremented at rising of SCK1 pin SIO1HIZ = 0 Not output SIO1HIZ = 1 Shifted from MSB each time SCK1 pin falls and is output --------------------------------------------------------------------------------- Input Shifted from LSB each time SCK1 pin rises and is input. SI1 pin outputs contents of output latch when P0BBIO0 = 1 253 PD17704, 17705, 17707, 17708, 17709 16.3.9 Status of serial interface 1 at reset (1) At power-ON reset Each pin is set in the general-purpose input port mode. The contents of presettable shift register 1 are undefined. (2) At WDT&SP reset Each pin is set in the general-purpose input port mode. The contents of presettable shift register 1 are undefined. (3) On execution of clock stop instruction Each pin is set in the general-purpose I/O port mode and remains in the previous input or output mode. The contents of presettable shift register 1 are undefined. (4) At CE reset Each pin is set in the general-purpose I/O port mode and remains in the previous input or output mode. The contents of presettable shift register 1 are undefined. (5) In halt status Each pin retains its set status. Output of the internal clock is stopped in the status where the HALT instruction is executed. When an external clock is used, the operation continues even if the HALT instruction is executed. Presettable shift register 1 retains the previous contents. 254 PD17704, 17705, 17707, 17708, 17709 17. 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) to a constant frequency by means of phase difference comparison. 17.1 Outline of PLL Frequency Synthesizer Figure 17-1 outlines the PLL frequency synthesizer. A PLL frequency synthesizer can be configured by connecting an external lowpass filter (LPF) and voltage controlled oscillator (VCO). The PLL frequency synthesizer divides a signal input from the VCOH or VCOL pin by using a programmable divider and outputs a phase difference between this signal and a reference frequency from the EO0 and EO1 pins. The PLL frequency synthesizer operates only while the CE pin is high. It is disabled when the CE pin is low. For the details of the disabled status of the PLL frequency synthesizer, refer to 17.5 PLL Disabled Status. Figure 17-1. Outline of PLL Frequency Synthesizer DBF VCOH VCOL PLLSCNF flag EO1 EO0 Note Input select block Programmable divider (PD) Phase comparator ( -DET) Charge pump 4.5 MHz Reference frequency generator Lowpass filter (LPF) Unlock FF Note Voltage controlled oscillator (VCO) PLLMD1 flag PLLMD0 flag PLLRFCK3 flag PLLRFCK2 flag PLLRFCK1 flag PLLRFCK0 flag PLLUL flag Note External circuit PLLMD1 and PLLMD0 (bits 1 and 0 of PLL mode selection register: refer to Figure 17-3) selects a division mode of the PLL frequency synthesizer. 2. 3. 4. PLLSCNF (bit 3 of PLL mode selection register: refer to Figure 17-3) selects the least significant bit of the swallow counter. PLLRFCK3 through PLLRFCK0 (bits 3 through 0 of PLL reference frequency selection register: refer to Figure 17-6) selects a reference frequency fr of the PLL frequency synthesizer. PLLUL (bit 0 of PLL unlock FF register: refer to Figure 17-9) detects the PLL unlock FF status. Remarks 1. 255 PD17704, 17705, 17707, 17708, 17709 17.2 Input Selection Block and Programmable Divider 17.2.1 Configuration and function of input selection block and programmable divider Figure 17-2 shows the configuration of the input selection block and programmable divider. The input selection block selects an input pin and division mode of the PLL frequency synthesizer. The VCOH or VCOL pin can be selected as the input pin. The voltage on the selected pin is at the intermediate level (approx. 1/2 VDD). The pin not selected is internally pulled down. Because these pins are connected to an internal AC amplifier, cut the DC component of the input signal by connecting a capacitor in series to the pin. Direct division mode and pulse swallow mode can be selected as division modes. The programmable divider divides the frequency of the input signal according to the value set to the swallow counter and programmable counter. The pin and division mode to be used are selected by the PLL mode selection register. Figure 17-3 shows the configuration of the PLL mode selection register. The value of the programmable divider is set by using the PLL data register via data buffer. Figure 17-2. Configuration of Input Selection Block and Programmable Divider PLLMD1 flag PLLMD0 flag DBF 16 PLL data register 12 bits 4 bits 4 R F Note VCOH 2-modulus prescaler 1/32, 1/33 12 Swallow counter 5 bits Programmable counter 12 bits fN To -DET VCOL PLL disable signal Note PLLSCNF flag 256 PD17704, 17705, 17707, 17708, 17709 Figure 17-3. Configuration of PLL Mode Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write PLL mode selection P L L S C N F 0 P L L P L L 10H R/W MM D 1 D 0 Selects division mode of PLL frequency synthesizer 0 0 1 1 0 1 0 1 Disables VCOL and VCOH pins Direct division (VCOL pin, MF mode) Pulse swallow (VCOH pin, VHF mode) Pulse swallow (VCOL pin, HF mode) Fixed to 0 Selects least significant bit of swallow counter 0 1 Clears least significant bit to 0 Sets least significant bit to 1 At reset Power-ON reset WDT&SP reset CE reset 1 U U R R 0 0 0 0 0 0 0 0 0 Clock stop U: Undefined R: Retained 17.2.2 Outline of each division mode (1) Direct division mode (MF) In this mode, the VCOL pin is used. The VCOH pin is pulled down. In this mode, only the programmable counter is used for frequency division. (2) Pulse swallow mode (HF) In this mode, the VCOL pin is used. The VCOH pin is pulled down. In this mode, the swallow counter and programmable counter are used for frequency division. 257 PD17704, 17705, 17707, 17708, 17709 (3) Pulse swallow mode (VHF) In this mode, the VCOH pin is used. The VCOL pin is pulled down. In this mode, the swallow counter and programmable counter are used for frequency division. (4) VCOL and VCOH pin disabled In this mode, only the VCOL and VCOH pins are internally pulled down, but the other blocks operate. 17.2.3 Programmable divider and PLL data register The programmable divider consists of a 5-bit swallow counter and a 12-bit programmable counter. Each counter is a 17-bit binary down counter. The programmable counter is allocated to the high-order 12 bits of the PLL data register, and the swallow counter is allocated to the low-order 4 bits. Data are set to these counters via data buffer. The least significant bit of the swallow counter sets data to the PLLSCNF flag of the control register. The value by which the input signal frequency is to be divided is called "N value". For how to set a division value (N value) in each division mode, refer to 17.6 Using PLL Frequency Synthesizer. (1) PLL data register and data buffer Figure 17-4 shows the relationships between the PLL data register and data buffer. In the direct division mode, the high-order 12 bits of the PLL data register are valid, and all 17 bits of the register are valid in the pulse swallow mode. In the direct division mode, all 12 bits are used as a programmable counter. In the pulse swallow mode, the high-order 12 bits are used as a programmable counter, and the low-order 5 bits are used as a swallow counter. (2) Relationship between division value N of programmable divider and divided output frequency The relationship between the value "N" set to the PLL data register and the signal frequency "fN" divided and output by the programmable divider is as shown below. For details, refer to 17.6 Using PLL Frequency Synthesizer. (a) Direct division mode (MF) fIN N fIN = N: 12 bits (b) Pulse swallow mode (HF, VHF) fIN N fIN = N: 17 bits 258 PD17704, 17705, 17707, 17708, 17709 Figure 17-4. Setting Division Value (N Value) of PLL Frequency Synthesizer Data buffer DBF3 DBF2 DBF1 DBF0 Transfer data GET PUT Peripheral register Name PLL data register b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 Symbol Peripheral address 42H PLLR Name PLL mode selection Register file b3 b2 b1 b0 P0PP LL L LL L MM S DD C 10 N F address 10H 16 Valid data Sets high-order 16 bits of division value Sets least significant bit of division value Note b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 b3 PLL N value data (17 bits) Sets division value (N value) of PLL frequency synthesizer Direct division mode 0 don't care Setting prohibited 15 (00FH) 16 (010H) don't care don't care b16 b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 x don't care Division value N: N = x 212-1 (FFFH) Pulse swallow mode 0 don't care Setting prohibited 1023 (3FFH) 1024 (400H) x Division value N: N = x 217-1 (1FFFFH) Note The value of PLLSCNF flag is transferred when a write (PUT) instruction is executed to the PLL data register (PLLR). Therefore, data must be set to the PLLSCNF flag before executing the write instruction to the PLL data register. 259 PD17704, 17705, 17707, 17708, 17709 17.3 Reference Frequency Generator Figure 17-5 shows the configuration of the reference frequency generator. The reference frequency generator generates the reference frequency "fr" of the PLL frequency synthesizer by dividing the 4.5 MHz output of a crystal oscillator. Thirteen frequencies can be selected as reference frequency fr: 1, 1.25, 2.5, 3, 5, 6.25, 9, 10, 12.5, 18, 20, 25, and 50 kHz. The reference frequency fr is selected by the PLL reference frequency selection register. Figure 17-6 shows the configuration and function of the PLL reference frequency selection registerion. Figure 17-5. Configuration of Reference Frequency Generator PLLRFCK3 flag PLLRFCK2 flag PLLRFCK1 flag PLLRFCK0 flag MUX 1 kHz 1.25 kHz 2.5 kHz 4.5 MHz Divider To -DET 25 kHz 50 kHz OFF PLL disable signal 260 PD17704, 17705, 17707, 17708, 17709 Figure 17-6. Configuration of PLL Reference Frequency Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write PLL reference frequency selection P L L R F C K 3 P L L R F C K 2 P L L R F C K 1 P L L R F C K 0 11H R/W Sets reference frequency fr of PLL frequency synthesizer 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1.25 kHz 2.5 kHz 5 kHz 10 kHz 6.25 kHz 12.5 kHz 25 kHz 50 kHz 3 kHz 9 kHz 18 kHz Setting prohibited 1 kHz 20 kHz Setting prohibited PLL disable At reset Power-ON reset WDT&SP reset CE reset 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Clock stop Remark When the PLL frequency synthesizer is disabled by the PLL reference frequency selection register, the VCOH and VCOL pins are internally pulled down. The EO1 and EO0 pins are floated. 261 PD17704, 17705, 17707, 17708, 17709 17.4 Phase Comparator (-DET), Charge Pump, and Unlock FF 17.4.1 Configuration of phase comparator, charge pump, and unlock FF Figure 17-7 shows the configuration of the phase comparator, charge pump, and unlock FF. The phase comparator compares the phase of the divided frequency "fN" output by the programmable divider with the phase of the reference frequency "fr" output by the reference frequency generator, and outputs an up (UP) or down (DW) request signal. The charge pump outputs the output of the phase comparator from an error out pin (EO1 and EO0 pins). The unlock FF detects the unlock status of the PLL frequency synthesizer. 17.4.2 through 17.4.4 describe the operations of the phase comparator, charge pump, and unlock FF. Figure 17-7. Configuration of Phase Comparator, Charge Pump, and Unlock FF PLLUL flag fr Reference frequency generator Phase comparator ( - DET) Programmable divider UP Unlock FF EO1 fN DW Charge pump EO0 PLL disable signal 262 PD17704, 17705, 17707, 17708, 17709 17.4.2 Function of phase comparator As shown in Figure 17-7, the phase comparator compares the phases of the divided frequency "fN" output by the programmable divider and the reference frequency "fr", and outputs an up or down request signal. If the divided frequency fN is lower than reference frequency fr, the up request signal is output. If fN is higher than fr, the down request signal is output. Figure 17-8 shows the relationship between reference frequency fr, divided frequency fN, up request signal, and down request signal. When the PLL frequency synthesizer is disabled, neither the up request nor the down request signal is output. The up and down request signals are input to the charge pump and unlock FF, respectively. Figure 17-8. Relationship between fr, fN, UP, and DW (a) If fN lags behind fr fr fN UP DW (b) If fN leads 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 263 PD17704, 17705, 17707, 17708, 17709 17.4.3 Charge pump As shown in Figure 17-7, the charge pump outputs the up request and down request signals output by the phase comparator, from the error out pins (EO1 and EO0 pins). Therefore, the relationship between the output of the error out pins, divided frequency fN and reference frequency fr is as follows: Where reference frequency fr > divided frequency fN: Low-level output Where reference frequency fr < divided frequency fN: High-level output Where reference frequency fr = divided frequency fN: Floating 17.4.4 Unlock FF As shown in Figure 17-7, the unlock FF detects the unlock status of the PLL frequency synthesizer from the up request and down request signals of the phase comparator. Because either the up request or down request signal is low in the unlock status, the unlock status is detected by this low-level signal. In the unlock status, the unlock FF is set to 1. The unlock FF is set in the cycle of the reference frequency fr selected at that time. When the contents of the PLL unlock FF register are read (by the PEEK instruction), the unlock FF is reset (Read & Reset). Therefore, the unlock FF must be detected in a cycle longer than cycle 1/fr of the reference frequency fr. The status of the unlock FF is detected by the PLL unlock FF register. Figure 17-9 shows the configuration of the PLL unlock FF register. Because this register is a read-only register, its contents can be read to the window register by the "PEEK" instruction. Because the unlock FF is set in a cycle of the reference frequency fr, the contents of the PLL unlock FF register are read to the window register in a cycle longer than cycle 1/fr of the reference frequency. The delay time of the up and down request signals of the phase comparator are fixed to 0.8 to 1.0 s. 264 PD17704, 17705, 17707, 17708, 17709 Figure 17-9. Configuration of PLL Unlock FF Register Name Flag symbol b3 b2 b1 b0 Address Read/Write PLL unlock FF 0 0 0 P L L U L 12H R & Reset Detects status of unlock FF 0 1 Unlock FF = 0: PLL locked status Unlock FF = 1: PLL unlocked status Fixed to 0 At reset Power-ON reset WDT&SP reset CE reset 0 0 0 U U R R Clock stop U: Undefined R: Retained 265 PD17704, 17705, 17707, 17708, 17709 17.5 PLL Disabled Status The PLL frequency synthesizer stops (is disabled) while the CE pin is low. Likewise, it also stops when PLL disabled status is selected by the PLL reference frequency register (RF address 11H). Table 17-1 shows the operation of each block in the PLL disabled status. When the VCOL and VCOH pins are disabled by the PLL mode selection register, only the VCOL and VCOH pins are internally pulled down, and the other blocks operate. Because the PLL frequency selection register and PLL mode selection register are not initialized at CE reset (hold the previous status), these registers return to the previous status when the CE pin has gone low, the PLL frequency synthesizer has been disabled, and then CE pin has gone high. To disable the PLL frequency synthesizer at CE reset, initialize these registers in software. At power-ON reset, the PLL frequency synthesizer is disabled. Table 17-1. Operation of Each Block under Each PLL Disable Condition Condition CE Pin = Low Level (PLL disabled) Each Block VCOL, VCOH pins Programmable divider Reference frequency generator Phase comparator Charge pump Internally pulled down Division stopped Output stopped Output stopped Error out pins are floated CE Pin = High Level PLL reference frequency selection register = 1111B (PLL disabled) Internally pulled down Division stopped Output stopped Output stopped Error out pins are floated PLL mode selection register = 0000B (VCOH and VCOL disabled) Internally pulled down Operates Operates Operates Operates. However, usually outputs low level because no signal is input 266 PD17704, 17705, 17707, 17708, 17709 17.6 Using PLL Frequency Synthesizer To control the PLL frequency synthesizer, the following data is necessary. (1) Division mode (2) Pins used (4) Division value : Direct division (MF), pulse swallow (HF, VHF) : VCOL and VCOH pins :N (3) Reference frequency : fr 17.6.1 through 17.6.3 below describe how to set PLL data in each division mode (MF, HF, and VHF). 17.6.1 Direct division mode (MF) (1) Selecting division mode Select the direct division mode by using the PLL mode selection register. (2) Pins used The VCOL pin is enabled to operate when the direct division mode is selected. (3) Selecting reference frequency fr Select the reference frequency by using the PLL reference frequency selection register. (4) Calculation of division value N Calculate N as follows: fVCOL fr fVCOL : Input frequency of VCOL pin fr : Reference frequency N= (5) Example of setting PLL data How to set data to receive broadcasting in the following MW band is described below. Reception frequency Reference frequency : 1422 kHz (MW band) : 9 kHz Intermediate frequency : +450 kHz Division value N is calculated as follows: fVCOL fr 1422 + 450 9 N= = = 208 (decimal) = 0D0H (hexadecimal) Set data to the PLL data register, PLL mode selection register, and PLL reference frequency selection register as follows: 267 PD17704, 17705, 17707, 17708, 17709 PLL data register (PLLR) PLL mode PLL reference selection frequency Note 1 register selection register 0 don't care Note 2 0 0 MF 11 1 0 1 0 0 0 0 01 1 D 0 10 0 0 0 9 kHz Notes 1. PLLSCNF flag 2. don't care 268 PD17704, 17705, 17707, 17708, 17709 17.6.2 Pulse swallow mode (HF) (1) Selecting division mode Select the pulse swallow mode by using the PLL mode selection register. (2) Pins used The VCOL pin is enabled to operate when the pulse swallow mode is selected. (3) Selecting reference frequency fr Select the reference frequency by using the PLL reference frequency selection register. (4) Calculation of division value N Calculate N as follows: fVCOL fr fVCOL : Input frequency of VCOL pin fr : Reference frequency N= (5) Example of setting PLL data How to set data to receive broadcasting in the following SW band is described below. Reception frequency Reference frequency : 25.50 MHz (SW band) : 5 kHz Intermediate frequency : +450 kHz Division value N is calculated as follows: fVCOL fr 25500 + 450 5 N= = = 5190 (decimal) = 1446H (hexadecimal) Set data to the PLL data register, PLL mode selection register, and PLL reference frequency selection register as follows: Caution The division value N is 17 bits long when the pulse swallow mode is selected, and the least significant bit of the swallow counter is the bit 3 of the PLL mode selection register (PLLSCNF). To set "1446H" as the division value N, the value to be actually set to the PLL data register is "0A23H". PLL data register (PLLR) PLL mode PLL reference selection frequency Note register selection register 00 0 1 1 6 0 0 1 HF 10 0 1 0 0 0 0 1 01 0 1 4 00 0 1 4 5 kHz Note PLLSCNF flag 269 PD17704, 17705, 17707, 17708, 17709 17.6.3 Pulse swallow mode (VHF) (1) Selecting division mode Select the pulse swallow mode by using the PLL mode selection register. (2) Pins used The VCOH pin is enabled to operate when the pulse swallow mode is selected. (3) Selecting reference frequency fr Select the reference frequency by using the PLL reference frequency selection register. (4) Calculation of division value N Calculate N as follows: fVCOH fr fVCOH : Input frequency of VCOH pin fr : Reference frequency N= (5) Example of setting PLL data How to set data to receive broadcasting in the following FM band is described below. Reception frequency Reference frequency : 98.15 MHz (FM band) : 50 kHz Intermediate frequency : +10.7 MHz Division value N is calculated as follows: fVCOH fr 98.15 + 10.7 0.050 N= = = 2177 (decimal) = 0881H (hexadecimal) Set data to the PLL data register, PLL mode selection register, and PLL reference frequency selection register as follows: Caution The division value N is 17 bits long when the pulse swallow mode is selected, and the least significant bit of the swallow counter is the bit 3 of the PLL mode selection register (PLLSCNF). To set "0881H" as the division value N, the value to be actually set to the PLL data register is "0440H". PLL data register (PLLR) PLL mode PLL reference selection frequency Note register selection register 00 0 0 0 1 1 0 1 VHF 00 1 1 1 0 0 0 0 00 1 0 8 00 1 0 8 50 kHz Note PLLSCNF flag 270 PD17704, 17705, 17707, 17708, 17709 Note that data must be set to the PLLSCNF flag before a write (PUT) instruction is executed to the PLL data register (PLLR). Example SET1 MOV MOV MOV PUT PLLSCNF DBF0, #0 DBF1, #4 DBF2, #4 PLLR, DBF 17.7 Status at Reset 17.7.1 At power-ON reset The PLL frequency synthesizer is disabled because the PLL reference frequency selection register is initialized to 1111B. 17.7.2 At WDT&SP reset The PLL frequency synthesizer is disabled because the PLL reference frequency selection register is initialized to 1111B. 17.7.3 On execution of clock stop instruction The PLL frequency synthesizer is disabled because the PLL reference frequency selection register is initialized to 1111B. 17.7.4 At CE reset The PLL frequency synthesizer is disabled because the PLL reference frequency selection register is initialized to 1111B. 17.7.5 In halt status The set status is retained if the CE pin is high. 271 PD17704, 17705, 17707, 17708, 17709 18. FREQUENCY COUNTER 18.1 Outline of Frequency Counter Figure 18-1 outlines the frequency counter. The frequency counter has an IF counter function to count the intermediate frequency (IF) of an external input signal and an external gate counter (FCG: Frequency Counter for external Gate signal) to detect the pulse width of an external input signal. The IF counter function counts the frequency input to the P1C0/FMIFC or P1C1/AMIFC pin at fixed intervals (1 ms, 4 ms, 8 ms, or open) by using a 16-bit counter. The external gate counter function counts the frequency of the internal clock (1 kHz, 100 kHz, 900 kHz) from the rising to the falling of the signal input to the P2A1/FCG1 or P2A0/FCG0 pin. The IF counter and external gate counter functions cannot be used at the same time. Figure 18-1. Outline of Frequency Counter FCGCH1 flag FCGCH0 flag IFCCK1 flag IFCCK0 falg IFCSTRT flag DBF P2A1/FCG1 P2A0/FCG0 P1C0/FMIFC P1C1/AMIFC IFCGOSTT flag IFCMD1 flag IFCMD0 flag IFCRES flag I/O selection block Gate time control block Start/stop control block IF counter (16 bits) Remarks 1. 2. 3. FCGCH1 and FCGCH0 (bits 1 and 0 of FCG channel selection register: refer to Figure 18-4) select the pin used for the external gate counter function. IFCMD1 and IFCMD0 (bits 3 and 2 of IF counter mode selection register: refer to Figure 18-3) select the IF counter or external gate counter function. IFCCK1 and IFCCK0 (bits 1 and 0 of IF counter mode selection register: refer to Figure 18-3) select the gate time of the IF counter function and the reference frequency of the external gate counter function. 4. 5. 6. IFCSTRT (bit 1 of IF counter control register: refer to Figure 18-6) control starting of the IF counter and external gate counter functions. IFCGOSTT (bit 0 of IF counter gate status detection register: refer to Figure 18-7) detects opening/ closing the gate of the IF counter function. IFCRES (bit 0 of IF counter control register: refer to Figure 18-6) reset the count value of the IF counter. 272 PD17704, 17705, 17707, 17708, 17709 18.2 Input/Output Selection Block and Gate Time Control Block Figure 18-2 shows the configuration of the input/output selection block and gate time control block. The input/output selection block consists of an IF counter input selection block and FCG I/O selection block. The IF counter input selection block selects whether the frequency counter is used as an IF counter or an external gate counter, by using the IF counter mode register. When the frequency counter is used as the IF counter, either P1C0/FMIFC or P1C1/AMIFC pin and a count mode are selected. The pin not used for the IF counter is used as a general-purpose input port pin. The FCG I/O selection block selects the P2A1/FCG1 or P2A0/FCG0 pin by using the FCG channel selection register, when the frequency counter is used as the external gate counter. The pin not used is used as a generalpurpose I/O port pin. When using the frequency counter as the external gate counter, the pin to be used must be set in the input mode by using the port 2A bit I/O selection register. This is because the pin is set in the general-purpose output port mode if it is set in the output mode even if the external gate counter function is selected by the IF counter mode selection register and FCG channel selection register. The gate time control block selects gate time by using the IF counter mode selection register when the frequency counter is used as the IF counter, or a count frequency when the frequency counter is used as the external gate counter. Figure 18-3 shows the configuration of the IF counter mode selection register. Figure 18-4 shows the configuration of the FCG channel selection register. Figure 18-2. Configuration of I/O Selection Block and Gate Time Control Block FCGCH1 flag FCGCH0 flag IFCMD1 flag IFCMD0 flag P2A1/FCG1 Selector P2A0/FCG0 I/O port FCG Gate signal Gate signal generator IFCCK1 flag IFCCK0 flag Frequency generator To start/stop control block Selector P1C0/FMIFC 1/2 P1C1/AMIFC Input port Frequency FMIFC AMIFC 273 PD17704, 17705, 17707, 17708, 17709 Figure 18-3. Configuration of IF Counter Mode Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write IF counter mode selection I F C I F C I F C C K 1 I F C C K 0 22H R/W MM D 1 D 0 Selects gate time of IF counter and reference frequency of external gate counter Gate time of IF counter 0 0 1 1 0 1 0 1 1 ms 4 ms 8 ms Open 1 kHz 100 kHz 900 kHz Setting prohibited Reference frequency of external gate counter Selects function of IF counter or external gate counter 0 0 1 1 0 1 0 1 External gate counter (FCG) IF counter (AMIFC pin, AMIF count mode) IF counter (FMIFC pin, FMIF count mode, 1/2 division) IF counter (FMIFC pin, AMIF count mode) At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Clock stop Caution The IF counter and external gate counter functions cannot be used at the same time. 274 PD17704, 17705, 17707, 17708, 17709 Figure 18-4. Configuration of FCG Channel Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write FCG channel selection 0 0 F C F C 20H R/W GG C H 1 C H 0 Selects pin used for FCG 0 0 1 1 0 1 0 1 FCG not used (general-purpose I/O port) P2A0/FCG0 pin P2A1/FCG1 pin Setting prohibited Fixed to 0 At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 0 0 Clock stop 275 PD17704, 17705, 17707, 17708, 17709 18.3 Start/Stop Control Block and IF Counter 18.3.1 Configuration of start/stop control block and IF counter Figure 18-5 shows the configuration of the start/stop control block and IF counter. The start/stop control block starts the frequency counter or 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. When the external gate counter function is used, however, the end of counting cannot be detected by the IF counter gate status detection register. Figure 18-6 shows the configuration of the IF counter control register. Figure 18-7 shows the configuration of the IF counter gate status detection register. 18.3.2 and 18.3.3 describe the gate operation when the IF counter function is selected and that when the external gate counter function is selected. The IF counter is a 16-bit binary counter that counts up the input frequency when the IF counter function or external gate counter function is selected. When the IF counter function is selected, the frequency input to a selected pin is counted while the gate is opened by an internal gate signal. The frequency count is counted without alteration in the AMIF count mode. In the FMIF counter mode, however, the frequency input to the pin is halved and counted. When the external gate counter function is selected, the internal frequency is counted while the gate is opened by the signal input to the pin. When the IF counter counts up to FFFFH, it remains at FFFFH until reset. The count value is read by the IF counter data register (IFC) via data buffer. The count value is reset by the IF counter control register. Figure 18-8 shows the configuration of the IF counter data register. Figure 18-5. Configuration of Start/Stop Control Block and IF Counter DBF 16 IFCSTRT flag IF counter data register (IFC) IFCGOSTT flag IFCRES flag 16 Gate signal From gate time selection block Frequency Start/Stop control RES IF counter (16 bits) 276 PD17704, 17705, 17707, 17708, 17709 Figure 18-6. Configuration of IF Counter Control Register Name Flag symbol b3 b2 b1 b0 Address Read/Write IF counter control 0 0 I F C S T R T I F C R E S 23H W Resets data of IF counter and external gate counter 0 1 Nothing is affected Resets counter Start IF counter and external gate counter 0 1 Nothing is affected Resets counter Fixed to 0 At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 0 0 Clock stop 277 PD17704, 17705, 17707, 17708, 17709 Figure 18-7. Configuration of IF Counter Gate Status Detection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write IF counter gate status detection 0 0 0 I F C G O S T T 21H R Detects opening/closing of gate of frequency counter When IF counter function is selected When external gate counter function is selected 0 Sets IFCSTRT flag to "1" and is set to Sets IFCSTRT flag to "1" and is set to 1 until gate is closed 1 1 while gate is open, regardless of input of P2A0/FCG0 and P2A1/FCG1 pins Fixed to "0" At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 Clock stop Cautions 1. 2. Do not read the contents of the IF counter data register (IFC) to the data buffer while the IFCGOSTT flag is set to 1. The gate of the external gate counter cannot be opened or closed by the IFCGOSTT flag. Use the IFCSTRT flag to open or close the gate. 278 PD17704, 17705, 17707, 17708, 17709 18.3.2 Operation of gate when IF counter function is selected (1) When gate time of 1, 4, or 8 ms is selected The gate is opened for 1, 4, or 8 ms from the rising of the internal 1-kHz signal after the IFCSTRT flag has been set to 1, as illustrated below. While this gate is open, the frequency input from a selected pin is counted by a 16-bit counter. When the gate is closed, the IFCG flag is cleared to 0. The IFCGOSTT flag is automatically set to 1 when the IFCSTRT flag is set. Internal 1 kHz 1 ms Gate time 4 ms 8 ms H L OPEN CLOSE Count period (IFCGOSTT flag = 1) Gate is actually opened at this point IFCSTRT flag is set IFCGOSTT flag is set at this point End of counting IFGOSTT flag is cleared (2) When gate is open If opening of the gate is selected by the IFCCK1 and IFCCK0 flags, the gate is opened as soon as its opening has been selected, as illustrated below. If the counter is started by using the IFCSTRT flag while the gate is open, the gate is closed after undefined time. To open the gate, therefore, do not set the IFCSTRT flag to 1. However, the counter can be reset by the IFCRES flag. H Internal 1 kHz L OPEN Gate CLOSE Count period Gate is closed after undefined time if IFCSTRT flag is set during this period Sets IFCCK1 = IFCCK0 = 1 Gate is actually opened at this point. If gate is opened while IFCGOSTT flag is 1, it is closed after undefined time The gate is opened or closed in the following two ways when opening the gate is selected as the gate time. 279 PD17704, 17705, 17707, 17708, 17709 (a) Resetting the gate to other than open by using IFCCK1 and IFCCK0 flags Gate OPEN CLOSE Count period IFCCK1 = IFCCK0 = 1 Resetting the gate to other than open by IFCCK1 and IFCCK0 flags (b) Unselect pin used by using IFCMD1 and IFCMD0 flags In this way, the gate remains open, and counting is stopped by disabling input from the pin. Gate OPEN CLOSE Count period Sets IFCCK1 = IFCCK0 = 1 Sets IFCMD1 = IFCMD0 = 0 (FCG) FMIFC and AMIFC pins are unselected and count signal cannot be input 18.3.3 Gate operation when external gate counter function is selected The gate is opened from the rising to the next rising of the signal input to a selected pin after the IFCSTRT flag has been set to 1, as illustrated below. While the gate is open, the internal frequency (1 kHz, 100 kHz, 900 kHz) is counted by a 16-bit counter. The IFCGOSTT flag is set to 1 from the rising to the next rising of the external signal after the IFCSTRT flag has been set. In other words, the opening or closing of the gate cannot be detected by the IFCG flag when the external gate counter function is selected. External signal H L Gate OPEN CLOSE Count period Gate is opened at this point IFCSTRT flag 1 End of counting IFCGOSTT flag is "0" If reset and started while gate is open External signal H L Gate OPEN CLOSE Count period Count period Gate is opened at this point End of counting IFCGOSTT flag is "0" IFCSTRT flag 1 IFCSTRT flag 1 280 PD17704, 17705, 17707, 17708, 17709 18.3.4 Function and operation of 16-bit counter The 16-bit counter counts up the frequency input within selected gate time. The 16-bit counter can be reset by writing "1" to the IFCRES flag of the IF counter control register. Once the 16-bit counter has counted up to FFFFH, it remains at FFFFH until it is reset. The following paragraphs (1) and (2) describe the operations when the IF counter function is selected and when the external gate counter function is selected. The value of the IF counter data register is read via data buffer. Figure 18-8 shows the configuration and function of the IF counter data register. (1) When IF counter is selected The frequency input to the P1C0/FMIFC or P1C1/AMIFC pin is counted while the gate is open. Note, however, that the frequency input to the P1C0/FMIFC is divided by two and counted. The relationship between count value "x (decimal)" and input frequencies (fFMIFC and fAMIFC) is shown below. * FMIFC fFMIFC = * AMIFC fAMIFC = x tGATE (kHz) tGATE: gate time (1 ms, 4 ms, 8 ms) x tGATE x 2 (kHz) tGATE: gate time (1 ms, 4 ms, 8 ms) (2) When external gate counter (FCG) is selected The internal frequency is counted while the gate is opened by the signal input to the P2A1/FCG1 or P2A0/ FCG0 pin. The relationship between the count value "x (decimal)" and the gate width tGATE of the input signal is shown below. x fr tGATE = (ms) fr: internal frequency (1, 100, 900 kHz) 281 PD17704, 17705, 17707, 17708, 17709 Figure 18-8. Configuration of IF Counter Data Register Data buffer DBF3 DBF2 DBF1 DBF0 Transfer data GET can be executed 16 PUT changes nothing Peripheral register Name IF counter data register Valid data b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 Symbol Peripheral address IFC 43H Count value of frequency counter 0 IF counter function * FMIF count mode of FMIFC pin Counts rising edge of signal input to P1C0/FMIFC pin via 1/2 divider * AMIF count mode of AMIFC pin Counts rising edge of signal input to P1C1/AMIFC pin * AMIF count mode of FMIFC pin x Counts rising edge of signal input to P1C0/FMIFC pin External gate counter function Counts rising edge of internal reference frequency signal from rising edge to next rising edge of signal input to P2A0/FCG0 or P2A1/FCG1 pin 216-1 (FFFFH) Once the IF counter data register has counted up to FFFFH, it remains at FFFFH until the counter is reset. 282 PD17704, 17705, 17707, 17708, 17709 18.4 Using IF Counter The following sections 18.4.1 through 18.4.3 describe how to use the hardware of the IF counter, a program example, and count error. 18.4.1 Using hardware of IF counter Figure 18-9 shows the block diagram when the P1C0/FMIFC and P1C1/AMIFC pins. As shown in the figure, the IF counter uses an input pin with an AC amplifier, the DC component of the input signal must be cut with a capacitor. When the P1C0/FMIFC or P1C1/AMIFC pin is selected for the IF counter function, switch SW turns ON, and the voltage level on each pin reaches about 1/2VDD. If the voltage has not risen to a sufficient intermediate level at this time, the IF counter does not operate normally because the AC amplifier is not in the normal operating range. Therefore, make sure that a sufficient wait time elapses after each pin has been specified to be used for the IF counter until counting is started. Figure 18-9. IF Count Function Block Diagram of Each Pin R SW C External frequecny FMIFC AMIFC To internal counter 283 PD17704, 17705, 17707, 17708, 17709 18.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 elapses after an instruction that selects the P1C0/FMIFC or P1C1/AMIFC pin for the IF counter function has been executed until counting is started. This is because, as described in 18.4.1, the internal AC amplifier does not operate normally immediately after a pin has been selected for the IF counter. Example To count the frequency input to the P1C0/FMIFC pin (FMIF count mode) (gate time: 8 ms) INITFLG IFCMD1, NOT IFCMD0, IFCCK1, NOT IFCCK0 ; Selects FMIFC pin (FMIF count mode), and sets gate time to 8 ms Wait SET1 SET1 LOOP: SKT1 BR IFCG0STT READ ; Detects opening or closing of gate ; Branches to READ: if gate is closed IFCRES IFCSTRT ; Internal AC amplifier stabilization time ; Resets counter ; Starts counting Processing A BR READ: GET 18.4.3 Error of IF counter The errors of the IF counter include a gate time error and a count error. The following paragraphs (1) and (2) describe each of these errors. (1) Gate time error The gate time of the IF counter is created by dividing the 4.5-MHz clock. Therefore, if the system clock is shifted from 4.5 MHz by "+x" ppm, the gate time is shifted by "-x" ppm. (2) Count error The IF counter counts frequency by the rising edge of the input signal. If a high level is input to the pin when the gate is open, therefore, one excess pulse is counted. If the gate is closed, however, a count error due to the status of the pin does not occur. Therefore, the count error is "+1, -0". DBF, IFC ; Reads value of IF counter data register to data buffer LOOP ; Do not read data of IF counter with this processing A 284 PD17704, 17705, 17707, 17708, 17709 18.5 Using External Gate Counter 18.5.1 Program example of external gate counter A program example of the external gate counter is shown below. Example To use the P2A0/FCG0 pin as external gate input pin INITFLG NOT IFCMD1, NOT IFCMD0, IFCCK1, NOT IFCCK0 ; Selects external gate counter function and sets gate time to 8 ms INITFLG NOT FCGCH1, FCGCH0 ; Selects FCG0 pin as external gate input pin SET1 SET1 LOOP: SKF1 BR IFCGOSTT READ ; Detects opening or closing of gate ; Branches to READ: if gate is closed ; Do not read data of IF counter with this processing A IFCRES IFCSTRT ; Resets counter ; Starts counting Processing A BR READ: GET DBF, IFC LOOP ; Reads value of IF counter data register to data buffer 18.5.2 Error of external gate counter The errors of the external gate counter include an internal frequency error and a count error. The following paragraphs (1) and (2) describe each of these errors. (1) Internal frequency error The internal frequency of the external gate counter is created by dividing the 4.5-MHz clock. Therefore, if the system clock is shifted from 4.5 MHz by "+x" ppm, the gate time is shifted by "-x" ppm. (2) Count error The external gate counter counts the frequency by the rising edge of the internal frequency. If the internal frequency is low when the gate is opened (when the signal input to the pin rises), one excess pulse is counted. If the gate is closed (when the signal rises next time), the excess pulse is not counted due to the count level of the internal frequency. Therefore, the count error is "+1, -0". 285 PD17704, 17705, 17707, 17708, 17709 18.6 Status at Reset 18.6.1 At power-ON reset The P1C0/FMIFC, P1C1/AMIFC, P2A0/FCG0, and P2A1/FCG1 pins are set in the general-purpose input port mode. 18.6.2 At WDT&SP reset The P1C0/FMIFC, P1C1/AMIFC, P2A0/FCG0, and P2A1/FCG1 pins are set in the general-purpose input port mode. 18.6.3 On execution of clock stop instruction The P1C0/FMIFC and P1C1/AMIFC pins are set in the general-purpose input port mode. The P2A0/FCG0 and P2A1/FCG1 pins are set in the general-purpose I/O port mode, and retain the previous input or output status. 18.6.4 At CE reset The P1C0/FMIFC and P1C1/AMIFC pins are set in the general-purpose input port mode. The P2A0/FCG0 and P2A1/FCG1 pins are set in the general-purpose I/O port mode, and retain the previous input or output status. 18.6.5 In halt status The P1C0/FMIFC, P1C1/AMIFC, P2A0/FCG0, and P2A1/FCG1 pins retain the status immediately before the halt mode is set. 286 PD17704, 17705, 17707, 17708, 17709 19. BEEP 19.1 Outline of BEEP Figure 19-1 outlines BEEP. BEEP outputs a clock of 1, 3, 4, or 6.7 kHz from the P1D0/BEEP0 pin, and a clock of 4 kHz, 3 kHz, 200 Hz, or 67 Hz from the P1D1/BEEP1 pin. The duty factor of the BEEP output is 50%. Figure 19-1. Outline of BEEP P1DBIO0 flag BEEP0SEL flag BEEP0CK1 falg BEEP0CK0 falg Clock generation block 1 kHz 3 kHz 4 kHz P1D0/BEEP0 I/O selection block Output selection flag Clock selection block Output latch Output latch 6.7 kHz P1D1/BEEP1 I/O selection block Output selection flag Clock selection block 67 Hz 200 Hz P1DBIO1 flag BEEP1SEL flag BEEP1CK1 flag BEEP1CK0 flag Remarks 1. 2. 3. 4. BEEP0CK1 and BEEP0CK0 (bits 1 and 0 of BEEP clock selection register: refer to Figure 19-4) select the output frequency of BEEP0. BEEP1CK1 and BEEP1CK0 (bits 3 and 2 of BEEP clock selection register: refer to Figure 19-4) select the output frequency of BEEP1. BEEP1SEL and BEEP0SEL (bits 1 and 0 of BEEP/general-purpose port pin function selection register: refer to Figure 19-3) select general-purpose I/O port and BEEP. P1DBIO1 and P1DBIO0 (bits 1 and 0 of port 1D bit I/O selection register: refer to Figure 19-2) select the input or output mode of the port. 287 PD17704, 17705, 17707, 17708, 17709 19.2 I/O Selection Block and Output Selection Block The I/O selection block selects the input or output mode of the P1D0/BEEP0 and P1D1/BEEP1 pins by using the port 1D bit I/O selection register. Set the pin to be used as a BEEP pin in the output mode. The output selection block sets the P1D0/BEEP0 and P1D1/BEEP1 pins in the general-purpose output port mode or BEEP output mode by using the BEEP/general-purpose port pin function selection register. Figure 19-2 shows the configuration of the port 1D bit I/O selection register. Figure 19-3 shows the configuration of the BEEP/general-purpose port pin function selection registerion. Figure 19-2. Configuration of Port 1D Bit I/O Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Port 1D bit I/O selection P 1 D B I P 1 D B I P 1 D B I P 1 D B I (BANK15) 6CH R/W OO 3 2 OO 1 0 Selects input or output port mode 0 1 Sets P1D0/BEEP0 pin in input mode Sets P1D0/BEEP0 pin in output mode. Selects input or output port mode 0 1 Sets P1D1/BEEP1 pin in input mode Sets P1D1/BEEP1 pin in output mode Selects input or output port mode 0 1 Sets P1D2 pin in input mode Sets P1D2 pin in output mode Selects input or output port mode 0 1 Sets P1D3 pin in input mode Sets P1D3 pin in output mode At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 Retained Retained Clock stop 288 PD17704, 17705, 17707, 17708, 17709 Figure 19-3. Configuration of BEEP/General-Purpose Port Pin Function Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write BEEP/general-purpose port pin function selection 0 0 B E E P 1 S E L B E E P 0 S E L 13H R/W Selects general-purpose I/O port or BEEP 0 1 Uses P1D0/BEEP0 pin as general-purpose I/O port Uses P1D0/BEEP0 pin for BEEP Selects general-purpose I/O port or BEEP 0 1 Uses P1D1/BEEP1 pin as general-purpose I/O port Uses P1D1/BEEP1 pin for BEEP Fixed to 0 At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 0 0 Clock stop 289 PD17704, 17705, 17707, 17708, 17709 19.3 Clock Selection Block and Clock Generation Block The clock selection block selects the output frequency of BEEP1 and BEEP0 by using the BEEP clock selection register. The clock generation block generates the clock to be output to BEEP0 and BEEP1. The clock frequency generated is 1 kHz, 3 kHz, 4 kHz, 6.7 kHz, 67 Hz, or 200 Hz. Figure 19-4. Configuration of BEEP Clock Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write BEEP clock selection B E E P 1 C K 1 B E E P 1 C K 0 B E E P 0 C K 1 B E E P 0 C K 0 14H R/W Sets output frequency of BEEP0 0 0 1 1 0 1 0 1 1 kHz 3 kHz 4 kHz 6.7 kHz Sets output frequency of BEEP1 0 0 1 1 0 1 0 1 4 kHz 3 kHz 200 Hz 67 Hz At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Clock stop 290 PD17704, 17705, 17707, 17708, 17709 19.4 Output Waveform of BEEP The duty factor of the BEEP output waveform is 50%. Example f = 3 kHz 166.7 s 166.7 s f = 1 kHz 500 s 500 s f = 200 Hz 2.5 ms f: output frequency of BEEP 2.5 ms 19.5 Status at Reset 19.5.1 At power-ON reset The P1D0/BEEP0 and P1D1/BEEP1 pins are set in the general-purpose input port mode. 19.5.2 At WDT&SP reset The P1D0/BEEP0 and P1D1/BEEP1 pins are set in the general-purpose input port mode. 19.5.3 On execution of clock stop instruction The P1D0/BEEP0 and P1D1/BEEP1 pins are set in the general-purpose I/O port mode, and retain the previous input or output status. 19.5.4 At CE reset The P1D0/BEEP0 and P1D1/BEEP1 pins are set in the general-purpose I/O port mode, and retain the previous input or output status. 19.5.5 In halt status The previous status is retained. 291 PD17704, 17705, 17707, 17708, 17709 20. STANDBY The standby function is used to reduce the current consumption of the device while the device is backed up. 20.1 Outline of Standby Function Figure 20-1 outlines the standby block. The standby function reduces the current consumption of the device by partly or totally stopping the device operation. The following three types of standby functions are available for selection as the application requires. * Halt function * Clock stop function * Device operation control function by CE pin The halt function reduces the current consumption of the device by stopping the CPU operation by using a dedicated instruction "HALT h". The clock stop function reduces the current consumption of the device by stopping the oscillation of the oscillation circuit by using a dedicated instruction "STOP s". The CE pin can be said to be one of the standby functions because it can be used to control the operation of the PLL frequency synthesizer and to reset the device. Figure 20-1. Outline of Standby Block CPU Interrupt control block Halt control circuit HALT h Program counter BTM0CY Instruction decoder P0D3/AD3 P0D2/AD2 P0D1/AD1 P0D0/AD0 Input latch ALU Clock stop control circuit STOP s System register Oscillation circuit XOUT Control register XIN 292 PD17704, 17705, 17707, 17708, 17709 20.2 Halt Function 20.2.1 Outline of halt function The halt function stops the operating clock of the CPU by executing the "HALT h" instruction. When this instruction is executed, the program is stopped until the halt status is later released. Therefore, the current consumption of the device in the halt status is reduced by the operating current of the CPU. The halt status is released by using basic timer 0 carry FF, interrupt, or port input (P0D). The release condition is specified by operand "h" of the "HALT h" instruction. 20.2.2 Halt status In the halt status, all the operations of the CPU are stopped. In other words, execution of the program is stopped at the "HALT h" instruction. However, the peripheral hardware units continue the operation specified before execution of the "HALT h" instruction. For the operation of each peripheral hardware unit, refer to 20.4 Device Operation in Halt and Clock Stop Status. 20.2.3 Halt release condition Figure 20-2 shows the halt release condition. The halt release condition is specified by 4-bit data specified by operand "h" of the "HALT h" instruction. The halt status is released when the condition specified by "1" in operand "h". When the halt status is released, program execution is started from the instruction after the "HALT h" instruction. If the halt status is released by an interrupt, the operation to be performed after the halt status has been released differs depending on whether the interrupts are enabled (EI status) or disabled (DI status) when an interrupt source (IRQxxx = 1) is issued with the interrupt (IPxxx = 1) enabled. If two or more releasing conditions are specified, the halt status is released when one of the specified condition is satisfied. If 0000B is set as halt release condition "h", no releasing condition is set. If the device is reset (by means of powerON reset, WDT&SP reset, or CE reset) at this time, the halt status is released. Figure 20-2. Halt Release Condition HALT h (4 bits) Operand b3 b2 b1 b0 Sets halt status releasing condition Released when high level is input to port 0D Released when basic timer 0 carry FF is set to 1 Undefined (Fix this bit to "0".) Released when interrupt is accepted 0 1 Not released even if condition is satisfied Released if condition is satisfied 293 PD17704, 17705, 17707, 17708, 17709 20.2.4 Releasing halt by input port (P0D) The halt releasing condition using an input port is specified by the "HALT 0001B" instruction. When the halt releasing condition using an input port is specified, the halt status is released if a high level is input to one of the P0D0 through P0D3 pins. The P0D0 through P0D3 pins are multiplexed with the A/D converter input pins AD0 through AD3, and the halt status is not released when these pins are used as A/D converter input pins. An example is given below. * To use as key matrix The P0D0 through P0D3 pins are general-purpose input port pins which can be set in the input or output mode in 1-bit units and can be connected to an internal pull-down resistor. If connection of the internal pull-down resistor is specified by software, an external resistor can be eliminated as shown in this example (the internalpull down resistor is connected at power-ON reset). P0D3/AD3 Latch P0DPLD3 flag P0D2/AD2 P0D1/AD1 Switch A P0D0/AD0 General-purpose output port The "HALT 0001B" instruction is executed after the general-purpose output ports for key source signal are made high. Note that if an alternate switch is used as shown by switch A in the above figure, the halt status is released immediately because a high level is input to the P0D0/AD0 pin while switch A is closed. 294 PD17704, 17705, 17707, 17708, 17709 20.2.5 Releasing halt status by basic timer 0 carry FF Releasing the halt status by using the basic timer 0 carry FF is specified by the "HALT 0010B" instruction. When releasing the halt status by the basic timer 0 carry FF is specified, the halt status is released as soon as the basic timer 0 carry FF has been set to 1. The basic timer 0 carry FF corresponds to the BTM0CY flag on a one-to-one basis and is set at fixed time intervals (100, 50, 20, or 10 ms). Therefore, the halt status can be released at fixed time intervals. Example To release halt status every 100 ms to execute processing A HLTTMR DAT INITFLG LOOP: HALT SKT1 BR HLTTMR BTMOCY LOOP ; Specifies setting of basic timer 0 carry FF as halt releasing condition ; Embedded macro ; Branches to LOOP if BTM0CY flag is not set 0010B ; Symbol definition NOT BTM0CK1, NOT BTM0CK0 ; Sets time interval of basic timer 0 to 100 ms Processing A ; Executes processing A if carry occurs BR LOOP 20.2.6 Releasing halt status by interrupt Releasing the halt status by an interrupt is specified by the "HALT 1000B" instruction. When releasing the halt status by an interrupt is specified, the halt status is released as soon as the interrupt has been accepted. Many interrupt sources are available as described in 12. INTERRUPTS. Which interrupt source is used to release the halt status must be specified in advance in software. To accept an interrupt, each interrupt request must be issued from each interrupt source and each interrupt must be enabled (by setting the corresponding interrupt enable flag). Therefore, the interrupt is not accepted even if the interrupt request is issued, and the halt status is not released. When the halt status is released by accepting an interrupt, the program flow branches to the vector address of the interrupt. When the RETI instruction is executed after interrupt servicing, the program flow is restored to the instruction after the HALT instruction. If all the interrupts are disabled (DI status), the halt status is released by enabling an interrupt (IPxxx = 1) and issuing an interrupt source (IRQxxx = 1), and the flow of the program goes to the instruction after the HALT instruction. 295 PD17704, 17705, 17707, 17708, 17709 Example Releasing halt status by timer 0 and INT0 pin interrupts In this example, the halt status is released and processing B is executed when timer 0 interrupt is accepted. And processing A is executed when INT0 pin interrupt is accepted. Each time the halt status has been released, processing C is executed. HLTINT START: DAT 1000B ; Symbol definition ; Address 0000H BR MAIN ;*** Interrupt vector address *** NOP NOP NOP NOP NOP BR INTTM0 NOP NOP NOP NOP BR INT0 NOP INT0: Processing A EI RETI INTMM0: Processing B EI RETI MAIN: INITFLG MOV MOV PUT SET2 SET2 LOOP: Processing C EI HALT ;<1> BR LOOP NOT TMOCK1, TM0CK0 DBF1, #0 DBF0, #0AH TM0M,DBF TM0RES, TM0EN IPTM0, IP0 ; ; ; ; ; ; ; ; ; ; ; ; ; SI01 SI00 TIMER3 TIMER2 TIMER1 Branches to timer 0 interrupt processing INT4 INT3 INT2 INT1 Branches to INT0 interrupt processing CE DOWN EDGE INT0 pin interrupt vector address (000BH) ; INT0 pin interrupt processing ; Timer 0 interrupt processing ; Sets timer 0 count clock to 100 s ; Sets time interval of timer 0 interrupt to 1 ms ; Resets and starts timer 0 ; Enables INT0 and timer 0 interrupts ; Main routine processing ; Enables all interrupts ; Specifies releasing halt status by interrupt HLTINT If the INT0 pin interrupt request and timer 0 interrupt request are issued simultaneously in the halt status, processing A for the INT0 pin, which has the higher hardware priority, is executed. After execution of processing A and when "RETI" is executed, the program branches to the "BR LOOP" instruction of <1>. However, the "BR LOOP" instruction is not executed, and timer 0 interrupt is immediately accepted. When the "RETI" instruction is executed after processing B of timer 0 interrupt has been executed, the "BR LOOP" instruction is executed. 296 PD17704, 17705, 17707, 17708, 17709 Caution To reset the interrupt request flag (IRQxxx) once before the halt instruction is executed, insert a NOP instruction (or one or more other instructions) between the HALT instruction and the instruction that resets the interrupt request flag (IRQxxx) as shown below. If a NOP instruction (or one or more other instructions) is not inserted, the interrupt request flag is not reset, and therefore, the halt status is released immediately. Example : : : CLR1 NOP IRQxxx ; Resets IRQxxx flag once ; Resets IRQxxx flag at this timing ; Unless this period is missing, the IRQxxx flag is not reset, ; and the next HALT instruction is immediately released HALT 1000B ; ; IRQxxx is set at certain timing 297 PD17704, 17705, 17707, 17708, 17709 20.2.7 If two or more releasing conditions are specified at same time If two or more halt releasing conditions are specified at same time, the halt status is released when one of the conditions is satisfied. The following program example shows how the releasing conditions are identified if two or more conditions are satisfied at the same time. Example HLTINT HLTBTM HLTP0D P0D START: BR MAIN ;*** Interrupt vector address *** NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP BR INT0 NOP INT0: Processing A EI RETI BTMOUP: Processing B RET P0DP: Processing C RET MAIN: INITFLG NOT BTM0CK1, NOT BTM0CK0 ; Selects 100 ms as clock of basic timer 0 SET1 IP0 ; Enables INT0 pin interrupt EI LOOP: HALT HLTINT OR HLTBTM OR HLTP0C ; Selects interrupt, timer carry FF, and P0D input as halt releasing conditions SKF1 BTM0CY ; Detects BTM0CY flag CALL BTM0UP ; Timer carry FF processing if flag is set to 1 SKF P0D, 1111B ; Detects P0D input CALL P0DP ; Port input processing if P0D is high BR LOOP ; P0D input processing ; Timer carry FF processing DAT DAT DAT MEM 1000B 0010B 0001B 0.73H ; ; ; ; ; ; ; ; ; ; ; ; SI01 SI00 TIMER3 TIMER2 TIMER1 TIMER0 INT4 INT3 INT2 INT1 Branches to INT0 interrupt processing CE DOWN EDGE ; INT0 pin interrupt vector address (000BH) ; INT0 pin interrupt processing 298 PD17704, 17705, 17707, 17708, 17709 In the above example, three halt status releasing conditions, INT0 pin interrupt, 100-ms basic timer 0 carry FF, and port 0D input, are specified. To identify which condition has released the halt status, a vector address (interrupt), BTM0CY flag (timer carry FF), and port register (port input) are detected. To use two or more releasing conditions, the following two points must be noted. * When the halt status is released, all the specified releasing conditions must be detected. * The releasing condition with the higher priority must be detected first. 20.3 Clock Stop Function 20.3.1 Outline of clock stop function The clock stop function stops the oscillation circuit of a 4.5-MHz crystal resonator by executing the "STOP s" instruction (clock stop status). Therefore, the current consumption of the device is reduced to 30 A MAX. 20.3.2 Clock stop status In the clock stop status, all the device operations of the CPU and peripheral hardware units are stopped because the generation circuit of the crystal resonator is stopped. For the operations of the CPU and peripheral hardware units, refer to 20.4 Device Operation in Halt and Clock Stop Status. In the clock stop status, the power failure detection circuit does not operate even if the supply voltage VDD of the device is raised to 2.2 V. Therefore, the data memory can be backed up at a low voltage. For the power failure detection circuit, refer to 21. RESET. 20.3.3 Releasing clock stop status Figure 20-3 shows the stop status releasing conditions. The stop status releasing condition is specified by 4-bit data specified by operand "s" of the "STOP s" instruction. The stop status is released when the condition specified by "1" in operand "s" is satisfied. When the stop status has been released, a halt period which is half the time (tSET/2) specified by the basic timer 0 clock selection register as oscillation circuit stabilization wait time has elapsed, and the program execution is started from the instruction next to the "STOP s" instruction. If releasing the stop status by an interrupt is specified, however, the program operation after the stop status has been released differs depending on whether the interrupt is enabled (EI status) or disabled (DI status) when an interrupt source is issued (IRQxxx = 1) with the interrupt enabled (IPxxx = 1). If all the interrupts are enabled (EI status), the stop status is released when the interrupt is enabled (IPxxx = 1) and the interrupt source is issued (IRQxxx = 1), and the program flow returns to the instruction next to the STOP instruction. If all the interrupts are disabled (DI status), the stop status is released when the interrupt is enabled (IPxxx = 1) and the interrupt resource is issued (IRQxxx = 1), and the program flow returns to the instruction next to the STOP instruction. If two or more releasing conditions are specified at one time, and if one of the conditions is satisfied, the stop status is released. If 0000B is specified as stop releasing condition "s", no releasing condition is satisfied. If the device is reset at this time (by means of power-ON reset, or CE reset), the stop status is released. 299 PD17704, 17705, 17707, 17708, 17709 Figure 20-3. Stop Releasing Conditions STOP s (4 bits) Operand b3 b2 b1 b0 Specifies stop status releasing condition Releases when high level is input to port 0D Undefined (Fix this bit to "0".) Undefined (Fix this bit to "0".) Released by interrupt of falling edge of INT0 through INT4 pins and CE pin 0 1 Not released even if condition is statisfied Released if condition is satisfied The "STOP s" instruction is executed as a "NOP" instruction when the CE pin rises and when the CE reset counter operates. The operating status of the CE reset counter can be detected by the CECNTSTT flag (for the CE reset counter, refer to 21. RESET). 20.3.4 Releasing clock stop status by high level input of port 0D Figure 20-4 illustrates how the clock stop status is released by the high level input to port 0D. Figure 20-4. Releasing Clock Stop Status By High Level Input of Port 0D 5V VDD 0V H P0D L XOUT Oscillation stops STOP s instruction tSET/2 HALT period Starts from instruction next to STOP s 2.2 V tSET: basic timer 0 setting time 20.3.5 Cautions on releasing clock stop status For the cautions on releasing the clock stop status, refer to (2) Releasing from clock stop status in 21.4.4 Cautions on raising supply voltage VDD. 300 PD17704, 17705, 17707, 17708, 17709 20.4 Device Operation in Halt and Clock Stop Status Table 20-1 shows the operations of the CPU and peripheral hardware units in the halt and clock stop status. In the halt status, all the peripheral hardware units continue the normal operation until instruction execution is stopped. In the clock stop status, all the peripheral hardware units stop operation. The control registers that control the operations of the peripheral hardware units operate normally (not initialized) in the halt status, but are initialized to specified values when the clock stop instruction is executed. In other words, all peripheral hardware continues the operation specified by the control register in the halt status, and the operation is determined by the initialized value of the control register in the clock stop status. For the values of the control registers in the clock stop status, refer to 8. REGISTER FILE (RF). Table 20-1. Device Operation in Halt and Clock Stop Status Peripheral Hardware Halt Program counter System register Peripheral register Control register Timer PLL frequency synthesizer A/D converter D/A converter Stops at address of HALT instruction Retained Retained Retained Normal operation Normal operationNote 2 Status Clock stop Stops at address of STOP instruction Retained Partly initializedNote 1 Partly initializedNote 1 Operation stops Operation stops Operation stops Stops operation and used as generalpurpose output port Stops operation and used as generalpurpose I/O port Normal operation Normal operation Serial interface Stops operation when internal clock (master) is selected and continues operation when external clock (slave) is selected Normal operation Frequency counter Stops operation and used as generalpurpose input port BEEP output Normal operation Stops operation and used as generalpurpose I/O port Retained Input port Retains output latch General-purpose I/O port General-purpose input port General-purpose output port Normal operation Normal operation Normal operation Notes 1. For the value to which these registers are initialized, refer to 5. SYSTEM REGISTER (SYSREG) and 8. REGISTER FILE (RF). 2. The PLL frequency synthesizer is automatically disabled by the low level input to the CE pin. 20.5 Cautions on Processing of Each Pin in Halt and Clock Stop Status The halt status is used to reduce the current consumption when, say, only the watch is used. The clock stop function is used to reduce the current consumption of the device to only use the data memory. Therefore, the current consumption must be reduced as much as possible in the halt status or clock stop status. At this time, the current consumption significantly varies depending on the status of each pin, and the points shown in Table 20-2 must be noted. 301 PD17704, 17705, 17707, 17708, 17709 Table 20-2. Status of Each Pin in Halt and Clock Stop Status and Cautions (1/2) Pin Function Pin Symbol Status of Each Pin and Cautions on Processing Halt status Generalpurpose I/O port Port 0A P0A3/SDA P0A2/SCL P0A1/SCK0 P0A0/SO0 Port 0B P0B3/SI0 P0B2/SCK1 P0B1/SO1 P0B0/SI1 Port 0C Port 1D P0C3-P0C0 P1D3 P1D2 P1D1/BEEP1 P1D0/BEEP0 Port 2A P2A2 P2A1/FCG1 P2A0/FCG0 Port 2B Port 2C Port 2D Port 3A Port 3B Port 3C Port 3D Generalpurpose input port Port 1A Port 0D P2B3-P2B0 P2C3-P2C0 P2D2-P2D0 P3A3-P3A0 P3B3-P3B0 P3C30P3C0 P3D3-P3D0 P0D3/AD3 | P0D0/AD0 P1A3/INT4 P1A2/INT3 P1A1 P1A0/TM0G Port 1C P1C3/AD5 P1C2/AD4 P1C1/AMIFC P1C0/FMIFC Generalpurpose output port Port 1B P1B3 P1B2/PWM2 | P1B0/PWM0 Specified as general-purpose output port. Output contents are retained as is. If pin is externally pulled down while it outputs high level or externally pulled up while it outputs low level, current consumption increases (4) Port 1C (P1C3/AD5, P1C2/AD4, P1C1/AMIFC, P1C0/FMIFC) When P1C1/AMIFC or P1C0/FMIFC pin is used for IF counter, current consumption increases because internal amplifier operates (4) P0D3/AD3 through P0D0/AD0, P1C3/AD5, P1C2/AD4 Pin used for A/D converter is retained as is. Pull-down resistor of P0D3 through P0D0 pin retains previous status (3) Port 0D (P0D3/AD3 through P0D0/ AD0) Current consumption increases if pin is externally pulled up because it is provided with pull-down resistor selectable by software (3) P1A3/INT4, P1A2/INT3 Set as interrupt pin and current consumption increases due to external noise if pin is floated (2) When specified as input pin Current consumption increases due to noise if pin is floated (2) When specified as general-purpose input port Current consumption does not increase due to noise even if pin is floated (1) When specified as output pin Current consumption increases if pin is externally pulled down while it outputs high level, or externally pulled up while it outputs low level. Exercise care in using N-ch opendrain output (P0A3, P0A2, P1B3 through P1B0) (1) When specified as general-purpose output port Current consumption increases due to noise if pin is floated Retains status before halt Clock stop status All port pins are set in general-purpose port mode (except P0D3/AD3 through P0D0/AD0, P1A3/INT4, P1A2/INT3, P1C3/AD5, and P1C2/AD4) Input or output mode of general-purpose I/O port set before clock stop status is retained. 302 PD17704, 17705, 17707, 17708, 17709 Table 20-2. Status of Each Pin in Halt and Clock Stop Status and Cautions (2/2) Pin Function Pin Symbol Status of Each Pin and Cautions on Processing Halt status External interrupt PLL frequency synthesizer INT4-INT0 VCOL VCOH EO0 EO1 Clock stop status Current consumption increases due to noise if pin is floated Current consumption increases during PLL operation. When PLL is disabled, pin is in following status: VCOH, VCOL : internally pulled down EO1, EO0 : floated PLL is disabled VCOH, VCOL : internally pulled down EO1, EO0 : floated PLL is automatically disabled if CE pin goes low Crystal oscillation circuit XIN XOUT Current consumption changes due to oscillation waveform of crystal oscillation circuit. The higher oscillation amplitude, the lower current consumption. Oscillation amplitude must be evaluated because it is influenced by crystal resonator or load capacitor used XIN pin is internally pulled down, and XOUT pin outputs high level 20.6 Device Operation Control Function of CE Pin The CE pin controls the following functions by the input level and rising edge of the signal input from an external source. * PLL frequency synthesizer * Interrupt by falling edge of CE pin * Resetting of device 20.6.1 Controlling operation of PLL frequency synthesizer The PLL frequency synthesizer can operate only when the CE pin is high. It is automatically disabled when the CE pin is low. When the synthesizer is disabled, the VCOH and VCOL pins are internally pulled down, and the EO0 and EO1 pins are floated. For details, refer to 17.5 PLL Disabled Status. The PLL frequency synthesizer can be disabled in software even when the CE pin is high. 20.6.2 Controlling interrupt by falling edge input of CE pin An interrupt can be generated by the falling edge of the CE pin. For details, refer to 12. INTERRUPTS. 303 PD17704, 17705, 17707, 17708, 17709 20.6.3 Resetting device The device can be reset (CE reset) by raising the CE pin. The device can also be reset as follows: * Power-ON reset on application of supply voltage VDD * Watchdog timer reset for software hang-up detection and stack overflow/underflow reset * Reset by RESET pin For details, refer to 21. RESET. 20.6.4 Signal input to CE pin The CE pin does not accept a low level or high level of less than 167 s to prevent malfunctioning due to noise. The level of the signal input to the CE pin can be detected by the CE pin status detection flag of the CE pin interrupt request register (RF address 3FH). Figure 20-5 shows the relationship between the input signal and CE flag. Figure 20-5. Relationship between Input Signal of CE Pin and CE Flag H CE pin L 1 CE flag 0 Less than 167 s 167 s Less than 167 s 167 s CE reset PLL can operate PLL disabled PLL disabledNote CE reset is effected in synchronization with next basic timer 0 carry FF (When CE reset count register is "1") Note Unless the PLL mode selection register and PLL reference frequency selection register are rewritten by software, the PLL disabled status is retained. 304 PD17704, 17705, 17707, 17708, 17709 20.6.5 Configuration and function of CE pin interrupt request register The CE pin interrupt request register detects the input signal level of the CE pin. Figure 20-6 shows the configuration of the CE pin interrupt request register. Figure 20-6. Configuration of CE Pin Interrupt Request Register Name Flag symbol b3 b2 b1 b0 Address Read/Write CE pin interrupt request C E 0 C E C N T S T T I R Q C E 3FH RNote Sets interrupt request issuance status of CE pin 0 1 No interrupt request Interrupt request Detects status of CE reset counter 0 1 Stops Operates Fixed to "0" Detects status of CE pin 0 1 Low level is input High level is input At Reset Power-ON reset WDT&SP reset CE reset U U U U 0 0 0 0 0 0 0 R R Clock stop U: Undefined R: Retained Note IRQCE is a R/W flag. 305 PD17704, 17705, 17707, 17708, 17709 21. RESET 21.1 Outline of Reset The reset function is used to initialize the device. The PD17709 can be reset in the following ways: * CE reset * Power-ON reset * Reset by RESET pin * WDT&SP reset Figure 21-1. Configuration of Reset Block XOUT Power failure detection block Timer FF block XIN BTM0CY flag read R STOP s instruction Q S Basic timer 0 carry disable FF Divider Selector Basic timer 0 carry VDD Voltage detection circuit Power-ON clear signal (POC) RESET Falling detection circuit Reset control CE Rising detection circuit CE reset timer carry counter CE reset signal circuit Watchdog timer stack overflow/underflow detection block WDT&SP reset signal STOP instruction 306 PD17704, 17705, 17707, 17708, 17709 21.2 CE Reset CE reset is effected by raising the CE pin. When the CE pin goes high, the next rising edge of the basic timer 0 carry FF setting pulse is counted. When the count value coincides with the value set to the CE reset timer carry counter register (1 to 15 counts), the reset signal is generated. When CE reset is effected, the program counter, stack, system registers, and some of the control registers are initialized to the initial values, and program execution is started from address 0000H. For the initial value of each register, refer to the description of each register. Figure 21-2. Configuration of CE Reset Timer Carry Counter Register Name Flag symbol b3 b2 b1 b0 Address Read/Write CE reset timer carry counter C E C N T 3 C E C N T 2 C E C N T 1 C E C N T 0 06H R/W Sets number of counts of timer carry counter for CE reset 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Setting prohibited 1 count 2 counts 3 counts 4 counts 5 counts 6 counts 7 counts 8 counts 9 counts 10 counts 11 counts 12 counts 13 counts 14 counts 15 counts At reset Power-ON reset WDT&SP reset CE reset 0 0 0 1 Retained Retained 0 0 0 1 Clock stop 307 PD17704, 17705, 17707, 17708, 17709 The operation of CE reset differs depending on whether the clock stop instruction is used or not. This difference is described in 21.2.1 and 21.2.2 below. 21.2.3 describes the points to be noted when CE reset is effected. 21.2.1 CE reset without clock stop (STOP s) instruction Figure 21-2 shows the operation. When the CE pin has gone high, the CE reset timer carry counter starts counting at the rising edge of the basic timer 0 carry FF setting pulse. Figure 21-3. CE Reset Operation without Clock Stop Instruction (1/2) (a) Normal operation * When "N" is set to CE reset timer carry counter VDD CE XOUT BTM0CY flag setting pulse CE reset timer carry counter Set value of CE reset timer carry counter CE reset signal 5V 0V H L H L H L H 0 L H L H L CE reset N 1 2 3 N-2 N-1 N 0 tSET * When "1" is set to CE reset timer carry counter VDD CE XOUT BTM0CY flag setting pulse CE reset timer carry counter Set value of CE reset timer carry counter CE reset signal 5V 0V H L H L H L H L H L H L CE reset tSET 0 1 1 0 308 PD17704, 17705, 17707, 17708, 17709 Figure 21-3. CE Reset Operation without Clock Stop Instruction (2/2) (b) If status of CE pin changes while CE counter operates At this time, the CE reset timer carry counter status is not affected. VDD CE XOUT BTM0CY flag setting pulse CE reset timer carry counter Set value of CE reset timer carry counter CE reset signal 5V 0V H L H L H L H 0 L H L H L CE reset N 1 2 3 N-2 N-1 N 0 tSET 21.2.2 CE reset with clock stop (STOP s) instruction used Figure 21-4 shows the operation. When the clock stop instruction is used, the clock stop signal is output when the "STOP s" instruction is executed, and oscillation is stopped and the device operation is stopped. When the CE pin goes high, the clock stop status is released, and oscillation is started (high level input of P0D or INT pin interrupt can also be used as the clock stop status releasing conditions. For details, refer to 20. STANDBY). If the basic timer 0 carry FF setting pulse goes high after the CE pin has gone high, the halt status is released, and program execution is started from address 0 (CE reset). As the set time (tSET) of the basic timer 0 carry FF setting pulse, the value immediately before the clock stop instruction is executed is retained. Because the set value of the CE reset timer carry counter is initialized to 1, CE reset is effected tSET/2 after the CE pin has gone high. 309 PD17704, 17705, 17707, 17708, 17709 Figure 21-4. CE Reset Operation with Clock Stop Instruction 5V VDD 0V H CE L H XOUT BTM0CY flag setting pulse L H L H 0 L H N L H CE reset signal L Normal operation Clock stop status Halt status tSET/2 STOP s instruction Clock stop status released. Oscillation starts 1 1 tSET CE reset timer carry counter Set value of CE reset timer carry counter CE reset Program execution starts from address 0 21.2.3 Cautions 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 to execute timer processing such as watch When creating a watch program by using the basic timer 0 carry, the processing time of the program must be kept to within a specific time. For details, refer to 13.2.6 Cautions on using basic timer 0. (2) Processing of data and flags used in program Exercise care in rewriting the data and flags whose contents must not be changed even when CE reset is effected, such as security code. An example is shown below. 310 PD17704, 17705, 17707, 17708, 17709 Example 1. R1 R2 R3 R4 M1 M2 START: Key input processing R1 contents of key A R2 contents of key B SET2 SUB SUB SKT1 BR MAIN: Key input processing R3 contents of key C R4 contents of key D ST ST BR ERROR: Must not operate Suppose the security code is "12H" in the program in Example 1. The contents of data memory addresses M1 and M2 are "1H" and "2H", respectively. If CE reset is effected, the contents of key input and security code "12H" are compared in <1>. If the two are the same, the normal processing is performed. If the security code is changed in the main processing, the new code is written 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>. If CE reset is effected as soon as <2> has been executed, program execution is started from address 0000H, without <3> being executed. Consequently, the security code is set to "32H", making it impossible to clear the security system. In this case, create the program shown in Example 2. M1, R3 M2, R4 MAIN ; Security code rewriting mode ; Substitutes contents of pressed key to R3 and R4 ; <2> ; Rewrites security code ; <3> CMP, Z R1, M1 R2, M2 Z ERROR ; Input data differs from security code ; Security code input wait mode ; Substitutes contents of pressed key to R1 and R2 ; <1> ; Compares security code and input data MEM MEM MEM MEM MEM MEM 0.01H 0.02H 0.03H 0.04H 0.11H 0.12H ; 1st digit of key input data of security code ; 2nd digit of key input data of security code ; 1st digit data when security code is changed ; 2nd digit data when security code is changed ; 1st digit of current security code ; 2nd digit of current security code 311 PD17704, 17705, 17707, 17708, 17709 Example 2. R1 R2 R3 R4 M1 M2 CHANGE START: Key input processing R1 contents of key A R2 contents of key B SKT1 BR ST ST CLR1 SECURITY_CHK: SET2 SUB SUB SKT1 BR MAIN: Key input processing R3 contents of key C R4 contents of key D SET1 ST ST CLR1 BR ERROR: Must not operate The program in Example 2 sets the CHANGE flag to "1" in <5> before the security code is rewritten in <2> and <3>. Therefore, even if CE reset is effected before <3> is executed, the security code is rewritten in <4>. CHANGE M1, R3 M2, R4 CHANGE MAIN ; Security code rewriting mode ; Substitutes contents of pressed key to R3 and R4 CMP, Z R1, M1 R2, M2 Z ERROR ; Input data differs from security code ; <1> ; Compares security code and input data CHANGE M1, R3 M2, R4 CHANGE ; Security code input wait mode ; Substitutes contents of pressed key to R1 and R2 MEM MEM MEM MEM MEM MEM FLG 0.01H 0.02H 0.03H 0.04H 0.11H 0.12H 0.13H.0 ; 1st digit of key input data of security code ; 2nd digit of key input data of security code ; 1st digit data when security code is changed ; 2nd digit data when security code is changed ; 1st digit of current security code ; 2nd digit of current security code ; "1" while security code is changed ; <4> ; If CHANGE flag is "1" ; Rewrites M1 and M2 SECURITY_CHK ; <5> ; Until security code is changed, ; Sets CHANGE flag to "1" ; <2> ; Rewrites security code ; <3> ; If security code has been changed, ; Sets CHANGE flag to "0" 312 PD17704, 17705, 17707, 17708, 17709 21.3 Power-ON Reset Power-ON reset is effected by raising the supply voltage VDD of the device from a specific level (called a powerON clear voltage). If supply voltage VDD is lower than the power-ON clear voltage, a power-ON clear signal (POC) is output from the voltage detection circuit shown in Figure 21-1. When the power-ON clear signal is input to the reset control circuit, the crystal oscillation circuit is stopped and consequently, the device operation is stopped. At this time, the program counter, stack, system registers, and control registers are initialized (for the initial value, refer to the description of each register). If supply voltage VDD exceeds the power-ON clear voltage, the power-ON clear signal is deasserted, crystal oscillation is started, and the device waits for release of the halt status by the basic timer 0 carry which has been initialized to 100 ms. Program execution is started from address 0 at the rising edge of the basic timer 0 carry FF setting signal 50 ms after the supply voltage has exceeded the power-ON clear voltage. Normally, the power-ON clear voltage is 3.5 V, but it is 2.2 V in the clock stop status. The operations of power-ON reset are described in 21.3.1 and 21.3.2. The operation when supply voltage VDD is raised from 0 V is described in 21.3.3. Caution Although it is stated that the normal power-ON clear voltage is 3.5 V (MAX.) and that in the clock stop status is 2.2 V (MAX.), the actual power-ON clear voltage does not exceed these maximum values. Figure 21-5. Operation of Power-ON Reset 5V VDD CE XOUT BTM0CY flag setting pulse Power-ON clear signal L Normal operation Device operation stops Halt status 50 ms Power-ON clear released Oscillation starts L H L H 0V H L H Power-ON clear voltage Program starts from address 0 313 PD17704, 17705, 17707, 17708, 17709 21.3.1 Power-ON reset during normal operation Figure 21-6 (a) shows the operation. As shown, the power-ON clear signal is output and the device operation is stopped if the supply voltage VDD drops below 3.5 V, regardless of the input level of the CE pin. If VDD rises beyond 3.5 V again, program execution starts from address 0000H after a halt of 50 ms. Normal operation means operation without the clock stop instruction, and includes the halt status set by the halt instruction. 21.3.2 Power-ON reset in clock stop status Figure 21-6 (b) shows the operation. As shown, the power-ON clear signal is output and the device operation is stopped when supply voltage VDD drops below 2.2 V. However, it does not appear that device operation has changed because the device is in the clock stop status. If VDD rises beyond 3.5 V, program execution starts from address 0000H after a halt of 50 ms. 21.3.3 Power-ON reset when supply voltage VDD rises from 0 V Figure 21-6 (c) shows the operation. As shown, the power-ON clear signal is output until supply voltage VDD rises from 0 V to 3.5 V. When VDD exceeds the power-ON clear voltage, the crystal oscillation circuit starts operating, and program execution starts from address 0000H after a half of 50 ms. 314 PD17704, 17705, 17707, 17708, 17709 Figure 21-6. Power-ON Reset and Supply Voltage VDD (a) Normal operation (including halt status) 5V 3.5 V VDD 0V H CE XOUT Power-ON clear signal L H L Normal operation Device operation stops Halt status 50 ms Power-ON clear released Program starts from address 0 Oscillation starts L H Power-ON clear voltage (b) In clock stop status 5V VDD 0V H CE XOUT Power ON clear signal L H L Normal operation Clock stop Device operation stops Halt status 50 ms Power-ON clear released Program starts from address 0 Oscillation starts L H 2.2 V 3.5 V Power-ON clear voltage STOP s instruction (c) If supply voltage VDD rises from 0 V 5V 3.5 V VDD 0V H CE XOUT L Power-ON H clear signal L Device operation stops Halt status 50 ms Power-ON clear released Program starts from address 0 Oscillation starts L H Power-ON clear voltage 315 PD17704, 17705, 17707, 17708, 17709 21.4 Relationship between CE Reset and Power-ON Reset On the first application of supply voltage VDD, power-ON reset and CE reset are performed at the same time. The reset operations at this time are described in 21.4.1 through 21.4.3. 21.4.4 describes the points to be noted when raising supply voltage VDD. 21.4.1 If VDD pin and CE pin go high at the same time Figure 21-7 (a) shows the operation. At this time, the program starts from address 0000H because of power-ON reset. 21.4.2 If CE pin rises in forced halt status set by power-ON reset Figure 21-7 (b) shows the operation. At this time, the program starts from address 0000H because of power-ON reset, in the same manner as 21.4.1. 21.4.3 If CE pin rises after power-ON reset Figure 21-7 (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. 316 PD17704, 17705, 17707, 17708, 17709 Figure 21-7. Relationship between Power-ON Reset and CE Reset (a) When VDD and CE pin rise at the same time 5V VDD 0V H CE BTM0CY flag setting pulse L H L Operation stops Halt status 50 ms 3.5 V Power-ON clear voltage Normal operation Power-ON reset Program starts (b) If CE pin rises in halt status 5V VDD 0V H CE BTM0CY flag setting pulse L H L Operation stops Halt status 50 ms 3.5 V Power-ON clear voltage Normal operation Power-ON reset Program starts (c) If CE pin rises after power-ON reset 5V VDD 0V H CE BTM0CY flag setting pulse L H L Operation stops Halt status 50 ms 3.5 V Power-ON clear voltage Normal operation CE reset Program starts (If CE reset timer carry counter is set to "1") Power-ON reset Program starts 317 PD17704, 17705, 17707, 17708, 17709 21.4.4 Cautions on raising supply voltage VDD The following points (1) and (2) must be noted when raising supply voltage VDD. (1) To raise supply voltage VDD from level lower than power-ON clear voltage Supply voltage VDD must be raised once to a level higher than 3.5 V. Figure 21-8 illustrates this. As shown in the figure, if a voltage less than 3.5 V is applied on application of VDD in a program that backs up VDD at 2.2 V by using the clock stop instruction, the power-ON clear signal remains output, and the program is not executed. At this time, the output ports of the device output undefined values, increasing the current consumption in some cases. Consequently, the backup time when the device is backed up by batteries is substantially shortened. Figure 21-8. Cautions on Raising VDD 5V 3.5 V VDD 2.2 V 0V H XOUT BTM0CY flag setting pulse Power-ON clear signal L H L H L Operation stops Because output ports are undefined during this period, current consumption may increase. Operation stops Halt status 50 ms Power-ON clear voltage Normal operation Initialize during this period and then execute clock stop instruction Back up Power-ON reset Progarm starts STOP s instruction 318 PD17704, 17705, 17707, 17708, 17709 (2) Releasing from clock stop status If the device is released from the backup status when supply voltage VDD is backed up at 2.2 V by using the clock stop status, VDD must be raised to 3.5 V or more within tSET/2 after the clock stop status has been released by INT pin interrupt or high level input to port 0D. As shown in Figure 21-9, the device is released from the clock stop status by means of CE reset. However, because the power-ON clear voltage is changed to 3.5 V tSET/2 after the clock stop status has been released, power-ON reset is effected unless VDD is 3.5 V or higher. The same applies when VDD is raised. Figure 21-9. Releasing from Clock Stop Status 5V 3.5 V VDD 2.2 V 0V H P0D 0V H XOUT BTM0CY flag setting pulse Power-ON clear signal L H L H L Backup in clock stop status Halt status tSET/2 Program starts Power-ON clear voltage changes to 3.5 V at this point. Therefore, VDD must be 3.5 V or higher before this point. Power-ON clear voltage Normal operation Backup STOP s instruction Power-ON clear voltage changes to 2.2 V at this point. Therefore, VDD must be 3.5 V or higher before this point. tSET: basic timer 0 setting time 319 PD17704, 17705, 17707, 17708, 17709 21.5 Reset by RESET Pin The device is reset by the RESET pin in the following cases: * To reset the device at voltage higher than power-ON clear voltage * External reset input in case of software hang-up Caution If the device is reset by the RESET pin during program execution, the data in the data memory may be corrupted. Therefore, be careful when resetting with the RESET pin. The reset operation is the same as that performed at power-ON reset. When a low level is input to the RESET pin, an internal reset signal is generated, the crystal oscillation circuit is stopped, and the device stops operation. At this point, the program counter, stack, system registers, and control registers are initialized (for the initial value, refer to the description of each register). When the RESET pin is raised next time, the crystal oscillation is started, and the device waits to be released from the halt wait status by the basic timer 0 carry which has been initialized to a 100-ms cycle. The program starts from address 0 at the rising edge of the basic timer 0 carry FF setting signal 50 ms after a high level has been input to the RESET pin. Because the PD17709 has a power-ON reset function, connect the RESET pin to VDD via resistor if the RESET pin is not used for the above application. Figure 21-10. Reset Operation by RESET Pin 5V VDD 0V H RESET L H XOUT L BTM0CY flag setting pulse H L Device opeation stops Halt status 50 ms Oscillation starts Program starts from address 0 320 PD17704, 17705, 17707, 17708, 17709 21.6 WDT&SP Reset WDT&SP reset includes the following: * Watchdog timer reset * Stack pointer overflow/underflow reset Figure 21-11. Outline of WDT&SP Reset WDTCK1 flag WDTCK0 falg Instruction count clock 65536 instruction counter WDTCY flag WDT&SP reset signal 131072 instruction counter WDTRES Stack overflow/under flow reset detection circuit ASPRES flag ISPRES flag 21.6.1 Watchdog timer reset The watchdog timer is a circuit that generates a reset signal when the execution sequence of the program is abnormal (hung-up). Hanging-up means that the program jumps to an unexpected routine due to external noise, entering a specific infinite loop and causing the system to be deadlocked. By using the watchdog timer, the program can be restored from this hang-up status because a reset signal is generated from the watchdog timer at fixed time intervals and program execution is started from address 0. The watchdog timer does not function in the clock stop mode and halt mode. Resetting by the watchdog timer initializes all the registers except the stack overflow selection register, watchdog timer counter reset register, basic timer 0 carry register, and CE reset timer carry counter. The watchdog timer reset is detected by the WDTCY flag (R&Reset). 321 PD17704, 17705, 17707, 17708, 17709 21.6.2 Watchdog timer setting flags These flags can be set only once after power-ON reset on power application or reset by the RESET pin. The WDTCK0 and WDTCK1 flags select an interval at which the reset signal is output. The reference time can be selected to the following three conditions: * 655356 instructions * 131072 instructions * Watchdog timer not set On power application, 131072 instructions are selected. If the reset signal generation interval is specified to be 131072 instructions, the watchdog timer FF must be reset at intervals not exceeding 131072 instructions. The valid reset period is from 1 to 131071 instructions. If the reset signal generation interval is 65536 instructions, the watchdog timer FF must be reset at intervals not exceeding 65536 instrutions. The valid reset period is from 1 to 65535 instructions. Figure 21-12. Configuration of Watchdog Timer Clock Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Watchdog timer clock selection 0 0 WW D T C K 1 D T C K 0 02H R/WNote Selects clock of watchdog timer 0 0 1 1 0 1 0 1 Does not set watchdog timer 65536 instructions Setting prohibited 131072 instructions Fixed to "0" At reset Power-ON reset WDT&SP reset CE reset 0 0 1 1 Retained Retained Retained Clock stop Note Can be written only once. 322 PD17704, 17705, 17707, 17708, 17709 The WDTRES flag is used to reset the watchdog timer counter. When this flag is set to 1, the watchdog timer counter is automatically reset. If the WDTRES flag is set to 1 once within a reference time in which the WDTCK0 and WDTCK1 flags are set, the reset signal is not output by the watchdog timer. Figure 21-13. Configuration of Watchdog Timer Counter Reset Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Watchdog timer counter reset W D T R E S 0 0 0 03H W&Reset Fixed to "0" Resets watchdog timer counter 0 1 Invalid Resets watchdog timer counter Power-ON reset U U U U 0 0 0 At reset WDT&SP reset CE reset Clock stop U: Undefined 323 PD17704, 17705, 17707, 17708, 17709 21.6.3 Stack pointer overflow/underflow reset A reset signal is generated if the address or interrupt stack overflows or underflows. Stack pointer overflow/underflow reset can be used to detect a program hang-up in the same manner as watchdog timer reset. The reset signal is generated under the following conditions: * Interrupt due to overflow or underflow of interrupt stack (4 levels) * Interrupt due to overflow or underflow of address stack (15 levels) Reset by stack pointer overflow or underflow initializes all the registers, except the stack overflow selection register, watchdog timer counter reset register, basic timer 0 carry register, and CE reset timer carry counter. Generation of stack pointer overflow or underflow reset is detected by the WDTCY flag (R&Reset). 21.6.4 Stack pointer setting flag The stack overflow/underflow reset selection register can be set only once after power-ON reset on power application or reset by the RESET pin. This register specifies whether reset by address stack overflow or underflow and reset by interrupt stack overflow or underflow are enabled or disabled. 324 PD17704, 17705, 17707, 17708, 17709 Figure 21-14. Configuration of Stack Overflow/Underflow Reset Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write Stack overflow/underflow reset selection 0 0 I S P R E S A S P R E S 05H R/WNote Selects address stack overflow/underflow reset 0 1 Disables reset Enables reset Selects interrupt stack overflow/underflow reset 0 1 Disables reset Enables reset Fixed to "0" Power-ON reset At reset WDT&SP reset CE reset 0 0 1 1 Retained Retained Retained Clock stop Note Can be written only once. 325 PD17704, 17705, 17707, 17708, 17709 Figure 21-15. Configuration of WDT&SP Reset Selection Register Name Flag symbol b3 b2 b1 b0 Address Read/Write WDT&SP reset status detection 0 0 0W D T C Y 16H R&Reset Detects occurrence of WDT&SP reset 0 1 No reset request Reset request Fixed to "0" At reset Power-ON reset WDT&SP reset CE reset 0 0 0 0 1 R R Clock stop R: Retained 326 PD17704, 17705, 17707, 17708, 17709 21.7 Power Failure Detection Power failure detection is used to identify whether the device has been reset by application of supply voltage VDD, RESET pin, or CE pin. Because the contents of the data memory and output ports are "undefined" on power application, these contents are initialized by using power failure detection. Power failure detection can be performed in two ways: by detecting the BTM0CY flag and the contents of the data memory (RAM judgment). 21.7.1 and 21.7.2 describe the power failure detection circuit and power failure detection by using the BTM0CY flag. 21.7.3 and 21.7.4 describe power failure detection by RAM judgment method. Figure 21-16. Power Failure Detection Flowchart Program starts Power failure detection Not power failure Power failure Initializes data memory and output ports 21.7.1 Power failure detection circuit The power failure detection circuit consists of a voltage detection circuit, and basic timer 0 carry disable flip-flop that is set by the output (power-ON clear signal) of the voltage detection circuit, and timer carry, as shown in Figure 21-1. The basic timer 0 carry disable FF is set to 1 by the power-ON clear signal, and is reset to 0 when an instruction that reads the BTM0CY flag is executed. When 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), the program starts with the BTM0CY flag reset. After that, the BTM0CY flag is disabled from being set until an instruction that reads the flag is executed. Once the instruction that reads this flag has been executed, the BTM0CY flag is set each time the basic timer 0 carry FF setting pulse rises. Therefore, by detecting the content of the BTM0CY flag when the device is reset, whether the device has been reset by power-ON reset (power failure) or CE reset (not power failure) can be identified. That is, the device has been reset by power-ON reset if the BTM0CY flag has been reset to 0. It has been reset by CE reset if the flag has been set to 1. Because the voltage at which a power failure can be detected is the same as that at which power-ON reset is executed, VDD = 3.5 V during crystal oscillation and VDD = 2.2 V in the clock stop status. The operation of the BTM0CY flag is the same regardless of whether the device has been reset by the RESET pin or by power-ON reset. 327 PD17704, 17705, 17707, 17708, 17709 21.7.2 Cautions on detecting power failure by BTM0CY flag The following points must be noted when counting the watch timer by using the BTM0CY flag. (1) Updating watch When creating a watch program using the timer carry, the watch must be updated after a power failure has been detected. This is because the BTM0CY flag is reset to 0 because it is read after a power failure has been detected. As a result, counting of the watch is overlooked once. (2) Watch updating processing time Updating the watch must be completed before the next basic timer 0 carry FF setting pulse rises. This is because CE reset is executed before the watch updating processing has been completed if the CE pin goes high during watch updating processing. For the details of (1) and (2), refer to (3) Compensating basic timer 0 carry at CE reset in 13.2.6. The following points must be noted when performing processing in case of a power failure. (3) Timing to detect power failure When counting the watch by using the BTM0CY flag, the BTM0CY flag must be read to detect a power failure before the next basic timer 0 carry FF setting pulse rises after the program has been started from address 0000H. This is because, if the basic timer 0 carry FF setting time is set to, say, 10 ms, and if the power failure is detected 11 ms after the program has been started, the BTM0CY flag is overlooked once. For further information, refer to (3) Compensating basic timer 0 carry at CE reset in 13.2.6. Power failure detection and initial processing must be performed within the time in which the basic timer 0 carry FF is set, as shown in the example below. This is because, if the CE pin rises and CE reset is executed during power failure processing or initial processing, the processing is stopped in midway, causing a problem. To update the basic timer 0 carry FF setting time in the initial processing, the instruction that changes the setting time must be executed at the end of the initial processing. This is because, if the basic timer 0 carry FF setting time is changed before the initial processing, the initial processing may not be executed to the end because CE reset may be executed. 328 PD17704, 17705, 17707, 17708, 17709 Example START: ; <1> Processing at reset ; <2> SKT1 BR BACKUP: ; <3> ; Program address 0000H BTM0CY INITIAL ; Power failure detection Watch updating BR INITIAL: ; <4> MAIN Initial processing ; <5> INITFLG BTM0CK1, BTM0CK0 ; Embedded macro ; Sets basic timer 0 carry FF ; Sets time to 10 ms MAIN: Main processing SKT1 BR BTM0CY MAIN Watch updating BR MAIN Operation example (if CE reset timer counter is set to "1") 5V 0V H L 50 ms 50-ms pluse BTM0CY flag setting pulse H L <1> <4> <1> <3> 50 ms 10 ms VDD CE 10-ms pluse <2> Power failure detection <2> Power failure detection If processing time of <1> + <4> is longer If processing time of <1> + <3> is than 100 ms, CE reset is executed too long, CE reset is executed. <5> in the middle of processing <4>. CE reset CE reset CE reset may be executed immediately depending on when the basic timer 0 carry FF setting time is changed. Therefore, if <5> is executed before <4>, power failure processing <4> may not be executed to the end. 329 PD17704, 17705, 17707, 17708, 17709 21.7.3 Power failure detection by RAM judgment method By the RAM judgment method, a power failure is detected by judging whether the contents of the data memory at a specific address are a specific value when the device has been reset. An example of a program that detects a power failure by RAM judgment method is shown below. By the RAM judgment method, a power failure is detected by comparing an "undefined" value and a "specific" value because the contents of the data memory are "undefined" on application of supply voltage VDD. Therefore, a power failure may be judged by mistake by this method as described in 21.7.4 Cautions on power failure detection by RAM judgment method. Example Program example of power failure detection by RAM judgment method M012 M034 M056 M107 M128 M16F DATA0 DATA1 DATA2 DATA3 DATA4 DATA5 START: SET2 SUB SUB SUB BANK1 SUB SUB SUB BANK0 SKF1 BR ; INITIAL: Initial processing MOV MOV MOV BANK1 MOV MOV MOV BR BACKUP: Backup processing MAIN: Main processing M012, #DATA0 M034, #DATA1 M056, #DATA2 M107, #DATA3 M128, #DATA4 M16F, #DATA5 MAIN CMP, Z M012, #DATA0 M034, #DATA1 M056, #DATA2 M107, #DATA3 M128, #DATA4 M16F, #DATA5 Z BACKUP ; If M012 = DATA0, and ; M034 = DATA1, and ; M056 = DATA2, and ; M107 = DATA3, and ; M128 = DATA4, and ; M16F = DATA5, MEM MEM MEM MEM MEM MEM DAT DAT DAT DAT DAT DAT 0.12H 0.34H 0.56H 1.07H 1.28H 1.6FH 1010B 0101B 0110B 1001B 1100B 0011B ; branches to BACKUP 330 PD17704, 17705, 17707, 17708, 17709 21.7.4 Cautions on power failure detection by RAM judgment method Because the values of the data memory on application of supply voltage VDD are basically "undefined", the following points (1) and (2) must be noted. (1) Data to be compared Where the number of bits of the data memory to be compared by the RAM judgment method is "n bits", the probability that the value of the data memory happens to coincide the value to be compared on application of VDD is (1/2)n. In other words, a power failure detected by the RAM judgment method may be judged as backup at a probability of (1/2)n. To minimize this probability, compare as many bits as possible. Because the contents of the data memory on application of VDD are likely to be the same value such as "0000B" and "1111B", it is recommended that the data to be compared consist of a combination of "0"s and "1"s, such as "1010B" and "0110B". (2) Cautions on program If VDD rises from a level at which the contents of the data memory are destroyed as shown in Figure 21-17, even if the value of the data memory to be compared is normal, the other parts of the data memory may be destroyed. If a power failure detection is performed by the RAM judgment method at this time, it is judged to be a backup. Therefore, the program must be designed so that a hang-up does not occur even if the contents of the data memory are destroyed. Figure 21-17. VDD and Destruction of Data Memory Contents 5V VDD Data memory destruction start voltage 0V Data memory Data memory for RAM judgment (normal) Values of data memory addresses not used for RAM judgment may be destroyed. (3) Cautions on using RESET pin Caution If the device is reset by the RESET pin during program execution, the data in the data memory may be corrupted. Therefore, be careful when resetting with the RESET pin. 331 PD17704, 17705, 17707, 17708, 17709 22. INSTRUCTION SET 22.1 Outline of Instruction Set b14-b11 BIN 0000 0001 0010 0011 0100 0101 0110 b15 HEX 0 1 2 3 4 5 6 ADD SUB ADDC SUBC AND XOR OR INC INC RORC MOVT PUSH POP GET PUT PEEK POKE BR CALL SYSCAL RET RETSK RETI EI DI STOP HALT NOP LD SKE MOV SKNE BR BR BR BR r,m r,m r,m r,m r,m r,m r,m AR IX r DBF,@AR AR AR DBF,p p,DBF WR,rf rf,WR @AR @AR entry ADD SUB ADDC SUBC AND XOR OR m,#n4 m, #n4 m,#n4 m,#n4 m,#n4 m,#n4 m,#n4 0 1 0111 7 s h 1000 1001 1010 1011 1100 1101 1110 1111 8 9 A B C D E F r,m m,#n4 @r,m m,#n4 addr (page 0) addr (page 1) addr (page 2) addr (page 3) ST SKGE MOV SKLT CALL MOV SKT SKF m,r m,#n4 m,@r m,#n4 addr (page 0) m,#n4 m,#n4 m,#n 332 PD17704, 17705, 17707, 17708, 17709 22.2 Legend AR ASR addr BANK CMP CY DBF entry entryH entryL h INTEF INTR INTSK IX MP MPE m mR mC n n4 PAGE PC P pH pL r rf rfR rfC SGR SP s WR (x) : Address register : Address stack register indicated by stack pointer : Program memory address (low-order 11 bits) : Bank register : Compare flag : Carry flag : Data buffer : Program memory address (bits 10 through 8, bits 3 through 0) : Program memory address (bits 10 through 8) : Program memory address (bits 3 through 0) : Halt release condition : Interrupt enable flag : Register automatically saved to stack when interrupt occurs : Interrupt stack register : Index register : Data memory row address pointer : Memory pointer enable flag : Data memory address indicated by mR, mC : Data memory row address (high-order) : Data memory column address (low-order) : Bit position (4 bits) : Immediate data (4 bits) : Page (bits 12 and 11 of program counter) : Program counter : Peripheral address : Peripheral address (high-order 3 bits) : Peripheral address (low-order 4 bits) : General register column address : Register file address : Register file row address (high-order 3 bits) : Register file column address (low-order 4 bits) : Segment register (bit 13 of program counter) : Stack pointer : Stop release condition : Window register : Contents addressed by x 333 PD17704, 17705, 17707, 17708, 17709 22.3 Instruction List Instructions Mnemonic Operand Operation Instruction Code Op code Add ADD r,m m,#n4 ADDC r,m m,#n4 INC AR IX Subtract SUB r,m m,#n4 SUBC r,m m,#n4 Logical operation AND OR r,m m,#n4 r,m m,#n4 XOR r,m m,#n4 Judge SKT SKF Compare SKE SKNE SKGE SKLT Rotate RORC m,#n m,#n m,#n4 m,#n4 m,#n4 m,#n4 r (r) (r) + (m) (m) (m) + n4 (r) (r) + (m) + CY (m) (m) + n4 + CY AR AR + 1 IX IX + 1 (r) (r) - (m) (m) (m) - n4 (r) (r) - (m) - CY (m) (m) - n4 - CY (r) (r) v (m) (m) (m) v n4 (r) (r) (m) (m) (m) n4 (r) (r) v (m) (m) (m) v n4 v CMP 0, if (m) CMP 0, if (m) n = n, then skip n = 0, then skip v v 00000 10000 00010 10010 00111 00111 00001 10001 00011 10011 00110 10110 00100 10100 00101 10101 11110 11111 01001 01011 11001 11011 00111 mR mR mR mR 000 000 mR mR mR mR mR mR mR mR mR mR mR mR mR mR mR mR 000 Operand mC mC mC mC 1001 1000 mC mC mC mC mC mC mC mC mC mC mC mC mC mC mC mC 0111 r n4 r n4 0000 0000 r n4 r n4 r n4 r n4 r n4 n n n4 n4 n4 n4 r (m) - n4, skip if zero (m) - n4, skip if not zero (m) - n4, skip if not borrow (m) - n4, skip if borrow CY (r) b3 (r) b2 (r) b1 (r) b0 (r) (m) (m) (r) if MPE = 1 : (MP, (r)) (m) if MPE = 0 : (BANK, mR, (r)) (m) if MPE = 1 : (m) (MP, (r)) if MPE = 0 : (m) (BANK, mR, (r)) (m) n4 SP SP - 1, ASR PC, PC AR, DBF (PC), PC ASR, SP SP + 1 SP SP - 1, ASR AR AR ASR, SP SP + 1 DBF (p) (p) DBF WR (rf) (rf) WR Transfer LD ST MOV r,m m,r @r,m m, @r m,#n4 MOVT DBF,@AR PUSH POP GET PUT PEEK POKE AR AR DBF,p p,DBF WR,rf rf,WR 334 v 01000 11000 01010 mR mR mR mC mC mC r r r 11010 mR mC r 11101 00111 mR 000 mC 0001 n4 0000 00111 00111 00111 00111 00111 00111 000 000 pH pH rfR rfR 1101 1100 1011 1010 0011 0010 0000 0000 pL pL rfC rfC PD17704, 17705, 17707, 17708, 17709 Instructions Mnemonic Operand Operation Instruction Code Op code Branch BR addr PC10-0 addr, PAGE 0 PC10-0 addr, PAGE 1 PC10-0 addr, PAGE 2 PC10-0 addr, PAGE 3 @AR Subroutine CALL addr PC AR SP SP - 1, ASR PC PC11 0, PC10-0 addr SP SP - 1, ASR PC PC AR SP SP - 1, ASR PC, SGR 1 PC12, 11 0, PC10-8 entryH, PC7-4 0, PC3-0 entryL PC ASR, SP SP + 1 PC ASR, SP SP + 1 and skip PC ASR, INTR INTSK, SP SP + 1 INTEF 1 INTEF 0 s h STOP HALT No operation 01100 01101 01110 01111 00111 11100 000 0100 addr 0000 Operand addr @AR 00111 000 0101 0000 SYSCAL entry 00111 entryH 0010 entryL RET RETSK RETI Interrupt EI DI Others STOP HALT NOP 00111 00111 00111 00111 00111 00111 00111 00111 000 001 010 000 001 010 011 100 1110 1110 1110 1111 1111 1111 1111 1111 0000 0000 0000 0000 0000 s h 0000 335 PD17704, 17705, 17707, 17708, 17709 22.4 Assembler (RA17K) Embedded Macro Instruction Legend flag n : FLG symbol n <> : Bit number : Can be omitted Mnemonic Embedded macro SKTn SKFn SETn CLRn NOTn Operand flag 1, ... flag n flag 1, ... flag n flag 1, ... flag n flag 1, ... flag n flag 1, ... flag n Operation if (flag1) ~ (flag n) = all "1", then skip if (flag 1) ~ (flag n) = all "0", then skip (flag 1) ~ (flag n) 1 (flag 1) ~ (flag n) 0 if (flag n) = "0", then (flag n) 1 if (flag n) = "1", then (flag n) 0 if description = NOT flag n, then (flag n) 0 if description = flag n, then (flag n) 1 (BANK) n Label function-name function-name or expression INITFLGX INITFLG BANKn Expanded instruction BRX CALLX SYSCALX 336 PD17704, 17705, 17707, 17708, 17709 23. RESERVED SYMBOLS 23.1 Data Buffer (DBF) Symbol Name Attribute DBF3 DBF2 DBF1 DBF0 MEM MEM MEM MEM Value 0.0CH 0.0DH 0.0EH 0.0FH R/W R/W R/W R/W R/W Description Bits 15 through 12 of data buffer Bits 11 through 8 of data buffer Bits 7 through 4 of data buffer Bits 3 through 0 of data buffer 23.2 System Registers (SYSREG) Symbol Name Attribute AR3 AR2 AR1 AR0 WR BANK IXH MPH MPE IXM MPL IXL RPH RPL BCD PSW CMP CY Z IXE MEM MEM MEM MEM MEM MEM MEM MEM FLG MEM MEM MEM MEM MEM FLG MEM FLG FLG FLG FLG Value 0.74H 0.75H 0.76H 0.77H 0.78H 0.79H 0.7AH 0.7AH 0.7AH.3 0.7BH 0.7BH 0.7CH 0.7DH 0.7EH 0.7EH.0 0.7FH 0.7FH.3 0.7FH.2 0.7FH.1 0.7FH.0 R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W Description Bits 15 through 12 of address register Bits 11 through 8 of address register Bits 7 through 4 of address register Bits 3 through 0 of address register Window register Bank register Bits 10 through 8 of index register Bits 6 through 4 of memory pointer Memory pointer enable flag Bits 7 through 4 of index register Bits 3 through 0 of memory pointer Bits 3 through 0 of index register Bits 6 through 3 of general register pointer Bits 2 through 0 of general register pointer BCD operation flag Program status word Compare flag Carry flag Zero flag Index enable flag 337 PD17704, 17705, 17707, 17708, 17709 23.3 Port Registers Symbol Name Attribute P0A3 P0A2 P0A1 P0A0 P0B3 P0B2 P0B1 P0B0 P0C3 P0C2 P0C1 P0C0 P0D3 P0D2 P0D1 P0D0 P1A3 P1A2 P1A1 P1A0 P1B3 P1B2 P1B1 P1B0 P1C3 P1C2 P1C1 P1C0 FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG Value 0.70H.3 0.70H.2 0.70H.1 0.70H.0 0.71H.3 0.71H.2 0.71H.1 0.71H.0 0.72H.3 0.72H.2 0.72H.1 0.72H.0 0.73H.3 0.73H.2 0.73H.1 0.73H.0 1.70H.3 1.70H.2 1.70H.1 1.70H.0 1.71H.3 1.71H.2 1.71H.1 1.71H.0 1.72H.3 1.72H.2 1.72H.1 1.72H.0 R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W RNote RNote RNote RNote RNote RNote RNote RNote R/W R/W R/W R/W RNote RNote RNote R/W Bit 3 of port 0A Bit 2 of port 0A Bit 1 of port 0A Bit 0 of port 0A Bit 3 of port 0B Bit 2 of port 0B Bit 1 of port 0B Bit 0 of port 0B Bit 3 of port 0C Bit 2 of port 0C Bit 1 of port 0C Bit 0 of port 0C Bit 3 of port 0D Bit 2 of port 0D Bit 1 of port 0D Bit 0 of port 0D Bit 3 of port 1A Bit 2 of port 1A Bit 1 of port 1A Bit 0 of port 1A Bit 3 of port 1B Bit 2 of port 1B Bit 1 of port 1B Bit 0 of port 1B Bit 3 of port 1C Bit 2 of port 1C Bit 1 of port 1C Bit 0 of port 1C Description ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- Note These are input ports. However, even if an instruction that outputs data to these ports is described, the assembler and in-circuit emulator do not output an error message. Moreover, nothing is affected in terms of operation even if such an instruction is actually executed on the device. 338 PD17704, 17705, 17707, 17708, 17709 Symbol Name Attribute P1D3 P1D2 P1D1 P1D0 P2A2 P2A1 P2A0 P2B3 P2B2 P2B1 P2B0 P2C3 P2C2 P2C1 P2C0 P2D2 P2D1 P2D0 P3A3 P3A2 P3A1 P3A0 P3B3 P3B2 P3B1 P3B0 P3C3 P3C2 P3C1 P3C0 P3D3 P3D2 P3D1 P3D0 FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG Value 1.73H.3 1.73H.2 1.73H.1 1.73H.0 2.70H.2 2.70H.1 2.70H.0 2.71H.3 2.71H.2 2.71H.1 2.71H.0 2.72H.3 2.72H.2 2.72H.1 2.72H.0 2.73H.2 2.73H.1 2.73H.0 3.70H.3 3.70H.2 3.70H.1 3.70H.0 3.71H.3 3.71H.2 3.71H.1 3.71H.0 3.72H.3 3.72H.2 3.72H.1 3.72H.0 3.73H.3 3.72H.2 3.73H.1 3.73H.0 R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W Bit 3 of port 1D Bit 2 of port 1D Bit 1 of port 1D Bit 0 of port 1D Bit 2 of port 2A Bit 1 of port 2A Bit 0 of port 2A Bit 3 of port 2B Bit 2 of port 2B Bit 1 of port 2B Bit 0 of port 2B Bit 3 of port 2C Bit 2 of port 2C Bit 1 of port 2C Bit 0 of port 2C Bit 2 of port 2D Bit 1 of port 2D Bit 0 of port 2D Bit 3 of port 3A Bit 2 of port 3A Bit 1 of port 3A Bit 0 of port 3A Bit 3 of port 3B Bit 2 of port 3B Bit 1 of port 3B Bit 0 of port 3B Bit 3 of port 3C Bit 2 of port 3C Bit 1 of port 3C Bit 0 of port 3C Bit 3 of port 3D Bit 2 of port 3D Bit 1 of port 3D Bit 0 of port 3D Description ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- 339 PD17704, 17705, 17707, 17708, 17709 23.4 Register File (Control Registers) Symbol Name Attribute SP WDTCK MEM MEM Value 0.81H 0.82H R/W R/W R/W Stack pointer Watchdog timer clock selection flag (can be set only once after power application) Watchdog timer clock selection flag (can be set only once after power application) Watchdog timer clock selection flag (can be set only once after power application) Watchdog timer counter reset (when read: 0) DBF stack pointer Stack overflow/underflow reset selection flag (can be set only once after power application) Stack overflow/underflow reset selection flag (can be set only once after power application) Stack overflow/underflow reset selection flag (can be set only once after power application) CE reset timer carry counter CE reset timer carry counter CE reset timer carry counter CE reset timer carry counter MOVT bit selection flag MOVT bit selection flag System register stack pointer Serial interface 0 wait status judgment flag I2C bus slave transmission operation mode selection flag Serial interface 0 I/O clock selection flag Serial interface 0 I/O clock selection flag Serial interface 0 interrupt mode selection flag (dummy) Serial interface 0 interrupt mode selection flag (dummy) Serial interface 0 interrupt mode selection flag Serial interface 0 interrupt mode selection flag 8-count detection flag of serial interface 0 clock counter 9-count detection flag of serial interface 0 clock counter Serial interface 0 (I2C mode) communication status detection flag (1: Start condition detected) Serial interface 0 (I2C mode) communication status detection flag (1: Start condition detected, 0: Stop condition detected) Serial interface 0 (I2C mode) ACK signal setting/detection flag Serial interface 0 wait status setting/detection flag (1: Wait status released (no wait)) ---------------------------------------------------------------------------------------------- Description WDTCK1 FLG 0.82H.1 R/W ---------------------------------------------------------------------------------------------- WDTCK0 FLG 0.82H.0 R/W WDTRES DBFSP SPRSEL FLG MEM MEM 0.83H.3 0.84H 0.85H R/W R R/W ISPRES FLG 0.85H.1 R/W ---------------------------------------------------------------------------------------------- ASPRES FLG 0.85H.0 R/W CECNT3 CECNT2 CECNT1 CECNT0 MOVTSEL1 MOVTSEL0 SYSRSP SIO0WSTT SBMD SIO0CK1 SIO0CK0 SIO0IMD3 SIO0IMD2 SIO0IMD1 SIO0IMD0 SIO0SF8 SIO0SF9 SBSTT FLG FLG FLG FLG FLG FLG MEM FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG 0.86H.3 0.86H.2 0.86H.1 0.86H.0 0.87H.1 0.87H.0 0.88H 0.8AH.0 0.8BH.2 0.8BH.1 0.8BH.0 0.8CH.3 0.8CH.2 0.8CH.1 0.8CH.0 0.8DH.3 0.8DH.2 0.8DH.1 R/W R/W R/W R/W R/W R/W R R R/W R/W R/W R/W R/W R/W R/W R R R ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- SBBSY FLG 0.8DH.0 R SBACK SIO0NWT FLG FLG 0.8EH.3 0.8EH.2 R/W R/W ---------------------------------------------------------------------------------------------- SIO0WRQ1 SIO0WRQ0 FLG FLG 0.8EH.1 0.8EH.0 R/W R/W Bit 1 of serial interface 0 wait condition setting flag Bit 0 of serial interface 0 wait condition setting flag ---------------------------------------------------------------------------------------------- 340 PD17704, 17705, 17707, 17708, 17709 Symbol Name Attribute SIO0CH SB SIO0MS SIO0TX PLLSCNF PLLMD1 PLLMD0 PLLRFCK3 PLLRFCK2 PLLRFCK1 PLLRFCK0 PLLUL BEEP1SEL BEEP0SEL BEEP1CK1 BEEP1CK0 BEEP0CK1 BEEP0CK0 WDTCY BTM0CY BTM0CK1 BTM0CK0 SIO1TS SIO1HIZ SIO1CK1 SIO1CK0 IEG4 INT4SEL IEG3 INT3SEL IEG2 IEG1 IEG0 FCGCH1 FCGCH0 IFCGOSTT FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG Value 0.8FH.3 0.8FH.2 0.8FH.1 0.8FH.0 0.90H.3 0.90H.1 0.90H.0 0.91H.3 0.91H.2 0.91H.1 0.91H.0 0.92H.0 0.93H.1 0.93H.0 0.94H.3 0.94H.2 0.94H.1 0.94H.0 0.96H.0 0.97H.0 0.98H.1 0.98H.0 0.9DH.3 0.9DH.2 0.9DH.1 0.9DH.0 0.9EH.3 0.9EH.2 0.9EH.1 0.9EH.0 0.9FH.2 0.9FH.1 0.9FH.0 0.0A0H.1 0.0A0H.0 0.0A1H.0 R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W Description Serial interface 0 mode selection flag Serial interface 0 mode selection flag Serial interface 0 shift clock mode selection flag Serial interface 0 transmission (TX)/reception (RX) selection flag Swallow counter least significant bit setting flag PLL mode selection flag PLL mode selection flag PLL reference frequency selection flag PLL reference frequency selection flag PLL reference frequency selection flag PLL reference frequency selection flag ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- R&Reset PLL unlock FF flag R/W R/W R/W R/W R/W R/W R R R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R BEEP1/general-purpose port pin function selection flag BEEP0/general-purpose port pin function selection flag BEEP1 clock selection flag BEEP1 clock selection flag BEEP0 clock selection flag BEEP0 clock selection flag Watchdog timer/stack pointer reset status detection flag Basic timer 0 carry flag Basic timer 0 clock selection flag Basic timer 0 clock selection flag Serial interface 1 transmission/reception start flag Serial interface 1/general-purpose port selection flag Serial interface 1 I/O clock selection flag Serial interface 1 I/O clock selection flag Edge direction selection flag for INT4 pin interrupt request detection INT4 pin interrupt request flag setting disable Edge direction selection flag for INT3 pin interrupt request detection INT3 pin interrupt request flag setting disable Edge direction selection flag for INT2 pin interrupt request detection Edge direction selection flag for INT1 pin interrupt request detection Edge direction selection flag for INT0 pin interrupt request detection FGC channel selection flag FGC channel selection flag IF counter gate status detection flag (1: Open, 0: Closed) ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- 341 PD17704, 17705, 17707, 17708, 17709 Symbol Name Attribute IFCMD1 IFCMD0 IFCCK1 IFCCK0 IFCSTRT IFCRES ADCCH3 ADCCH2 ADCCH1 ADCCH0 ADCMD ADCSTT FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG Value 0.0A2H.3 0.0A2H.2 0.0A2H.1 0.0A2H.0 0.0A3H.1 0.0A3H.0 0.0A4H.3 0.0A4H.2 0.0A4H.1 0.0A4H.0 0.0A5H.2 0.0A5H.1 R/W R/W R/W R/W R/W W W R/W R/W R/W R/W R/W R Description IF counter mode selection flag (10: AMIF, 11: FCG) IF counter mode selection flag (00: CGP, 11: FMIF) IF counter clock selection flag IF counter clock selection flag IF counter count start flag IF counter reset flag A/D converter channel selection flag (dummy) A/D converter channel selection flag A/D converter channel selection flag A/D converter channel selection flag A/D converter compare mode selection flag A/D converter operation status detection flag (0: End of conversion, 1: Conversion in progress) A/D converter compare result detection flag PWM counter bit selection flag (0: 8 bits, 1: 9 bits) PWM timer output clock selection flag PWM2/general-purpose port pin function selection flag PWM1/general-purpose port pin function selection flag PWM0/general-purpose port pin function selection flag PWM/modulo timer 3 selection flag ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ADCCMP PWMBIT PWMCK PWM2SEL PWM1SEL PWM0SEL TM3SEL TM3EN FLG FLG FLG FLG FLG FLG FLG 0.0A5H.0 0.0A6H.2 0.0A6H.0 0.0A7H.2 0.0A7H.1 0.0A7H.0 0.0A8H.3 R R/W R/W R/W R/W R/W R/W ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- FLG 0.0A8H.1 R/W Modulo timer 3 count start flag TM3RES TM2EN TM2RES TM2CK1 TM2CK0 TM1EN TM1RES TM1CK1 TM1CK0 TM0EN TM0RES TM0CK1 TM0CK0 TM0OVF TM0GCEG TM0GOEG TM0MD FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG 0.0A8H.0 0.0A9H.3 0.0A9H.2 0.0A9H.1 0.0A9H.0 0.0AAH.3 0.0AAH.2 0.0AAH.1 0.0AAH.0 0.0ABH.3 0.0ABH.2 0.0ABH.1 0.0ABH.0 0.0ACH.3 0.0ACH.2 0.0ACH.1 0.0ACH.0 R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R R/W R/W R/W Modulo timer 3 reset flag (when read: 0) Modulo timer 2 count start flag Modulo timer 2 reset flag (when read: 0) Modulo timer 2 clock selection flag Modulo timer 2 clock selection flag Modulo timer 1 count start flag Modulo timer 1 reset flag (when read: 0) Modulo timer 1 clock selection flag Modulo timer 1 clock selection flag Modulo timer 0 count start flag Modulo timer 0 reset flag (when read: 0) Modulo timer 0 clock selection flag Modulo timer 0 clock selection flag Modulo timer 0 overflow detection flag Modulo timer 0 gate close input signal edge selection flag Modulo timer 0 gate open input signal edge selection flag Modulo timer 0 modulo counter/gate counter selection flag ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- 342 PD17704, 17705, 17707, 17708, 17709 Symbol Name Attribute IPSIO1 IPSIO0 IPTM3 IPTM2 IPTM1 IPTM0 IP4 IP3 IP2 IP1 IP0 IPCE IRQSIO1 IRQSIO0 IRQTM3 IRQTM2 IRQTM1 IRQTM0 INT4 IRQ4 INT3 IRQ3 INT2 IRQ2 INT1 IRQ1 INT0 IRQ0 CE CECNTSTT IRQCE P0DPLD3 P0DPLD2 P0DPLD1 P0DPLD0 FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG Value 0.0ADH.3 0.0ADH.2 0.0ADH.1 0.0ADH.0 0.0AEH.3 0.0AEH.2 0.0AEH.1 0.0AEH.0 0.0AFH.3 0.0AFH.2 0.0AFH.1 0.0AFH.0 0.0B4H.0 0.0B5H.0 0.0B6H.0 0.0B7H.0 0.0B8H.0 0.0B9H.0 0.0BAH.3 0.0BAH.0 0.0BBH.3 0.0BBH.0 0.0BCH.3 0.0BCH.0 0.0BDH.3 0.0BDH.0 0.0BEH.3 0.0BEH.0 0.0BFH.3 0.0BFH.1 0.0BFH.0 15.66H.3 15.66H.2 15.66H.1 15.66H.0 R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R R/W R R/W R R/W R R/W R R/W R R R/W R/W R/W R/W R/W Description Serial interface 1 interrupt enable flag Serial interface 0 interrupt enable flag PWM timer interrupt enable flag ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- Modulo timer 2 interrupt enable flag Modulo timer 1 interrupt enable flag Modulo timer 0 interrupt enable flag INT4 pin interrupt enable flag INT3 pin interrupt enable flag INT2 pin interrupt enable flag INT1 pin interrupt enable flag INT0 pin interrupt enable flag CE pin interrupt enable flag Serial interface 1 interrupt request detection flag Serial interface 0 interrupt request detection flag PWM timer interrupt request detection flag Modulo timer 2 interrupt request detection flag Modulo timer 1 interrupt request detection flag Modulo timer 0 interrupt request detection flag INT4 pin status detection flag INT4 pin interrupt request detection flag INT3 pin status detection flag INT3 pin interrupt request detection flag INT2 pin status detection flag INT2 pin interrupt request detection flag INT1 pin status detection flag INT1 pin interrupt request detection flag INT0 pin status detection flag INT0 pin interrupt request detection flag CE pin status detection flag CE reset counter status detection flag CE pin interrupt request detection flag P0D3 pin pull-down resistor selection flag P0D2 pin pull-down resistor selection flag P0D1 pin pull-down resistor selection flag P0D0 pin pull-down resistor selection flag ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- 343 PD17704, 17705, 17707, 17708, 17709 Symbol Name Attribute P3DGIO P3CGIO P3BGIO P3AGIO P2DBIO3 P2DBIO2 P2DBIO1 P2DBIO0 P2CBIO3 P2CBIO2 P2CBIO1 P2CBIO0 P2BBIO3 P2BBIO2 P2BBIO1 P2BBIO0 P2ABIO3 P2ABIO2 P2ABIO1 P2ABIO0 P1DBIO3 P1DBIO2 P1DBIO1 P1DBIO0 P0CBIO3 P0CBIO2 P0CBIO1 P0CBIO0 P0BBIO3 P0BBIO2 P0BBIO1 P0BBIO0 P0ABIO3 P0ABIO2 P0ABIO1 P0ABIO0 FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG FLG Value 15.67H.3 15.67H.2 15.67H.1 15.67H.0 15.68H.3 15.68H.2 15.68H.1 15.68H.0 15.69H.3 15.69H.2 15.69H.1 15.69H.0 15.6AH.3 15.6AH.2 15.6AH.1 15.6AH.0 15.6BH.3 15.6BH.2 15.6BH.1 15.6BH.0 15.6CH.3 15.6CH.2 15.6CH.1 15.6CH.0 15.6DH.3 15.6DH.2 15.6DH.1 15.6DH.0 15.6EH.3 15.6EH.2 15.6EH.1 15.6EH.0 15.6FH.3 15.6FH.2 15.6FH.1 15.6FH.0 R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W Description P3D input/output selection flag P3C input/output selection flag P3B input/output selection flag P3A input/output selection flag P2D3 input/output selection flag (dummy) P2D2 input/output selection flag P2D1 input/output selection flag P2D0 input/output selection flag P2C3 input/output selection flag P2C2 input/output selection flag P2C1 input/output selection flag P2C0 input/output selection flag P2B3 input/output selection flag P2B2 input/output selection flag P2B1 input/output selection flag P2B0 input/output selection flag P2A3 input/output selection flag (dummy) P2A2 input/output selection flag P2A1 input/output selection flag P2A0 input/output selection flag P1D3 input/output selection flag P1D2 input/output selection flag P1D1 input/output selection flag P1D0 input/output selection flag P0C3 input/output selection flag P0C2 input/output selection flag P0C1 input/output selection flag P0C0 input/output selection flag P0B3 input/output selection flag P0B2 input/output selection flag P0B1 input/output selection flag P0B0 input/output selection flag P0A3 input/output selection flag P0A2 input/output selection flag P0A1 input/output selection flag P0A0 input/output selection flag ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- 344 PD17704, 17705, 17707, 17708, 17709 23.5 Peripheral Hardware Registers Symbol Name Attribute ADCR SIO0SFR SIO1SFR TM0M TM0C TM1M TM1C TM2M TM2C AR DBFSTK PLLR IFC PWMR0 PWMR1 PWMR2 TM3M DAT DAT DAT DAT DAT DAT DAT DAT DAT DAT DAT DAT DAT DAT DAT DAT DAT Value 02H 03H 04H 1AH 1BH 1CH 1DH 1EH 1FH 40H 41H 42H 43H 44H 45H 46H 46H R/W R/W R/W R/W R/W R R/W R R/W R R/W R/W R/W R R/W R/W R/W R/W Description A/D converter reference voltage setting register Serial interface 0 presettable shift register Serial interface 1 presettable shift register Timer modulo 0 register Timer modulo 0 counter Timer modulo 1 register Timer modulo 1 counter Timer modulo 2 register Timer modulo 2 counter Address register DBF stack register PLL data register IF counter data register PWM0 data register PWM1 data register PWM2 data register Timer modulo 3 register 23.6 Others Symbol Name Attribute DBF IX AR_EPA1 AR_EPA0 DAT DAT DAT DAT Value 0FH 01H 8040H 4040H Description Operand of GET/PUT/MOVT/MOVTH/MOVL instruction (DBF) Operand of INC instruction (IX) Operand of CALL/BR/MOVT/MOVTH/MOVTL instruction (EPA bit on) Operand of CALL/BR/MOVT/MOVTH/MOVTL instruction (EPA bit off) 345 PD17704, 17705, 17707, 17708, 17709 24. ELECTRICAL CHARACTERISTICS Absolute Maximum Ratings (TA = 25 C) Parameter Supply voltage Input voltage Symbol VDD VI Other than CE, INT0 through INT4, and RESET pins CE, INT0 through INT4, and RESET pins Output voltage High-level output current VO IOH Except P1B0 through P1B3 1 pin Total of P2A0 through P2A2, P3A0 through P3A3, and P3B0 through P3B3 Total of P0A0 through P0A3, P0B0 through P0B3, P0C0 through P0C3, P1D0 through P1D3, P2B0 through P2B3, P2C0 through P2C3, P2D0 through P2D2, P3C0 through P3C3, and P3D0 through P3D3 Low-level output current IOL 1 pin of P1B0 through P1B3 1 pin of P1B0 through P1B3 Total of P2A0 through P2A2, P3A0 through P3A3, and P3B0 through P3B3 Total of P0A0 through P0A3, P0B0 through P0B3, P0C0 through P0C3, P1D0 through P1D3, P2B0 through P2B3, P2C0 through P2C3, P2D0 through P2D2, P3C0 through P3C3, and P3D0 through P3D3 Total of P1B0 through P1B3 pins Output voltage Total power dissipation Operating ambient temperature Storage temperature VBDS Pt TA P1B0-P1B3 25.0 mA Condition Rating -0.3 ~ +6.0 -0.3 ~ VDD+0.3 -0.3 ~ VDD+0.6 -0.3 ~ VDD+0.3 -8.0 -15.0 Unit V V V mA mA mA -25.0 mA 12.0 8.0 15.0 mA mA mA 25.0 14.0 200 -40 ~ +85 mA V mW C C Tstg -55 ~ +125 Caution If the rated value of even one of the above parameters is exceeded even momentarily, the quality of the product may be degraded. The absolute maximum ratings define the rated values exceeding which the product may be physically damaged. Never exceed these ratings. Recommended Operating Range (TA = -40 to +85 C) Parameter Supply voltage Symbol VDD1 VDD2 Condition When CPU and PLL are operating When CPU and PLL are stopped MIN. 4.5 3.5 TYP. 5.0 5.0 MAX. 5.5 5.5 Unit V V Recommended Output Voltage (TA = -40 to +85 C) Parameter Output voltage Symbol VBDS P1B0-P1B3 Condition MIN. TYP. MAX. 12 Unit V 346 PD17704, 17705, 17707, 17708, 17709 DC Characteristics (TA = -40 to +85 C, VDD = 3.5 to 5.5 V) Parameter Supply current Symbol IDD1 Condition When CPU is operating and PLL is stopped with sine wave input to XIN pin. (fIN = 4.5 MHz1%, VIN = VDD) When CPU and PLL are stopped with sine wave input to XIN pin. (fIN = 4.5 MHz1%, VIN = VDD) With HALT instruction Crystal oscillation Crystal oscillation stops Crystal oscillation stops P0A0, P0B1, P0C0-P0C3, P1A0, P1A1, P1C0-P1C3, P1D0-P1D3, P2A2, P2B0-P2B3, P2C0-P2C3, P2D0-P2D2, P3A0-P3A3, P3B0-P3B3, P3C0-P3C3, P3D0-P3D3 P0A1-P0A3, P0B0, P0B2, P0B3, P2A0, P2A1, CE, INT0-INT4, RESET P0D0-P0D3 P0A0, P0B1, P0C0-P0C3, P1A0, P1A1, P1C0-P1C3, P1D0-P1D3, P2A2, P2B0-P2B3, P2C0-P2C3, P2D0-P2D2, P3A0-P3A3, P3B0-P3B3, P3C0-P3C3, P3D0-P3D3 P0A1-P0A3, P0B0, P0B2, P0B3, P2A0, P2A1, CE, INT0-INT4, RESET P0D0-P0D3 P0A0-P0A3, P0B0-P0B3, P0C0-P0C3, P1D0-P1D3, P2A0-P2A2, P2B0-P2B3, P2C0-P2C3, P2D0-P2D2, P3A0-P3A3, P3B0-P3B3, P3C0-P3C3, P3D0-P3D3 VOH = VDD-1 V EO0, EO1 VDD = 4.5~5.5 V, VOH = VDD-1 V 0.7VDD Power failure detection by timer FF Data memory retained VDD = 5 V, TA = 25 C 3.5 2.2 2.0 2.0 2.0 MIN. TYP. 1.5 MAX. 3.0 Unit mA IDD2 0.7 1.5 mA Data retention voltage VDDR1 VDDR2 VDDR3 5.5 5.5 5.5 4.0 30.0 VDD V V V Data retention current IDDR1 IDDR2 A A V High-level input voltage VIH1 VIH2 0.8VDD VDD V VIH3 Low-level input voltage VIL1 0.55VDD 0 VDD 0.3VDD V V VIL2 0 0.2VDD V VIL3 High-level output current IOH1 0 -1.0 0.15VDD V mA IOH2 Low-level output current IOL1 -3.0 1.0 mA mA P0A0-P0A3, P0B0-P0B3, P0C0-P0C3, P1D0-P1D3, P2A0-P2A2, P2B0-P2B3, P2C0-P2C3, P2D0-P2D2, P3A0-PA3A, P3B0-P3B3, P3C0-P3C3, P3D0-P3D3 VOL = 1 V EO0, EO1 P1B0-P1B3 P0D0 through P0D3 pulled down P1B0-P1B3 EO0, EO1 Input pin VDD = 4.5 ~ 5.5 V, VOL = 1 V VOL = 1 V VIN = VDD VIN = 12 V VIN = VDD, VIN = 0 V VIN = VDD IOL2 IOL3 High-level input current Output off leakage current High-level input leakage current Low-level input leakage current IIH ILO1 ILO2 ILIH 3.0 7.0 5.0 150 1.0 1.0 1.0 mA mA A A A A A ILIL Input pin VIN = 0 V -1.0 347 PD17704, 17705, 17707, 17708, 17709 AC Characteristics (TA = -40 to +85 C, VDD = 5 V10%) Parameter Operating frequency Symbol fIN1 Condition VCOL pin, MF mode, sine wave input VIN = 0.1 Vp-pNote fIN2 VCOL pin, HF mode, sine wave input VIN = 0.1 Vp-pNote fIN3 VCOH pin, VHF mode, sine wave input VIN = 0.1 Vp-pNote AMIFC pin, sine wave input VIN = 0.15 Vp-pNote fIN5 FMIFC pin, FMIF count mode, sine wave input VIN = 0.20 Vp-p FMIFC pin, AMIF count mode, sine wave input VIN = 0.15 Vp-p External clock External clock 10 11 MHz 60 130 MHz 10 40 MHz MIN. 0.5 TYP. MAX. 3 Unit MHz fIN4 0.4 0.5 MHz fIN6 0.4 0.5 MHz SIO0 input frequency SIO1 input frequency fIN7 fIN8 1 0.7 MHz MHz Note The condition of sine wave input VIN = 0.1 Vp-p is the rated value when the PD17704, 17705, 17707, 17708, or 17709 alone is operating. Where influence of noise must be taken into consideration, operation under input amplitude condition of VIN = 0.15 Vp-p is recommended. A/D Converter Characteristics (TA = -40 to +85 C, VDD = 5 V10%) Parameter A/D conversion total error A/D conversion total error Symbol 8 BIT 8 BIT TA = 0 ~ 85 C Condition MIN. TYP. MAX. 3.0 2.5 Unit LSB LSB Reference Characteristics (TA = +25 C, VDD = 5.0 V) Parameter Supply current Symbol IDD3 Condition When CPU and PLL are operating with sine wave input to VCOH pin (fIN = 130 MHz, VIN = 0.3 Vp-p) MIN. TYP. 6.0 MAX. 12.0 Unit mA 348 PD17704, 17705, 17707, 17708, 17709 25. PACKAGE DRAWING 80 PIN PLASTIC QFP (14x14) A B 60 61 41 40 detail of lead end CD S Q R 80 1 21 20 F G H P I M J 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 C D F G H I J K L M N P Q R S MILLIMETERS 17.20.4 14.00.2 14.00.2 17.20.4 0.825 0.825 0.300.10 0.13 0.65 (T.P.) 1.60.2 0.80.2 0.15 +0.10 -0.05 0.10 2.7 0.10.1 55 3.0 MAX. INCHES 0.6770.016 0.551 +0.009 -0.008 0.551 +0.009 -0.008 0.6770.016 0.032 0.032 0.012 +0.004 -0.005 0.005 0.026 (T.P.) 0.0630.008 0.031 +0.009 -0.008 0.006 +0.004 -0.003 0.004 0.106 0.0040.004 55 0.119 MAX. S80GC-65-3B9-4 Remark The dimensions and materials of the ES model are the same as those of the mass-produced model. 349 PD17704, 17705, 17707, 17708, 17709 26. RECOMMENDED SOLDERING CONDITIONS Solder the PD17709 under the following recommended conditions. For the details of the recommended soldering conditions, refer to "Semiconductor Device Mounting Technology Manual" (C10535E). For the soldering method and conditions other than those recommended, consult NEC. Table 26-1. Soldering Conditions of Surface Mount Type PD17704GC-xxx-3B9: 80-pin plastic QFP (14 x 14 mm, 0.65 mm pitch) PD17705GC-xxx-3B9: 80-pin plastic QFP (14 x 14 mm, 0.65 mm pitch) PD17707GC-xxx-3B9: 80-pin plastic QFP (14 x 14 mm, 0.65 mm pitch) PD17708GC-xxx-3B9: 80-pin plastic QFP (14 x 14 mm, 0.65 mm pitch) PD17709GC-xxx-3B9: 80-pin plastic QFP (14 x 14 mm, 0.65 mm pitch) Symbol of Recommended Condition IR35-00-2 Soldering Method Soldering Condition Package peak temperature: 235 C, Time: 30 seconds MAX. (210 C MIN.) Number of times: 2 MAX. Package peak temperature: 215 C, Time: 40 seconds MAX. (200 C MIN.) Number of times: 2 MAX. Preheating temperature: 120 C MAX. (package surface temperature) Infrared reflow VPS VP15-00-2 Wave soldering Soldering bath temperature: 260 C MAX., Time: 10 seconds MAX., Number of times: 1, WS60-00-1 Pin temperature: 300 C MAX., Time: 3 seconds MAX. (per side of device) -- Partial heating Caution Do not use two or more soldering methods in combination (except partial heating method). 350 PD17704, 17705, 17707, 17708, 17709 APPENDIX A. CAUTIONS ON CONNECTING CRYSTAL RESONATOR When using the system clock oscillation circuit, wire the portion enclosed by the dotted line in the figure below as follows to prevent adverse influence from wiring capacity. * Keep the wiring length as short as possible. * If capacitances C1 and C2 are too high, the oscillation start characteristics may be degraded or current consumption may increase. * Generally, connect a trimmer capacitor for adjusting the oscillation frequency to the XIN pin. Depending on the crystal resonator to be used, however, the oscillation stability differs. Therefore, evaluate the crystal resonator actually used. * The crystal oscillation frequency cannot be accurately adjusted when an emulation probe is connected to the XOUT and XIN pin, because of the capacitance of the probe. Adjust the frequency while measuring the VCO oscillation frequency. PD17709 XOUT XIN 4.5-MHz crystal resonator C1 C2 351 PD17704, 17705, 17707, 17708, 17709 APPENDIX B. DEVELOPMENT TOOLS The following development tools are available for development of programs for the PD17709. Hardware Name In-circuit emulator IE-17K IE-17K-ETNote 1 EMU-17KNote 2 Outline IE-17K, IE-17K-ET, and EMU-17K are in-circuit emulators that can be used with any model in the 17K series. IE-17K and IE-17K-ET are connected to a host machine, which is PC-9800 series or IBM PC/ATTM, with RS-232C. EMU-17K is mounted to the expansion slot of a host machine, PC-9800 series. By using these in-circuit emulators with a system evaluation board (SE board) corresponding to each model, these emulators operate dedicated to the model. When man-machine interface software SIMPLEHOSTTM is used, a more sophisticated debugging environment can be created. EMU-17K also has a function to allow you to check the contents of the data memory real-time. SE-17709 is an SE board for the PD17709 subseries. This board can be used alone to evaluate a system, or in combination with an in-circuit emulator for debugging. EP-17K80GC is an emulation probe for the PD17709 subseries. By using this probe with EV9200GC-80Note 3, the SE board and target system are connected. EV-9200GC-80 is a conversion socket for 80-pin plastic QFP (14 x 14 mm). It is used to connect EP17K80GC and target system. PG-1500 is a PROM programmer supporting PD17P709. It can program PD17P709 when connected with PG-1500 adapter PA-17KDZ and programmer adapter PA-17P709GC. PA-17P709GC is an adapter to program PD17P709. It is used with PG-1500. SE board (SE-17709) Emulation probe (EP-17K80GC) Conversion socket (EV-9200GC-80Note 3) PROM programmer (PG-1500) Programmer adapter (PA-17P709GC) Notes 1. Low-price model: external power supply type 2. This is a product of I.C Corp. For details, consult I.C Corp. ((03) 3447-3793). 3. One EV-9200GC-80 is supplied with the EP-17K80GC. Five EV-9200GC-80 are also available as a set. Remark Third party PROM programmers AF-9703, AF-9704, AF-9705, and AF-9706 are available from Ando Electric Co., Ltd. Use these programmers with programmer adapter PA-17P709GC. For details, consult Ando Electric Co., Ltd. ((03) 3733-1163). 352 PD17704, 17705, 17707, 17708, 17709 Software Name 17K series assembler (AS17K) Outline AS17K is an assembler that can be commonly used with 17K series. To develop programs for the PD17709, this AS17K and a device file (AS17707) are used in combination. AS17707 is a device file for the PD17709 subseries. It is used with the assembler common to the 17K series (AS17K). Host Machine PC-9800 series OS MS-DOSTM Media 5" 2HD 3.5" 2HD IBM PC/AT PC DOSTM 5" 2HC 3.5" 2HC PC-9800 series MS-DOS 5" 2HD 3.5" 2HD IBM PC/AT PC DOS 5" 2HC 3.5" 2HC Parts Number S5A10AS17K S5A13AS17K S7B10AS17K S7B13AS17K S5A10AS17707 S5A13AS17707 S7B10AS17707 S7B13AS17707 S5A10IE17K S5A13IE17K S7B10IE17K S7B13IE17K Device file (AS17707) SIMPLEHOST is man-machine interface software that runs on software Windows TM when a program is (SIMPLEHOST) developed by using an in-circuit emulator and personal computer. Support PC-9800 series MS-DOS Windows 5" 2HD 3.5" 2HD IBM PC/AT PC DOS 5" 2HC 3.5" 2HC Remark The version of the supported OS is as follows: OS MS-DOS PC DOS Windows Version Ver.3.30 ~ Ver.5.00ANote Ver.3.1~Ver.5.0 Note Ver.3.0~Ver.3.1 Note MS-DOS Ver. 5.00/5.00A and PC DOS Ver. 5.0 have a task swap function, but this function cannot be used with this software. 353 PD17704, 17705, 17707, 17708, 17709 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. 354 PD17704, 17705, 17707, 17708, 17709 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.) Santa Clara, California Tel: 800-366-9782 Fax: 800-729-9288 NEC Electronics (Germany) GmbH Benelux Office Eindhoven, The Netherlands Tel: 040-2445845 Fax: 040-2444580 NEC Electronics Hong Kong Ltd. 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. NEC Electronics (France) S.A. Velizy-Villacoublay, 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 (UK) Ltd. Milton Keynes, UK Tel: 01908-691-133 Fax: 01908-670-290 NEC Electronics (France) S.A. Spain Office Madrid, Spain Tel: 01-504-2787 Fax: 01-504-2860 NEC Electronics Singapore Pte. Ltd. United Square, Singapore 1130 Tel: 253-8311 Fax: 250-3583 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: 08-63 80 820 Fax: 08-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. 8 355 PD17704, 17705, 17707, 17708, 17709 Purchase of NEC I2C components conveys a license under the Philips I2C Patent Rights to use these components in an I2C system, provided that the system conforms to the I2C Standard Specification as defined by Philips. SIMPLEHOST is a trademark of NEC Corporation. MS-DOS and Windows are trademarks of Microsoft Corporation. PC/AT and PC DOS are trademarks of IBM 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 2 |
Price & Availability of UPD17704
![]() |
|
|
All Rights Reserved © IC-ON-LINE 2003 - 2022 |
[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy] |
Mirror Sites : [www.datasheet.hk]
[www.maxim4u.com] [www.ic-on-line.cn]
[www.ic-on-line.com] [www.ic-on-line.net]
[www.alldatasheet.com.cn]
[www.gdcy.com]
[www.gdcy.net] |