Before using this material, please visit our website to verify that this is the most
updated document available.
Rev. 2.00
Revision date: Nov. 28, 2005
www.renesas.com
Keep safety first in your circuit designs!
•
Renesas Technology Corporation puts the maximum effort into making semiconductor products better and more reliable, but there is always the possibility that trouble may occur with
them. Trouble with semiconductors may lead to personal injury, fire or property damage.
Remember to give due consideration to safety when making your circuit designs, with appropriate measures such as (i) placement of substitutive, auxiliary circuits, (ii) use of nonflammable material or (iii) prevention against any malfunction or mishap.
Notes regarding these materials
• These materials are intended as a reference to assist our customers in the selection of the
Renesas Technology Corporation product best suited to the customer's application; they do
not convey any license under any intellectual property rights, or any other rights, belonging
to Renesas Technology Corporation or a third party.
• Renesas Technology Corporation assumes no responsibility for any damage, or infringement of any third-party's rights, originating in the use of any product data, diagrams, charts,
programs, algorithms, or circuit application examples contained in these materials.
• All information contained in these materials, including product data, diagrams, charts, programs and algorithms represents information on products at the time of publication of these
materials, and are subject to change by Renesas Technology Corporation without notice
due to product improvements or other reasons. It is therefore recommended that customers contact Renesas Technology Corporation or an authorized Renesas Technology Corporation product distributor for the latest product information before purchasing a product
listed herein.
The information described here may contain technical inaccuracies or typographical errors.
Renesas Technology Corporation assumes no responsibility for any damage, liability, or
other loss rising from these inaccuracies or errors.
Please also pay attention to information published by Renesas Technology Corporation by
various means, including the Renesas Technology Corporation Semiconductor home page
(http://www.renesas.com).
• When using any or all of the information contained in these materials, including product
data, diagrams, charts, programs, and algorithms, please be sure to evaluate all information as a total system before making a final decision on the applicability of the information
and products. Renesas Technology Corporation assumes no responsibility for any damage, liability or other loss resulting from the information contained herein.
• Renesas Technology Corporation semiconductors are not designed or manufactured for
use in a device or system that is used under circumstances in which human life is potentially at stake. Please contact Renesas Technology Corporation or an authorized Renesas
Technology Corporation product distributor when considering the use of a product contained herein for any specific purposes, such as apparatus or systems for transportation,
vehicular, medical, aerospace, nuclear, or undersea repeater use.
• The prior written approval of Renesas Technology Corporation is necessary to reprint or
reproduce in whole or in part these materials.
• If these products or technologies are subject to the Japanese export control restrictions,
they must be exported under a license from the Japanese government and cannot be imported into a country other than the approved destination.
Any diversion or reexport contrary to the export control laws and regulations of Japan and/
or the country of destination is prohibited.
• Please contact Renesas Technology Corporation for further details on these materials or
the products contained therein.
How to Use This Manual
1. Introduction
This hardware manual provides detailed information on the M16C/6N Group (M16C/6NK, M16C/6NM) of
microcomputers.
Users are expected to have basic knowledge of electric circuits, logical circuits and microcomputers.
2. Register Diagram
The symbols, and descriptions, used for bit function in each register are shown below.
XXX Register
b7 b6 b5 b4 b3 b2 b1 b0
00
Symbol
XXX
XXX
(b2)
(b4-b3)
*1
Symbol
XXX
Bit
0
1
-
-
Bit Name
XXX Bit
Nothing is assigned. When write, set to "0",
When read, its content is indeterminate.
Reserved BitSet to "0"
Address
XXX
Function
b1b0
0 0: XXX
0 1: XXX
1 0: Do not set a value
1 1: XXX
After Reset
00h
*5
RW
RW
RW
WO
*2
*3
*4
XXX5
XXX
XXX
XXX Bit
6
7
XXX Bit
Function varies depending on
mode of operation
0: XXX
1: XXX
*1
Blank:Set to “0” or “1” according to the application
0 :Set to “0”
1 :Set to “1”
X :Nothing is assigned
*2
RW : Read and write
RO : Read only
WO: Write only
–: Nothing is assigned
*3
• Reserved bit
Reserved bit. Set to specified value.
*4
• Nothing is assigned
Nothing is assigned to the bit concerned. As the bit may be use for future functions, set to “0” when
writing to this bit.
• Do not set to this value
The operation is not guaranteed when a value is set.
• Function varies depending on mode of operation
Bit function varies depending on peripheral function mode.
Refer to respective register for each mode.
*5
Follow the text in each manual for binary and hexadecimal notations.
RW
RW
RO
3. M16C Family Documents
The following documents were prepared for the M16C family
DocumentContents
Short SheetHardware overview
Data SheetHardware overview and electrical characteristics
1.4 Product List ..................................................................................................................................................5
2.5 Program Counter (PC) ...............................................................................................................................17
2.7 Static Base Register (SB) .......................................................................................................................... 17
2.8 Flag Register (FLG) ................................................................................................................................... 17
2.8.1 Carry Flag (C Flag) ............................................................................................................................ 17
2.8.2 Debug Flag (D Flag) .......................................................................................................................... 17
2.8.3 Zero Flag (Z Flag) ..............................................................................................................................17
2.8.4 Sign Flag (S Flag) ..............................................................................................................................17
2.8.5 Register Bank Select Flag (B Flag).................................................................................................... 17
2.8.6 Overflow Flag (O Flag)....................................................................................................................... 17
2.8.7 Interrupt Enable Flag (I Flag) .............................................................................................................17
2.8.8 Stack Pointer Select Flag (U Flag)..................................................................................................... 17
2.8.10 Reserved Area .................................................................................................................................17
5.5 Internal Space ............................................................................................................................................ 37
7. Bus ......................................................................................................................................45
7.1 Bus Mode ................................................................................................................................................... 45
7.1.1 Separate Bus ..................................................................................................................................... 45
7.2 Bus Control ................................................................................................................................................ 46
7.2.1 Address Bus ....................................................................................................................................... 46
7.2.2 Data Bus ............................................................................................................................................ 46
7.2.4 Read and Write Signals ..................................................................................................................... 48
7.2.5 ALE Signal ......................................................................................................................................... 48
________
7.2.6 RDY Signal ........................................................................................................................................49
7.2.7 HOLD Signal ......................................................................................................................................50
7.2.9 External Bus Status When Internal Area Accessed ...........................................................................52
8.1 Types of Clock Generating Circuit .............................................................................................................. 56
8.1.1 Main Clock ......................................................................................................................................... 64
8.1.2 Sub Clock........................................................................................................................................... 65
8.2 CPU Clock and Peripheral Function Clock ................................................................................................ 68
8.2.1 CPU Clock and BCLK ........................................................................................................................68
8.2.2 Peripheral Function Clock .................................................................................................................. 68
8.3 Clock Output Function ............................................................................................................................... 68
8.4 Power Control ............................................................................................................................................ 69
8.4.1 Normal Operation Mode..................................................................................................................... 69
10.1 Type of Interrupts ..................................................................................................................................... 81
10.3.1 Special Interrupts .............................................................................................................................83
10.3.2 Peripheral Function Interrupts.......................................................................................................... 83
10.4 Interrupts and Interrupt Vector .................................................................................................................84
10.5 Interrupt Control .......................................................................................................................................86
10.5.1 I Flag ................................................................................................................................................88
10.5.2 IR Bit ................................................................................................................................................ 88
10.5.3 ILVL2 to ILVL0 Bits and IPL ............................................................................................................. 88
10.6 INT Interrupt ............................................................................................................................................. 94
12.1 Transfer Cycle ........................................................................................................................................ 108
12.1.1 Effect of Source and Destination Addresses .................................................................................. 108
12.1.2 Effect of BYTE Pin Level................................................................................................................ 108
12.1.3 Effect of Software Wait................................................................................................................... 108
________
12.1.4 Effect of RDY Signal ...................................................................................................................... 108
12.2 DMA Transfer Cycles ............................................................................................................................. 110
13.1 Timer A ................................................................................................................................................... 115
16.2 Function ................................................................................................................................................. 216
16.2.1 Resolution Select Function ............................................................................................................ 216
16.2.2 Sample and Hold ........................................................................................................................... 216
16.2.3 Extended Analog Input Pins........................................................................................................... 216
19.4 CAN SFR Registers ...............................................................................................................................228
19.5.1 CAN Reset/Initialization Mode ....................................................................................................... 234
19.5.2 CAN Operation Mode..................................................................................................................... 235
19.5.3 CAN Sleep Mode ........................................................................................................................... 235
19.5.4 CAN Interface Sleep Mode ............................................................................................................ 235
19.5.5 Bus Off State.................................................................................................................................. 236
19.6 Configuration CAN Module System Clock ............................................................................................. 237
19.7 Bit Timing Configuration ......................................................................................................................... 237
19.8.1 Calculation of Bit-rate..................................................................................................................... 238
19.9 Acceptance Filtering Function and Masking Function............................................................................239
19.10 Acceptance Filter Support Unit (ASU)..................................................................................................240
19.11 Basic CAN Mode ..................................................................................................................................241
19.12 Return from Bus Off Function .............................................................................................................. 242
19.13 Time Stamp Counter and Time Stamp Function ..................................................................................242
19.16 CAN Interrupt .......................................................................................................................................246
21.3.6 Data Protect Function .................................................................................................................... 278
21.3.7 Status Register (SRD Register) .....................................................................................................278
21.3.8 Full Status Check ........................................................................................................................... 280
21.4 Standard Serial I/O Mode ...................................................................................................................... 282
21.4.1 ID Code Check Function ................................................................................................................ 282
21.4.2 Example of Circuit Application in Standard Serial I/O Mode .......................................................... 286
23.1 External Bus ........................................................................................................................................... 339
23.4 PLL Frequency Synthesizer ...................................................................................................................341
23.5 Power Control ........................................................................................................................................ 342
23.6 Oscillation Stop, Re-oscillation Detection Function ............................................................................... 344
23.8.5 INT Interrupt ................................................................................................................................... 347
23.8.6 Rewrite Interrupt Control Register ................................................................................................. 348
23.10.1 Timer A ......................................................................................................................................... 350
23.11 Thee-Phase Motor Control Timer Function ..........................................................................................356
23.12 Serial Interface ..................................................................................................................................... 357
23.12.1 Clock Synchronous Serial I/O Mode ............................................................................................357
23.12.2 Special Modes ............................................................................................................................. 358
23.14 CAN Module ......................................................................................................................................... 362
23.18 Mask ROM Version ............................................................................................................................. 370
23.19 Flash Memory Version .........................................................................................................................371
23.20 Flash Memory Programming Using Boot Program .............................................................................. 373
CAN0/1 Wake-up Interrupt Control Register
CAN0 Successful Reception Interrupt Control Register
CAN0 Successful Transmission Interrupt Control Register
INT3 Interrupt Control Register
Timer B5 Interrupt Control Register
SI/O5 Interrupt Control Register
Timer B4 Interrupt Control Register
UART1 Bus Collision Detection Interrupt Control Register
Timer B3 Interrupt Control Register
UART0 Bus Collision Detection Interrupt Control Register
CAN1 Successful Reception Interrupt Control Register
SI/O4 Interrupt Control Register
INT5 Interrupt Control Register
CAN1 Successful Transmission Interrupt Control Register
SI/O3 Interrupt Control Register
INT4 Interrupt Control Register
UART2 Bus Collision Detection Interrupt Control Register
DMA0 Interrupt Control Register
DMA1 Interrupt Control Register
CAN0/1 Error Interrupt Control Register
A/D Conversion Interrupt Control Register
Key Input Interrupt Control Register
UART2 Transmit Interrupt Control Register
UART2 Receive Interrupt Control Register
UART0 Transmit Interrupt Control Register
UART0 Receive Interrupt Control Register
UART1 Transmit Interrupt Control Register
UART1 Receive Interrupt Control Register
Timer A0 Interrupt Control Register
Timer A1 Interrupt Control Register
Timer A2 Interrupt Control Register
INT7 Interrupt Control Register
Timer A3 Interrupt Control Register
INT6 Interrupt Control Register
Timer A4 Interrupt Control Register
Timer B0 Interrupt Control Register
SI/O6 Interrupt Control Register
Timer B1 Interrupt Control Register
INT8 Interrupt Control Register
Timer B2 Interrupt Control Register
INT0 Interrupt Control Register
INT1 Interrupt Control Register
INT2 Interrupt Control Register
Three-Phase PWM Control Register 0
Three-Phase PWM Control Register 1
Three-Phase Output Buffer Register 0
Three-Phase Output Buffer Register 1
Dead Time Timer
Timer B2 Interrupt Occurrence Frequency Set Counter
Interrupt Cause Select Register 2
Timer B3 Register
Timer B4 Register
Timer B5 Register
SI/O6 Transmit/Receive Register
SI/O6 Control Register
SI/O6 Bit Rate Generator
SI/O3, 4, 5, 6 Transmit/Receive Register
Timer B3 Mode Register
Timer B4 Mode Register
Timer B5 Mode Register
Interrupt Cause Select Register 0
Interrupt Cause Select Register 1
SI/O3 Transmit/Receive Register
SI/O3 Control Register
SI/O3 Bit Rate Generator
SI/O4 Transmit/Receive Register
SI/O4 Control Register
SI/O4 Bit Rate Generator
SI/O5 Transmit/Receive Register
SI/O5 Control Register
SI/O5 Bit Rate Generator
UART0 Special Mode Register 4
UART0 Special Mode Register 3
UART0 Special Mode Register 2
UART0 Special Mode Register
UART1 Special Mode Register 4
UART1 Special Mode Register 3
UART1 Special Mode Register 2
UART1 Special Mode Register
UART2 Special Mode Register 4
UART2 Special Mode Register 3
UART2 Special Mode Register 2
UART2 Special Mode Register
UART2 Transmit/Receive Mode Register
UART2 Bit Rate Generator
UART2 Transmit Buffer Register
UART2 Transmit/Receive Control Register 0
UART2 Transmit/Receive Control Register 1
A/D Control Register 0
A/D Control Register 1
D/A Register 0
D/A Register 1
D/A Control Register
Port P14 Control Register
Pull-Up Control Register 3
Port P0 Register
Port P1 Register
Port P0 Direction Register
Port P1 Direction Register
Port P2 Register
Port P3 Register
Port P2 Direction Register
Port P3 Direction Register
Port P4 Register
Port P5 Register
Port P4 Direction Register
Port P5 Direction Register
Port P6 Register
Port P7 Register
Port P6 Direction Register
Port P7 Direction Register
Port P8 Register
Port P9 Register
Port P8 Direction Register
Port P9 Direction Register
Port P10 Register
Port P11 Register
Port P10 Direction Register
Port P11 Direction Register
Port P12 Register
Port P13 Register
Port P12 Direction Register
Port P13 Direction Register
Pull-up Control Register 0
Pull-up Control Register 1
Pull-up Control Register 2
Port Control Register
This document is under development and its contents are subject to change
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Nov 28, 2005
1. Overview
The M16C/6N Group (M16C/6NK, M16C/6NM) of single-chip microcomputers are built using the
high-performance silicon gate CMOS process using an M16C/60 Series CPU core and are packaged in
100-pin and 128-pin plastic molded LQFP. These single-chip microcomputers operate using sophisticated
instructions featuring a high level of instruction efficiency. With 1 Mbyte of address space, they are capable
of executing instructions at high speed. Being equipped with two CAN (Controller Area Network) modules in
M16C/6N Group (M16C/6NK, M16C/6NM), the microcomputer is suited to car audio and industrial control
systems. The CAN modules comply with the 2.0B specification. In addition, this microcomputer contains a
multiplier and DMAC which combined with fast instruction processing capability, makes it suitable for control
of various OA and communication equipment which requires high-speed arithmetic/logic operations.
1.1 Applications
• Car audio and industrial control systems, other (Normal-ver. product)
• Automotive, industrial control systems and other automobile, other (T/V-ver. product)
Rev.2.00
Rev.2.00 Nov 28, 2005 page 1 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)1. Overview
1.2 Performance Outline
Tables 1.1 and 1.2 list a performance outline of M16C/6N Group (M16C/6NK, M16C/6NM).
Table 1.1 Performance Outline of M16C/6N Group (100-pin Version: M16C/6NK)
1. I2C-bus is a registered trademark of Koninklijke Philips Electronics N.V.
2. IEBus is a registered trademark of NEC Electronics Corporation.
option: All options are on request basis.
Rev.2.00 Nov 28, 2005 page 3 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)1. Overview
1.3 Block Diagram
Figure 1.1 shows a block diagram of M16C/6N Group (M16C/6NK, M16C/6NM).
8
Port P0
Port P18Port P2
Internal peripheral functions
Expandable up to 26 channels)
Timer (16 bits)
Output (timer A): 5
Input (timer B): 6
Three-phase motor
control circuit
Watchdog timer
(15 bits)
DMAC
(2 channels)
D/A converter
(8 bits ✕ 2 channels)
NOTES:
1: ROM size depends on microcomputer type.
2: RAM size depends on microcomputer type.
3: Ports P11 to P14 are only in the 128-pin version.
4: 8 bits ✕ 2 channels in the 100-pin version.
Clock synchronous serial I/O
CRC arithmetic circuit (CCITT)
8888
A/D converter
(10 bits ✕ 8 channels
UART or
(3 channels)
(Polynomial: X
R0HR0L
R1HR1L
R2
R3
A0
A1
FB
16+X12+X5
+1)
SB
USP
ISP
INTB
PC
FLG
Port P14
(3)
2
Port P5Port P4Port P3
System clock generating circuit
XIN-XOUT
XCIN-XCOUT
PLL frequency synthesizer
On-chip oscillator
Clock synchronous serial I/O
(8 bits ✕ 4 channels)
CAN module
(2 channels)
(4)
MemoryM16C/60 series CPU core
(1)
ROM
(2)
RAM
Multiplier
Port P13
Port P12
(3)
8
(3)
8
8
Port P6
Port P7
8
Port P8
7
Port P8_5
Port P9
8
Port P10
8
Port P11
(3)
8
Figure 1.1 Block Diagram
Rev.2.00 Nov 28, 2005 page 4 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)1. Overview
1.4 Product List
Table 1.3 lists the M16C/6N Group (M16C/6NK, M16C/6NM) products and Figure 1.2 shows the type numbers,
memory sizes and packages.
Table 1.3 Product List
Type No.ROM Capacity RAM Capacity Package TypeRemarks
1. Not available the bus control pins in T/V-ver..
Rev.2.00 Nov 28, 2005 page 12 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)1. Overview
1.6 Pin Description
Tables 1.9 to 1.11 list the pin descriptions.
Table 1.9 Pin Description (100-pin and 128-pin Versions) (1)
Signal NamePin NameI/O TypeDescription
Power supply
input
Analog power
supply input
Reset input
CNVSS
(2)
External data
bus width
select input
Bus control
(3)
pins
VCC1, VCC2,
VSS
AVCC, AVSS
_____________
RESET
CNVSS
BYTE
(2)
D0 to D7
D8 to D15
A0 to A19
A0/D0 to A7/D7
A1/D0 to A8/D7
______________
CS0 to CS3
_________ ______
WRL/WR
_________ ________
WRH/BHE
______
RD
ALE
__________
HOLD
__________
HLDA
________
RDY
I: Input O: Output I/O: Input/Output
I
I
I
I
I
I/O
I/O
O
I/O
I/O
O
O
O
I
O
I
Apply 3.0 to 5.5V to the VCC1 and VCC2 pins and 0V to the VSS
pin. The VCC apply condition is that VCC2 = VCC1
(1)
.
Applies the power supply for the A/D converter. Connect the AVCC
pin to VCC1. Connect the AVSS pin to VSS.
The microcomputer is in a reset state when applying “L” to the this pin.
Switches processor mode. Connect this pin to VSS to when after
a reset to start up in single-chip mode. Connect this pin to VCC1
to start up in microprocessor mode.
Switches the data bus in external memory space. The data bus
is 16-bit long when the this pin is held “L” and 8-bit long when
the this pin is held “H”. Set it to either one. Connect this pin to
VSS when an single-chip mode.
Inputs and outputs data (D0 to D7) when these pins are set as
the separate bus.
Inputs and outputs data (D8 to D15) when external 16-bit data
bus is set as the separate bus.
Output address bits (A0 to A19).
Input and output data (D0 to D7) and output address bits (A0 to
A7) by time-sharing when external 8-bit data bus are set as the
multiplexed bus.
Input and output data (D0 to D7) and output address bits (A1 to
A8) by time-sharing when external 16-bit data bus are set as the
multiplexed bus.
____________________________
Output CS0 to CS3 signals. CS0 to CS3 are chip-select signals
to specify an external space.
Output WRL, WRH, (WR, BHE), RD signals. WRL and WRH or
______________
BHE and WR can be switched by program.
• WRL, WRH and RD are selected
• WR, BHE and RD are selected
ALE is a signal to latch the address.
While the HOLD pin is held “L”, the microcomputer is placed in
a hold state.
In a hold state, HLDA outputs a “L” signal.
While applying a “L” signal to the RDY pin, the microcomputer
The WRL signal becomes “L” by writing data to an even address
in an external memory space.
_________
The WRH signal becomes “L” by writing data to an odd address
in an external memory space.
_____
The RD pin signal becomes “L” by reading data in an external
memory space.
______ _____________
______
The WR signal becomes “L” by writing data in an external
memory space.
_____
The RD signal becomes “L” by reading data in an external
memory space.
________
The BHE signal becomes “L” by accessing an odd address.
______ _____________
Select WR, BHE and RD for an external 8-bit data bus.
__________
__________
________
is placed in a wait state.
NOTES:
1. In this manual, hereafter, VCC refers to VCC1 unless otherwise noted.
2. Connect to VSS in T/V-ver..
3. Not available the bus control pins in T/V-ver..
Rev.2.00 Nov 28, 2005 page 13 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)1. Overview
Table 1.10 Pin Description (100-pin and 128-pin Versions) (2)
Signal NamePin NameI/O TypeDescription
Main clock
input
Main clock
output
Sub clock
input
Sub clock
output
BCLK output
(3)
Clock output
INT interrupt input
_______
NMI interrupt
input
Key input
XIN
XOUT
XCIN
XCOUT
BCLK
CLKOUT
NT0 to INT8
________
NMI
____________
KI0 to KI3
(3)
I/O pins for the main clock oscillation circuit. Connect a ceramic
I
resonator or crystal oscillator between XIN and XOUT
To use the external clock, input the clock from XIN and leave
O
XOUT open.
I/O pins for a sub clock oscillation circuit. Connect a crystal
I
oscillator between XCIN and XCOUT
To use the external clock, input the clock from XCIN and leave
O
(1)
.
XCOUT open.
Outputs the BCLK signal.
O
The clock of the same cycle as fC, f8, or f32 is output.
O
Input pins for the INT interrupt.
I
Input pin for the NMI interrupt.
I
Input pins for the key input interrupt.
I
______
_______
(1)
.
interrupt input
Timer A
TA0OUT to TA4OUT
TA0IN to TA4IN
ZP
Timer B
Three-phase motor
control output
Serial interface
TB0IN to TB5IN
U, U, V, V, W, W
____________________
CTS0 to CTS2
____________________
RTS0 to RTS2
CLK0 to CLK6
RXD0 to RXD2
SIN3 to SIN6
TXD0 to TXD2
SOUT3 to SOUT6
CLKS1
__________
(3)
(3)
I/O
I/O
(3)
These are timer A0 to timer A4 I/O pins.
These are timer A0 to timer A4 input pins.
I
Input pin for the Z-phase.
I
These are timer B0 to timer B5 input pins.
I
These are Three-phase motor control output pins.
O
These are send control input pins.
I
These are receive control output pins.
O
These are transfer clock I/O pins.
These are serial data input pins.
I
These are serial data input pins.
I
These are serial data output pins.
O
These are serial data output pins.
O
This is output pin for transfer clock output from multiple pins
O
function.
2
I
C mode
SDA0 to SDA2
SCL0 to SCL2
I/O
I/O
These are serial data I/O pins.
These are transfer clock I/O pins. (however, SCL2 for
the N-channel open drain output.)
Reference
voltage input
A/D converter
VREF
AN0 to AN7
Applies the reference voltage for the A/D converter and D/A
I
converter.
Analog input pins for the A/D converter.
I
AN0_0 to AN0_7
AN2_0 to AN2_7
_____________
ADTRG
ANEX0
I/O
This is an A/D trigger input pin.
I
This is the extended analog input pin for the A/D converter,
and is the output in external op-amp connection mode.
This is the extended analog input pin for the A/D converter.
I
These are the output pins for the D/A converter.
O
These are the input pins for the CAN module.
I
These are the output pins for the CAN module.
O
D/A converter
CAN module
ANEX1
DA0, DA1
CRX0, CRX1
CTX0, CTX1
I: Input O: Output I/O: Input/Output
NOTES:
1. Ask the oscillator maker the oscillation characteristic.
________________
2. INT6 to INT8, CLK5, CLK6, SIN5, SIN6, SOUT5, SOUT6 are only in the 128-pin version.
3. Not available the bus control pins in T/V-ver..
Rev.2.00 Nov 28, 2005 page 14 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)1. Overview
Table 1.11 Pin Description (100-pin and 128-pin Versions) (3)
Signal NamePin NameI/O TypeDescription
I/O port
P0_0 to P0_7
P1_0 to P1_7
P2_0 to P2_7
P3_0 to P3_7
P4_0
to
P4_7
P5_0 to P5_7
P6_0 to P6_7
I/O
8-bit I/O ports in CMOS, having a direction register to select
an input or output.
Each pin is set as an input port or output port. An input port
can be set for a pull-up or for no pull-up in 4-bit unit by
program.
(however P7_1 and P9_1 for the N-channel open drain
output.)
P7_0 to P7_7
P8_0 to P8_4
P8_6, P8_7
P9_0 to P9_7
P10_0 to P10_7
(1)
(1)
(1)
(1)
I
Input pin for the NMI interrupt.
_______
Input port
P11_0 to P11_7
P12_0 to P12_7
P13_0 to P13_7
P14_0, P14_1
P8_5
Pin states can be read by the P8_5 bit in the P8 register.
I: Input O: Output I/O: Input/Output
NOTE:
1. Ports P11 to P14 are only in the 128-pin version.
Rev.2.00 Nov 28, 2005 page 15 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)2. Central Processing Unit (CPU)
2. Central Processing Unit (CPU)
Figure 2.1 shows the CPU registers. The CPU has 13 registers. Of these, R0, R1, R2, R3, A0, A1 and FB
comprise a register bank. There are two register banks.
b31b15b8 b7b0
R2
R3
R0H (R0's high bits) R0L (R0's low bits)
R1H (R1's high bits) R1L (R1's low bits)
R2
R3
A0
A1
FB
Data Registers
Address Registers
Frame Base Registers
(1)
(1)
(1)
b19b15
INTBLINTBH
The upper 4 bits of INTB are INTBH and the lower 16 bits of INTB are INTBL.
b19
PC
b15b0
USP
ISP
SB
b15b0
FLG
b15b0
IPL U I O B S Z D C
NOTE:
1. These registers comprise a register bank. There are two register banks.
b7b8
b0
Interrupt Table Register
b0
Program Counter
User Stack Pointer
Interrupt Stack Pointer
Static Base Register
Flag Register
Carry Flag
Debug Flag
Zero Flag
Sign Flag
Register Bank Select Flag
Overflow Flag
Interrupt Enable Flag
Stack Pointer Select Flag
Reserved Area
Processor Interrupt Priority Level
Reserved Area
Figure 2.1 CPU Registers
2.1 Data Registers (R0, R1, R2, and R3)
The R0 register consists of 16 bits, and is used mainly for transfers and arithmetic/logic operations. R1 to
R3 are the same as R0.
The R0 register can be separated between high (R0H) and low (R0L) for use as two 8-bit data registers.
R1H and R1L are the same as R0H and R0L. Conversely R2 and R0 can be combined for use as a 32-bit
data register (R2R0). R3R1 is the same as R2R0.
2.2 Address Registers (A0 and A1)
The A0 register consists of 16 bits, and is used for address register indirect addressing and address
register relative addressing. They also are used for transfers and arithmetic/logic operations. A1 is the
same as A0.
In some instructions, A1 and A0 can be combined for use as a 32-bit address register (A1A0).
Rev.2.00 Nov 28, 2005 page 16 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)2. Central Processing Unit (CPU)
2.3 Frame Base Register (FB)
FB is configured with 16 bits, and is used for FB relative addressing.
2.4 Interrupt Table Register (INTB)
INTB is configured with 20 bits, indicating the start address of an interrupt vector table.
2.5 Program Counter (PC)
PC is configured with 20 bits, indicating the address of an instruction to be executed.
2.6 User Stack Pointer (USP), Interrupt Stack Pointer (ISP)
Stack pointer (SP) comes in two types: USP and ISP, each configured with 16 bits.
Your desired type of stack pointer (USP or ISP) can be selected by the U flag of FLG.
2.7 Static Base Register (SB)
SB is configured with 16 bits, and is used for SB relative addressing.
2.8 Flag Register (FLG)
FLG consists of 11 bits, indicating the CPU status.
2.8.1 Carry Flag (C Flag)
This flag retains a carry, borrow, or shift-out bit that has occurred in the arithmetic/logic unit.
2.8.2 Debug Flag (D Flag)
This flag is used exclusively for debugging purpose. During normal use, it must be set to “0”.
2.8.3 Zero Flag (Z Flag)
This flag is set to “1” when an arithmetic operation resulted in 0; otherwise, it is “0”.
2.8.4 Sign Flag (S Flag)
This flag is set to “1” when an arithmetic operation resulted in a negative value; otherwise, it is “0”.
2.8.5 Register Bank Select Flag (B Flag)
Register bank 0 is selected when this flag is “0” ; register bank 1 is selected when this flag is “1”.
2.8.6 Overflow Flag (O Flag)
This flag is set to “1” when the operation resulted in an overflow; otherwise, it is “0”.
2.8.7 Interrupt Enable Flag (I Flag)
This flag enables a maskable interrupt.
Maskable interrupts are disabled when the I flag is “0”, and are enabled when the I flag is “1”. The I flag is
set to “0” when the interrupt request is accepted.
2.8.8 Stack Pointer Select Flag (U Flag)
ISP is selected when the U flag is “0” ; USP is selected when the U flag is “1”.
The U flag is set to “0” when a hardware interrupt request is accepted or an INT instruction for software
interrupt Nos. 0 to 31 is executed.
2.8.9 Processor Interrupt Priority Level (IPL)
IPL is configured with three bits, for specification of up to eight processor interrupt priority levels from level
0 to level 7.
If a requested interrupt has priority greater than IPL, the interrupt request is enabled.
2.8.10 Reserved Area
When white to this bit, write “0”. When read, its content is indeterminate.
Rev.2.00 Nov 28, 2005 page 17 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)3. Memory
3. Memory
Figure 3.1 shows a memory map of the M16C/6N Group (M16C/6NK, M16C/6NM). The address space
extends the 1 Mbyte from address 00000h to FFFFFh.
The internal ROM is allocated in a lower address direction beginning with address FFFFFh. For example, a
512-Kbyte internal ROM is allocated to the addresses from 80000h to FFFFFh.
As for the flash memory version, 4-Kbyte space (block A) exists in 0F000h to 0FFFFh. 4-Kbyte space is
mainly for storing data. In addition to storing data, 4-Kbyte space also can store programs.
The fixed interrupt vector table is allocated to the addresses from FFFDCh to FFFFFh. Therefore, store the
start address of each interrupt routine here.
The internal RAM is allocated in an upper address direction beginning with address 00400h. For example, a
31-Kbyte internal RAM is allocated to the addresses from 00400h to 07FFFh. In addition to storing data, the
internal RAM also stores the stack used when calling subroutines and when interrupts are generated.
The SFR is allocated to the addresses from 00000h to 003FFh. Peripheral function control registers are
located here. Of the SFR, any area which has no functions allocated is reserved for future use and cannot be
used by users.
The special page vector table is allocated to the addresses from FFE00h to FFFDBh. This vector is used by
the JMPS or JSRS instruction. For details, refer to M16C/60, M16C/20, M16C/Tiny Series Software Manual.
In memory expansion and microprocessor modes, some areas are reserved for future use and cannot be
used by users.
Use T/V-ver. in single-chip mode. The memory expansion and microprocessor modes cannot be used.
00000h
SFR
Internal RAM
Capacity
16 Kbytes043FF
20 Kbytes
31 Kbytes
Address XXXXX
053FF
07FFF
h
Capacity
h
192 KbytesD0000
h
256 KbytesC0000
h
384 KbytesA0000
512 Kbytes80000
Internal ROM
Address YYYYY
00400h
XXXXX
0F000h
0FFFFh
10000h
27000h
(1)
h
h
h
h
h
28000h
80000h
YYYYY
FFFFFh
h
Reserved area
Reserved area
h
(program area)
Internal RAM
Internal ROM
(data area)
External area
Reserved area
External area
Internal ROM
(1)
(3)
FFE00h
Special page
vector table
FFFDCh
(2)
(4)
FFFFFh
Undefined instruction
Overflow
BRK instruction
Address match
Single step
Oscillation stop and re-oscillation
detection / watchdog timer
DBC
NMI
Reset
NOTES:
1. During memory expansion mode or microprocessor mode, cannot be used.
2. In memory expansion mode, cannot be used.
3. As for the flash memory version, 4-Kbyte space (block A) exists.
4. When using the masked ROM version, write nothing to internal ROM area.
5. Shown here is a memory map for the case where the PM10 bit in the PM1 register is "1" (block A enabled, addresses 10000h to
26FFFh for CS2 area) and the PM13 bit in the PM1 register is "1" (internal RAM area is expanded over 192 Kbytes).
* Not available memory expansion and microprocessor modes in T/V-ver..
And not available external area in T/V-ver..
Figure 3.1 Memory Map
Rev.2.00 Nov 28, 2005 page 18 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)4. Special Function Register (SFR)
4. Special Function Register (SFR)
SFR (Special Function Register) is the control register of peripheral functions.
Tables 4.1 to 4.16 list the SFR information.
System Clock Control Register 0
System Clock Control Register 1
Chip Select Control Register
Address Match Interrupt Enable Register
Protect Register
Oscillation Stop Detection Register
Watchdog Timer Start Register
Watchdog Timer Control Register
Address Match Interrupt Register 0
Address Match Interrupt Register 1
Chip Select Expansion Control Register
PLL Control Register 0
Processor Mode Register 2
DMA0 Source Pointer
DMA0 Destination Pointer
DMA0 Transfer Counter
DMA0 Control Register
DMA1 Source Pointer
DMA1 Destination Pointer
DMA1 Transfer Counter
DMA1 Control Register
(1)
(4)
(2)
PM0
PM1
CM0
CM1
CSR
AIER
PRCR
CM2
WDTS
WDC
RMAD0
RMAD1
(4)
CSE
PLC0
PM2
SAR0
DAR0
TCR0
DM0CON
SAR1
DAR1
TCR1
DM1CON
00000000b (CNVSS pin is "L")
00000011b (CNVSS pin is "H")
00001000b
01001000b
00100000b
00000001b
XXXXXX00b
XX000000b
0X000000b
XXh
00XXXXXXb
00h
00h
X0h
00h
00h
X0h
00h
0001X010b
XXX00000b
XXh
XXh
XXh
XXh
XXh
XXh
XXh
XXh
00000X00b
XXh
XXh
XXh
XXh
XXh
XXh
XXh
XXh
00000X00b
(3)
NOTES:
1. The PM00 and PM01 bits in the PM0 register do not change at software reset, watchdog timer reset and oscillation stop detection reset.
* Effective when memory expansion and microprocessor modes (= Normal-ver.).
2. The CM20, CM21, and CM27 bits in the CM2 register do not change at oscillation stop detection reset.
3. CNVSS pin = H is not available in T/V-ver.. Do not set a value.
4. These registers are not available in T/V-ver.
5. The blank areas are reserved and cannot be accessed by users.
Rev.2.00 Nov 28, 2005 page 19 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)4. Special Function Register (SFR)
CAN0/1 Wake-up Interrupt Control Register
CAN0 Successful Reception Interrupt Control Register
CAN0 Successful Transmission Interrupt Control Register
INT3 Interrupt Control Register
Timer B5 Interrupt Control Register
SI/O5 Interrupt Control Register
Timer B4 Interrupt Control Register
UART1 Bus Collision Detection Interrupt Control Register
Timer B3 Interrupt Control Register
UART0 Bus Collision Detection Interrupt Control Register
CAN1 Successful Reception Interrupt Control Register
SI/O4 Interrupt Control Register
INT5 Interrupt Control Register
CAN1 Successful Transmission Interrupt Control Register
SI/O3 Interrupt Control Register
INT4 Interrupt Control Register
UART2 Bus Collision Detection Interrupt Control Register
DMA0 Interrupt Control Register
DMA1 Interrupt Control Register
CAN0/1 Error Interrupt Control Register
A/D Conversion Interrupt Control Register
Key Input Interrupt Control Register
UART2 Transmit Interrupt Control Register
UART2 Receive Interrupt Control Register
UART0 Transmit Interrupt Control Register
UART0 Receive Interrupt Control Register
UART1 Transmit Interrupt Control Register
UART1 Receive Interrupt Control Register
Timer A0 Interrupt Control Register
Timer A1 Interrupt Control Register
Timer A2 Interrupt Control Register
INT7 Interrupt Control Register
Timer A3 Interrupt Control Register
INT6 Interrupt Control Register
Timer A4 Interrupt Control Register
Timer B0 Interrupt Control Register
SI/O6 Interrupt Control Register
Timer B1 Interrupt Control Register
INT8 Interrupt Control Register
Timer B2 Interrupt Control Register
INT0 Interrupt Control Register
INT1 Interrupt Control Register
INT2 Interrupt Control Register
Timer A4-1 Register
Three-Phase PWM Control Register 0
Three-Phase PWM Control Register 1
Three-Phase Output Buffer Register 0
Three-Phase Output Buffer Register 1
Dead Time Timer
Timer B2 Interrupt Occurrence Frequency Set Counter
SI/O4 Control Register
SI/O4 Bit Rate Generator
SI/O5 Transmit/Receive Register
SI/O5 Control Register
(1)
SI/O5 Bit Rate Generator
(1)
(1)
UART0 Special Mode Register 4
UART0 Special Mode Register 3
UART0 Special Mode Register 2
UART0 Special Mode Register
UART1 Special Mode Register 4
UART1 Special Mode Register 3
UART1 Special Mode Register 2
UART1 Special Mode Register
UART2 Special Mode Register 4
UART2 Special Mode Register 3
UART2 Special Mode Register 2
UART2 Special Mode Register
UART2 Transmit/Receive Mode Register
UART2 Bit Rate Generator
UART2 Transmit Buffer Register
UART2 Transmit/Receive Control Register 0
UART2 Transmit/Receive Control Register 1
UART2 Receive Buffer Register
S4C
S4BRG
S5TRR
S5C
S5BRG
U0SMR4
U0SMR3
U0SMR2
U0SMR
U1SMR4
U1SMR3
U1SMR2
U1SMR
U2SMR4
U2SMR3
U2SMR2
U2SMR
U2MR
U2BRG
U2TB
U2C0
U2C1
U2RB
X: Undefined
000XXXXXb
XXh
XXh
XXh
XXh
XXh
XXh
00h
00h
00h
00h
XXh
XXh
X0000000b
XXh
XXh
XXh
XXh
XXh
XXh
XXh
01000000b
XXh
XXXX0000b
00XX0000b
00XX0000b
00XX0000b
00h
00h
XXh
01000000b
XXh
XXh
01000000b
XXh
XXh
01000000b
XXh
00h
000X0X0Xb
X0000000b
X0000000b
00h
000X0X0Xb
X0000000b
X0000000b
00h
000X0X0Xb
X0000000b
X0000000b
00h
XXh
XXh
XXh
00001000b
00000010b
XXh
XXh
NOTES:
1. These registers exist only in the 128-pin version.
2. The S5TRF and S6TRF bits in the S3456TRR register are used in the 128-pin version.
3. The blank areas are reserved and cannot be accessed by users.
Rev.2.00 Nov 28, 2005 page 26 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)4. Special Function Register (SFR)
CAN0 Message Control Register 0
CAN0 Message Control Register 1
CAN0 Message Control Register 2
CAN0 Message Control Register 3
CAN0 Message Control Register 4
CAN0 Message Control Register 5
CAN0 Message Control Register 6
CAN0 Message Control Register 7
CAN0 Message Control Register 8
CAN0 Message Control Register 9
CAN0 Message Control Register 10
CAN0 Message Control Register 11
CAN0 Message Control Register 12
CAN0 Message Control Register 13
CAN0 Message Control Register 14
CAN0 Message Control Register 15
CAN1 Message Control Register 0
CAN1 Message Control Register 1
CAN1 Message Control Register 2
CAN1 Message Control Register 3
CAN1 Message Control Register 4
CAN1 Message Control Register 5
CAN1 Message Control Register 6
CAN1 Message Control Register 7
CAN1 Message Control Register 8
CAN1 Message Control Register 9
CAN1 Message Control Register 10
CAN1 Message Control Register 11
CAN1 Message Control Register 12
CAN1 Message Control Register 13
CAN1 Message Control Register 14
CAN1 Message Control Register 15
Port P14 Control Register
Pull-Up Control Register 3
Port P0 Register
Port P1 Register
Port P0 Direction Register
Port P1 Direction Register
Port P2 Register
Port P3 Register
Port P2 Direction Register
Port P3 Direction Register
Port P4 Register
Port P5 Register
Port P4 Direction Register
Port P5 Direction Register
Port P6 Register
Port P7 Register
Port P6 Direction Register
Port P7 Direction Register
Port P8 Register
Port P9 Register
Port P8 Direction Register
Port P9 Direction Register
Port P10 Register
Port P11 Register
(1)
Port P10 Direction Register
Port P11 Direction Register
Port P12 Register
Port P13 Register
(1)
(1)
Port P12 Direction Register
Port P13 Direction Register
Pull-up Control Register 0
1. At hardware reset, the register is as follows:
"00000000b" where "L" is input to the CNVSS pin
"00000010b" where "H" is input to the CNVSS pin (CNVSS pin = H is not available in T/V-ver..)
At software reset, watchdog timer reset and oscillation stop detection reset, the register is as follows:
"00000000b" where the PM01 to PM00 bits in the PM0 register are "00b" (single-chip mode)
"00000010b" where the PM01 to PM00 bits in the PM0 register are "01b" (memory expansion mode) or "11b" (microprocessor mode)
* Not available memory expansion and microprocessor modes in T/V-ver..
2. These registers exist only in the128-pin version.
3. The blank areas are reserved and cannot be accessed by users.
Rev.2.00 Nov 28, 2005 page 34 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)5. Reset
5. Reset
Hardware reset, software reset, watchdog timer reset and oscillation stop detection reset are available to
reset the microcomputer.
5.1 Hardware Reset
____________
The microcomputer resets pins, the CPU and SFR by setting the RESET pin. If the supply voltage meets
the recommended operating conditions, the microcomputer resets all pins when an “L” signal is applied to
_______________________
the RESET pin (see Table 5.1 Pin Status When RESET Pin Level is “L”). The oscillation circuit is also
reset and the main clock starts oscillation. The microcomputer resets the CPU and SFR when the signal
____________
applied to the RESET pin changes low (“L”) to high (“H”). The microcomputer executes the program in an
address indicated by the reset vector. The internal RAM is not reset. When an “L” signal is applied to the
____________
RESET pin while writing data to the internal RAM, the internal RAM is in an indeterminate state.
Figure 5.1 shows an example of the reset circuit. Figure 5.2 shows a reset sequence. Table 5.1 lists pin
____________
states while the RESET pin is held low (“L”).
5.1.1 Reset on a Stable Supply Voltage
____________
(1) Apply “L” to the RESET pin
(2) Apply 20 or more clock cycles to the XIN pin
____________
(3) Apply “H” to the RESET pin
5.1.2 Power-on Reset
____________
(1) Apply “L” to the RESET pin
(2) Raise the supply voltage to the recommended operating level
(3) Insert td(P-R) ms as wait time for the internal voltage to stabilize
(4) Apply 20 or more clock cycles to the XIN pin
____________
(5) Apply “H” to the RESET pin
RESET
NOTE
1. Use the shortest possible wiring to connect external circuit.
VCC
Figure 5.1 Example Reset Circuit
VCC
0 V
R E S E T
0 V
v o l t a g
Re c o m m e n d e d
operation
e
0.2VCC or
below
0.2VCC or below
Supply a clock with td(P-R) +20
or more cycles to the XIN pin
Rev.2.00 Nov 28, 2005 page 35 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)5. Reset
VCC
XIN
td(P-R) More than
20 cycles
are needed
RESET
BCLK
Microprocessor
mode BYTE = H
Address
RD
WR
CS0
Microprocessor
mode BYTE = L
Address
RD
(1)
(1)
BCLK 28cycles
Content of reset vector
FFFFChFFFFDhFFFFEh
Content of reset vector
FFFFChFFFFEh
WR
CS0
Single-chip
mode
Addres
s
NOTE:
1. Not available in T/V-ver.
FFFFCh
Content of reset vector
FFFFEh
Figure 5.2 Reset Sequence
____________
Table 5.1 Pin Status When RESET Pin Level is “L”
Status
Pin Name
CNVSS = VSS
CNVSS = VCC
BYTE = VSSBYTE = VCC
(1)
P0Input portData inputData input
P1Input portData inputInput port
P2, P3, P4_0 to P4_3 Input portAddress output (undefined)Address output (undefined)
P4_4Input port
P4_5 to P4_7Input portInput port (Pulled high)Input port (Pulled high)
P5_0Input port
P5_1Input port
P5_2Input port
P5_3Input portBCLK outputBCLK output
P5_4Input port
P5_5Input port
P5_6Input portALE output (“L” is output)ALE output (“L” is output)
P5_7Input port
______
CS0 output (“H” is output)
______
WR output (“H” is output)
________
BHE output (undefined)
______
RD output (“H” is output)
___________
HLDA output
(The output value depends on (The output value depends on
the input to the HOLD pin)
__________
__________
HOLD input
________
RDY input
______
CS0 output (“H” is output)
______
WR output (“H” is output)
________
BHE output (undefined)
______
RD output (“H” is output)
___________
HLDA output
__________
the input to the HOLD pin)
__________
HOLD input
________
RDY input
P6, P7, P8_0 to P8_4, Input portInput portInput port
P8_6, P8_7, P9, P10
P11, P12, P13,Input portInput portInput port
P14_0, P14_1
(2)
NOTES:
1. Shown here is the valid pin state when the internal power supply voltage has stabilized after power-on.
When CNVSS = VCC, the pin state is indeterminate until the internal power supply voltage stabilizes.
* CNVSS = VCC is not available in T/V-ver..
2. P11, P12, P13, P14_0 and P14_1 pins are only in the 128-pin version.
Rev.2.00 Nov 28, 2005 page 36 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)5. Reset
5.2 Software Reset
The microcomputer resets pins, the CPU and SFR when the PM03 bit in the PM0 register is set to “1”
(microcomputer reset). Then the microcomputer executes the program in an address determined by the reset vector.
Set the PM03 bit to “1” while the main clock is selected as the CPU clock and the main clock oscillation is stable.
In the software reset, the microcomputer does not reset a part of the SFR. Refer to 4. Special FunctionRegister (SFR) for details.
Processor mode remains unchanged since the PM01 to PM00 bits in the PM0 register are not reset.
5.3 Watchdog Timer Reset
The microcomputer resets pins, the CPU and SFR when the PM12 bit in the PM1 register is set to “1” (reset
when watchdog timer underflows) and the watchdog timer underflows. Then the microcomputer executes
the program in an address determined by the reset vector.
In the watchdog timer reset, the microcomputer does not reset a part of the SFR. Refer to 4. SpecialFunction Register (SFR) for details.
Processor mode remains unchanged since the PM01 to PM00 bits in the PM0 register are not reset.
5.4 Oscillation Stop Detection Reset
The microcomputer resets and stops pins, the CPU and SFR when the CM27 bit in the CM2 register is “0”
(reset at oscillation stop, re-oscillation detection), if it detects main clock oscillation circuit stop. Refer to 8.5Oscillation Stop and Re-Oscillation Detection Function for details.
In the oscillation stop detection reset, the microcomputer does not reset a part of the SFR. Refer to 4. SpecialFunction Register (SFR) for details.
Processor mode remains unchanged since the PM01 to PM00 bits in the PM0 register are not reset.
5.5 Internal Space
Figure 5.3 shows CPU register status after reset. Refer to 4. Special Function Register (SFR) for SFR
states after reset.
b15b0
0000h
0000h
0000h
0000h
0000h
0000h
0000h
b19
00000h
Content of addresses FFFFEh to FFFFCh
b15b0
0000h
0000h
0000h
b15b0
0000h
b15b0
b7b8
Data Register (R0)
Data Register (R1)
Data Register (R2)
Data Register (R3)
Address Register (A0)
Address Register (A1)
Frame Base Register (FB)
b0
Interrupt Table Register (INTB)
Program Counter (PC)
User Stack Pointer (USP)
Interrupt Stack Pointer (ISP)
Static Base Register (SB)
Flag Register (FLG)
IPL U I O B S Z D C
Figure 5.3 CPU Register Status After Reset
Rev.2.00 Nov 28, 2005 page 37 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)6. Processor Mode
6. Processor Mode
Note
6. Processor Mode explains as an example of a Normal-ver..
T/V-ver. is available single-chip mode only. Not available memory expansion mode and microprocessor
mode.
6.1 Types of Processor Mode
Three processor modes are available to choose from: single-chip mode, memory expansion mode, and
microprocessor mode. (Not available memory expansion and microprocessor modes in T/V-ver..)
Table 6.1 shows the features of these processor modes.
Table 6.1 Features of Processor Modes
Processor ModeAccess SpacePins Which are Assigned I/O Ports
Single-chip ModeSFR, internal RAM, internal ROMAll pins are I/O ports or
peripheral function I/O pins
Memory Expansion Mode
Microprocessor Mode
NOTES:
1. Refer to 7. Bus.
2. Not available in T/V-ver..
(2)
SFR, internal RAM, internal ROM,Some pins serve as bus control pins
external area
(2)
SFR, internal RAM, external area
(1)
(1)
Some pins serve as bus control pins
(1)
(1)
Rev.2.00 Nov 28, 2005 page 38 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)6. Processor Mode
6.2 Setting Processor Modes
Processor mode is set by using the CNVSS pin and the PM01 to PM00 bits in the PM0 register.
Table 6.2 shows the processor mode after hardware reset. Table 6.3 shows the PM01 to PM00 bits set
values and processor modes.
Table 6.2 Processor Mode After Hardware Reset
CNVSS Pin Input LevelProcessor Mode
VSSSingle-chip mode
(1) (2) (3)
VCC
NOTES:
1. If the microcomputer is reset in hardware by applying VCC to the CNVSS pin, the internal ROM
cannot be accessed regardless of PM01 to PM00 bits.
2.
The multiplexed bus cannot be assigned to the entire CS space.
3. Not available in T/V-ver.. Do not set a value.
Table 6.3 PM01 to PM00 Bits Set Values and Processor Modes
PM01 to PM 00 BitsProcessor Mode
00bSingle-chip mode
(1)
01b
10bDo not set a value
(1)
11b
NOTE:
1. Not available in T/V-ver.. Do not set a value.
Microprocessor mode
_____
Memory expansion mode
Microprocessor mode
Rewriting the PM01 to PM00 bits places the microcomputer in the corresponding processor mode regardless of
whether the input level on the CNVSS pin is “H” or “L”. Note, however, that the PM01 to PM00 bits cannot
be rewritten to “01b” (memory expansion mode) or “11b” (microprocessor mode)
(1)
at the same time the
PM07 to PM02 bits are rewritten. Note also that these bits cannot be rewritten to enter microprocessor
mode in the internal ROM, nor can they be rewritten to exit microprocessor mode in areas overlapping the
internal ROM.
NOTE:
1. Not available memory expansion and mocroprocessor modes in T/V-ver..
If the microcomputer is reset in hardware by applying VCC to the CNVSS pin (hardware reset), the internal
ROM cannot be accessed regardless of PM01 to PM00 bits.
Figures 6.1 and 6.2 show the processor mode related registers. Figure 6.3 shows the memory map in
_____
single-chip mode. Figures 6.4 to 6.7 show the memory map and CS area in memory expansion mode and
microprocessor mode (Normal-ver. only).
Rev.2.00 Nov 28, 2005 page 39 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)6. Processor Mode
0 0 : Single-chip mode
0 1 : Memory expansion mode
1 0 : Do not set a value
1 1 : Microprocessor mode
0 : RD, BHE, WR
(3)
1 : RD, WRH, WRL
Setting this bit to "1" resets the
microcomputer. When read, its
.
content is "0"
b5 b4
0 0 : Multiplexed bus is unused
(Separate bus in the entire CS space)
0 1 : Allocated to CS2 space
1 0 : Allocated to CS1 space
1 1 :
Allocated to the entire CS space
0 : Address output
1 : Port function
(Address is not output)
0 : BCLK is output
1 : BCLK is not output
(Pin is left high-impedance)
(2)
(5)
(5)
(5)
NOTES:
1. Write to this register after setting the PRC1 bit in the PRCR register to "1" (write enable).
2. The PM01 to PM00 bits do not change at software reset, watchdog timer reset and oscillation stop detection reset.
* Effective in memory expansion and microprocessor modes (= Normal-ver.)
3. Effective when the PM01 to PM00 bits are set to "01b" (memory expansion mode) or "11b" (microprocessor mode).
* Not available memory expansion and microprocessor modes in T/V-ver.. These bits are reserved bit in
T/V-ver., and set to "0".
4. To set the PM01 to PM00 bits are "01b" and the PM05 to PM04 bits are "11b" (multiplexed bus assigned to
the entire CS space), apply an "H" signal to the BYTE pin (external data bus is 8-bit width).
While the CNVSS pin is held "H" (VCC), do not rewrite the PM05 to PM04 bits to "11b" after reset.
If the PM05 to PM04 bits are set to "11b" during memory expansion mode, P3_1 to P3_7 and P4_0 to P4_3
become I/O ports, in which case the accessible area for each CS is 256 bytes.
* Not available memory expansion and microprocessor modes in T/V-ver..
5. Not available in T/V-ver.. Do not set a value.
(4)
RW
RW
RW
RW
RW
RW
RW
RW
RW
Figure 6.1 PM0 Register
Rev.2.00 Nov 28, 2005 page 40 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)6. Processor Mode
1. Write to this register after setting the PRC1 bit in the PRCR register to "1" (write enable).
2. For the mask ROM version, this bit must be set to "0".
For the flash memory version, the PM10 bit also controls block A by enabling or disabling it. When the PM10
bit is set to "1", 0F000h to 0FFFFh (block A) can be used as internal ROM area.
In addition, the PM10 bit is automatically set to "1" when the FMR01 bit in the FMR0 register is "1" (CPU rewrite
mode).
3. Effective when the PM01 to PM00 bits are set to "01b" (memory expansion mode) or "11b" (microprocessor mode).
* Not available memory expansion and microprocessor modes in T/V-ver.. This bit is reserved bit in T/V-ver.,
and set to "0".
4. The PM12 bit is set to "1" by writing a "1" in a program. (Writing a "0" has no effect.)
5. Be sure to set this bit to "0" except for products with internal ROM area over 192 Kbytes.
The PM13 bit is automatically set to "1" when the FMR01 bit in the FMR0 register is "1" (CPU rewrite mode).
6. When the PM17 bit is set to "1" (with wait state), one wait state is inserted when accessing the internal RAM
or internal ROM.
When the PM17 bit is set to "1" and accesses an external area, set the CSiW bit (i = 0 to 3) in the CSR register
to "0" (with wait state).
7. The access area is changed by the PM13 bit as listed in the table below.
Access areaPM13 = 0PM13 = 1
Internal
External
RAM
ROM
Up to addresses 00400h to 03FFFh (15 Kbytes)
Up to addresses D0000h to FFFFFh (192 Kbytes)
Addresses 04000h to 07FFFh are usable
Addresses 80000h to CFFFFh are usable
The entire area is usable
The entire area is usable
Addresses 04000h to 07FFFh are reserved
Addresses 80000h to CFFFFh are reserved
(Memory expansion mode)
* External area is not available in T/V-ver..
RW
RW
RW
RW
RW
RW
RW
Figure 6.2 PM1 Register
Rev.2.00 Nov 28, 2005 page 41 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)6. Processor Mode
Single-chip mode
00000h
SFR
00400h
Internal RAM
XXXXXh
Can not use
YYYYYh
Internal ROM
FFFFFh
NOTES:
1. If the PM13 bit in the PM1 register is set to "0", 15 Kbytes of the internal RAM and 192
Kbytes of the internal ROM can be used.
2. For the mask ROM version, set the PM10 bit in the PM1 register to "0" (block A disabled,
addresses 08000h to 26FFFh for CS2 area).
1. For the flash memory version, when the PM10 bit is set to "1", 0F000h to 0FFFFh (block A)
can be used as internal ROM area.
2. Not available memory expansion and microprocessor modes in T/V-ver..
_____
Figure 6.7 Memory Map and CS Area in Memory Expansion Mode and Microprocessor Mode (4)
Rev.2.00 Nov 28, 2005 page 44 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)7. Bus
7. Bus
Note
7. Bus explains as an example of a Normal-ver..
Not available the bus control pins in T/V-ver..
During memory expansion or microprocessor mode, some pins serve as the bus control pins to perform data
input/output to and from external devices. These bus control pins include A0 to A19, D0 to D15, CS0 to CS3,
RD, WRL/WR, WRH/BHE, ALE, RDY, HOLD, HLDA and BCLK.
7.1 Bus Mode
The bus mode, either multiplexed or separate, can be selected using the PM05 to PM04 bits in the PM0
register.
7.1.1 Separate Bus
In this bus mode, data and address are separate.
7.1.2 Multiplexed Bus
In this bus mode, data and address are multiplexed.
7.1.2.1 When the input level on BYTE pin is high (8-bit data bus)
D0 to D7 and A0 to A7 are multiplexed.
7.1.2.2 When the input level on BYTE pin is low (16-bit data bus)
D0 to D7 and A1 to A8 are multiplexed. D8 to D15 are not multiplexed. Do not use D8 to D15.
External devices connecting to a multiplexed bus are allocated to only the even addresses of the
microcomputer. Odd addresses cannot be accessed.
Table 7.1 shows the difference between a separate bus and multiplexed bus.
Table 7.1 Difference between Separate Bus and Multiplexed Bus
Pin Name
(1)
Separate Bus
BYTE = HBYTE = L
Multiplexed Bus
P0_0 to P0_7/D0 to D7D0 to D7(NOTE 2)(NOTE 2)
P1_0 to P1_7/D8 to D15D8 to D15
I/O Port
P1_0 to P1_7
(NOTE 2)
P2_0/A0(/D0/-)A0A0 D0A0
P2_1 to P2_7/A1 to A7
(/D1 to D7/D0 to D6)
A1 to A7A1 to A7 D1 to D7A1 to A7 D0 to D6
P3_0/A8(/-/D7)A8A8A8 D7
NOTES :
1. See Table 7.6 Pin Functions for Each Processor Mode for bus control signals other than the above.
2. It changes with a setup of PM05 to PM04, and area to access. See Table 7.6 Pin Functions for EachProcessor Mode for details.
Rev.2.00 Nov 28, 2005 page 45 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)7. Bus
7.2 Bus Control
The following describes the signals needed for accessing external devices and the functionality of software
wait.
7.2.1 Address Bus
The address bus consists of 20 lines, A0 to A19.
The address bus width can be chosen to be 12,
16 or 20 bits by using the PM06 bit in the PM0
register and the PM11 bit in the PM1 register.
Table 7.2 shows the PM06 and PM11 bits set
values and address bus widths.
When processor mode is changed from single-chip
mode to memory expansion mode, the address
bus is indeterminate until any external area is
accessed.
Table 7.2 PM06 and PM11 Bits Set Value and
Address Bus Width
Set Value
(1)
Pin Function Address Bus Width
PM11 = 1P3_4 to P3_7 12 bits
PM06 = 1P4_0 to P4_3
PM11 = 0A12 to A1516 bits
PM06 = 1P4_0 to P4_3
PM11 = 0A12 to A1520 bits
PM06 = 0A16 to A19
NOTE:
1. No values other than those shown above can
be set.
7.2.2 Data Bus
When input on the BYTE pin is high (data bus is an 8-bit width), 8 lines D0 to D7 comprise the data bus;
when input on the BYTE pin is low (data bus is a 16-bit width), 16 lines D0 to D15 comprise the data bus.
Do not change the input level on the BYTE pin while in operation.
7.2.3 Chip Select Signal
The chip select (hereafter referred to as the CS) signals are output from the CSi (i = 0 to 3) pins. These
pins can be chosen to function as I/O ports or as CS by using the CSi bit in the CSR register.
Figure 7.1 shows the CSR register.
During 1 Mbyte mode, the external area can be separated into up to 4 by the CSi signal which is output
from the CSi pin.
Figure 7.2 shows the example of address bus and CSi signal output.
______
___________
_____
______
______
Chip Select Control Register
b7 b6 b5 b4 b3 b2 b1 b0
NOTES:
1. Where the RDY signal is used in the area indicated by CSi (i = 0 to 3) or the multiplexed bus is used, set the
CSiW bit to "0" (Wait state).
2. If the PM17 bit in the PM1 register is set to "1" (with wait state), set the CSiW bit to "0" (with wait state).
3. When the CSiW bit = 0 (with wait state), the number of wait states (in terms of clock cycles) can be selected
using the CSEi1W to CSEi0W bits in the CSE register.
4. Not available this register in T/V-ver..
Figure 7.1 CSR Register
(4)
SymbolAddressAfter Reset
CSR0008h00000001b
Bit Symbol
CS0
CS1
CS2
CS3
CS0W
CS1W
CS2W
CS3W
Bit NameFunction
CS0 Output Enable Bit
CS1 Output Enable Bit
CS2 Output Enable Bit
CS3 Output Enable Bit
CS0 Wait Bit
CS1 Wait Bit
CS2 Wait Bit
CS3 Wait Bit
0 : Chip select output disabled
1 : Chip select output enabled
0 : With wait state
1 : Without wait state
(functions as I/O port)
(1) (2) (3)
RW
RW
RW
RW
RW
RW
RW
RW
RW
Rev.2.00 Nov 28, 2005 page 46 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)7. Bus
Example 1
To access the external area indicated by CSj in the next cycle
after accessing the external area indicated by CSi.
The address bus and the chip select signal both change state
between these two cycles.
Access to the external
area indicated by CSi
BCLK
Read signal
Data bus
Address bus
CSi
CSj
Example 3
To access the external area indicated by CSi in the next cycle
after accessing the external area indicated by the same CSi.
The address bus changes state but t he chip select signal
does not change state.
Address
Access to the external
area indicated by CSj
Data
Data
Address
Example 2
To access the internal ROM or internal RAM in the next cycle
after accessing the external area indicated by CSi.
The chip select s ignal changes state but the address bus
does not change state.
Access to the external
area indicated by CSi
BCLK
Read signal
Data bus
Address bus
CSi
Example 4
Not to access any area (nor instruction prefetch generated)
in the next cycle after accessing the external area indicated
by CSi.
Neither the address bus nor the chip select signal changes
state between these two cycles.
Access to the internal
ROM or internal RAM
Data
Address
Access to the external
area indicated by CSi
BCLK
Read signal
Data bus
Address bus
CSi
NOTE:
1. These examples show the address bus and chip select signal when accessing areas in two successive cycles. The chip select bus cycle may be
extended more than two cycles depending on a combination of these examples.
Shown above is the case where separate bus is selected and the area is accessed for read without wait states. i = 0 to 3, j = 0 to 3 (not including i, however)
Address
Access to the same
external area
DataData
Address
Read signal
Address bus
______
Access to the external
area indicated by CSi
BCLK
Data bus
CSi
No access
Data
Address
Figure 7.2 Example of Address Bus and CSi Signal Output
Rev.2.00 Nov 28, 2005 page 47 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)7. Bus
7.2.4 Read and Write Signals
When the data bus is 16-bit width, the read and write signals can be chosen to be a combination of RD,
___________________ ________________
WR and BHE or a combination of RD, WRL and WRH by using the PM02 bit in the PM0 register. When
the data bus is 8-bit width, use a combination of RD, WR and BHE.
Table 7.3 shows the operation of RD, WRL, and WRH signals. Table 7.4 shows the operation of RD, WR,
________
_____ ______________________ ______
and BHE signals.
_____ _________________
Table 7.3 Operation of RD, WRL and WRH Signals
Data Bus Width
16 Bits
(BYTE pin
input = L)
Table 7.4 Operation of RD, WR and BHE Signals
Data Bus Width
16 Bits
(BYTE pin
input = L)
8 Bits
(BYTE pin input = H)
_____
RD
L
H
H
H
_____ ______________
_____
RD
______
WR
H
L
H
L
H
L
H
L
________
WRL
H
L
H
L
________
BHE
L
H
L
H
L
H
L
H
L
L
H
H
L
L
Not used
Not used
_____ ______________
_________
WRHStatus of External Data Bus
H
H
L
L
A0
H
H
L
L
L
L
H to L
H to L
Read data
Write 1 byte of data to an even address
Write 1 byte of data to an odd address
Write data to both even and odd addresses
Status of External Data Bus
Write 1 byte of data to an odd address
Read 1 byte of data from an odd address
Write 1 byte of data to an even address
Read 1 byte of data from an even address
Write data to both even and odd addresses
Read data from both even and odd addresses
Write 1 byte of data
Read 1 byte of data
_____
7.2.5 ALE Signal
The ALE signal latches the address when accessing the multiplexed bus space. Latch the address when
the ALE signal falls. Figure 7.3 shows the ALE signal, address bus and data bus.
When BYTE pin input = HWhen BYTE pin input = L
ALE
A0/D0 to A7/D7
A8 to A19
NOTE:
1. If the entire CS space is assigned a multiplexed bus, these pins function as I/O ports.
Address Data
Address
(1)
Figure 7.3 ALE Signal, Address Bus, Data Bus
A1/D0 to A8/D7
ALE
A0
A9 to A19
Address
Address Data
Address
Rev.2.00 Nov 28, 2005 page 48 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)7. Bus
________
7.2.6 RDY Signal
This signal is provided for accessing external devices which need to be accessed at low speed. If input on
________
the RDY pin is asserted low at the last falling edge of BCLK of the bus cycle, one wait state is inserted in
the bus cycle. While in a wait state, the following signals retain the state in which they were when the RDY
signal was acknowledged.
A0 to A19, D0 to D15, CS0 to CS3, RD, WRL, WRH, WR, BHE, ALE, HLDA
________
Then, when the input on the RDY pin is detected high at the falling edge of BCLK, the remaining bus cycle
is executed. Figure 7.4 shows example in which the wait state was inserted into the read cycle by the
________________
RDY signal. To use the RDY signal, set the corresponding bit (CS3W to CS0W bits) in the CSR register
________________
to “0” (with wait state). When not using the RDY signal, the RDY pin must be pulled-up.
In an instance of separate bus
BCLK
________
RD
CSi
(i=0 to 3)
RDY
Accept timing of RDY signal
In an instance of multiplexed bus
BCLK
RD
CSi
(i=0 to 3)
RDY
: Wait using RDY signal
: Wait using software
tsu(RDY - BCLK)
tsu(RDY - BCLK)
Accept timing of RDY signal
tsu(RDY-BCLK): RDY input setup time
Shown above is the case where CSEi1W to CSEi0W (i = 0 to 3) bits in the CSE register are
"00b" (one wait state).
________
Figure 7.4 Example in which Wait State was Inserted into Read Cycle by RDY Signal
Rev.2.00 Nov 28, 2005 page 49 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)7. Bus
__________
7.2.7 HOLD Signal
This signal is used to transfer control of the bus from CPU or DMAC to an external circuit. When the input
__________
on HOLD pin is pulled low, the microcomputer is placed in a hold state after the bus access then in
process finishes. The microcomputer remains in a hold state while the HOLD pin is held low, during which
__________
__________
time the HLDA pin outputs a low-level signal.
Table 7.5 shows the microcomputer status in the hold state.
__________
Bus-using priorities are given to HOLD, DMAC, and CPU in order of decreasing precedence (see Figure
7.5 Bus-using Priorities). However, if the CPU is accessing an odd address in word units, the DMAC
cannot gain control of the bus during two separate accesses.
__________
HOLD > DMAC > CPU
Figure 7.5 Bus-using Priorities
Table 7.5 Microcomputer Status in Hold State
ItemStatus
BCLKOutput
A0 to A19, D0 to D15, CS0 to CS3, RD, WRL, WRH,High-impedance
2. The watchdog timer does not stop when the PM22 bit in the PM2 register is set to “1” (the count source
for the watchdog timer is the on-chip oscillator clock).
______________ ______ _________ _________
P6 to P10Maintains status when hold signal is received
(1)
High-impedance
(2)
)
7.2.8 BCLK Output
If the PM07 bit in the PM0 register is set to “0” (output enable), a clock with the same frequency as that
of the CPU clock is output as BCLK from the BCLK pin. Refer to 8.2 CPU Clock and Peripheral FunctionClock.
Table 7.6 shows the pin functions for each processor mode.
Rev.2.00 Nov 28, 2005 page 50 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)7. Bus
Table 7.6 Pin Functions for Each Processor Mode
Processor ModeMemory Expansion Mode or Microprocessor Mode
_______
01b (CS2 is for multiplexed bus and
others are for separate bus)
PM05 to PM04 Bits00b (separate bus)
_______
10b (CS1 is for multiplexed bus and
others are for separate bus)
Memory Expansion Mode
11b
(multiplexed bus for
the entire space)
(1)
Data Bus Width8 bits16 bits8 bits16 bits 8 bits
BYTE Pin“H”“L”“H”“L”“H”
P0_0 to P0_7D0 to D7D0 to D7
P1_0 to P1_7I/O portsD8 to D15I/O ports
P2_0A0A0/D0
P2_1 to P2_7A1 to A7A1 to A7A1 to A7
/D1 to D7
P3_0A8A8/D7
(4)
D8 to D15
(2)
A0A0/D0
(4)
I/O ports
I/O ports
A1 to A7/D1 to D7
(2)
/D0 to D6
(2)
(2)
A8
P3_1 to P3_3A9 to A11I/O ports
P3_4PM11 = 0 A12 to A15I/O ports
to P3_7PM11 = 1 I/O ports
P4_0PM06 = 0 A16 to A19I/O ports
to P4_3PM06 = 1 I/O ports
P4_4CS0 = 0I/O ports
CS0 = 1
P4_5CS1 = 0I/O ports
CS1 = 1
P4_6CS2 = 0I/O ports
CS2 = 1
P4_7CS3 = 0I/O ports
CS3 = 1
P5_0PM02 = 0
PM02 = 1-
P5_1PM02 = 0
PM02 = 1P5_2
P5_3BCLK
P5_4
P5_5
P5_6ALE
P5_7
_______
CS0
_______
CS1
_______
CS2
_______
CS3
_______
WR
(3)
________
BHE
(3)
_____
RD
__________
HLDA
__________
HOLD
________
RDY
________
WRL
_________
WRH
(3)
-
(3)
-
________
WRL
_________
WRH
(3)
-
(3)
-
I/O ports: Function as I/O ports or peripheral function I/O pins.
NOTES:
1. For setting the PM01 to PM00 bits to “01b” (memory expansion mode) and the PM05 to PM04 bits to
_____
“11b” (multiplexed bus assigned to the entire CS space), apply “H” to the BYTE pin (external data bus is
an 8-bit width). While the CNVSS pin is held “H” (VCC), do not rewrite the PM05 to PM04 bits to “11b”
after reset. If the PM05 to PM04 bits are set to “11b” during memory expansion mode, P3_1 to P3_7
_____
and P4_0 to P4_3 become I/O ports, in which case the accessible area for each CS is 256 bytes.
2. In separate bus mode, these pins serve as the address bus.
3.
If the data bus is 8-bit width, make sure the PM02 bit is set to “0” (RD, BHE, WR).
_____ ________ ______
4. When accessing the area that uses a multiplexed bus, these pins output an indeterminate value during
a write.
Rev.2.00 Nov 28, 2005 page 51 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)7. Bus
7.2.9 External Bus Status When Internal Area Accessed
Table 7.7 shows the external bus status when the internal area is accessed.
Table 7.7 External Bus Status When Internal Area Accessed
A0 to A19Address outputMaintain status before accessed address
of external area or SFR
D0 to D15 When read High-impedanceHigh-impedance
_____ ______ ________ _________
RD, WR, WRL, WRH
________
BHE
______________
When write Output dataUndefined
_____ ______ _________ __________
RD, WR, WRL, WRH outputOutput “H”
________
BHE outputMaintain status before accessed status of
external area or SFR
CS0 to CS3Output “H”Output “H”
ALEOutput “L”Output “L”
7.2.10 Software Wait
Software wait states can be inserted by using the PM17 bit in the PM1 register, the CS0W to CS3W bits
in the CSR register, and the CSE register. The SFR area is unaffected by these control bits. This area is
always accessed in 2 BCLK or 3 BCLK cycles as determined by the PM20 bit in the PM2 register. See
Table 7.8 Bit and Bus Cycle Related to Software Wait for details.
To use the RDY signal, set the corresponding CS3W to CS0W bit to “0” (with wait state). Figure 7.6 shows
the CSE register. Table 7.8 shows the software wait related bits and bus cycles. Figures 7.7 and 7.8 show
the typical bus timings using software wait.
________
Chip Select Expansion Control Register
b7 b6 b5 b4 b3 b2 b1 b0
NOTES:
1. Set the CSiW bit (i = 0 to 3) in the CSR register to "0" (with wait state) before writing to the CSEi1W to CSEi0W
bits. If the CSiW bit needs to be set to "1" (without wait state), set the CSEi1W to CSEi0W bits to "00b" before
setting it.
2. Not available this register in T/V-ver..
SymbolAddressAfter Reset
CSE001Bh00h
Bit Symbol
CSE00W
CS0 Wait Expansion Bit
CSE01W
CSE10W
CS1 Wait Expansion Bit
CSE11W
CS20WE
CS2 Wait Expansion Bit
CSE21W
CSE30W
CS3 Wait Expansion Bit
CSE31W
(2)
Bit NameFunction
b1 b0
0 0 : 1 wait
0 1 : 2 waits
(1)
1 0 : 3 waits
1 1 : Do not set a value
b3 b2
0 0 : 1 wait
0 1 : 2 waits
(1)
1 0 : 3 waits
1 1 : Do not set a value
b5 b4
0 0 : 1 wait
0 1 : 2 waits
(1)
1 0 : 3 waits
1 1 : Do not set a value
b7 b6
0 0 : 1 wait
0 1 : 2 waits
(1)
1 0 : 3 waits
1 1 : Do not set a value
RW
RW
RW
RW
RW
RW
RW
RW
RW
Figure 7.6 CSE Register
Rev.2.00 Nov 28, 2005 page 52 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)7. Bus
Table 7.8 Software Wait Related Bits and Bus Cycles
2. To access in multiplexed bus mode, set the corresponding bit of CS0W to CS3W to “0” (with wait state).
3. After reset, the PM17 bit is set to “0” (without wait state), all of the CS0W to CS3W bits are set to “0”
______________
(with wait state), and the CSE register is set to “00h” (one wait state for CS0 to CS3). Therefore, the
internal RAM and internal ROM are accessed with no wait state, and all external areas are accessed
with one wait state.
4. When the selected CPU clock source is the PLL clock, the number of wait cycles can be altered by the
PM20 bit in the PM2 register. When using PLL clock over 16 MHz, be sure to set the PM20 bit to “0”
(2 wait cycles).
5. When the PM17 bit is set to “1” and access an external area, set the CSiW bits (i = 0 to 3) to “0” (with
wait sate).
Rev.2.00 Nov 28, 2005 page 53 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)7. Bus
(1) Separate bus, No wait setting
BCLK
Write signal
Read signal
Data bus
Address bus
CS
(2) Separate bus, 1-wait setting
BCLK
Write signal
Read signal
Bus cycle
Output
Address
Bus cycle
(1)
Bus cycle
(1)
Input
Address
(1)
Bus cycle
(1)
Data bus
Address bus
Address
Output
Address
Input
CS
(3) Separate bus, 2-wait setting
Bus cycle
(1)
Bus cycle
(1)
BCLK
Write signal
Read signal
Address
Output
Address
Data bus
Address bus
CS
NOTE:
1. These example timing charts indicate bus cycle length. After this bus cycle sometimes come read and
write cycles in succession.
Input
Figure 7.7 Typical Bus Timings Using Software Wait (1)
Rev.2.00 Nov 28, 2005 page 54 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)7. Bus
(1) Separate bus, 3-wait setting
BCLK
Write signal
Read signal
Bus cycle
(1)
Bus cycle
(1)
Data bus
Address bus
CS
(2)Multiplexed bus, 1- or 2-wait setting
BCLK
Write signal
Read signal
ALE
Address bus
Address bus/
Data bus
Address
CS
(3)Multiplexed bus, 3-wait setting
Address
Bus cycle
Address
Data output
Bus cycle
Output
(1)
Bus cycle
Address
Address
(1)
(1)
Input
Address
Bus cycle
Input
(1)
BCLK
Write signal
Read signal
ALE
Address bus
Address bus/
Data bus
Address
Address
Data output
CS
NOTE:
1. These example timing charts indicate bus cycle length. After this bus cycle sometimes come read and
write cycles in succession.
Figure 7.8 Typical Bus Timings Using Software Wait (2)
Rev.2.00 Nov 28, 2005 page 55 of 378
REJ09B0124-0200
Address
Address
Input
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
8. Clock Generating Circuit
8.1 Types of Clock Generating Circuit
Four circuits are incorporated to generate the system clock signal:
• Main clock oscillation circuit
• Sub clock oscillation circuit
• On-chip oscillator
• PLL frequency synthesizer
Table 8.1 lists the clock generating circuit specifications. Figure 8.1 shows the clock generating circuit.
Figures 8.2 to 8.8 show the clock-related registers.
Table 8.1 Clock Generating Circuit Specifications
Item
Use of Clock
Clock
Frequency
Usable
Oscillator
Pins to Connect
Oscillator
Oscillation Stop
and Re-Oscillation
Detection Function
Oscillation Status
After Reset
Main Clock
Oscillation Circuit
• CPU clock source
• Peripheral function
clock source
0 to 16 MHz
•Ceramic oscillator
•Crystal oscillator
XIN, XOUT
Available
Oscillating
Sub Clock
Oscillation Circuit
• CPU clock source
• Clock source of Timer
A, B
32.768 kHz
•Crystal oscillator
XCIN, XCOUT
Available
Stopped
On-chip Oscillator
• CPU clock source
• Peripheral function
clock source
• CPU and peripheral
function clock sources
when the main clock
stops oscillating
About 1 MHz
-
-
Available
Stopped
PLL Frequency
Synthesizer
• CPU clock source
• Peripheral function
clock source
16 MHz, 20 MHz,
24 MHz
(1)
-
-
Available
Stopped
Other
Externally derived clock can be input
NOTE:
1. 24 MHs is available Normal-ver. only.
Rev.2.00 Nov 28, 2005 page 56 of 378
REJ09B0124-0200
-
-
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
WAIT instruction
Sub clock oscillation circuit
CM04
CM10=1
(stop mode)
Software reset
Interrupt request level
QS
R
CM05
QS
R
RESET
NMI
judgment output
PM00, PM01: Bits in PM0 register
CM00, CM01, CM02, CM04, CM05, CM06, CM07 : BIts in CM0 register
CM10, CM11, CM16, CM17: Bits in CM1 register
PCLK0, PCLK1: Bits in PCLKR register
CM21, CM27: Bits in CM2 register
CCLK0 to CCLK2, CCLK4 to CCLK6: Bits in CCLKR register
Oscillation stop,
re-oscillation detection
interrupt signal
CM21 switch signal
Voltage
control
(VCO)
Internal
1/2
PLL clock
Rev.2.00 Nov 28, 2005 page 57 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
System Clock Control Register 0
b7 b6 b5 b4 b3 b2 b1 b0
SymbolAddressAfter Reset
(1)
CM00006h 01001000b
Bit NameFunctionBit Symbol
CM00
CM01
CM02
CM03
CM04
CM05
CM06
CM07
Clock Output Function
Select Bit
(Valid only in single-chip
mode)
WAIT Mode Peripheral
Function Clock Stop Bit
XCIN-XCOUT Drive
Capacity Select Bit
Port XC Select Bit
Main Clock Stop Bit
Main Clock Division Select
(7) (10) (12)
Bit 0
System Clock Select
(6) (11)
Bit
(3)
(3)
(5) (6) (7)
NOTES:
1. Write to this register after setting the PRC0 bit in the PRCR register to "1" (write enable).
2. The fC32 clock does not stop. During low-speed or low power dissipation mode, do not set this bit to "1"
(peripheral clock turned off when in wait mode).
3. The CM03 bit is set to "1" (high) while the CM04 bit is set to "0" (I/O port) or when entered to stop mode.
4. To use a sub clock, set this bit to "1". Also make sure ports P8_6 and P8_7 are directed for input, with no
pull-ups.
5. This bit is provided to stop the main clock when the low power dissipation mode or on-chip oscillator low
power dissipation mode is selected. This bit cannot be used for detection as to whether the main clock stopped
or not. To stop the main clock, set bits in the following order.
(1) Set the CM07 bit to "1" (sub clock select) or the CM21 bit in the CM2 register to "1" (on-chip oscillator select)
with the sub clock stably oscillating.
(2) Set the CM20 bit in the CM2 register to "0" (oscillation stop, re-oscillation detection function disabled).
(3) Set the CM05 bit to "1" (stop).
6. To use the main clock as the clock source for the CPU clock, set bits in the following order.
(1) Set the CM05 bit to "0" (oscillate)
(2) Wait until the main clock oscillation stabilizes.
(3) Set the CM11, CM21 and CM07 bits all to "0".
7. When the CM21 bit = 0 (on-chip oscillator turned off) and the CM05 bit = 1 (main clock turned off), the CM06
bit is fixed to "1" (divide-by-8 mode) and the CM15 bit is fixed to "1" (drive capability High).
8. During external clock input, set the CM05 bit to "0" (oscillate).
9. When the CM05 bit is set to "1", the XOUT pin goes "H". Furthermore, because the internal feedback resistor
remains connected, the XIN pin is pulled "H" to the same level as XOUT via the feedback resistor.
10. When entering stop mode from high- or medium-speed mode, on-chip oscillator mode or on-chip oscillator
low power dissipation mode, the CM06 bit is set to "1" (divide-by-8 mode).
11. After setting the CM04 bit to "1" (XCIN-XCOUT oscillator function), wait until the sub clock oscillates stably
before switching the CM07 bit from "0" to "1" (sub clock).
12. To return from on-chip oscillator mode to high-speed or medium-speed mode, set the CM06 and CM15 bits
both to "1".
clock in wait mode
1 : Stop peripheral function clock
in wait mode
(2)
0 : LOW
1 : HIGH
0 : I/O port P8_6, P8_7
1 : XCIN-XCOUT generation
function
0 : On
1 : Off
(4)
(8) (9)
0 : CM16 and CM17 valid
1 : Divide-by-8 mode
0 : Main clock, PLL clock,
or on-chip oscillator clock
1 : Sub clock
RW
RW
RW
RW
RW
RW
RW
RW
RW
Figure 8.2 CM0 Register
Rev.2.00 Nov 28, 2005 page 58 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
System Clock Control Register 1
b7 b6 b5 b4 b3 b2 b1 b0
000
Symbol
CM10007h00100000b
(1)
AddressAfter Reset
Bit NameFunctionBit Symbol
CM10
CM11
-
(b4-b2)
CM15
CM16
CM17
All Clock Stop Control
(2) (3)
Bit
System Clock Select Bit 1
Reserved Bit
XIN-XOUT Drive Capacity
Select Bit
Main Clock Division
Select Bit 1
(6)
(7)
NOTES:
1. Write to this register after setting the PRC0 bit in the PRCR register to "1" (write enable)
2. If the CM10 bit is "1" (stop mode), XOUT goes "H" and the internal feedback resistor is disconnected.
The XCIN and XCOUT pins are placed in the high-impedance state. When the CM11 bit is set to "1" (PLL
clock), or the CM20 bit in the CM2 register is set to "1" (oscillation stop, re-oscillation detection function enabled),
do not set the CM10 bit to "1".
3. When the PM22 bit in the PM2 register is set to "1" (watchdog timer count source is on-chip oscillator clock),
writing to the CM10 bit has no effect.
4. Effective when the CM07 bit is "0" and the CM21 bit is "0".
5. After setting the PLC07 bit in the PLC0 register to "1" (PLL operation), wait until tsu(PLL) elapses before
setting the CM11 bit to "1" (PLL clock).
6. When entering stop mode from high- or medium-speed mode, or when the CM05 bit is set to "1" (main clock
turned off) in low-speed mode, the CM15 bit is set to "1" (drive capability high).
7. Effective when the CM06 bit is "0" (CM16 and CM17 bits enabled).
1. Write to this register after setting the PRC0 bit in the PRCR register to "1" (write enable).
2. The CM20, CM21 and CM27 bits do not change at oscillation stop detection reset.
3. Set the CM20 bit to "0" (disable) before entering stop mode. After exiting stop mode, set the CM20 bit back
to "1" (enable).
4. Set the CM20 bit to "0" (disable) before setting the CM05 bit in the CM0 register.
5. When the CM20 bit is "1" (oscillation stop, re-oscillation detection function enabled), the CM27 bit is "1"
(oscillation stop, re-oscillation detection interrupt), and the CPU clock source is the main clock, the CM21 bit
is set to "1" (on-chip oscillator clock) if the main clock stop is detected.
6. If the CM20 bit is "1" and the CM23 bit is "1" (main clock turned off), do not set the CM21 bit to "0".
7. Effective when the CM07 bit in the CM0 register is "0".
8. Where the CM20 bit is "1" (oscillation stop, re-oscillation detection function enabled), the CM27 bit is "1"
(oscillation stop, re-oscillation detection interrupt), and the CM11 bit is "1" (the CPU clock source is PLL clock),
the CM21 bit remains unchanged even when main clock stop is detected. If the CM22 bit is "0" under these
conditions, an oscillation stop, re-oscillation detection interrupt request is generated at main clock stop detection;
it is, therefore, necessary to set the CM21 bit to "1" (on-chip oscillator clock) inside the interrupt routine.
9. This bit is set to "1" when the main clock is detected to have stopped and when the main clock is detected to
have restarted oscillating. When this bit changes state from "0" to "1", an oscillation stop and re-oscillation
detection interrupt request is generated. Use this bit in an interrupt routine to discriminate the causes of
interrupts between the oscillation stop and re-oscillation detection interrupt and the watchdog timer interrupt.
This bit is set to "0" by writing "0" in a program. (Writing "1" has no effect. Nor is it set to "0" by an oscillation
stop and re-oscillation detection interrupt request acknowledged.)
If an oscillation stop or a re-oscillation is detected when the CM22 bit = 1, no oscillation stop and re-oscillation
detection interrupt requests are generated.
10. Read the CM23 bit in an oscillation stop and re-oscillation detection interrupt handling routine to determine
the main clock status.
11. When the CM21 bit = 0 (on-chip oscillator turned off) and the CM05 bit = 1 (main clock turned off), the CM06
bit is fixed to "1" (divide-by-8 mode) and the CM15 bit is fixed to "1" (drive capability High).
RW
RW
RW
RW
RO
RW
-
RW
Figure 8.4 CM2 Register
Rev.2.00 Nov 28, 2005 page 60 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
Peripheral Clock Select Register
b7 b6 b5 b4 b3 b2 b1 b0
000
SymbolAddress After Reset
PCLKR025Eh00h
(1)
Bit NameFunctionBit Symbol
Timers A, B, and A/D Clock
PCLK0
Select Bit
(Clock source for the timers A, B,
the dead time timer and A/D)
SI/O Clock Select Bit
PCLK1
-
(b4-b2)
PCLK5
PCLK6
PCLK7
(Clock source for UART0 to UART2,
SI/O3 to SI/O6)
(5)
Reserved Bit
Pin Function Swirch Bit
Software Interrupt Number/SFR
Location Switch Bit
A/D Clock Direct Input Bit
NOTES:
1. Write to this register after setting the PRC0 bit in the PRCR register to "1" (write enable).
2. If this bit is set to "1", the software interrupt number and SFR location can be changed as follows.
(1) Software interrupt number of the key input interrupt in the vector table can be changed from 14 to 13.
- No.13 is changed from the CAN0/1 error interrupt to the CAN0/1 error/key input interrupt.
- No.14 is changed from the A/D/key input interrupt to the A/D interrupt.
(2) Address of the KUPIC register in the SFR can be changed from 004Eh to 004Dh.
- Address 004Dh is changed from the C01ERRIC register to the C01ERRIC/KUPIC register.
- Address 004Eh is changed from the ADIC/KUPIC register to the ADIC register.
3. When this bit = 1, the A/D clock is set to divide-by-1 of fAD mode regardless of whether the PCLK0 bit is set.
4. When the PCLK5 bit and the SM43 bit in the S4C register = 1, the pin function of SI/O4 can be changed as follows.
P8_0/TA4OUT/U/(SIN4)
P7_5/TA2IN/W/(SOUT4)
P7_4/TA2OUT/W/(CLK4)
5. SI/O5 and SI/O6 are only in the 128-pin version.
0 : Divide-by-2 of fAD, f2
1 : fAD, f1
0 : f2SIO
1 : f1SIO
Set to "0"
0: Normal mode
1: Swiching mode
0: Normal mode
1: Swiching mode
0: Normal mode
1: Swiching mode
(4)
(2)
(3)
RW
RW
RW
RW
RW
RW
RW
Figure 8.5 PCLKR Register
Rev.2.00 Nov 28, 2005 page 61 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
CAN0/1 Clock Select Register
b7 b6 b5 b4 b3 b2 b1 b0
(1)
SymbolAddressAfter Reset
CCLKR025Fh00h
Bit NameFunctionBit Symbol
b2 b1 b0
CCLK0
CCLK1
CAN0 Clock Select Bits
CCLK2
CCLK3
CAN0 CPU Interface
Sleep Bit
(3)
CCLK4
CCLK5
CAN1 Clock Select Bits
CCLK6
CCLK7
CAN1 CPU Interface
Sleep Bit
(3)
NOTES:
1. Write to this register after setting the PRC0 bit in the PRCR register to "1" (Write enabled).
2. Set only when the Reset bit in the CiCTLR register (i = 0, 1) = 1 (Reset/Initialization mode).
3. Before setting this bit to "1", set the Sleep bit in the CiCTLR register to "1" (Sleep mode enabled).
0 1 1 : Divide-by-8
1 0 0: Divide-by-16
1 0 1 :
1 1 0 : Do not set a value
1 1 1 :
0: CAN1 CPU interface operating
1: CAN1 CPU interface in sleep
RW
RW
RW
RW
RW
RW
RW
RW
RW
Figure 8.6 CCLKR Register
Processor Mode Register 2
b7 b6 b5 b4 b3 b2 b1 b0
000
NOTES:
1. Write to this register after setting the PRC1 bit in the PRCR register to "1" (write enable).
2. The PM20 bit become effective when the PLC07 bit in the PLC0 register is set to "1" (PLL on). Change the PM20
bit when the PLC07 bit is set to "0" (PLL off). Set the PM20 bit t "0" (2 waits) when PLL clock > 16MHz.
3. Once this bit is set to "1", it cannot be set to "0" in a program.
4. Setting the PM22 bit to "1" results in the following conditions:
The on-chip oscillator starts oscillating, and the on-chip oscillator clock becomes the watchdog timer count source.
The CM10 bit in the CM1 register is disabled against write. (Writing a "1" has no effect, nor is stop mode entered.)
The watchdog timer does not stop when in wait mode or hold state.
(1)
SymbolAddress After Reset
PM2001EhXXX00000b
Bit Symbol
Bit NameFunction
Specifying Wait when
PM20
-
(b1)
PM22
-
(b4-b3)
-
(b7-b5)
Accessing SFR at PLL
Operation
(2)
Reserved BitSet to "0"
WDT Count Source
Protective Bit
(3) (4)
Reserved Bit
Nothing is assigned. When write, set to "0".
When read, their contents are indeterminate.
0 : 2 waits
1 : 1 wait
0 : CPU clock is used for the
watchdog timer count source
1 : On-chip oscillator clock is used for
the watchdog timer count source
Set to "0"
RW
RW
RW
RW
RW
-
Figure 8.7 PM2 Register
Rev.2.00 Nov 28, 2005 page 62 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
Nothing is assigned. When write, set to "0".
When read, its content is indeterminate.
Reserved BitSet to "1"
Reserved BitSet to "0"
0 : PLL Off
Operation Enable Bit
(3)
1 : PLL On
Function
Do not set a value
(4)
NOTES:
1. Write to this register after setting the PRC0 bit in the PRCR register to "1" (write enable).
2. This bit can only be modified when the PLC07 bit = 0 (PLL turned off). The value once written to this bit
cannot be modified.
3. Before setting this bit to "1", set the CM07 bit in the CM0 register to "0" (main clock), set the CM17 to
CM16 bits in the CM1 register to "00b" (main clock undivided mode), and set the CM06 bit in the CM0
register to "0" (CM16 and CM17 bits enable).
4. Multiply by 6 is available Normal-ver. only.
RW
RW
RW
RW
-
RW
RW
RW
Figure 8.8 PLC0 Register
Rev.2.00 Nov 28, 2005 page 63 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
The following describes the clocks generated by the clock generating circuit.
8.1.1 Main Clock
The main clock is generated by the main clock oscillation circuit. This clock is used as the clock source for
the CPU and peripheral function clocks. The main clock oscillator circuit is configured by connecting a
resonator between the XIN and XOUT pins. The main clock oscillator circuit contains a feedback resistor,
which is disconnected from the oscillator circuit during stop mode in order to reduce the amount of power
consumed in the chip. The main clock oscillator circuit may also be configured by feeding an externally
generated clock to the XIN pin. Figure 8.9 shows the examples of main clock connection circuit.
After reset, the main clock divided by 8 is selected for the CPU clock.
The power consumption in the chip can be reduced by setting the CM05 bit in the CM0 register to “1”
(main clock oscillator circuit turned off) after switching the clock source for the CPU clock to a sub clock or
on-chip oscillator clock. In this case, XOUT goes “H”. Furthermore, because the internal feedback resistor remains on, XIN is pulled “H” to XOUT via the feedback resistor. Note, that if an externally generated
clock is fed into the XIN pin, the main clock cannot be turned off by setting the CM05 bit to “1” unless the
sub clock is selected as a CPU clock. If necessary, use an external circuit to turn off the clock.
During stop mode, all clocks including the main clock are turned off. Refer to 8.4 Power Control.
Microcomputer
(Built-in feedback resistor)
CIN
XIN
Oscillator
XOUT
VSS
NOTE:
1.Place a damping resistor if required. The resistance will vary depending on the oscillator
and the oscillation drive capacity setting. Use the value recommended by each oscillator
the oscillator manufacturer.
When the oscillation drive capacity is set to low, check that oscillation is stable.
Also, place a feedback resistor between XIN and XOUT if the oscillator manufacturer
recommends placing the resistor externally.
Rd
(1)
COUT
Microcomputer
(Built-in feedback resistor)
Figure 8.9 Examples of Main Clock Connection Circuit
XIN
XOUT
External clock
VCC
VSS
Open
Rev.2.00 Nov 28, 2005 page 64 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
8.1.2 Sub Clock
The sub clock is generated by the sub clock oscillation circuit. This clock is used as the clock source for
the CPU clock, as well as the timer A and timer B count sources. In addition, an fC clock with the same
frequency as that of the sub clock can be output from the CLKOUT pin.
The sub clock oscillator circuit is configured by connecting a crystal resonator between the XCIN and
XCOUT pins. The sub clock oscillator circuit contains a feedback resistor, which is disconnected from the
oscillator circuit during stop mode in order to reduce the amount of power consumed in the chip. The sub
clock oscillator circuit may also be configured by feeding an externally generated clock to the XCIN pin.
Figure 8.10 shows the examples of sub clock connection circuit.
After reset, the sub clock is turned off. At this time, the feedback resistor is disconnected from the oscillator circuit.
To use the sub clock for the CPU clock, set the CM07 bit in the CM0 register to “1 ” (sub clock) after the
sub clock becomes oscillating stably.
During stop mode, all clocks including the sub clock are turned off. Refer to 8.4 Power Control.
Microcomputer
(Built-in feedback resistor)
CCIN
XCIN
Oscillator
XCOUT
VSS
NOTE:
1.Place a damping resistor if required. The resistance will vary depending on the oscillator
and the oscillation drive capacity setting. Use the value recommended by each oscillator
the oscillator manufacturer.
When the oscillation drive capacity is set to low, check that oscillation is stable.
Also, place a feedback resistor between XCIN and XCOUT if the oscillator manufacturer
recommends placing the resistor externally.
RCd
(1)
CCOUT
Microcomputer
(Built-in feedback resistor)
Figure 8.10 Examples of Sub Clock Connection Circuit
XCIN
XCOUT
External clock
VCC
VSS
Open
Rev.2.00 Nov 28, 2005 page 65 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
8.1.3 On-chip Oscillator Clock
This clock, approximately 1 MHz, is supplied by a on-chip oscillator. This clock is used as the clock
source for the CPU and peripheral function clocks. In addition, if the PM22 bit in the PM2 register is “1”
(on-chip oscillator clock for the watchdog timer count source), this clock is used as the count source for
the watchdog timer (refer to 11.1 Count Source Protective Mode).
After reset, the on-chip oscillator is turned off. It is turned on by setting the CM21 bit in the CM2 register
to “1” (on-chip oscillator clock), and is used as the clock source for the CPU and peripheral function
clocks, in place of the main clock. If the main clock stops oscillating when the CM20 bit in the CM2 register
is “1” (oscillation stop, re-oscillation detection function enabled) and the CM27 bit is “1” (oscillation stop,
re-oscillation detection interrupt), the on-chip oscillator automatically starts operating, supplying the necessary clock for the microcomputer.
8.1.4 PLL Clock
The PLL clock is generated by a PLL frequency synthesizer. This clock is used as the clock source for the
CPU and peripheral function clocks. After reset, the PLL clock is turned off. The PLL frequency synthesizer is activated by setting the PLC07 bit to “1” (PLL operation). When the PLL clock is used as the clock
source for the CPU clock, wait a fixed period of tsu(PLL) for the PLL clock to be stable, and then set the
CM11 bit in the CM1 register to “1”.
Before entering wait mode or stop mode, be sure to set the CM11 bit to “0” (CPU clock source is the main
clock). Furthermore, before entering stop mode, be sure to set the PLC07 bit in the PLC0 register to “0”
(PLL stops). Figure 8.11 shows the procedure for using the PLL clock as the clock source for the CPU.
The PLL clock frequency is determined by the equation below. When the PLL clock frequency is 16 MHz
or more, set the PM20 bit in the PM2 register to “0” (2 waits).
PLL clock frequency = f(XIN) ✕ (multiplying factor set by the PLC02 to PLC00 bits in the PLC0 register)
(However, PLL clock frequency = 16 MHz, 20 MHz or 24 MHz
(1)
)
NOTE:
1. 24 MHz is available Normal-ver. only.
The PLC02 to PLC00 bits can be set only once after reset. Table 8.2 shows the example for setting PLL
clock frequencies.
Table 8.2 Example for Setting PLL Clock Frequencies
XIN
(MHz)
8
4
10
5
12
6
4
PLC02
0
0
0
0
0
0
0
PLC01 PLC00
0
1
0
1
0
1
1
1
0
1
0
1
0
1
Multiply
Factor
2
4
2
4
2
4
(3)
6
PLL Clock
(1)
(MHz)
16
20
(2)
24
NOTES:
1. PLL clock frequency = 16 MHz , 20 MHz or 24 MHz
2. 24 MHz is available Normal-ver. only.
3. Multiply by 6 is available Normal-ver. only.
Rev.2.00 Nov 28, 2005 page 66 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
Using the PLL clock as the clock source for the CPU
Set the CM07 bit to "0" (main clock), the CM17 to CM16
bits to "00b" (main clock undivided), and the CM06 bit to "0"
(CM16 and CM17 bits enabled).
(1)
Set the PLC02 to PLC00 bits (multiplying factor).
(When PLL clock > 16 MHz)
Set the PM20 bit to "0" (2-wait state).
Set the PLC07 bit to "1" (PLL operation).
Wait until the PLL clock becomes stable (tsu(PLL)).
Set the CM11 bit to "1" (PLL clock for the CPU clock source).
END
NOTE:
1. PLL operation mode can be entered from high-speed mode.
Figure 8.11 Procedure to Use PLL Clock as CPU Clock Source
Rev.2.00 Nov 28, 2005 page 67 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
8.2 CPU Clock and Peripheral Function Clock
Two type clocks: CPU clock to operate the CPU and peripheral function clocks to operate the peripheral
functions.
8.2.1 CPU Clock and BCLK
These are operating clocks for the CPU and watchdog timer.
The clock source for the CPU clock can be chosen to be the main clock, sub clock, on-chip oscillator clock
or the PLL clock.
If the main clock or on-chip oscillator clock is selected as the clock source for the CPU clock, the selected
clock source can be divided by 1 (undivided), 2, 4, 8 or 16 to produce the CPU clock. Use the CM06 bit in
the CM0 register and the CM17 to CM16 bits in the CM1 register to select the divide-by-n value.
When the PLL clock is selected as the clock source for the CPU clock, the CM06 bit should be set to “0”
and the CM17 to CM16 bits to “00b” (undivided).
After reset, the main clock divided by 8 provides the CPU clock.
During memory expansion or microprocessor mode
CPU clock can be output from the BCLK pin by setting the PM07 bit of PM0 register to “0” (output enabled).
Note that when entering stop mode from high- or medium-speed mode, on-chip oscillator mode or on-chip
oscillator low power dissipation mode, or when the CM05 bit in the CM0 register is set to “1” (main clock
turned off) in low-speed mode, the CM06 bit in the CM0 register is set to “1” (divide-by-8 mode).
(1)
, a BCLK signal with the same frequency as the
NOTE:
1. Not available memory expansion and microprocessor modes in T/V-ver..
These are operating clocks for the peripheral functions.
Two of these, fi (i = 1, 2, 8, 32) and fiSIO are derived from the main clock, PLL clock or on-chip oscillator
clock by dividing them by i. The clock fi is used for timers A and B, and fiSIO is used for serial interface.
The f8 and f32 clocks can be output from the CLKOUT pin.
The fAD clock is produced from the main clock, PLL clock or on-chip oscillator clock, and is used for the
A/D converter.
The fCANi (i =0, 1) clock is derived from the main clock, PLL clock or on-chip oscillator clock by dividing
them by 1 (undivided), 2, 4, 8 or 16, and is used for the CAN module.
When the WAIT instruction is executed after setting the CM02 bit in the CM0 register to “1” (peripheral
function clock turned off during wait mode), or when the microcomputer is in low power dissipation mode,
the fi, fiSIO, fAD, fCAN0 and fCAN1 clocks are turned off
(1)
.
The fC32 clock is derived from the sub clock, and is used for timers A and B. This clock can be used when
the sub clock is activated.
NOTE:
1. fCAN0 and fCAN1 clocks stop at “H” in CAN0, 1 sleep mode.
8.3 Clock Output Function
During single-chip mode, the f8, f32 or fC clock can be output from the CLKOUT pin. Use the CM01 to
CM00 bits in the CM0 register to select.
Rev.2.00 Nov 28, 2005 page 68 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
8.4 Power Control
Normal operation mode, wait mode and stop mode are provided as the power consumption control.
All mode states, except wait mode and stop mode, are called normal operation mode in this document.
8.4.1 Normal Operation Mode
Normal operation mode is further classified into seven sub modes.
In normal operation mode, because the CPU clock and the peripheral function clocks both are on, the
CPU and the peripheral functions are operating. Power control is exercised by controlling the CPU clock
frequency. The higher the CPU clock frequency, the greater the processing capability. The lower the CPU
clock frequency, the smaller the power consumption in the chip. If the unnecessary oscillator circuits are
turned off, the power consumption is further reduced.
Before the clock sources for the CPU clock can be switched over, the new clock source to which switched
must be oscillating stably. If the new clock source is the main clock, sub clock or PLL clock, allow a
sufficient wait time in a program until it becomes oscillating stably.
Note that operation modes cannot be changed directly from low speed or low power dissipation mode to
on-chip oscillator or on-chip oscillator low power dissipation mode. Nor can operation modes be changed
directly from on-chip oscillator or on-chip oscillator low power dissipation mode to low-speed or low power
dissipation mode. Where the CPU clock source is changed from the on-chip oscillator to the main clock,
change the operation mode to the medium-speed mode (divide-by-8 mode) after the clock was divided by
8 (the CM06 bit in the CM0 register was set to “1”) in the on-chip oscillator mode.
8.4.1.1 High-speed Mode
The main clock divided by 1 provides the CPU clock. If the sub clock is activated, fC32 can be used as
the count source for timers A and B.
8.4.1.2 PLL Operation Mode
The main clock multiplied by 2, 4 or 6
(1)
provides the PLL clock, and this PLL clock serves as the CPU
clock. If the sub clock is activated, fC32 can be used as the count source for timers A and B. PLL
operation mode can be entered from high speed mode. If PLL operation mode is to be changed to wait
or stop mode, first go to high speed mode before changing.
NOTE:
1. The main clock multiplied by 6 is available Normal-ver. only.
8.4.1.3 Medium-speed Mode
The main clock divided by 2, 4, 8 or 16 provides the CPU clock. If the sub clock is activated, fC32 can be
used as the count source for timers A and B.
8.4.1.4 Low-speed Mode
The sub clock provides the CPU clock. The main clock is used as the clock source for the peripheral
function clock when the CM21 bit in the CM2 register is set to “0” (on-chip oscillator turned off), and the
on-chip oscillator clock is used when the CM21 bit is set to “1” (on-chip oscillator oscillating).
The fC32 clock can be used as the count source for timers A and B.
8.4.1.5 Low Power Dissipation Mode
In this mode, the main clock is turned off after being placed in low speed mode. The sub clock provides
the CPU clock. The fC32 clock can be used as the count source for timers A and B.
Simultaneously when this mode is selected, the CM06 bit in the CM0 register becomes “1” (divide-by-8
mode). In the low power dissipation mode, do not change the CM06 bit. Consequently, the medium
speed (divide-by-8) mode is to be selected when the main clock is operated next.
Rev.2.00 Nov 28, 2005 page 69 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
8.4.1.6 On-chip Oscillator Mode
The on-chip oscillator clock divided by 1 (undivided), 2, 4, 8 or 16 provides the CPU clock. The on-chip
oscillator clock is also the clock source for the peripheral function clocks. If the sub clock is activated,
fC32 can be used as the count source for timers A and B. When the operation mode is returned to the
high- and medium-speed modes, set the CM06 bit in the CM0 register to “1” (divide-by-8 mode).
8.4.1.7 On-chip Oscillator Low Power Dissipation Mode
The main clock is turned off after being placed in on-chip oscillator mode. The CPU clock can be
selected like in the on-chip oscillator mode. The on-chip oscillator clock is the clock source for the
peripheral function clocks. If the sub clock is activated, fC32 can be used as the count source for timers
A and B.
Table 8.3 lists the setting clock related bit and modes.
Table 8.3 Setting Clock Related Bit and Modes
Modes
CM2 Register
CM21CM11
CM1 RegisterCM0 Register
CM17, CM16
CM07CM06CM05CM04
PLL Operation Mode0100b000-
High-Speed Mode0000b000-
Medium-
Speed
Mode
Divide-by-2
Divide-by-4
Divide-by-8
Divide-by-16
0001b000-
0010b000-
00-0 10-
0011b000-
Low-Speed Mode-0-1-01
Low Power00-11
(1)
1
(1)
1
Dissipation Mode
On-chip
Oscillator
Mode
Divide-by-1
Divide-by-2
Divide-by-4
Divide-by-8
Divide-by-16
1000b000-
1001b000-
1010b000-
10-0 10-
1011b000-
On-chip Oscillator10(NOTE 2)0(NOTE 2)1Low power Dissipation
Mode
-: “0” or “1”
NOTES:
1. When the CM05 bit is set to “1” (main clock turned off) in low-speed mode, the mode goes to low power
dissipation mode and the CM06 bit is set to “1” (divide-by-8 mode) simultaneously.
2. The divide-by-n value can be selected the same way as in on-chip oscillator mode.
Rev.2.00 Nov 28, 2005 page 70 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
8.4.2 Wait Mode
In wait mode, the CPU clock is turned off, so are the CPU (because operated by the CPU clock) and the
watchdog timer. However, if the PM22 bit in the PM2 register is “1” (on-chip oscillator clock for the watchdog
timer count source), the watchdog timer remains active. Because the main clock, sub clock and on-chip
oscillator clock all are on, the peripheral functions using these clocks keep operating.
8.4.2.1 Peripheral Function Clock Stop Function
If the CM02 bit in the CM0 register is “1” (peripheral function clocks turned off during wait mode), the f1,
f2, f8, f32, f1SIO, f8SIO, f32SIO, fAD, fCAN0 and fCAN1 clocks are turned off when in wait mode, with
the power consumption reduced that much. However, fC32 remains on.
8.4.2.2 Entering Wait Mode
The microcomputer is placed into wait mode by executing the WAIT instruction.
When the CM11 bit = 1 (CPU clock source is the PLL clock), be sure to set the CM11 bit in the CM1
register to “0” (CPU clock source is the main clock) before going to wait mode. The power consumption
of the chip can be reduced by setting the PLC07 bit in the PLC0 register to “0” (PLL stops).
8.4.2.3 Pin Status During Wait Mode
Table 8.4 lists the pin status during wait mode.
Table 8.4 Pin Status During Wait Mode
Pin
A0 to A19, D0 to D15,Retains status before wait modeDoes not become a bus control pin
______________ ________
CS0 to CS3, BHE
______ _______ _________ _________
RD, WR, WRL, WRH
___________
HLDA, BCLK
(2)
ALE
(2)
(2)
(2)
Memory Expansion Mode
Microprocessor Mode
“H”
“H”
“L”
(1)
Single-chip Mode
I/O portsRetains status before wait modeRetains status before wait mode
CLKOUTDoes not become a CLKOUT pinDoes not stop
When fC selected
When f8, f32
selected
•CM02 bit = 0: Does not stop
•CM02 bit = 1: Retains status before
wait mode
NOTES:
1. Not available memory expansion and microprocessor modes in T/V-ver..
2. Not available the bus control pins in T/V-ver..
8.4.2.4 Exiting Wait Mode
The microcomputer is moved out of wait mode by a hardware reset, NMI interrupt or peripheral function
interrupt.
If the microcomputer is to be moved out of wait mode by a hardware reset or NMI interrupt, set the
peripheral function interrupt priority ILVL2 to ILVL0 bits to “000b” (interrupt disabled) before executing
the WAIT instruction.
The peripheral function interrupts are affected by the CM02 bit. If the CM02 bit is “0” (peripheral function
clocks not turned off during wait mode), peripheral function interrupts can be used to exit wait mode. If
the CM02 bit is “1” (peripheral function clocks turned off during wait mode), the peripheral functions
using the peripheral function clocks stop operating, so that only the peripheral functions clocked by
external signals can be used to exit wait mode.
Table 8.5 lists the interrupts to exit wait mode.
Rev.2.00 Nov 28, 2005 page 71 of 378
REJ09B0124-0200
______
______
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
Table 8.5 Interrupts to Exit Wait Mode and Use Conditions
_______
InterruptCM02 Bit = 0CM02 Bit = 1
NMI InterruptCan be usedCan be used
Serial Interface InterruptCan be used when operating withCan be used when operating with
internal or external clockexternal clock
Key Input InterruptCan be usedCan be used
A/D Conversion InterruptCan be used in one-shot mode or- (Do not use)
single sweep mode
Timer A InterruptCan be used in all modesCan be used in event counter mode
Timer B interruptor when the count source is fc32
______
INT InterruptCan be usedCan be used
CAN0/1 Wake-up Interrupt Can be used in CAN sleep modeCan be used in CAN sleep mode
If the microcomputer is to be moved out of wait mode by a peripheral function interrupt, set up the
following before executing the WAIT instruction.
(1) Set the ILVL2 to ILVL0 bits in the interrupt control register, for peripheral function interrupts used to
exit wait mode.
The ILVL2 to ILVL0 bits in all other interrupt control registers, for peripheral function interrupts not
used to exit wait mode, are set to “000b” (interrupt disable).
(2) Set the I flag to “1”.
(3) Start operating the peripheral functions used to exit wait mode.
When the peripheral function interrupt is used, an interrupt routine is performed as soon as an
interrupt request is acknowledged and the CPU clock is supplied again.
When the microcomputer exits wait mode by the peripheral function interrupt, the CPU clock is the same
clock as the CPU clock executing the WAIT instruction.
Rev.2.00 Nov 28, 2005 page 72 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
8.4.3 Stop Mode
In stop mode, all oscillator circuits are turned off, so are the CPU clock and the peripheral function clocks.
Therefore, the CPU and the peripheral functions clocked by these clocks stop operating. The least
amount of power is consumed in this mode. If the voltage applied to VCC is VRAM or more, the internal
RAM is retained.
However, the peripheral functions clocked by external signals keep operating.
Table 8.6 lists the interrupts to stop mode and use conditions.
Table 8.6 Interrupts to Stop Mode and Use Conditions
_______
NMI InterruptCan be used
Key Input InterruptCan be used
______
INT InterruptCan be used
Timer A InterruptCan be used
Timer B interrupt(when counting external pulses in event counter mode)
Serial Interface InterruptCan be used (when external clock is selected)
CAN0/1 Wake-up InterruptCan be used (when CAN sleep mode is selected)
InterruptCondition
8.4.3.1 Entering Stop Mode
The microcomputer is placed into stop mode by setting the CM10 bit in the CM1 register to “1” (all clocks
turned off). At the same time, the CM06 bit in the CM0 register is set to “1” (divide-by-8 mode) and the
CM15 bit in the CM1 register is set to “1” (main clock oscillator circuit drive capability high).
Before entering stop mode, set the CM20 bit in the CM2 register to “0” (oscillation stop, re-oscillation
detection function disabled).
Also, if the CM11 bit in the CM1 register is “1” (PLL clock for the CPU clock source), set the CM11 bit to
“0” (main clock for the CPU clock source) and the PLC07 bit in the PLC0 register to “0” (PLL turned off)
before entering stop mode.
8.4.3.2 Pin Status in Stop Mode
Table 8.7 lists the pin status in stop mode.
Table 8.7 Pin Status in Stop Mode
Pin
A0 to A19, D0 to D15,Retains status before stop modeDoes not become a bus control pin
______________ ________
CS0 to CS3, BHE
______ _______ _________ _________
RD, WR, WRL, WRH
___________
HLDA, BCLK
(2)
ALE
(2)
(2)
(2)
Memory Expansion Mode
Microprocessor Mode
“H”
“H”
indeterminate
(1)
Single-chip Mode
I/O portsRetains status before stop modeRetains status before stop mode
CLKOUTDoes not become a CLKOUT pin“H”
When fC selected
When f8, f32
Retains status before stop mode
selected
NOTES:
1. Not available memory expansion and microprocessor modes in T/V-ver..
2. Not available the bus control pins in T/V-ver..
Rev.2.00 Nov 28, 2005 page 73 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
8.4.3.3 Exiting Stop Mode
Stop mode is exited by a hardware reset, NMI interrupt or peripheral function interrupt.
_______
_______
When the hardware reset or NMI interrupt is used to exit wait mode, set all ILVL2 to ILVL0 bits in the
interrupt control registers for the peripheral function interrupt to “000b” (interrupt disabled) before setting
the CM10 bit in the CM1 register to “1”.
When the peripheral function interrupt is used to exit stop mode, set the CM10 bit to “1” after the following
settings are completed.
(1) The ILVL2 to ILVL0 bits in the interrupt control registers, for the peripheral function interrupt used to
exit stop mode, must have larger value than that of the RLVL2 to RLVL0 bits.
The ILVL2 to ILVL0 bits in all other interrupt control registers, for the peripheral function interrupts
which are not used to exit stop mode, must be set to “000b” (interrupt disabled).
(2) Set the I flag to “1”.
(3) Start operation of peripheral function being used to exit wait mode.
When exiting stop mode by the peripheral function interrupt, the interrupt routine is performed when
an interrupt request is generated and the CPU clock is supplied again.
_______
When stop mode is exited by the peripheral function interrupt or NMI interrupt, the CPU clock source is
as follows, in accordance with the CPU clock source setting before the microcomputer had entered stop
mode.
• When the sub clock is the CPU clock before entering stop mode:Sub clock
• When the main clock is the CPU clock source before entering stop mode: Main clock divided by 8
• When the on-chip oscillator clock is the CPU clock source before entering stop mode:
On-chip oscillator clock divided by 8
Rev.2.00 Nov 28, 2005 page 74 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
Figure 8.12 shows the state transition from normal operation mode to stop mode and wait mode. Figure
8.13 shows the state transition in normal operation mode.
Table 8.8 shows a state transition matrix describing allowed transition and setting. The vertical line shows
current state and horizontal line show state after transition.
Reset
CPU operation stoppedAll oscillators stopped
Wait Mode
Wait Mode
Wait Mode
Wait Mode
CM07 = 0
CM06 = 1
CM05 = 0
CM11 = 0
CM10 = 1
(5)
CM10 = 1
Stop Mode
(3)
Stop Mode
Stop Mode
Stop Mode
Interrupt
Interrupt
CM10 = 1
CM10 = 1
Interrupt
CM10 = 1
Interrupt
(5)
(5)
(5)
(4)
When
power
dissipation
mode
Medium-Speed Mode
(divided-by-8 mode)
High-Speed Mode,
Medium-Speed Mode
When
low
low-
speed
mode
PLL Operation Mode
Low-Speed Mode,
Low Power Dissipation Mode
On-chip Oscillator Mode,
On-chip Oscillator Dissipation Mode
(NOTES 1, 2)
WAIT
instruction
Interrupt
WAIT
instruction
Interrupt
WAIT
instruction
Interrupt
WAIT
instruction
Interrupt
Normal Mode
CM05, CM06, CM07: Bits in CM0 register
CM10, CM11: Bits in CM1 register
NOTES:
Do not go directly from PLL operation mode to wait or stop mode.
1.
2.PLL operation mode can be entered from high-speed mode. Similarly, PLL operation mode can be changed back to high-speed mode.
3.Write to the CM0 and CM1 registers per 16 bits with the CM21 bit in the CM2 register = 0 (on-chip oscillator stops).
Since the operation starts from the main clock after exiting stop mode, the time until the CPU operates can be reduced.
4.The on-chip oscillator clock divided by 8 provides the CPU clock.
5.Before entering stop mode, be sure to set the CM20 bit in the CM2 register to "0" (oscillation stop, re-oscillation detection function disabled).
Figure 8.12 State Transition to Stop Mode and Wait Mode
Rev.2.00 Nov 28, 2005 page 75 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
Main Clock Oscillation
PLL operation mode
: f(PLL)
: f(PLL)
PLC07 = 1
CM11 = 1
PLC07 = 0
CM11 = 0
PLC07 = 1
CM11 = 1
PLC07 = 0
CM11 = 0
CPU clock
CM07 = 0
CM06 = 0
CM17 = 0
CM16 = 0
CPU clock
CM07 = 0
CM06 = 0
CM17 = 0
CM16 = 0
PLL operation mode
High-Speed Mode
CPU clock
(6)
: f(XIN)
CM07 = 0
CM06 = 0
CM17 = 0
CM16 = 0
High-Speed mode
CPU clock
(6)
: f(XIN)
CM07 = 0
CM06 = 0
CM17 = 0
CM16 = 0
Medium-Speed Mode
(divide by 2)
CPU clock
: f(XIN)/2
CM07 = 0
CM06 = 0
CM17 = 0
CM16 = 1
Medium-Speed Mode
(divide by 2)
CPU clock
: f(XIN)/2
CM07 = 0
CM06 = 0
CM17 = 0
CM16 = 1
Medium-Speed Mode
(divide by 4)
CPU clock
: f(XIN)/4
CM07 = 0
CM06 = 0
CM17 = 1
CM16 = 0
CM04 = 1CM04 = 1 CM04 = 0CM04 = 0
Medium-Speed Mode
(divide by 4)
CPU clock
: f(XIN)/4
CM07 = 0
CM06 = 0
CM17 = 1
CM16 = 0
(3)
CM07 =1
CPU clock: f(XCIN)
CM07 = 0
(1) (8)
CM05 = 1
Low Power Dissipation Mode
CPU clock: f(XCIN)
CM07 = 0
CM06 = 1
CM15 = 1
Medium-Speed Mode
(divide by 8)
CPU clock
: f(XIN)/8
CM07 = 0
CM06 = 1
Medium-Speed Mode
(divide by 8)
CPU clock
: f(XIN)/8
CM07 = 0
CM06 = 1
CM07 = 0
CM05 = 0
Medium-Speed Mode
Medium-Speed Mode
(2) (4)
(divide by 16)
CPU clock
: f(XIN)/16
CM07 = 0
CM06 = 0
CM17 = 1
CM16 = 1
(divide by 16)
CPU clock
: f(XIN)/16
CM07 = 0
CM06 = 0
CM17 = 1
CM16 = 1
CM21 = 0
CM21 = 1
CM21 = 0
CM21 = 1
CM21 = 0
CM21 = 1
On-chip Oscillator
Mode
CPU clock
(7)
f(Ring)
f(Ring)/2
f(Ring)/4
f(Ring)/8
f(Ring)/16
CM04 = 1
CM04 = 0
CPU clock
(7)
f(Ring)
f(Ring)/2
f(Ring)/4
f(Ring)/8
f(Ring)/16
On-chip Oscillator
Mode
Low-Speed ModeLow-Speed Mode
CPU clock: f(XCIN)
CM07 = 0
On-chip Oscillator
Clock Oscillation
On-chip Oscillator
Low Power Dissipation Mode
CPU clock
CM05 = 0
f(Ring)
f(Ring)/2
f(Ring)/4
(1)
CM05 = 1
f(Ring)/8
f(Ring)/16
CM04 = 1
CM04 = 0
CPU clock
CM05 = 0
f(Ring)
f(Ring)/2
f(Ring)/4
(1)
CM05 = 1
f(Ring)/8
f(Ring)/16
On-chip Oscillator
Low Power Dissipation Mode
Sub clock oscillation
CM04, CM05, CM06, CM07: Bits in CM0 register
CM11, CM15, CM16, CM17: Bits in CM1 register
CM20, CM21: Bits in CM2 register
PLC07: Bit in PLC0 register
NOTES:
1. Avoid making a transition when the CM20 bit is set to "1" (oscillation stop, re-oscillation detection function enabled).
Set the CM20 bit to "0" (oscillation stop, re-oscillation detection function disabled) before transiting.
2. Wait for the main clock oscillation stabilization time.
3. Switch clock after oscillation of sub clock is sufficiently stable.
4. Change the CM17 and CM16 bits before changing the CM06 bit.
5. Transit in accordance with arrow.
6. The PM20 bit in the PM2 register become effective when the PLC07 bit is set to "1" (PLL on). Change the PM20 bit when the PLC07 bit is
set to "0" (PLL off). Set the PM20 bit to "0" (2 waits) when PLL clock > 16 MHz.
PM20 bit to "0" (SFR accessed with two wait states) before setting the PLC07 bit to "1" (PLL operation).
7. Set the CM06 bit to "1" (divide-by-8 mode) before changing back the operation mode from on-chip oscillator mode to high- or middle-speed mode.
8. When the CM21 bit = 0 (on-chip oscillator turned off) and the CM05 bit = 1 (main clock turned off), the CM06 bit is fixed to "1" (divide-by-8 mode)
and the CM15 bit is fixed to "1" (drive capability High).
Figure 8.13 State Transition in Normal Operation Mode
Rev.2.00 Nov 28, 2005 page 76 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
Table 8.8 Allowed Transition and Setting
(9)
State after transition
High-Speed Mode,
Medium-Speed
Mode
High-Speed Mode,
Medium-Speed Mode
(NOTE 8) (9)
Low-Speed
(2)
Mode
Low Power
Dissipation Mode
PLL Operation
(2)
Mode
On-chip Oscillator
Mode
Current state
On-chip Oscillator Low
(12)
(14)
Power Dissipation Mode
Stop Mode
Wait Mode
-: Cannot transit
NOTES:
1. Avoid making a transition when the CM20 bit = 1 (oscillation stop, reoscillation detection function enabled). Set the CM20 bit to “0” (oscillation
stop, re-oscillation detection function disabled) before transiting.
2. On-chip oscillator clock oscillates and stops in low-speed mode. In this
mode, the on-chip oscillator can be used as peripheral function clock. Sub
clock oscillates and stops in PLL operation mode. In this mode, sub clock
can be used as peripheral function clock.
3. PLL operation mode can only be entered from and changed to high-speed
mode.
4. Set the CM06 bit to “1” (divide-by-8 mode) before transiting from on-chip
oscillator mode to high- or medium-speed mode.
5. When exiting stop mode, the CM06 bit is set to “1” (divide-by-8 mode).
6. If the CM05 bit is set to “1” (main clock stop), then the CM06 bit is set to “1”
(divide-by-8 mode).
7. A transition can be made only when sub clock is oscillating.
8. State transitions within the same mode (divide-by-n values changed or sub
clock oscillation turned on or off) are shown in the table below.
(1) CM04=0Sub clock turned off
(2) CM04=1Sub clock oscillating
(
3) CM06=0CPU clock no division
(
4) CM06=0CPU clock divide-by-2
(
5) CM06=0CPU clock divide-by-4
(
6) CM06=0CPU clock divide-by-16
(7) CM06=1
(8) CM07=0Main clock, PLL clock
(9) CM07=1Sub clock selected
(10)
(11)
(12)
(
--
(1)
13)
-
(14)
(1)
(
15)
(16)
(17)
(18)
CM04, CM05, CM06, CM07: Bits in CM0 register
CM10, CM11, CM16, CM17: Bits in CM1 register
CM20, CM21: Bits in CM2 register
PLC07: Bit in PLC0 register
On-chip Oscillator
Low Power
Dissipation Mode
-
(5)
(18)
StopWait
ModeMode
(16)
(16)
(16)
(1)
(16)
(5)
(1)
(17)
(1)
(17)
(1)
(17)
(1)
(17)
(1)
(17)
-
-
SettingOperation
CM17=0mode
CM16=0
CM17=0mode
CM16=1
CM17=1mode
CM16=0
CM17=1mode
CM16=1
CPU clock divide-by-8 mode
or on-chip oscillator
clock selected
CM05=0Main clock oscillating
CM05=1Main clock turned off
PLC07=0Main clock selected
CM11=0
PLC07=1PLL clock selected
CM11=1
CM21=0Main clock or
PLL clock selected
CM21=1On-chip oscillator clock
selected
CM10=1Transition to stop mode
WAITTransition to wait mode
instruction
HardwareExit stop mode or wait
interruptmode
Rev.2.00 Nov 28, 2005 page 77 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
8.5 Oscillation Stop and Re-oscillation Detection Function
The oscillation stop and re-oscillation detection function is such that main clock oscillation circuit stop and
re-oscillation are detected. At oscillation stop, re-oscillation detection, reset or oscillation stop, re-oscillation
detection interrupt request are generated. Which one is to be generated can be selected using the CM27 bit
in the CM2 register.
The oscillation stop and re-oscillation detection function can be enabled or disabled using the CM20 bit in
the CM2 register.
Table 8.9 lists a specification overview of the oscillation stop and re-oscillation detection function.
Table 8.9 Specification Overview of Oscillation Stop and Re-oscillation Detection Function
ItemSpecification
Oscillation Stop Detectable Clock andf(XIN) ≥ 2 MHz
Frequency Bandwidth
Enabling Condition for Oscillation Stop Set CM20 bit to “1” (enable)
and Re-oscillation Detection Function
Operation at Oscillation Stop,•Reset occurs (when CM27 bit = 0)
Re-oscillation Detection•
Oscillation stop, re-oscillation detection interrupt occurs (when the CM27 bit =1)
8.5.1 Operation When CM27 Bit = 0 (Oscillation Stop Detection Reset)
Where main clock stop is detected when the CM20 bit is “1” (oscillation stop, re-oscillation detection
function enabled), the microcomputer is initialized, coming to a halt (oscillation stop reset; refer to
4. Special Function Register (SFR), 5. Reset).
This status is reset with hardware reset. Also, even when re-oscillation is detected, the microcomputer
can be initialized and stopped; it is, however, necessary to avoid such usage (During main clock stop, do
not set the CM20 bit to “1” and the CM27 bit to “0”).
8.5.2 Operation When CM27 Bit = 1 (Oscillation Stop, Re-oscillation Detection Interrupt)
Where the main clock corresponds to the CPU clock source and the CM20 bit is “1” (oscillation stop, re-oscillation
detection function enabled), the system is placed in the following state if the main clock comes to a halt:
• Oscillation stop, re-oscillation detection interrupt request is generated.
• The on-chip oscillator starts oscillation, and the on-chip oscillator clock becomes the clock source for
CPU clock and peripheral functions in place of the main clock.
• CM21 bit = 1 (on-chip oscillator clock is the clock source for CPU clock)
• CM22 bit = 1 (main clock stop detected)
• CM23 bit = 1 (main clock stopped)
Where the PLL clock corresponds to the CPU clock source and the CM20 bit is “1”, the system is placed
in the following state if the main clock comes to a halt: Since the CM21 bit remains unchanged, set it to “1”
(on-chip oscillator clock) inside the interrupt routine.
• Oscillation stop, re-oscillation detection interrupt request is generated.
• CM22 bit = 1 (main clock stop detected)
• CM23 bit = 1 (main clock stopped)
• CM21 bit remains unchanged
Where the CM20 bit is “1”, the system is placed in the following state if the main clock re-oscillates from
the stop condition:
• Oscillation stop, re-oscillation detection interrupt request is generated.
• CM22 bit = 1 (main clock re-oscillation detected)
• CM23 bit = 0 (main clock oscillation)
• CM21 bit remains unchanged
Rev.2.00 Nov 28, 2005 page 78 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)8. Clock Generating Circuit
8.5.3 How to Use Oscillation Stop and Re-oscillation Detection Function
• The oscillation stop, re-oscillation detection interrupt shares the vector with the watchdog timer interrupt.
If the oscillation stop, re-oscillation detection and watchdog timer interrupts both are used, read the
CM22 bit in an interrupt routine to determine which interrupt source is requesting the interrupt.
• Where the main clock re-oscillated after oscillation stop, the clock source for CPU clock and peripheral
function must be switched to the main clock in the program. Figure 8.14 shows the procedure to switch
the clock source from the on-chip oscillator to the main clock.
• Simultaneously with oscillation stop, re-oscillation detection interrupt request occurrence, the CM22 bit
becomes “1”. When the CM22 bit is set at “1”, oscillation stop, re-oscillation detection interrupt are
disabled. By setting the CM22 bit to “0” in the program, oscillation stop, re-oscillation detection interrupt
are enabled.
• If the main clock stops during low speed mode where the CM20 bit is “1”, an oscillation stop, re-oscillation
detection interrupt request is generated. At the same time, the on-chip oscillator starts oscillating. In this
case, although the CPU clock is derived from the sub clock as it was before the interrupt occurred, the
peripheral function clocks now are derived from the on-chip oscillator clock.
• To enter wait mode while using the oscillation stop and re-oscillation detection function, set the CM02
bit to “0” (peripheral function clocks not turned off during wait mode).
• Since the oscillation stop and re-oscillation detection function is provided in preparation for main clock
stop due to external factors, set the CM20 bit to “0” (oscillation stop, re-oscillation detection function
disabled) where the main clock is stopped or oscillated in the program, that is where the stop mode is
selected or the CM05 bit is altered.
• This function cannot be used if the main clock frequency is 2 MHz or less. In that case, set the CM20 bit to “0”.
Switch the main clock
NO
CM06 bit: Bit in CM0 register
CM21, CM22, CM 23 bits: Bits in CM2 register
NOTE:
1. If the clock source for CPU clock is to be changed to PLL clock,
set to PLL operation mode after set to high-speed mode.
Determine several times
whether the CM23 bit is set to "0"
(main clock oscillates)
YES
Set the CM06 bit to "1" (divide-by-8)
Set the CM22 bit to "0" (main clock stop,
re-oscillation not detected)
Set the CM21 bit to "0"
(main clock for the CPU clock source)
End
(1)
Figure 8.14 Procedure to Switch Clock Source from On-chip Oscillator to Main Clock
Rev.2.00 Nov 28, 2005 page 79 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)9. Protection
9. Protection
In the event that a program runs out of control, this function protects the important registers so that they will
not be rewritten easily. Figure 9.1 shows the PRCR register. The following lists the registers protected by the
PRCR register.
• The PRC0 bit protects the CM0, CM1, CM2, PLC0, PCLKR and CCLKR registers;
• The PRC1 bit protects the PM0, PM1, PM2, TB2SC, INVC0 and INVC1 registers;
• The PRC2 bit protects the PD7, PD9, S3C, S4C, S5C and S6C registers
NOTE:
1. The S5C and S6C registers are only in the 128-pin version.
Set the PRC2 bit to “1” (write enabled) and then write to any address, and the PRC2 bit will be set to “0” (write
protected). The registers protected by the PRC2 bit should be changed in the next instruction after setting
the PRC2 bit to “1”. Make sure no interrupts or DMA transfers will occur between the instruction in which the
PRC2 bit is set to “1” and the next instruction. The PRC0 and PRC1 bits are not automatically set to “0” by
writing to any address. They can only be set to “0” in a program.
(1)
.
Protect Register
b7 b6 b5 b4 b3 b2 b1 b0
0 0 0
NOTES:
1. The PRC2 bit is set to "0" by writing to any address after setting it to "1". Other bits are not set to "0" by writing
to any address, and must therefore be set in a program.
2. The S5C and S6C registers are only in the 128-pin version.
SymbolAddressAfter Reset
PRCR000AhXX000000b
Bit NameBit SymbolFunction
Enable write to CM0, CM1, CM2,
PRC0
PRC1
PRC2
-
(b5-b3)
-
(b7-b6)
Protect Bit 0
Protect Bit 1
Protect Bit 2
Reserved BitSet to "0"
Nothing is assigned. When write, set to "0".
When read, their contents are indeterminate.
Rev.2.00 Nov 28, 2005 page 80 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)10. Interrupt
10. Interrupt
10.1 Type of Interrupts
Figure 10.1 shows the types of interrupts.
Undefined instruction (UND instruction)
Overflow (INTO instruction)
Software
(Non-maskable interrupt)
BRK instruction
INT instruction
Interrupt
Hardware
Special
(Non-maskable interrupt)
Peripheral function
(Maskable interrupt)
(1)
_______
NMI
________
(2)
DBC
Oscillation stop and re-oscillation detection
Watchdog timer
Single step
Address match
(2)
NOTES:
1. The peripheral functions in the microcomputer are used to generate the peripheral interrupt.
2. Do not normally use this interrupt because it is provided exclusively for use by development
tools.
Figure 10.1 Interrupts
• Maskable Interrupt:An interrupt which can be enabled (disabled) by the interrupt enable flag
(I flag) or whose interrupt priority can be changed by priority level.
• Non-Maskable Interrupt: An interrupt which cannot be enabled (disabled) by the interrupt enable flag
(I flag) or whose interrupt priority cannot be changed by priority level.
Rev.2.00 Nov 28, 2005 page 81 of 378
REJ09B0124-0200
Under development
This document is under development and its contents are subject to change.
M16C/6N Group (M16C/6NK, M16C/6NM)10. Interrupt
10.2 Software Interrupts
A software interrupt occurs when executing certain instructions. Software interrupts are non-maskable
interrupts.
10.2.1 Undefined Instruction Interrupt
An undefined instruction interrupt occurs when executing the UND instruction.
10.2.2 Overflow Interrupt
An overflow interrupt occurs when executing the INTO instruction with the O flag in the FLG register set to
“1” (the operation resulted in an overflow). The following are instructions whose O flag changes by arithmetic:
ABS, ADC, ADCF, ADD, CMP, DIV, DIVU, DIVX, NEG, RMPA, SBB, SHA, SUB
10.2.3 BRK Interrupt
A BRK interrupt occurs when executing the BRK instruction.
10.2.4 INT Instruction Interrupt
An INT instruction interrupt occurs when executing the INT instruction. Software interrupt Nos. 0 to 63 can
be specified for the INT instruction. Because software interrupt Nos. 1 to 31 are assigned to peripheral
function interrupts, the same interrupt routine as for peripheral function interrupts can be executed by
executing the INT instruction.
In software interrupt Nos. 0 to 31, the U flag is saved to the stack during instruction execution and is set
to “0” (ISP selected) before executing an interrupt sequence. The U flag is restored from the stack when
returning from the interrupt routine. In software interrupt Nos. 32 to 63, the U flag does not change state
during instruction execution, and the SP then selected is used.
Rev.2.00 Nov 28, 2005 page 82 of 378
REJ09B0124-0200
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.