To our customers,
Old Company Name in Catalogs and Other Documents
On April 1st, 2010, NEC Electronics Corporation merged with Renesas Technology Corporation, and Renesas Electronics Corporation took over all the business of both companies. Therefore, although the old company name remains in this document, it is a valid Renesas Electronics document. We appreciate your understanding.
Renesas Electronics website: http://www.renesas.com
April 1st, 2010 Renesas Electronics Corporation
Issued by: Renesas Electronics Corporation (http://www.renesas.com) Send any inquiries to http://www.renesas.com/inquiry.
Notice 1. All information included in this document is current as of the date this document is issued. Such information, however, is subject to change without any prior notice. Before purchasing or using any Renesas Electronics products listed herein, please confirm the latest product information with a Renesas Electronics sales office. Also, please pay regular and careful attention to additional and different information to be disclosed by Renesas Electronics such as that disclosed through our website. 2. Renesas Electronics does not assume any liability for infringement of patents, copyrights, or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or technical information described in this document. No license, express, implied or otherwise, is granted hereby under any patents, copyrights or other intellectual property rights of Renesas Electronics or others. 3. You should not alter, modify, copy, or otherwise misappropriate any Renesas Electronics product, whether in whole or in part. 4. Descriptions of circuits, software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples. You are fully responsible for the incorporation of these circuits, software, and information in the design of your equipment. Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the use of these circuits, software, or information. 5. When exporting the products or technology described in this document, you should comply with the applicable export control laws and regulations and follow the procedures required by such laws and regulations. You should not use Renesas Electronics products or the technology described in this document for any purpose relating to military applications or use by the military, including but not limited to the development of weapons of mass destruction. Renesas Electronics products and technology may not be used for or incorporated into any products or systems whose manufacture, use, or sale is prohibited under any applicable domestic or foreign laws or regulations. 6. Renesas Electronics has used reasonable care in preparing the information included in this document, but Renesas Electronics does not warrant that such information is error free. Renesas Electronics assumes no liability whatsoever for any damages incurred by you resulting from errors in or omissions from the information included herein. 7. Renesas Electronics products are classified according to the following three quality grades: “Standard”, “High Quality”, and “Specific”. The recommended applications for each Renesas Electronics product depends on the product’s quality grade, as indicated below. You must check the quality grade of each Renesas Electronics product before using it in a particular application. You may not use any Renesas Electronics product for any application categorized as “Specific” without the prior written consent of Renesas Electronics. Further, you may not use any Renesas Electronics product for any application for which it is not intended without the prior written consent of Renesas Electronics. Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for an application categorized as “Specific” or for which the product is not intended where you have failed to obtain the prior written consent of Renesas Electronics. The quality grade of each Renesas Electronics product is “Standard” unless otherwise expressly specified in a Renesas Electronics data sheets or data books, etc. “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. “High Quality”: 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”: Aircraft; aerospace equipment; submersible repeaters; nuclear reactor control systems; medical equipment or systems for life support (e.g. artificial life support devices or systems), surgical implantations, or healthcare intervention (e.g. excision, etc.), and any other applications or purposes that pose a direct threat to human life. 8. You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics, especially with respect to the maximum rating, operating supply voltage range, movement power voltage range, heat radiation characteristics, installation and other product characteristics. Renesas Electronics shall have no liability for malfunctions or damages arising out of the use of Renesas Electronics products beyond such specified ranges. 9. Although Renesas Electronics endeavors to improve the quality and reliability of its products, semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions. Further, Renesas Electronics products are not subject to radiation resistance design. Please be sure to implement safety measures to guard them against the possibility of physical injury, and injury or damage caused by fire in the event of the failure of a Renesas Electronics product, such as safety design for hardware and software including but not limited to redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other appropriate measures. Because the evaluation of microcomputer software alone is very difficult, please evaluate the safety of the final products or system manufactured by you. 10. Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product. Please use Renesas Electronics products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances, including without limitation, the EU RoHS Directive. Renesas Electronics assumes no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations. 11. This document may not be reproduced or duplicated, in any form, in whole or in part, without prior written consent of Renesas Electronics. 12. Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products, or if you have any other inquiries.
(Note 1) “Renesas Electronics” as used in this document means Renesas Electronics Corporation and also includes its majority- owned subsidiaries. (Note 2) “Renesas Electronics product(s)” means any product developed or manufactured by or for Renesas Electronics. 7517 Group REJ03B0087-0101Z SINGLE-CHIP 8-BIT CMOS MICROCOMPUTER Rev.1.01 Aug 02, 2004
DESCRIPTION Current integrator ...... 1 channel The 7517 group is the 8-bit microcomputer based on the 740 fam- Over current detector ...... 1 channel ily core technology. Watchdog timer ...... 16-bit ✕ 1 The 7517 group is designed for battery-pack and includes serial Clock generating circuit ...... Built-in 4 circuits interface functions, 8-bit timer, A/D converter, current integrator (built-in 4MHz on-chip oscillator and 32kHz RC oscillator, or con- and I2C-BUS interface. nect to external ceramic resonator or quartz-crystal oscillator) Power source voltage FEATURES In high-speed mode ...... 3.0 to 3.6 V Basic machine-language instructions ...... 71 (at 4 MHz oscillation frequency) Minimum instruction execution time ...... 1.0 µs In middle-speed mode...... 3.0 to 3.6 V (at 4 MHz oscillation frequency) (at 8 MHz oscillation frequency) Memory size In low-speed mode ...... 3.0 to 3.6 V Flash memory ...... 32 kbytes (at 32 kHz oscillation frequency) RAM ...... 1 kbytes Power dissipation Programmable input/output ports ...... 36 In high-speed mode ...... 8.25 mW Interrupts ...... 19 sources, 16 vectors (at 4 MHz oscillation frequency, at 3.3 V power source voltage) Timers ...... 8-bit ✕ 4 In low-speed mode ...... 660µW Serial I/O1 ...... 8-bit ✕ 1 (UART or Clock-synchronized) (at 32 kHz oscillation frequency, at 3.3 V power source voltage) Serial I/O2 ...... 8-bit ✕ 1(Clock-synchronized) Operating temperature range...... Ð20 to 85¡C Multi-master I2C-BUS interface (option) ...... 1 channel PWM ...... 8-bit ✕ 1 APPLICATION A/D converter ...... 10-bit ✕ 10 channels Battery-Pack, etc.
PIN CONFIGURATION (TOP VIEW)
)
)
1
0
7
4
9
8
6
5
CLK2
RDY2
IN2
OUT2
/AN
/AN
/(LED
/S
/S
/AN
/S /AN
/AN
/AN
/(LED
/S
5
4
1
2
3
7
0
6
4
5
0
1
P0
P3
P1
P0
P0
P0
P0 P0
P0
P3
P1
P0
25
36
27
31
34
32
29
26
33
28
35
30
P33/AN3 37 24 P12/(LED2)
P32/AN2 38 23 P13/(LED3)
P31/AN1 39 22 P14/(LED4)
P30/AN0 40 21 P15/(LED5)
ADVSS 41 20 P16/(LED6) ADVREF 42 M37517F8HP 19 P17/(LED7) VCC 43 18 VSS
AVCC 44 17 XOUT
AVSS 45 16 XIN ISENS0 46 15 RESET
ISENS1 47 14 P20/XCOUT
DFETCNT/P45 48 13 P21/XCIN
1
7
9
3
8
6
5
4
2
11
10 12
1
1
1
1
0
D
D
SS
X
X
CLK
RDY1
CMP2
/T
/R
/INT
/S
/INT
2
2
/SCL
2
/PWM
/SDA
6
1
/S
/S
3
3
CNV
2
0
2
/CNTR
0
P4
P2
P4
P2
P2
/SCL
/SDA
/INT
P4
5
/INT
4
4
3
/CNTR
P2
P2
P4
7
P4
P2
Package type : 48P6Q-A
Fig. 1 M37517F8HP pin configuration
Rev.1.01 Aug 02, 2004 page 1 of 96 7517 Group
FUNCTIONAL BLOCK
SI/O2(8)
34
33
P0(8)
I/O port P 0
27 28 29 30 31 32
Timer 1 (8)
Timer 2 (8)
Timer X (8)
Timer Y (8)
P1(8)
21 23 25
I/O port P 1
20 22 24 26
19
COUT
X
1
SS
CIN
12
X
Prescaler 12 (8)
Prescaler X (8)
Prescaler Y (8)
CNTR
CNV
P2(8)
0
7 9 11 14
I/O port P 2
681013
15
CNTR
RESET
Reset input
2
I C (8)
L
PS
A
X
Y
S
PC
SI/O1(8)
43
CC
V
C P U
H 0
39 40
PC
P3(6)
SS
36 38
18
V
35 37
I/O port P 3
R O M
3
- INT
0
INT
2
P4(6)
135
R A M
I/O port P 4
48 4
Reset
PWM (8)
COUT
X sub-clock output
REF
ADV
17
42
Main-clock output X
A/D
41
10-bit
SS
converter
ADV
IN OUT
16
X
input
CIN
AVcc
X sub-clock input
Clock generating circuit
44
Watchdog timer
AVss
45
Main-clock
46
Current
integrator
47
ISENS0
ISENS1
Over current detector
FUNCTIONAL BLOCK DIAGRAM
Fig. 2 Functional block diagram
Rev.1.01 Aug 02, 2004 page 2 of 96 7517 Group
PIN DESCRIPTION Table 1 Pin description
Pin Name Functions Function except a port function VCC, VSS Power source ¥Apply voltage of 3.3V to Vcc, and 0 V to Vss. AVCC Analog power ¥Apply voltage of 3.3V to AVcc, and 0 V to AVss and ADVss. AVSS source ADVSS ADVREF Analog reference ¥Reference voltage input pin for A/D converter. voltage
CNVSS CNVSS input ¥This pin controls the operation mode of the chip. ¥Normally connected to VSS. RESET Reset input ¥Reset input pin for active “L”. XIN Clock input ¥Input and output pins for the clock generating circuit. ¥Connect a ceramic resonator or quartz-crystal oscillator between the XIN and XOUT pins to set the oscillation frequency. XOUT Clock output ¥When an on-chip oscillator is used, leave the XIN pin and XOUT pin open. ¥When an external clock is used, connect the clock source to the XIN pin and leave the XOUT pin open. P00/SIN2 I/O port P0 ¥8-bit CMOS I/O port. ¥ Serial I/O2 function pin P01/SOUT2 ¥I/O direction register allows each pin to be individually P02/SCLK2 programmed as either input or output. P03/SRDY2 ¥CMOS compatible input level. P04/AN8ÐP07/AN11 ¥ A/D converter input pin ¥CMOS 3-state output structure. P10ÐP17 I/O port P1 ¥P10 to P17 (8 bits) are enabled to output large current for LED drive. P20/XCOUT I/O port P2 ¥8-bit CMOS I/O port. ¥ Sub-clock generating circuit I/O P21/XCIN ¥I/O direction register allows each pin to be individually pins (connect a resonator) P22/SDA1 programmed as either input or output. ¥ I2C-BUS interface function pin P23/SCL1 ¥CMOS compatible input level. P24/SDA2/RxD 2 ¥P22 to P25 can be switched between CMOS compat- ¥ I C-BUS interface function pin/ P25/SCL2/TxD ible input level or SMBUS input level in the I2C-BUS Serial I/O1 function pin P26/SCLK interface function. ¥ Serial I/O1 function pin P27/CNTR0/ ¥P20, P21, P24 to P27: CMOS3-state output structure. ¥ Serial I/O1 function pin/ RDY1 S ¥P24, P25: N-channel open-drain structure in the I2C- Timer X function pin BUS interface function. ¥P22, P23: N-channel open-drain structure. P30/AN0Ð I/O port P3 ¥8-bit CMOS I/O port with the same function as port P0. ¥ A/D converter input pin P35/AN5 ¥CMOS compatible input level. ¥CMOS 3-state output structure. P40/CNTR1 I/O port P4 ¥6-bit CMOS I/O port with the same function as port P0. ¥ Timer Y function pin P41/INT0 ¥CMOS compatible input level. ¥ Interrupt input pin P42/INT1 ¥CMOS 3-state output structure. P43/INT2/SCMP2 ¥ Interrupt input pin/SCMP2 output pin P44/INT3/PWM ¥ Interrupt input pin/PWM output pin P45/DFETCNT ¥ Over current detector function pin ISENS0 Analog input ¥Input pins for the current integrator and the over current detector. Connect these pins at both ISENS1 ends of a detection resistor, and connect ISENS0 to GND.
Rev.1.01 Aug 02, 2004 page 3 of 96 7517 Group
FUNCTIONAL DESCRIPTION [CPU Mode Register (CPUM)] 003B16 CENTRAL PROCESSING UNIT (CPU) The CPU mode register contains the stack page selection bit, etc. The 7517 group uses the standard 740 Family instruction set. Re- The CPU mode register is allocated at address 003B16. fer to the table of 740 Family addressing modes and machine instructions or the 740 Family Software Manual for details on the instruction set. Machine-resident 740 Family instructions are as follows: The FST and SLW instructions cannot be used. The STP, WIT, MUL, and DIV instructions can be used.
b7 b0
CPU mode register (CPUM : address 003B16)
Processor mode bits b1 b0 0 0 : Single-chip mode 01 : 1 0 : Not available 11 : Stack page selection bit 0 : 0 page 1 : 1 page Clock source switch bit 0 : On-chip oscillation function 1 : XCINÐXCOUT oscillation function
Port XC switch bit 0 : I/O port function (stop oscillating) 1 : XCINÐXCOUT oscillation function
Main clock (XINÐXOUT) stop bit 0 : Oscillating 1 : Stopped
Main clock division ratio selection bits b7 b6 00 : φ = f(XIN)/2 (high-speed mode) 01 : φ = f(XIN)/8 (middle-speed mode) 1 0 : φ = f(XCIN)/2 (low-speed mode) 1 1 : Not available
Note : All bits in this register are protected by protect mode.
Fig. 3 Structure of CPU mode register
Rev.1.01 Aug 02, 2004 page 4 of 96 7517 Group
MEMORY Interrupt Vector Area Special Function Register (SFR) Area The interrupt vector area contains reset and interrupt vectors. The Special Function Register area in the zero page contains con- trol registers such as I/O ports and timers. Zero Page Access to this area with only 2 bytes is possible in the zero page RAM addressing mode. RAM is used for data storage and for stack area of subroutine calls and interrupts. Special Page Access to this area with only 2 bytes is possible in the special Flash Memory page addressing mode. The first 128 bytes and the last 2 bytes of flash memory are re- served for device testing and the rest is user area for storing programs.
000016 SFR area
004016 Zero page RAM 1024 bytes 010016
044016 Not used 0FFD16 SFR area 0FFF16 Not used 800016 Flash memory Reserved memory area 32 kbytes (128 bytes)
808016
FF0016
FFD416 Flash memory ID code FFDC16 Special page Interrupt vector area
FFFE16 Reserved memory area FFFF16
Fig. 4 Memory map diagram
Rev.1.01 Aug 02, 2004 page 5 of 96 7517 Group
000016 Port P0 (P0) 002016 Prescaler 12 (PRE12)
000116 Port P0 direction register (P0D) 002116 Timer 1 (T1)
000216 Port P1 (P1) 002216 Timer 2 (T2)
000316 Port P1 direction register (P1D) 002316 Timer XY mode register (TM)
000416 Port P2 (P2) 002416 Prescaler X (PREX)
000516 Port P2 direction register (P2D) 002516 Timer X (TX)
000616 Port P3 (P3) 002616 Prescaler Y (PREY)
000716 Port P3 direction register (P3D) 002716 Timer Y (TY)
000816 Port P4 (P4) 002816 Timer count source selection register (TCSS)
000916 Port P4 direction register (P4D) 002916 SFR protect control register (PRREG)
000A16 Discharge counter latch low-order register (DCHARGEL) 002A16 Reserved ✽
000B16 Discharge counter latch high-order register (DCHARGEH) 002B16 I2C data shift register (S0) 2 000C16 Charge counter latch low-order register (CHARGEL) 002C16 I C address register (S0D) 2 000D16 Charge counter latch high-order register (CHARGEH) 002D16 I C status register (S1) 2 000E16 Current integrator control register (CINFCON) 002E16 I C control register (S1D) 2 000F16 Short current detector control register (SCDCON) 002F16 I C clock control register (S2) 2 001016 Over current detector control register (OCDCON) 003016 I C start/stop condition control register (S2D) 2 001116 Current detect time set up register (OCDTIME) 003116 I C additional function register (S3)
001216 Wake up current detector control register1 (WUDCON1) 003216 32kHz oscillation control register 0 (32KOSCC0)
001316 Current detect status register (OCDSTS) 003316 32kHz oscillation control register 1 (32KOSCC1)
001416 Wake up current detector control register2 (WUDCON2) 003416 A/D control register (ADCON)
001516 Serial I/O2 control register 1 (SIO2CON1) 003516 A/D conversion low-order register (ADL)
001616 Serial I/O2 control register 2 (SIO2CON2) 003616 A/D conversion high-order register (ADH)
001716 Serial I/O2 register (SIO2) 003716 MISRG2
001816 Transmit/Receive buffer register (TB/RB) 003816 MISRG
001916 Serial I/O1 status register (SIOSTS) 003916 Watchdog timer control register (WDTCON)
001A16 Serial I/O1 control register (SIOCON) 003A16 Interrupt edge selection register (INTEDGE)
001B16 UART control register (UARTCON) 003B16 CPU mode register (CPUM)
001C16 Baud rate generator (BRG) 003C16 Interrupt request register 1 (IREQ1)
001D16 PWM control register (PWMCON) 003D16 Interrupt request register 2 (IREQ2)
001E16 PWM prescaler (PREPWM) 003E16 Interrupt control register 1 (ICON1)
001F16 PWM register (PWM) 003F16 Interrupt control register 2 (ICON2)
0FFD16 Reserved ✽
0FFE16 Flash memory control register (FCON)
✽ Reserved : Do not write any data to the reserved area. 0FFF16 Reserved ✽
Fig. 5 Memory map of special function register (SFR)
Rev.1.01 Aug 02, 2004 page 6 of 96 7517 Group
I/O PORTS If data is read from a pin which is set to output, the value of the The I/O ports have direction registers which determine the input/ port output latch is read, not the value of the pin itself. Pins set to output direction of each individual pin. Each bit in a direction reg- input are floating. If a pin set to input is written to, only the port ister corresponds to one pin, and each pin can be set to be input output latch is written to and the pin remains floating. port or output port. When “0” is written to the bit corresponding to a pin, that pin be- comes an input pin. When “1” is written to that bit, that pin becomes an output pin.
Table 2 I/O port function Pin Name Input/Output I/O Structure Non-Port Function Related SFRs Ref.No. P00/SIN2 Port P0 Input/output, CMOS compatible Serial I/O2 function I/O Serial I/O2 control (1) P01/SOUT2 individual input level register (2) P02/SCLK2 bits CMOS 3-state output (3) P03/SRDY2 (4) P04/AN8ÐP07/AN11 A/D conversion input A/D control register, MISRG2 (5) P10ÐP17 Port P1 (6) P20/XCOUT Port P2 Sub-clock generating CPU mode register (7) P21/XCIN circuit MISRG2 (8) 2 (9) P22/SDA1 CMOS compatible I2C-BUS interface func- I C control register (10) P23/SCL1 input level tion I/O CMOS/SMBUS input level (when selecting I2C-BUS interface function) N-channel open-drain output P24/SDA2/RxD CMOS compatible 2 (11) I2C-BUS interface func- I C control register P25/SCL2/TxD input level tion I/O Serial I/O1 control (12) CMOS/SMBUS input register level (when selecting Serial I/O1 function I/O I2C-BUS interface function) CMOS 3-state output N-channel open-drain output (when selecting I2C-BUS interface function) P26/SCLK CMOS compatible Serial I/O1 function I/O Serial I/O1 control (13) input level register P27/CNTR0/ CMOS 3-state output Serial I/O1 function I/O Serial I/O1 control (14) SRDY1 Timer X function I/O register Timer XY mode register P30/AN0Ð Port P3 A/D conversion input A/D control register (5) P35/AN5 MISRG2 P40/CNTR1 Port P4 Timer Y function I/O Timer XY mode register (15) P41/INT0 External interrupt input Interrupt edge selection (16) P42/INT1 register P43/INT2/SCMP2 External interrupt input Interrupt edge selection (17) register SCMP2 output Serial I/O2 control register P44/INT3/PWM External interrupt input Interrupt edge selection (18) PWM output register PWM control register P45/DFETCNT Over current detector Short current detect (19) output control register Over current detect control register Wake up current detect control register
Rev.1.01 Aug 02, 2004 page 7 of 96 7517 Group
(1) Port P00 (2) Port P01
P01/SOUT2 P-channel output Direction disable bit register Serial I/O2 transmit completion signal Serial I/O2 port selection bit Data bus Port latch Direction register
Data bus Port latch
Serial I/O2 input
Serial I/O2 output
(3) Port P02
(4) Port P03 P02/SCLK2 P-channel output disable bit Serial I/O2 synchronous clock selection bit SRDY2 output enable bit Serial I/O2 port selection bit Direction Direction register register
Data bus Port latch Data bus Port latch
Serial I/O2 ready output Serial I/O2 clock output Serial I/O2 external clock input
(5) Ports P04ÐP07, P30ÐP35 (6) Port P1
Direction register Direction register
Data bus Port latch Data bus Port latch
A/D converter input Analog input pin selection bit
(7) Port P20 (8) Port P21
Port XC switch bit Port XC switch bit Direction Direction register register
Data bus Port latch Data bus Port latch
Port P21 32kHz RC oscillation enable bit Sub-clock generating circuit input Port Xc switch bit 32kHz RC oscillation enable bit - Reference + voltage
Fig. 6 Port block diagram (1)
Rev.1.01 Aug 02, 2004 page 8 of 96 7517 Group
(9) Port P22 (10) Port P23 I2C-BUS interface enable bit I2C-BUS interface enable bit SDA/SCL pin selection bit SDA/SCL pin selection bit
Direction Direction register register
Data bus Port latch Data bus Port latch
SDA output SCL output SDA input SCL input
(11) Port P24 (12) Port P25 I2C-BUS interface enable bit P-channel output disable bit SDA/SCL pin selection bit Serial I/O1 enable bit Serial I/O1 enable bit Transmit enable bit Receive enable bit I2C-BUS interface enable bit SDA/SCL pin selection bit Direction Direction register register
Data bus Port latch Data bus Port latch
SDA output SDA input Serial I/O1 input Serial I/O1 output SCL input
SCL output
(13) Port P26 (14) Port P27 Pulse output mode Serial I/O1 synchronous clock Serial I/O1 mode selection bit selection bit Serial I/O1 enable bit Serial I/O1 enable bit SRDY1 output enable bit Serial I/O1 mode selection bit Direction Serial I/O1 enable bit register Direction register Data bus Port latch Data bus Port latch
Pulse output mode
Serial I/O1 ready CNTR0 interrupt Serial I/O1 clock output output input Serial I/O1 external Timer output clock input
(16) Ports P41, P42 (15) Port P40
Direction Direction register register
Data bus Port latch Data bus Port latch
Pulse output mode Timer output Interrupt input CNTR1 interrupt input
Fig. 7 Port block diagram (2)
Rev.1.01 Aug 02, 2004 page 9 of 96 7517 Group
(17) Port P43 (18) Port P44 PWM output enable bit Serial I/O2 input/output comparison signal control bit Direction register Direction register Data bus Port latch
Data bus Port latch
PWM output
Serial I/O2 input/output Interrupt input comparison signal output
Interrupt input
(19) Port P45 Short current detect enable bit Over current detect enable bit Wake up current detect enable bit Direction register
Data bus Port latch
DFETCNT output
Fig. 8 Port block diagram (3)
Rev.1.01 Aug 02, 2004 page 10 of 96 7517 Group
INTERRUPTS ■Notes Interrupts occur by 16 sources among 19 sources: seven external, When the active edge of an external interrupt (INT0ÐINT3, SCL/ eleven internal, and one software. SDA, CNTR0, CNTR1) is set, the corresponding interrupt request bit may also be set. Therefore, take the following sequence: Interrupt Control Each interrupt is controlled by an interrupt request bit, an interrupt 1. Disable the interrupt. enable bit, and the interrupt disable flag except for the software in- 2. Set the interrupt edge selection register terrupt set by the BRK instruction. An interrupt occurs if the (SCL/SDA interrupt pin polarity selection bit for SCL/SDA; the corresponding interrupt request and enable bits are “1” and the in- timer XY mode register for CNTR0 and CNTR1). terrupt disable flag is “0”. 3. Set the interrupt request bit to “0”. Interrupt enable bits can be set or cleared by software. 4. Accept the interrupt. Interrupt request bits can be cleared by software, but cannot be set by software. The BRK instruction cannot be disabled with any flag or bit. The I (interrupt disable) flag disables all interrupts except the BRK in- struction interrupt. When several interrupts occur at the same time, the interrupts are received according to priority.
Interrupt Operation By acceptance of an interrupt, the following operations are auto- matically performed: 1. The contents of the program counter and the processor status register are automatically pushed onto the stack. 2. The interrupt disable flag is set and the corresponding interrupt request bit is cleared. 3. The interrupt jump destination address is read from the vector table into the program counter.
Rev.1.01 Aug 02, 2004 page 11 of 96 7517 Group
Table 3 Interrupt vector addresses and priority
Vector Addresses (Note 1) Interrupt Request Interrupt Source Priority Remarks High Low Generating Conditions Reset (Note 2) 1 FFFD16 FFFC16 At reset Non-maskable At detection of either rising or External interrupt INT0 2 FFFB16 FFFA16 falling edge of INT0 input (active edge selectable) At detection of either rising or External interrupt SCL, SDA 3 FFF916 FFF816 falling edge of SCL or SDA input (active edge selectable) At detection of either rising or External interrupt INT1 16 FFF616 4 FFF7 falling edge of INT1 input (active edge selectable) At detection of either rising or External interrupt 2 5 FFF516 FFF416 INT falling edge of INT2 input (active edge selectable) At detection of either rising or External interrupt INT3 falling edge of INT3 input (active edge selectable) 6 FFF316 FFF216 At completion of serial I/O2 data Serial I/O2 Valid when serial I/O2 is selected reception I2C 7 FFF116 FFF016 At completion of data transfer Timer X 8 FFEF16 FFEE16 At timer X underflow Timer Y 9 FFED16 FFEC16 At timer Y underflow Timer 1 10 FFEB16 FFEA16 At timer 1 underflow STP release timer underflow Timer 2 11 FFE916 FFE816 At timer 2 underflow Serial I/O1 At completion of serial I/O1 data 12 FFE716 FFE616 Valid when serial I/O1 is selected reception reception At completion of serial I/O1 Serial I/O1 transfer shift or when transmis- Valid when serial I/O1 is selected transmission sion buffer is empty 13 FFE516 FFE416 At short current is detected, at Valid when short current detector Over current over current is detected, or at or over current detector, or wake detection wake up current is detected. up current detector is selected. At detection of either rising or External interrupt CNTR0 14 FFE316 FFE216 falling edge of CNTR0 input (active edge selectable) At detection of either rising or External interrupt CNTR1 15 FFE116 FFE016 falling edge of CNTR1 input (active edge selectable) A/D converter At completion of A/D conversion 16 FFDF16 FFDE16 At end of current integration Valid when current integrator is Current integration period, or at end of calibration selected BRK instruction 17 FFDD16 FFDC16 At BRK instruction execution Non-maskable software interrupt Notes 1: Vector addresses contain interrupt jump destination addresses. 2: Reset function in the same way as an interrupt with the highest priority.
Rev.1.01 Aug 02, 2004 page 12 of 96 7517 Group
Interrupt request bit Interrupt enable bit
Interrupt disable flag (I)
BRK instruction Interrupt request Reset
Fig. 9 Interrupt control
b7 b0 Interrupt edge selection register (INTEDGE : address 003A16)
INT0 active edge selection bit INT1 active edge selection bit 0 : Falling edge active INT2 active edge selection bit 1 : Rising edge active INT3 active edge selection bit Serial I/O2 / INT3 interrupt source bit 0 : INT3 interrupt selected 1 : Serial I/O2 interrupt selected Current integrate/A/D converter interrupt source bit 0 : AD converter interrupt selected 1 : Current integrate interrupt selected Over current detect / Serial I/O1 transmit interrupt source bit 0 : Serial I/O1 transmit interrupt selected 1 : Over current detect interrupt selected Not used (returns “0” when read)
b7 b0 Interrupt request register 1 b7 b0 Interrupt request register 2 (IREQ1 : address 003C16) (IREQ2 : address 003D16)
INT0 interrupt request bit Timer 1 interrupt request bit SCL/SDA interrupt request bit Timer 2 interrupt request bit INT1 interrupt request bit Serial I/O1 reception interrupt request bit INT2 interrupt request bit Serial I/O1 transmit / Over current detect interrupt request bit INT3 / Serial I/O2 interrupt request bit CNTR0 interrupt request bit 2 I C interrupt request bit CNTR1 interrupt request bit Timer X interrupt request bit AD converter /current integrate interrupt request bit Timer Y interrupt request bit Not used (returns “0” when read) 0 : No interrupt request issued 0 : No interrupt request issued 1 : Interrupt request issued 1 : Interrupt request issued
b7 b0 b7 b0 Interrupt control register 1 Interrupt control register 2 (ICON1 : address 003E16) (ICON2 : address 003F16)
INT0 interrupt enable bit Timer 1 interrupt enable bit SCL/SDA interrupt enable bit Timer 2 interrupt enable bit INT1 interrupt enable bit Serial I/O1 reception interrupt enable bit INT2 interrupt enable bit Serial I/O1 transmit / Over current detect interrupt enable bit INT3 / Serial I/O2 interrupt enable bit CNTR0 interrupt enable bit I2C interrupt enable bit CNTR1 interrupt enable bit Timer X interrupt enable bit AD converter / current integrate interrupt enable bit Timer Y interrupt enable bit Not used (returns “0” when read) (Do not write “1” to this bit) 0 : Interrupts disabled 0 : Interrupts disabled 1 : Interrupts enabled 1 : Interrupts enabled
Fig. 10 Structure of interrupt-related registers (1)
Rev.1.01 Aug 02, 2004 page 13 of 96 7517 Group
TIMERS Timer 1 and Timer 2 The 7517 group has four timers: timer X, timer Y, timer 1, and The count source of prescaler 12 is the oscillation frequency timer 2. which is selected by timer 12 count source selection bit. The out- The division ratio of each timer or prescaler is given by 1/(n + 1), put of prescaler 12 is counted by timer 1 and timer 2, and a timer where n is the value in the corresponding timer or prescaler latch. underflow sets the interrupt request bit. All timers are count down. When the timer reaches “0016”, an un- derflow occurs at the next count pulse and the corresponding Timer X and Timer Y timer latch is reloaded into the timer and the count is continued. Timer X and Timer Y can each select in one of four operating When a timer underflows, the interrupt request bit corresponding modes by setting the timer XY mode register. to that timer is set to “1”. (1) Timer Mode The timer counts the count source selected by Timer count source selection bit.
b7 b0 (2) Pulse Output Mode Timer XY mode register The timer counts the count source selected by Timer count source (TM : address 002316) selection bit. Whenever the contents of the timer reach “0016”, the Timer X operating mode bits b1b0 signal output from the CNTR0 (or CNTR1) pin is inverted. If the 0 0: Timer mode 0 1: Pulse output mode CNTR0 (or CNTR1) active edge selection bit is “0”, output begins 1 0: Event counter mode 1 1: Pulse width measurement mode at “ H”.
CNTR0 active edge selection bit If it is “1”, output starts at “L”. When using a timer in this mode, set 0: Interrupt at falling edge Count at rising edge in event the corresponding port P27 ( or port P40) direction register to out- counter mode 1: Interrupt at rising edge put mode. Count at falling edge in event counter mode Timer X count stop bit (3) Event Counter Mode 0: Count start 1: Count stop Operation in event counter mode is the same as in timer mode, except that the timer counts signals input through the CNTR0 or Timer Y operating mode bits b5b4 0 0: Timer mode CNTR1 pin. 0 1: Pulse output mode 1 0: Event counter mode When the CNTR0 (or CNTR1) active edge selection bit is “0”, the 1 1: Pulse width measurement mode rising edge of the CNTR0 (or CNTR1) pin is counted. CNTR1 active edge selection bit 0: Interrupt at falling edge When the CNTR0 (or CNTR1) active edge selection bit is “1”, the Count at rising edge in event counter mode falling edge of the CNTR0 (or CNTR1) pin is counted. 1: Interrupt at rising edge Count at falling edge in event counter mode (4) Pulse Width Measurement Mode Timer Y count stop bit 0: Count start If the CNTR0 (or CNTR1) active edge selection bit is “0”, the timer 1: Count stop counts the selected signals by the count source selection bit while the CNTR0 (or CNTR1) pin is at “H”. If the CNTR0 (or CNTR1) ac- tive edge selection bit is “1”, the timer counts it while the CNTR0 Fig. 11 Structure of timer XY mode register (or CNTR1) pin is at “L”.
The count can be stopped by setting “1” to the timer X (or timer Y) b7 b0 Timer count source selection register count stop bit in any mode. The corresponding interrupt request (TCSS : address 002816) bit is set each time a timer underflows. Timer X count source selection bit 0 : f(XIN)/16 (f(XCIN)/16 at low-speed mode) 1 : f(XIN)/2 (f(XCIN)/2 at low-speed mode) Timer Y count source selection bit ■Note 0 : f(XIN)/16 (f(XCIN)/16 at low-speed mode) 1 : f(XIN)/2 (f(XCIN)/2 at low-speed mode) When switching the count source by the timer 12, X or Y count Timer 12 count source selection bit source bit, the value of timer count is altered in inconsiderable 0 : f(XIN)/16 (f(XCIN)/16 at low-speed mode) 1 : f(XCIN) amount owing to generating of a thin pulses in the count input Not used (returns “0” when read) signals. Therefore, select the timer count source before set the value to Fig. 12 Structure of timer count source selection register the prescaler and the timer.
Rev.1.01 Aug 02, 2004 page 14 of 96 7517 Group
Data bus
f(XIN)/16 Prescaler X latch (8) Timer X latch (8) f(XIN)/2 Pulse width Timer mode Timer X count source selection bit measurement Pulse output mode mode To timer X interrupt Prescaler X (8) Timer X (8) request bit CNTR0 active Event edge selection Timer X count stop bit P27/CNTR0 counter “0” bit mode To CNTR0 interrupt request bit “1” CNTR0 active edge selection “1” Q bit Toggle flip-flop T Q “0” R Timer X latch write pulse Port P27 Port P27 latch Pulse output mode direction register Pulse output mode
Data bus
f(XIN)/16 Prescaler Y latch (8) Timer Y latch (8) f(XIN)/2 Pulse width Timer mode Timer Y count source selection bit measure- ment mode Pulse output mode Prescaler Y (8) Timer Y (8) To timer Y interrupt CNTR1 active request bit Event Timer Y count stop bit P40/CNTR1 edge selection “0 ” bit counter mode To CNTR1 interrupt “1” request bit CNTR1 active edge selection “1” Q bit Toggle flip-flop T Q “0” R Port P40 Timer Y latch write pulse Port P40 latch Pulse output mode direction register Pulse output mode
Data bus
Prescaler 12 latch (8) Timer 1 latch (8) Timer 2 latch (8)
f(XIN)/16 Prescaler 12 (8) Timer 1 (8) Timer 2 (8) To timer 2 interrupt f(XCIN) request bit Timer 12 count source selection bit
To timer 1 interrupt request bit
Fig. 13 Block diagram of timer X, timer Y, timer 1, and timer 2
Rev.1.01 Aug 02, 2004 page 15 of 96 7517 Group
SERIAL I/O1 (1) Clock Synchronous Serial I/O Mode Serial I/O1 can be used as either clock synchronous or asynchro- Clock synchronous serial I/O mode can be selected by setting the nous (UART) serial I/O. A dedicated timer is also provided for serial I/O1 mode selection bit of the serial I/O1 control register (bit baud rate generation. 6 of address 001A16) to “1”. For clock synchronous serial I/O, the transmitter and the receiver must use the same clock. If an internal clock is used, transfer is started by a write signal to the TB/RB.
Data bus
Serial I/O1 control register Address 001A16 Address 001816 Receive buffer register Receive buffer full flag (RBF)
P24/RXD Receive shift register Receive interrupt request (RI)
Shift clock Clock control circuit
P26/SCLK Serial I/O1 synchronous clock selection bit BRG count source selection bit Frequency division ratio 1/(n+1) XIN Baud rate generator 1/4 Address 001C16 1/4
Clock control circuit P27/SRDY1 F/F Falling-edge detector Shift clock Transmit shift completion flag (TSC) Transmit interrupt source selection bit P25/TXD Transmit shift register Transmit interrupt request (TI)
Transmit buffer register Transmit buffer empty flag (TBE)
Serial I/O1 status register Address 001916 Address 001816 Data bus
Fig. 14 Block diagram of clock synchronous serial I/O1
Transfer shift clock (1/2 to 1/2048 of the internal clock, or an external clock)
Serial output TxD D0 D1 D2 D3 D4 D5 D6 D7
Serial input RxD D0 D1 D2 D3 D4 D5 D6 D7
Receive enable signal SRDY1
Write pulse to receive/transmit buffer register (address 001816)
TBE = 0 RBF = 1 TBE = 1 TSC = 1 TSC = 0 Overrun error (OE) detection
Notes 1: As the transmit interrupt (TI), either when the transmit buffer has emptied (TBE=1) or after the transmit shift operation has ended (TSC=1), by setting the transmit interrupt source selection bit (TIC) of the serial I/O1 control register. 2: If data is written to the transmit buffer register when TSC=0, the transmit clock is generated continuously and serial data is output continuously from the TxD pin. 3: The receive interrupt (RI) is set when the receive buffer full flag (RBF) becomes “1” .
Fig. 15 Operation of clock synchronous serial I/O1 function
Rev.1.01 Aug 02, 2004 page 16 of 96 7517 Group
(2) Asynchronous Serial I/O(UART) Mode two buffers have the same address in memory. Since the shift reg- Clock asynchronous serial I/O mode (UART) can be selected by ister cannot be written to or read from directly, transmit data is clearing the serial I/O1 mode selection bit (b6) of the serial I/O1 written to the transmit buffer register, and receive data is read control register to “0”. from the receive buffer register. Eight serial data transfer formats can be selected, and the transfer The transmit buffer register can also hold the next data to be formats used by a transmitter and receiver must be identical. transmitted, and the receive buffer register can hold a character The transmit and receive shift registers each have a buffer, but the while the next character is being received.
Data bus
Address 001816 Serial I/O1 control register Address 001A16 OE Receive buffer register Receive buffer full flag (RBF) Character length selection bit Receive interrupt request (RI) P24/RXD ST detector 7 bits Receive shift register 8 bits 1/16 PE FE SP detector UART control register Clock control circuit Address 001B16
Serial I/O1 synchronous clock selection bit P26/SCLK1
BRG count source selection bit Frequency division ratio 1/(n+1) XIN Baud rate generator 1/4 Address 001C16 ST/SP/PA generator
1/16 Transmit shift completion flag (TSC) Transmit interrupt source selection bit P25/TXD Transmit shift register Transmit interrupt request (TI) Character length selection bit Transmit buffer register Transmit buffer empty flag (TBE) Serial I/O1 status register Address 001916 Address 001816 Data bus
Fig. 16 Block diagram of UART serial I/O1
Rev.1.01 Aug 02, 2004 page 17 of 96 7517 Group
Transmit or receive clock
Transmit buffer write signal
TBE=0 TBE=0 TSC=0 TBE=1 TBE=1 TSC=1
Serial output TXD ST D0 D1 SP ST D0 D1 SP
1 start bit Generated at 2nd bit in 2-stop-bit mode 7 or 8 data bit 1 or 0 parity bit Receive buffer read 1 or 2 stop bit (s) signal
RBF=0 RBF=1 RBF=1
ST Serial input RXD D0 D1 SP ST D0 D1 SP
Notes 1: Error flag detection occurs at the same time that the RBF flag becomes “1” (at 1st stop bit, during reception). 2: As the transmit interrupt (TI), when either the TBE or TSC flag becomes “1”, can be selected to occur depending on the setting of the transmit interrupt source selection bit (TIC) of the serial I/O1 control register. 3: The receive interrupt (RI) is set when the RBF flag becomes “1”. 4: After data is written to the transmit buffer when TSC=1, 0.5 to 1.5 cycles of the data shift cycle is necessary until changing to TSC=0.
Fig. 17 Operation of UART serial I/O1 function
[Transmit Buffer Register/Receive Buffer [Serial I/O1 Control Register (SIOCON)] 001A16 Register (TB/RB)] 001816 The serial I/O1 control register consists of eight control bits for the The transmit buffer register and the receive buffer register are lo- serial I/O1 function. cated at the same address. The transmit buffer is write-only and the receive buffer is read-only. If a character bit length is 7 bits, the [UART Control Register (UARTCON)] 001B16 MSB of data stored in the receive buffer is “0”. The UART control register consists of four control bits (bits 0 to 3) which are valid when asynchronous serial interface is selected [Serial I/O1 Status Register (SIOSTS)] 001916 and set the data format of an data transfer and one bit (bit 4) The read-only serial I/O1 status register consists of seven flags which is always valid and sets the output structure of the P25/TXD (bits 0 to 6) which indicate the operating status of the serial I/O1 pin. function and various errors. Three of the flags (bits 4 to 6) are valid only in UART mode. [Baud Rate Generator (BRG)] 001C16 The receive buffer full flag (bit 1) is cleared to “0” when the receive The baud rate generator determines the baud rate for serial trans- buffer register is read. fer. If there is an error, it is detected at the same time that data is The baud rate generator divides the frequency of the count source transferred from the receive shift register to the receive buffer reg- by 1/(n + 1), where n is the value written to the baud rate genera- ister, and the receive buffer full flag is set. A write to the serial I/O1 tor. status register clears all the error flags OE, PE, FE, and SE (bit 3 ■Note 2 to bit 6, respectively). Writing “0” to the serial I/O1 enable bit SIOE When using the serial I/O1, clear the I C-BUS interface enable bit (bit 7 of the serial I/O1 control register) also clears all the status to “0” or the SCL/SDA pin selection bit to “0”. flags, including the error flags. Bits 0 to 6 of the serial I/O1 status register are initialized to “0” at reset, but if the transmit enable bit (bit 4) of the serial I/O1 control register has been set to “1”, the transmit shift completion flag (bit 2) and the transmit buffer empty flag (bit 0) become “1”.
Rev.1.01 Aug 02, 2004 page 18 of 96 7517 Group
b7 b0 b7 b0 Serial I/O1 status register Serial I/O1 control register (SIOSTS : address 001916) (SIOCON : address 001A16) BRG count source selection bit (CSS) Transmit buffer empty flag (TBE) 0: f(XIN) 0: Buffer full 1: f(XIN)/4 1: Buffer empty
Serial I/O1 synchronous clock selection bit (SCS) Receive buffer full flag (RBF) 0: BRG output divided by 4 when clock synchronous 0: Buffer empty serial I/O1 is selected, BRG output divided by 16 1: Buffer full when UART is selected. 1: External clock input when clock synchronous serial Transmit shift completion flag (TSC) I/O1 is selected, external clock input divided by 16 0: Transmit shift in progress when UART is selected. 1: Transmit shift completed
SRDY1 output enable bit (SRDY) Overrun error flag (OE) 0: P27 pin operates as ordinary I/O pin 0: No error 1: P27 pin operates as SRDY1 output pin 1: Overrun error
Transmit interrupt source selection bit (TIC) Parity error flag (PE) 0: Interrupt when transmit buffer has emptied 0: No error 1: Interrupt when transmit shift operation is completed 1: Parity error
Transmit enable bit (TE) Framing error flag (FE) 0: Transmit disabled 0: No error 1: Transmit enabled 1: Framing error
Receive enable bit (RE) Summing error flag (SE) 0: Receive disabled 0: (OE) U (PE) U (FE)=0 1: Receive enabled 1: (OE) U (PE) U (FE)=1
Serial I/O1 mode selection bit (SIOM) Not used (returns “1” when read) 0: Clock asynchronous (UART) serial I/O 1: Clock synchronous serial I/O
Serial I/O1 enable bit (SIOE) b0 b7 UART control register 0: Serial I/O1 disabled (UARTCON : address 001B16) (pins P24 to P27 operate as ordinary I/O pins) Character length selection bit (CHAS) 1: Serial I/O1 enabled 0: 8 bits (pins P24 to P27 operate as serial I/O1 pins) 1: 7 bits
Parity enable bit (PARE) 0: Parity checking disabled 1: Parity checking enabled
Parity selection bit (PARS) 0: Even parity 1: Odd parity
Stop bit length selection bit (STPS) 0: 1 stop bit 1: 2 stop bits
P25/TXD P-channel output disable bit (POFF) 0: CMOS output (in output mode) 1: N-channel open drain output (in output mode)
Not used (return “1” when read)
Fig. 18 Structure of serial I/O1 control registers
Rev.1.01 Aug 02, 2004 page 19 of 96 7517 Group