Page 1
FUJITSU SEMICONDUCTOR CM44-10127-1E CONTROLLER MANUAL ® -16LX 16 bit Microcontroller MB90895 series Hardware Manual...
Page 3
® -16LX 16 bit Microcontroller MB90895 series Hardware Manual FUJITSU LIMITED...
Page 5
ASICs (application specific ICs) and were developed as general-purpose products in the MC-16LX series. This manual describes the functions and operation of the MB90895 series and is intended for engineers who intend to use MB90895 series microcontrollers to develop actual products. Please read through this manual.
Page 6
I Organization of this document This manual contains the following 21 chapters and an appendix. CHAPTER 1 Overview This chapter describes the features and basic specifications of MB90895 series. CHAPTER 2 Handling Devices This chapter describes points to note when using the MB90895 series.
Page 7
module CHAPTER 19 512 KBIT FLASH MEMORY This section describes the functions and operations of the 512 Kbit flash memory. CHAPTER 20 Dual Operation Flash This section describes the functions and operations of the dual operation flash. CHAPTER 21 FLASH SERIAL PROGRAMMING CONNECTION EXAMPLE This section describes the functions and operations of the flash serial programming connection example.
Page 9
(2) for use requiring extremely high reliability (i.e., submersible repeater and artificial satellite). Please note that FUJITSU will not be liable against you and/or any third party for any claims or damages arising in connection with above-mentioned uses of the products.
CONTENTS CHAPTER 1 OVERVIEW....................1 Features of the MB90895 series......................2 Product Lineup for MB90895 Series....................4 Block Diagram of MB90895 Series...................... 7 Pin Assignment............................ 8 Package Dimensions ........................... 9 Pin Description........................... 10 I/O Circuit............................13 CHAPTER 2 HANDLING DEVICES ................. 15 Precautions when Handling Devices ....................
Page 12
3.5.9 Software interrupt ......................... 77 3.5.10 Interrupts by extended intelligent I/O service (EI OS) ..............78 3.5.11 OS descriptor (ISD) ......................... 80 3.5.12 Each Register of EI OS Descriptor (ISD) ..................82 3.5.13 Operation of EI OS........................85 3.5.14 Procedure for Use of EI OS ......................
Page 13
4.4.1 Registers for Port 2 (PDR2, DDR2) .................... 170 4.4.2 Operation of Port 2 ........................171 Port 3 ............................... 173 4.5.1 Registers for Port 3 (PDR3, DDR3) .................... 175 4.5.2 Operation of Port 3 ........................176 Port 4 ............................... 178 4.6.1 Registers for Port 4 (PDR4, DDR4) ....................
Page 14
CHAPTER 8 16-bit reload timer..................245 Overview of 16-bit Reload Timer ..................... 246 Block Diagram of 16-bit Reload Timer..................... 249 Configuration of 16-bit Reload Timer....................252 8.3.1 Timer Control Status Registers (High) (TMCSR0: H, TMCSR1: H)..........255 8.3.2 Timer Control Status Registers (High) (TMCSR0: H, TMCSR1: H)..........257 8.3.3 16-bit Timer Registers (TMR0, TMR1) ..................
Page 15
11.5 Precautions when Using Delayed Interrupt Generation Module............327 11.6 Program Example of Delayed Interrupt Generation Module............328 CHAPTER 12 DTP/external interrupt ................329 12.1 Overview of DTP/External Interrupt ....................330 12.2 Block Diagram of DTP/External Interrupt..................331 12.3 Configuration of DTP/External Interrupt................... 333 12.3.1 DTP/external interrupt factor register (EIRR) ................
Page 16
14.4.2 Generation of Transmit Interrupt and Timing of Flag Set ............403 14.5 UART0 baud rate..........................405 14.5.1 Baud rate by dedicated baud rate generator ................407 14.5.2 Baud Rate by Internal Timer (16-bit Reload Timer)..............410 14.5.3 Baud rate by external clock ......................412 14.6 Explanation of Operation of UART0 ....................
Page 18
19.7.1 Data Polling Flag (DQ7) ......................592 19.7.2 Toggle Bit Flag (DQ6) ........................ 594 19.7.3 Timing Limit Over Flag (DQ5) ....................595 19.7.4 Sector Erase Timer Flag (DQ3) ....................596 19.7.5 Toggle Bit 2 Flag (DQ2) ......................597 19.8 Details of Programming/Erasing Flash Memory ................599 19.8.1 Read/Reset State in Flash Memory ...................
CHAPTER 1 OVERVIEW This chapter describes the features and basic specifications of MB90895 series. 1.1 Features of the MB90895 series 1.2 Product Lineup for MB90895 Series 1.3 Block Diagram of MB90895 Series 1.4 Pin Assignment 1.5 Package Dimensions 1.6 Pin Description...
CHAPTER 1 OVERVIEW Features of the MB90895 series MB90895 series devices are 16-bit micro general-purpose controllers designed for applications which need high-speed real-time processing. The devices of this series are high-performance 16-bit CPU micro controllers em-ploying of the dual operation flash memory and CAN controller on LQFP-48 small package.
Page 21
CHAPTER 1 OVERVIEW Low-power consumption (standby) mode • Sleep mode (stops CPU clock) • Timebase timer mode (operates only oscillation clock and sub clock, timebase timer and watch timer) • Watch mode (operates only sub clock and watch timer) • Stop mode (stops oscillation clock and sub clock) •...
CHAPTER 1 OVERVIEW Product Lineup for MB90895 Series MB90895 series is available in two types. This section provides the product lineup, CPU, and peripherals. I Product Lineup for MB90895 Series Table 1.2-1 Product Lineup for MB90895 Series MB90V495G MB90F897/S Classification...
Page 23
CHAPTER 1 OVERVIEW I CPU and peripheral functions of MB90895 series Table 1.2-2 CPU and peripheral functions of MB90895 series (1/2) MB90V495G MB90F897/S CPU function Number of basic instructions: 351 instructions Instruction bit length: 8 bits, 16 bits Instruction length: 1 byte to 7 bytes Data bit length: 1 bit, 8 bits, 16 bits Minimum instruction execution time: 62.5 ns (at a machine clock frequency of 16 MHz)
Page 24
CHAPTER 1 OVERVIEW Table 1.2-2 CPU and peripheral functions of MB90895 series (2/2) MB90V495G MB90F897/S 8/10-bit A/D converter Channel count: 8 Resolution: 10 or 8 bits Conversion time: 6.125 µs (including sampling time at 16-MHz machine clock frequency) Two or more continuous channels can be converted sequentially (up to 8 channels)
CHAPTER 1 OVERVIEW Block Diagram of MB90895 Series Block diagram of MB90895 series is shown in the figure below. I Block Diagram of MB90895 Series Figure 1.3-1 Block Diagram of MB90895 Series X0,X1 Clock controller MC-16LX core X0A,X1A Watch timer...
CHAPTER 1 OVERVIEW Package Dimensions MB90895 series is available in one type of package. The package dimensions below are for reference only. Contact Fujitsu for the correct package dimensions. I Package Dimension of FPT-48P-M26 48-pin plastic LQFP Lead pitch 0.50 mm Package width ×...
CHAPTER 1 OVERVIEW Pin Description This section describes the I/O pins and their functions of MB90895 series. I Pin Description Table 1.6-1 Pin Description (1/3) Number Circuit Pin Name Functional description Type − power input pin for A/D converter Power (Vref+) input pin for A/D converter. The power supply should not be input V −...
Page 29
CHAPTER 1 OVERVIEW Table 1.6-1 Pin Description (2/3) Number Circuit Pin Name Functional description Type − Power (0 V) input pin Capacity pin for stabilizing power supply. This pin should be connected to a ceramic − capacitor of approx.0.1µF. High-speed oscillation pin High-speed oscillation pin P10 to P13 General-purpose I/O port...
Page 30
CHAPTER 1 OVERVIEW Table 1.6-1 Pin Description (3/3) Number Circuit Pin Name Functional description Type X1A* Low-speed oscillation pin. P36* General-purpose I/O port − power input pin for A/D converter *: MB90F897:X1A,X0A MB90F897S:P36,P35...
CHAPTER 1 OVERVIEW I/O Circuit I/O circuit of MB90895 series is shown in the figure below. I I/O Circuit Table 1.7-1 I/O Circuit (1/2) Classifi Circuit Remarks cation • Approximately 1MΩ high speed oscillation feedback resistor. • Oscillation feedback resistor for low speed approximately Clock input 10MΩ...
Page 32
CHAPTER 1 OVERVIEW Table 1.7-1 I/O Circuit (2/2) Classifi Circuit Remarks cation • CMOS hysteresis input V cc • CMOS-level output • Also used as analog input pin • Standby control provided Digital output • Automotive Input Digital output V ss Hysteresis input Standby control automotive input...
CHAPTER 2 HANDLING DEVICES This chapter describes the precautions when handling the general-purpose one chip micro-controller. 2.1 Precautions when Handling Devices...
Using External Clock" shows an use example of external clock. Figure 2.1-1 Example of Using External Clock Open MB90895 Series Precautions when not using sub clock If an oscillator is not connected to the X0A and X1A pins, connect the X0A pin to Pull-down resistor and leave the X1A pin open.
Page 35
Crystal oscillator circuit • Noise near the X0 and X1 pins may cause MB90895 series to malfunction. When designing a PC board using the device, place the X0 and X1 pins, the crystal (or ceramic) oscillator, and the bypass capacitor leading to the ground as close to one another as possible and prevent the wiring patterns for the X0 and X1 pins from crossing.
CHAPTER 3 CPU Memory Space The memory space of the F MC-16LX is 16 MB and is allocated to I/O, programs, and data. Part of the memory space is used for specific uses such as the expansion intelligent I/O service (EI OS) descriptors, the general-purpose registers, and the vector tables.
Page 39
CHAPTER 3 CPU I ROM Area Vector table area (address: FFFC00 to FFFFFF • The vector table is provided for reset and interrupts. • This area is allocated at the top of the ROM area. And The starting address of the corresponding processing routine is set to the address of each vector table as data.
I Memory Map for MB90895 Series In MB90895 series, the internal address bus is output up to a width of 24 bits and the external address bus is output up to a width of 24 bits; the external access memory can access up to the 16-MB memory space.
Page 41
CHAPTER 3 CPU I Image Access to Internal ROM In the F MC-16LX family, with the internal ROM in operation, ROM data in the FF bank can be seen as an image in the top 00 bank. This function is called ROM mirroring and enables effective use of a small C compiler.
3.1.2 Memory Map MB90895 series memory map is shown for each device. I Memory Map Figure 3.1-3 "Memory Map of MB90895 Series" shows the memory map for MB90895 series. Figure 3.1-3 Memory Map of MB90895 Series MB90F897/S MB90V495G Internal ROM...
CHAPTER 3 CPU 3.1.3 Addressing Linear and bank types are available for addressing. The F MC-16LX family basically uses bank addressing. • Linear type: direct-addressing all 24 bits by instruction • Bank type: addressing higher 8 bits by bank registers suitable for the use, and lower 16 bits by instruction I Linear Addressing and Bank Addressing The linear addressing is to access the 16-MB memory space by direct-addressing.
CHAPTER 3 CPU 3.1.4 Linear Addressing The linear addressing has the following two types: • Direct-addressing 24 bits by instruction • Using lower 24 bits of 32-bit general-purpose register for address I Linear Addressing by Specifying 24-bit Operand Figure 3.1-5 Example of 24-bit Physical Direct Addressing in Linear Type JMPP 123456 Old program bank 452D...
CHAPTER 3 CPU 3.1.5 Bank Addressing The bank addressing is a type of addressing each of 254 64-KB banks into which the 16- MB memory space is divided, using the bank register, and the lower 16 bits by an instruction. The following five types of bank registers are available for different purposes.
Page 46
CHAPTER 3 CPU Figure 3.1-7 "Example of Bank Addressing" shows the relationships between the memory space divided into banks and each register. Figure 3.1-7 Example of Bank Addressing 0 0 0 0 0 0 0 7 0 0 0 0 System stack space SSB (System stack bank register) 07FFFF...
CHAPTER 3 CPU 3.1.6 Allocation of Multi-byte Data in Memory Multi-byte data is written to memory in sequence starting from the low addresses. For 32- bit length data, the lower 16 bits are written first, and then the higher 16 bits are written.
Page 48
CHAPTER 3 CPU I Storage of Multi-byte Data in Stack Figure 3.1-10 "Storage of Multi-byte Data in Stack" shows the order in which multi-byte data is stored in the stack. Figure 3.1-10 Storage of Multi-byte Data in Stack PUSHW RW1,RW3 Lower address PUSHW RW1, 35A4...
CHAPTER 3 CPU Dedicated Registers The CPU has the following dedicated registers. • Accumulator • User stack pointer • System stack pointer • Processor status • Program counter • Direct page register • Bank registers (program bank register, data bank register, user stack bank register, system stack bank register, additional data bank register) I Configuration of Dedicated Registers Figure 3.2-1 Configuration of Dedicated Registers...
Page 50
CHAPTER 3 CPU Table 3.2-1 Reset Values of Dedicated Registers Dedicated Registers Reset Value Accumulator (A) Undefined User stack pointer (USP) Undefined System stack pointer (SSP) Undefined Processor status (PS) bit15 bit13 bit12 bit8 bit7 bit0 0 0 0 0 0 0 0 0 0 1 x x x x x Value of reset vector (data at FFFFDC and FFFFD...
CHAPTER 3 CPU 3.2.1 Dedicated Registers and General-purpose Register The F MC-16LX family has two types of registers: dedicated registers in the CPU and general-purpose register in the internal RAM. I Dedicated Registers and General-purpose Register The dedicated registers are limited to the use in the hardware architecture of the CPU. The general-purpose registers are in the internal RAM in the CPU address space.
CHAPTER 3 CPU 3.2.2 Accumulator (A) The accumulator (A) consists of two 16-bit length operation registers (AH and AL) used for temporary storage of the operation result or data. The accumulator can be used as a 32-, 16-, or 8-bit register to perform various operations between the AH and AL registers and memory or other registers.
Page 53
CHAPTER 3 CPU Byte processing arithmetic operation of accumulator When the arithmetic operation instruction for byte processing is executed for the AL register, the higher 8 bits of the AL register in pre-operation are ignored, and the higher 8 bits of the operation result become all "0".
Page 54
CHAPTER 3 CPU Figure 3.2-6 Example of 16-bit Data Transfer to Accumulator (A) (Data Saving) (Instruction of following execution; MOVW A,@RW1+6 - Reading by the result(RW1 contents + 8-bit length offset) as address - Storing the data contents in register A Memory space Before XXXX...
CHAPTER 3 CPU 3.2.3 Stack Pointer (USP, SSP) The stack pointers include a user stack pointer (USP) and a system stack pointer (SSP). Both these pointers indicate the address where saved data and return data are stored when the PUSH instruction, the POP instruction, and the subroutine are executed. •...
Page 56
CHAPTER 3 CPU Figure 3.2-8 "Stack Operation Instructions and Stack Pointers" shows an example of the stack operation using the system stack. Figure 3.2-8 Stack Operation Instructions and Stack Pointers PUSHW A when S flag is "0" A624 F328 C6F327 C6F326 Before execution...
Page 57
CHAPTER 3 CPU I Stack Area Securing stack area The stack area is used to save and return the program counter (PC) at execution of the interrupt processing, subroutine call instruction (CALL) and vector call instruction (CALLV). It is also used to save and return temporary registers using the PUSHW and POP The stack area is secured with the data area in RAM.
CHAPTER 3 CPU 3.2.4 Processor status (PS) The processor status (PS) consists of the bits controlling CPU and various bits indicating the CPU status. The processor status (PS) consists of the following three registers. • Interrupt level mask register (ILM) •...
Page 59
CHAPTER 3 CPU 3.2.4.1 Condition Code Register (PS: CCR) The condition code register (CCR) is an 8-bit register consisting of bits indicating the result of instruction execution, and the bits enabling or disabling the interrupt request. I Configuration of Condition Code Register (CCR) Figure 3.2-11 "Configuration of Condition Code Register (CCR)"...
Page 60
CHAPTER 3 CPU Zero flag (Z) If all the bits of the operation result are "0", this flag is set to "1". If any 1 bit is "1", the flag is cleared to "0". Overflow flag (V) If an overflow occurs as a signed numeric value at the execution of operation, this flag is set to "1". If no overflow occurs, the flag is cleared to "0".
Page 61
CHAPTER 3 CPU 3.2.4.2 Register Bank Pointer (PS: RP) The register bank pointer (RP) is a 5-bit register that indicates the starting address of the currently used general-purpose register bank. I Register bank pointer (RP) Figure 3.2-12 "Configuration of Register Bank Pointer (RP)" shows the configuration of the register bank pointer (RP).
Page 62
CHAPTER 3 CPU 3.2.4.3 Interrupt Level Mask Register (PS: ILM) The interrupt level mask register (ILM) is a 3-bit register indicating the interrupt level accepted by the CPU. I Interrupt level mask register (ILM) Figure 3.2-14 shows the configuration of the interrupt level mask register (ILM). Figure 3.2-14 Configuration of Interrupt Level Mask Register (ILM) bit15 13 12 11 10...
CHAPTER 3 CPU 3.2.5 Program counter (PC) The program counter (PC) is a 16-bit counter indicating the lower 16 bits of the address for the next instruction code to be executed by the CPU. I Program counter (PC) The program bank register (PCB) indicates the higher 8 bits of addresses where the next instruction code to be executed by the CPU is stored;...
CHAPTER 3 CPU 3.2.6 Direct page register (DPR) The direct page register (DPR) sets bit 8 to bit 15 (addr 15 to addr 8) for the 8 bits of the low address directly specified using the operand when executing the instruction by the abbreviated direct addressing.
CHAPTER 3 CPU 3.2.7 Bank Register (PCB, DTB, USB, SSB, and ADB) The bank register sets the MSB 8 bit of the 24-bit address using bank addressing The following five registers are included. • Program bank register (PCB) • Data bank register (DTB) •...
CHAPTER 3 CPU General-purpose Register The general-purpose register is a memory block allocated to addresses "000180 " to "00037F " in the internal RAM in 1 bank units of 16 bits x 8. • General-purpose 8-bit register (byte registers R0 to R7) •...
Page 67
CHAPTER 3 CPU I Register Bank The register bank can be used as a general-purpose register (byte registers R0 to R7, word registers RW0 to RW7, and long-word registers RL0 to RL3) to perform various operations or to serve as a pointer. The long- word register can also be used as a linear addressing to directly access the entire memory space.
CHAPTER 3 CPU Prefix Code When prefix code is inserted by an instruction, the operation of the instruction can be changed partially. The prefix code has the following three types: • Bank select prefix (PCB, DTB, ADB, and SPB) • Common register bank prefix (CMR) •...
CHAPTER 3 CPU 3.4.1 Bank select prefix (PCB, DTB, ADB, and SPB) When the bank select prefix codes precede an instruction, any memory space accessed by the instruction can be set, regardless of the addressing modes. I Bank select prefix (PCB, DTB, ADB, and SPB) Memory space used at data access is predetermined for each addressing mode.
Page 70
CHAPTER 3 CPU Table 3.4-3 Instructions Requiring Precaution When Using Bank Select Prefix Instruction Types Instruction Description Flag change instruction AND CCR,#imm8 The bank select prefix code affects up to the next instruction. OR CCR,#imm8 ILM setting instruction MOV ILM,#imm8 The bank select prefix code affects up to the next instruction.
CHAPTER 3 CPU 3.4.2 Common register bank prefix (CMR) When the common register bank prefix (CMR) code precedes an instruction for accessing a general-purpose register, the general-purpose register to be accessed by the instruction can be changed to a common bank (register bank selected when the register bank pointer (RP) is 0) at 000180 to 00018F , regardless of the current value of...
CHAPTER 3 CPU 3.4.3 Flag change inhibit prefix (NCC) When the flag change inhibit prefix (NCC) code precedes an instruction for changing various flags of the condition code register (CCR), a flag change caused by instruction execution can be inhibited. I Flag change inhibit prefix (NCC) The flag change inhibit prefix (NCC) code is used to inhibit an unnecessary flag change.
CHAPTER 3 CPU 3.4.4 Restrictions on Prefix Code The use of the prefix codes is restricted as follows: • No interrupt request is accepted during execution of a prefix code and interrupt inhibit instruction. • When a prefix code precedes an interrupt inhibit instruction, The effect of the prefix code is delayed.
Page 74
CHAPTER 3 CPU Delay of the effect of the prefix code When a prefix code precedes an interrupt inhibit instruction, it affects the next instruction after the interrupt inhibit instruction. Figure 3.4-2 Interrupt Inhibit Instruction and Prefix Code Interrupt inhibit instruction MOV A,FF MOV ILM,#imm8 ADD A,01...
CHAPTER 3 CPU Interrupt The F MC-16LX family has four interrupt functions for suspending the current processing to pass control to a separately defined program when a specific event occurs. • Hardware Interrupt • Software interrupt • Interrupts by extended intelligent I/O service (EI •...
Page 76
CHAPTER 3 CPU I Interrupt Operation Figure 3.5-1 shows interrupt start and return processing. Figure 3.5-1 General Flow of Interrupt Operation START Main program Valid interrupt ? Interrupt start/return processing During execution of string instruction* Starting the EI OS ? Fetch of next instruction and decode OS processing...
CHAPTER 3 CPU 3.5.1 Interrupt Factor and Interrupt Vector The F MC-16LX family has vector tables corresponding to 256 types of interrupt factor. I Interrupt Vector The interrupt vector tables referenced at interrupt processing are allocated to the most significant addresses ("FFFC00 "...
Page 78
CHAPTER 3 CPU I Interrupt Factor, Interrupt Vector, and Interrupt Control Register Table 3.5-2 shows the relationships between the interrupt factor except software interrupt, and interrupt vector and interrupt control register. Table 3.5-2 Interrupt Factor, Interrupt Vector, and Interrupt Control Register Interrupt Vector Interrupt Control Register Priority...
Page 79
CHAPTER 3 CPU :Available :Not available :Interrupt factor corresponds to EI OS and has EI OS stop function : Interrupt factor can be used when not using interrupt sources sharing ICR register • The interrupt level for resources sharing an ICR register become the same. •...
CHAPTER 3 CPU 3.5.2 Interrupt Control Registers and Peripherals The interrupt control registers (ICR00 to ICR15) are allocated in he interrupt controller, and correspond to all peripherals with interrupt functions. The registers control the interrupt and extended intelligent I/O service (EI OS).
Page 81
CHAPTER 3 CPU Each interrupt control register (ICR) has the following four functions. Some functions of the interrupt control register (ICR) are different at write and read. • Setting of interrupt level of corresponding peripheral • Selection of whether to perform normal interrupt or EI OS for corresponding peripheral •...
CHAPTER 3 CPU 3.5.3 Interrupt Control Register (ICR00 to ICR15) The functions of the interrupt control registers are shown below. I Interrupt Control Register (ICR00 to ICR15) Some functions differ depending on whether data is written to or read from the interrupt control registers. Figure 3.5-2 Interrupt Control Register (ICR00 to ICR15) at Write At writing Reset value...
Page 83
CHAPTER 3 CPU Figure 3.5-3 Interrupt Control Register (ICR00 to ICR15) at Read At read Reset value X X 0 0 0 1 1 1 bit0 bit2 bit1 Interupt level setting bit Interrupt level 0 (highest) Interrupt level 7 (without interruption) bit3 OS enable bit When an interrupt occurs, start normal interrupt process...
CHAPTER 3 CPU 3.5.4 Function of Interrupt Control Register The interrupt control registers (ICR00 to ICR15) consist of the following bits with four functions. • Interrupt level setting bits (IL2 to IL0) • EI OS enable bit (ISE) • EI OS channel select bits (ICS3 to ICS0) •...
Page 85
CHAPTER 3 CPU I Function of Interrupt Control Register Interrupt level setting bits (IL2 to IL0) Sets corresponding peripheral Functions of Interrupt Control Register. At reset, the bits are set to level 7 (IL2 to IL0 = "111 ": no interrupt). Table 3.5-4 shows the relationship between the interrupt level setting bits and interrupt levels.
Page 86
CHAPTER 3 CPU Table 3.5-5 Correspondence between EI OS Channel Select Bits and Descriptor Addresses (2/2) ICS3 ICS2 ICS1 ICS0 Channel to be Selected Descriptor Address 000128 000130 000138 000140 000148 000150 000158 000160 000168 000170 000178 OS status bits (S1 and S0) When the S1 and S0 bits are read at the termination of the EI OS, the operating and end states can be checked.
CHAPTER 3 CPU 3.5.5 Hardware Interrupt The hardware interrupt responds to the interrupt request from a resource, suspends the current-executing program and transfers control to the interrupt processing program defined by user. The hardware interrupt corresponds to the EI I Hardware Interrupt Function of hardware interrupt When a hardware interrupt occurs, the interrupt level (IR: IL) of the interrupt request from a peripheral resource is compared with the interrupt level mask register (PS: ILM) and the state of the interrupt enable...
Page 88
CHAPTER 3 CPU I Mechanism of Hardware Interrupt The mechanism related to hardware interrupts consists of the four sections. When starting the hardware interrupt, these four sections must be set by the program. Table 3.5-7 Mechanism Related to Hardware Interrupt Mechanism Related to Hardware Function Interrupt...
Page 89
CHAPTER 3 CPU Hardware interrupt inhibition by interrupt inhibit instruction Table 3.5-8 shows the hardware interrupt inhibit instructions. If a hardware interrupt occurs during execution of a hardware interrupt inhibit instruction, the interrupt is processed after execution of the hardware interrupt inhibit instruction and other instructions. Table 3.5-8 Hardware Interrupt Inhibit Instructions Prefix Code Interrupt Inhibit Instruction...
CHAPTER 3 CPU 3.5.6 Operation of Hardware Interrupt The operation from the generation of hardware interrupt request to the completion of interrupt processing is explained below. I Start of Hardware Interrupt Operation of peripheral (generation of interrupt request) The peripherals with a hardware interrupt request function have an interrupt request flag indicating the generation of an interrupt request, as well as an interrupt enable flag selecting between enabling and disabling an interrupt request.
Page 91
CHAPTER 3 CPU I Operation of Hardware Interrupt Figure 3.5-6 shows the operation from the generation of hardware interrupt to the completion of interrupt processing. Figure 3.5-6 Operation of Hardware Interrupt Internal bus PS,PC Micro code Check Comparator F MC-16LXCPU Other peripheral function Peripheral function of interrupt request generate...
CHAPTER 3 CPU 3.5.7 Procedure for Use of Hardware Interrupt The settings of the system stack area, resources, interrupt control registers (ICR) are required for using the hardware interrupt. I Procedure for Use of Hardware Interrupt Figure 3.5-7 shows an example of the procedure for use of the hardware interrupt. Figure 3.5-7 Procedure for Use of Hardware Interrupt Start Setting the system stack area...
CHAPTER 3 CPU 3.5.8 Multiple interrupts Multiple hardware interrupts can be generated by setting different interrupt levels in the interrupt level setting bits of the interrupt control register (ICR: ILO to IL2) in response to multiple interrupt requests from the resource. However, multiple EI OS cannot be started.
Page 94
CHAPTER 3 CPU Example of multiple interrupts As an example of multiple interrupt processing, assuming that a timer interrupt is preferred to an A/D converter interrupt, set the interrupt level of the A/D converter to 2 and the interrupt level of the timer to 1. Figure 3.5-8 shows the processing of the timer interrupt generated during processing of the A/D converter interrupt.
CHAPTER 3 CPU 3.5.9 Software interrupt The software interrupt is a function for transiting control from the current-executing program to the interrupt processing program defined by user by execution of a software interrupt instruction (INT instruction). The software interrupt is held during execution of a software interrupt.
CHAPTER 3 CPU 3.5.10 Interrupts by extended intelligent I/O service (EI OS is a function to automatically transfer data between the peripherals (I/O) and memory. It generates the hardware interrupt at termination of data transfer. I EI The EI OS provides automatic data transfer between the I/O area and memory. When data transfer is terminated, the termination factor (end condition) is set, branching automatically to the interrupt processing routine.
Page 97
CHAPTER 3 CPU I Operation of EI Figure 3.5-9 shows the operation of the EI Figure 3.5-9 Operation of EI Memory space By IOA I/O area 00 Bank area Interrupt request By ICS Interrupt control register (ICR) Interrupt controller By BAP Buffer Count by DCT ISD :EI...
CHAPTER 3 CPU 3.5.11 OS descriptor (ISD) The EI OS descriptor (ISD) is allocated to the addresses "000100 " to "00017F " in the internal RAM, and consists of 8 bytes x 16 channels. I Configuration of EI OS Descriptor (ISD) ISD consists of 8 bytes x 16 channels, and each ISD is composed as shown in Figure 3.5-10.
Page 99
CHAPTER 3 CPU Table 3.5-9 EI OS Descriptor (ISD) Area (2/2) Channel Descriptor header Address (ICR: ICS3 to ICS0) 000140 000148 000150 000158 000160 000168 000170 000178...
CHAPTER 3 CPU 3.5.12 Each Register of EI OS Descriptor (ISD) The EI OS descriptor (ISD) consists of the following registers. • Data counter (DCT) • I/O address pointer (IOA) • EI OS status register (ISCS) • Buffer address pointer (BAP) The reset value of each register is undefined and a reset should be performed carefully.
Page 101
CHAPTER 3 CPU I EI OS Status Register (ISCS) The EI OS status register (ISCS) is an 8-bit register that sets the method to update the buffer address pointer and I/O address pointer, transfer data format (byte/word), and transfer direction. Figure 3.5-13 shows the bit configuration of the EI OS status register (ISCS).
Page 102
CHAPTER 3 CPU I Buffer address pointer (BAP) The buffer address pointer (BAP) is a 24-bit register and sets the 16-MB addresses where data is transferred to or from I/O area. When the BAP updating/fixing select bit of the EI OS status register (ISCS: BF) is set to updated (ISCS: BF=0), the buffer address pointer (BAP) changes only in the lower 16 bits (BAPH, BAPL) and does not change in the higher 8 bits (BAPH).
CHAPTER 3 CPU 3.5.13 Operation of EI The flowchart of operation of the EI OS using the microcode in the CPU is shown below: I Operation of EI Figure 3.5-15 Flowchart of Operation of EI Interrupt request generate : EI OS descriptor from peripheral resource ISCS...
CHAPTER 3 CPU 3.5.14 Procedure for Use of EI The procedure for using the EI OS is shown below: I Procedure for Use of EI Figure 3.5-16 Procedure for Use of EI Processing by software Processing by hardware Start Setting of system stack area Setting of EI OS Descriptor Setting of peripheral resource interruption...
CHAPTER 3 CPU 3.5.15 OS Processing Time The time required for EI OS processing depends on the following factors: • Setting of EI OS status register (ISCS) • Data length of transfer data Some interrupt handling time is required at the transition to hardware interrupt processing after completion of data transfer.
Page 106
CHAPTER 3 CPU At end of data counter (DCT) (DCT ≠ 0, ISCS: SE=0) At completion of data transfer by the EI OS, since the hardware interrupt is started, the interrupt handling time is added. The EI OS processing time at the end of counting is calculated by the following expression. OS Processing Time after count finish OS Processing Time at continuing data transfer + (21 + 6 ×...
CHAPTER 3 CPU 3.5.16 Exception Processing Interrupt The F MC-16LX family performs exception processing when an undefined instruction is executed. Exception is basically the same as interrupt. When an exception is detected between instructions, normal processing is suspended to perform exception processing. Exception processing is performed when an unexpected operation is performed, and should be used only for starting recovery software at debugging or in an emergency.
CHAPTER 3 CPU 3.5.17 Time Required to Start Interrupt Processing The time for terminating the currently executing instruction plus the interrupt handling time is required from generation of the hardware interrupt request to execution of the interrupt-processing. I Time Required to Start Interrupt Processing The interrupt request sampling wait time and the interrupt handling time (time required for preparation for interrupt processing) are required from generation of the interrupt request and acceptance of interrupt, to execution of the interrupt processing.
Page 109
CHAPTER 3 CPU Table 3.5-13 Compensation Value (Z) of Interrupt Handling Time Address Set by Stack Pointer Compensation Value (Z) For internal area (even address) For internal area (odd address) Reference: One machine cycle is equal to one clock cycle of the machine clock (φ).
CHAPTER 3 CPU 3.5.18 Stack Operation for Interrupt Processing When an interrupt request is accepted, the values of dedicated registers are automatically saved to the system stack before transition to interrupt processing. At completion of interrupt processing, the values of the dedicated registers are automatically returned from the system stack.
CHAPTER 3 CPU 3.5.19 Program Example of Interrupt Processing This section gives a program example of interrupt processing. I Program Example of Interrupt Processing Processing specification This is an example of interrupt program using external interrupt 4 (INT4). Coding example DDR2 000012H ;Port 2 direction register...
Page 112
CHAPTER 3 CPU ;----------Interupt program------------------------------------- ED_INT1: I:EIRR,#00H ;Prohibition of new INT4 reception RETI ;Recover from interrupt CODE ENDS ;----------Vector setting---------------------------------------- VECT CSEG ABS=0FFH 0FFD0H ;Setting vector to interrupt #11(0BH) ED_INT1 0FFDCH ;Setteing of reset vector START ;Setting to single chip mode VECT ENDS START...
Page 113
CHAPTER 3 CPU ;----------Main program----------------------------------- CODE CSEG START: CCR,#0BFH ;I flag of CCR in PS cleared to interrupt disabled RP,#00 ;Setting register bank pointer A,#!STACK_T ;Setting system stack SSB,A MOVW A,#STACK_T ;Setting system stack pointer MOVW SP,A ;in this case,S flag=1,so set to SSP I:DDR2,#00000000B ;Setting P24/INT4 pin to input BAPL,#00H...
CHAPTER 3 CPU Reset When a reset trigger even occurs, the CPU immediately suspends the current process and starts the reset operation. The reset factors are as follows: • Power on reset • Watchdog timer overflow • Generation of software reset request •...
Page 115
CHAPTER 3 CPU inputting Low level from the RST pin requires at least 16 machine cycles (main clock). • An external reset does not require the oscillation stabilization wait time. • If an external reset request is generated from the RST pin during writing by a transfer Notes: instruction (such as MOV), the reset cancel wait state is set after completion of the transfer instruction, so writing is terminated normally.
Software reset None External reset None HCLK: Oscillation clock frequency *: MB90V495G requires 2 /HCLK. Figure 3.6-1 MB90895 series oscillation stabilization wait time at generating power-on reset CPU operation /HCLK Oscillation time of oscillator /HCLK Wait time for stabilizing oscillation...
Page 117
CHAPTER 3 CPU Table 3.6-3 Oscillation stabilization wait time setting by clock select register (CKSCR) Clock select bit Oscillation Stabilization Wait Time Parenthesized values are examples calculated at an oscillation clock frequency of 4 MHz. /HCLK (256µs) /HCLK (approx.2.048ms) /HCLK (approx.4.1ms) *1,*2 /HCLK (approx.8.19ms) HCLK: Oscillation clock frequency...
External Reset Pin The external reset pin (RST pin) is a reset input pin. Input of an external Low level generates a reset factor. MB90895 series starts the reset operation in synchronization between the CPU and clock. I Block Diagram of External Reset Pin Figure 3.6-2 Block Diagram of External Reset Pin...
CHAPTER 3 CPU 3.6.3 Reset Operation During reset operation, the mode for reading mode data and reset vectors is set according to the settings of the mode pins (MD0 to MD2) and a mode fetch is executed. When the oscillation clock is returned from stop states (power on, stop mode) by a reset, a mode fetch is executed after the elapse of the main clock oscillation stabilization wait time.
Page 120
CHAPTER 3 CPU I Mode Fetch At transition to the reset operation, the CPU automatically transfers mode data and reset vectors by hardware to the appropriate register in the CPU core. The mode data and reset vector are allocated to four bytes of addresses "FFFFDC "...
CHAPTER 3 CPU 3.6.4 Reset Factor Bit To check reset factors, read the value of the watchdog timer control register (WDTC). I Reset Factor Bit Each reset factor provides a flip-flop circuit corresponding to each factor. The state of the flip-flop circuit can be checked by reading the value of the watchdog timer control register (WDTC).
Page 122
CHAPTER 3 CPU I Correspondence of Reset Factor Bit and Reset Factor Figure 3.6-6 shows the configuration of the reset factor bits in the watchdog timer control register (WDTC: PONR, WRST, ERST, SRST). Figure 3.6-6 Configuration of Reset Factor Bit bit7 bit6 bit5...
Page 123
CHAPTER 3 CPU I Notes on Reset Factor Bit Power on reset When a power on reset is executed, the PONR bit is set to "1" after completion of the reset operation. Any reset factor bit other than the PONR bit is undefined. When the PONR bit is "1" after completion of the reset operation, ignore the value of any bit other than the PONR bit.
CHAPTER 3 CPU 3.6.5 State of Each Pin at Reset This section explains the state of each pin at reset. I State of Pins at Reset The state of the pins during reset operation is determined by the settings of the mode pins (MD2 to MD0). When internal vector mode set: •...
CHAPTER 3 CPU Clock The clock generation section controls the internal clock that is an operating clock for the CPU or resources. The clock generated by the clock generation section is called a machine clock and one cycle of the machine clock is a machine cycle. The clock to be supplied from a high-speed oscillator is called an oscillation clock and the 2- frequency division of the oscillation clock is called a main clock.
Page 126
CHAPTER 3 CPU Machine clock This clock is an operating clock for the CPU and the resources. One cycle of the machine clock is a machine cycle (1/φ). One clock can be selected from the main clock sub clock, and four types of PLL clock.
Page 127
CHAPTER 3 CPU I Clock Supply Map Machine clocks generated by the clock generation section are supplied as operating clocks of the CPU and peripherals. The operation of the CPU and peripheral peripherals is affected by switching between the main clock and subclock or PLL clock (clock mode) or by switching the PLL clock multiplier.
CHAPTER 3 CPU 3.7.1 Block Diagram of Clock Generation Section The clock generation section consists of the following five blocks: • Oscillation clock generator/sub clock generator • PLL multiplying circuit • Clock selector • Clock select register (CKSCR) • Oscillation stabilization wait time selector I Block Diagram of Clock Generation Section Figure 3.7-2 shows the block diagram of the clock generation section.
Page 129
CHAPTER 3 CPU Oscillation clock generator This generator generates an oscillation clock (HCLK) by connecting an oscillator or inputting an external clock to the high-speed oscillation pins. Sub clock generator This generator generates a sub clock (SCLK) by connecting an oscillator or inputting an external clock to the low-speed oscillation pins (X0A, X1A).
CHAPTER 3 CPU 3.7.2 Register in Clock Generation Section This section explains the register in the clock generation section. I Register in Clock Generation Section and List of Reset Values Figure 3.7-3 Clock Select Register and List of Reset Values Clock select register (CKSCR)
CHAPTER 3 CPU 3.7.3 Clock select register (CKSCR) The clock select register (CKSCR) is used to switch the clock mode between main clock, subclock, and PLL clock and to select the oscillation stabilization wait time and the PLL clock multiplier. I Clock select register (CKSCR) Figure 3.7-4 Clock select register (CKSCR) Reset value...
Page 132
CHAPTER 3 CPU Table 3.7-1 Functions of clock select register (CKSCR) (1/2) bit name Function bit9 CS1, CS0: The PLL clock multiplier is selected from among seven options depending on the combination of bit8 the multiplication rate PSCCR: CS2 and CKSCR: CS1/CS0. select bits Any reset causes the bit to return to the reset value.
Page 133
CHAPTER 3 CPU Table 3.7-1 Functions of clock select register (CKSCR) (2/2) bit name Function bit13 WS1, WS0: These bits are used to select an oscillation stabilization wait time required for the oscillation clock bit12 oscillation stabilization when the stop mode is canceled, when transition occurs from subclock mode to main clock mode, wait time select bit or when transition occurs from subclock mode to PLL clock •...
CHAPTER 3 CPU 3.7.4 PLL/subclock control register (PSCCR) The PLL/subclock control register (PSCCR) is used to switch the subclock frequency divide ratio (selecting division by 2 or 4) and to set the PLL clock multiplier (division by 1, 2, 3 or 4). I PLL/subclock control register (PSCCR) Figure 3.7-5 PLL/subclock control register (PSCCR) Address:003F...
Page 135
CHAPTER 3 CPU Table 3.7-3 PLL multipliler setting in PSCCR:CS2 and CKSCR:CS1/CS0 (Calculated assuming a frequency of 4 MHz) Function × HCLK (4 MHz) × HCLK (8 MHz) × HCLK (12 MHz) × HCLK (16 MHz) × HCLK(8 MHz) × HCLK(16 MHz) Unavailable Unavailable...
CHAPTER 3 CPU 3.7.5 Clock Mode Clock modes have a main clock mode, sub clock mode, and PLL clock mode. I Clock Mode Main clock mode In the main clock mode, a clock with 2-frequency division of the clock generated by connecting an oscillator or inputting an external clock to the high-speed oscillation pins (X0, X1) is used as the operating clock for the CPU or peripherals.
Page 137
CHAPTER 3 CPU Transition from sub clock mode to main clock mode When the sub clock select bit (CKSCR: SCS) is rewritten from "0" to "1", the sub clock switches to the main clock after the main clock oscillation stabilization wait time has elapsed. Notes: •...
Page 138
CHAPTER 3 CPU Figure 3.7-6 shows the transition of a clock mode. Figure 3.7-6 Clock Mode Transition → Main MCS=1 MCM=1 Main SCS=0 (10) MCS=1 MCS=1 SCM=1 MCM=1 MCM=1 CS1,CS0=xx (16) SCS=1 SCS=0 (10) SCM=1 SCM=0 (11) → Main CS1,CS0=xx CS1,CS0=xx MCS=1 MCM=1...
Page 139
CHAPTER 3 CPU (1) MCS bit "0" write (2) Termination of PLL clock oscillation stabilization wait time & CS1,CS0=00 (3) Termination of PLL clock oscillation stabilization wait time & CS1,CS0=01 (4) Termination of PLL clock oscillation stabilization wait time & CS1,CS0=10 (5) Termination of PLL clock oscillation stabilization wait time &...
CHAPTER 3 CPU 3.7.6 Oscillation Stabilization Wait Time At power on or return from the stop mode when the oscillation clock is stopped, a time until the oscillation clock stabilizes (oscillation stabilization wait time) is required after starting an oscillation.The oscillation stabilization wait time is also required for switching the clock mode from main clock mode to PLL clock or subclock mode and from subclock mode to main clock or PLL clock mode.
3.7.7 Connection of Oscillator and External Clock MB90895 series has a system clock generator and generates an internal clock by connecting an oscillator to the oscillation pins. External clocks that are input to the oscillation pins can be used as oscillation clocks.
CHAPTER 3 CPU Low-power Consumption Mode The CPU operation modes are classified as follows according to the selection of the operation clock and the oscillation control of a clock. All the operation modes except the PLL clock mode are low-power consumption modes. •...
Page 143
CHAPTER 3 CPU I Clock Mode PLL clock mode In PLL clock mode, the CPU and peripherals operate on a PLL multiplying clock of oscillation clock (HCLK). Main clock mode In main clock mode, the CPU and peripherals operate on a clock with 2-frequency division of oscillation clock (HCLK).
Page 144
CHAPTER 3 CPU Timebase timer mode The timebase timer mode operates only the oscillation clock (HCLK), sub clock (SCLK), timebase timer, and watch timer.Resources other than the timebase timer and watch timer stop. Stop mode The stop mode stops the oscillation clock (HCLK) and sub clock (SCLK) during operation in each clock mode.It enables data to be retained with the least power consumption.
CHAPTER 3 CPU 3.8.1 Block Diagram of Low-power Consumption Circuit This section shows block diagram of low-power consumption circuit. I Block Diagram of Low-power Consumption Circuit Figure 3.8-2 Block Diagram of Low-power Consumption Circuit Low power consumption mode control register (LPMCR) CG1 CG0 Reserved Pin High-Z...
Page 146
CHAPTER 3 CPU CPU intermittent operation selector This selector selects the halt cycle count of the CPU clock in the CPU intermittent operation mode. Standby controller The CPU clock controller and resource clock controller switch between the CPU operating clock and resource operating clock to enter and cancel the standby mode.
CHAPTER 3 CPU 3.8.2 Registers for Setting Low-power Consumption Modes This section explains the registers to be used to set lower-power consumption modes. I Low-power Consumption Mode Control Register and Reset Values Figure 3.8-3 Low-power Consumption Mode Control Register and Reset Values Low power consumption control register (LPMCR)
CHAPTER 3 CPU 3.8.3 Low-power consumption mode control register (LPMCR) The low-power consumption mode control register (LPMCR) transits an operation mode to, and cancels the low-power consumption modes, generates an internal reset signal, and sets the halt cycle count in the CPU intermittent operation mode. I Low-power consumption mode control register (LPMCR) Figure 3.8-4 Low-power consumption mode control register (LPMCR) Reset value...
Page 149
CHAPTER 3 CPU Table 3.8-1 Functions of low-power consumption mode control register (LPMCR) bit name Function bit0 Reserved: reserved bit Always set this bit to "0". bit1 CG1, CG0: These bits are used to set the halt cycle count of the CPU clock in the CPU intermittent operation bit2 CPU halt cycle count mode.
Page 150
CHAPTER 3 CPU • To access the low-power consumption mode control register (LPMCR) with C language, refer to "I Notes on Accessing the Low-Power Consumption Made Control Register (LPMCR) to Enter the Standby Mode" in the section 3.8.8 "Precautions when Using Low-Power Consumption Mode". •...
CHAPTER 3 CPU 3.8.4 CPU Intermittent operation mode The CPU intermittent operation mode causes the CPU to operate intermittently with an operating clock supplied to the CPU or resources to reduce power consumption. I Operation in CPU Intermittent Operation Mode CPU The CPU intermittent operation mode halts the clock supplied to the CPU at every instruction execution when the CPU accesses registers, internal memory, I/O, or resources delaying to start the internal bus.Decreasing the CPU processing speed while supplying a high-speed clock to resources reduces the...
CHAPTER 3 CPU 3.8.5 Standby Mode The standby mode causes the standby control circuit to either stop supplying an operation clock to the CPU and resources, or to stop the oscillation clock (HCLK) to reduce power consumption. I the operating state in each standby mode Table 3.8-3 shows the operating state in each standby mode.
Page 153
CHAPTER 3 CPU : operation, : stop, : held in the state before transiting, Hi-Z: High impedance *1: The timebase timer and watch timer operate.- *2: The watch timer operates. *3: The DTP/external interrupt input pin operates. *4: Watch timer, timebase timer, and external interrupts *5: Watch timer and external interrupts *6: External interrupt INT6/INT7 MCS: PLL clock select bit in clock select register (CKSCR)
Page 154
CHAPTER 3 CPU 3.8.5.1 Sleep Mode The sleep mode stops the operating clock to the CPU during an operation in each clock mode.The CPU stops and the resources continue to operate. I Transition to Sleep Mode When the mode transits to the sleep mode by setting the low-power consumption mode control register (LPMCR: SLP = 1, STP = 0), the mode transits to the sleep mode according to the settings of the MCS and SCS bits in the clock select register (CKSCR).
Page 155
CHAPTER 3 CPU I Return from Sleep Mode The sleep mode is cancelled by a reset factor or when an interrupt is generated. Return by reset factor When the sleep mode is cancelled by a reset factor, the mode transits to the main clock mode after the sleep mode is cancelled, transiting to the reset sequence.
Page 156
CHAPTER 3 CPU 3.8.5.2 Watch Mode The watch mode operates only the sub clock (SCLK) and the watch timer.-The main clock and PLL clock stop. I Transition to Watch Mode In the sub clock mode, when 0 is written to the TMD bit in the LPMCR register according to the settings of the low-power consumption mode control register (LPMCR), the mode transits to the watch mode.
Page 157
CHAPTER 3 CPU I Return from Watch Mode The watch mode is cancelled by a reset factor or when an interrupt is generated. Return by reset factor When the watch mode is cancelled by a reset factor, the mode transits to the main clock mode after the watch mode is cancelled, transiting to the reset sequence.
Page 158
CHAPTER 3 CPU 3.8.5.3 Timebase Timer Mode The timebase timer mode operates only the oscillation clock (HCLK), sub clock (SCLK), timebase timer, and watch timer. Peripherals other than the timebase timer and watch timer stop. I Timebase Timer Mode The mode transits to the timebase timer mode when 0 is written to the TMD bit of the low-power consumption mode control register (LPMCR) during operation in the PLL clock mode or the main clock mode (CKSCR: SCM = 1).
Page 159
CHAPTER 3 CPU I Return from Timebase Timer Mode The timebase timer mode is cancelled by a reset factor or when an interrupt is generated. Return by reset factor When the timebase timer mode is cancelled by a reset factor, the mode transits to the main clock mode after the timebase timer mode is cancelled, transiting to the reset sequence.
Page 160
CHAPTER 3 CPU 3.8.5.4 Stop Mode The stop mode stops the oscillation clock (HCLK) and sub clock (SCLK) during operation in each clock mode.It enables data to be retained with the least power consumption. I Stop Mode When 1 is written to the STP bit of the low-power consumption mode control register (LPMCR) during operation in the PLL clock mode, the mode transits to the stop mode according to the settings of the MCS bit and SCS bit in the clock select register (CKSCR).
Page 161
CHAPTER 3 CPU Note: To set that pin to high impedance which serves either as a peripheral resource or as a port in stop mode, disable the output of the peripheral resource, then set the STP bit of to "1".Listed below are applicable ports.
Page 162
CHAPTER 3 CPU Return by interrupt When an interrupt request higher than the interrupt level (IL) of 7 is generated from external interrupt in the stop mode, the stop mode is cancelled.In the stop mode, the main clock oscillation stabilization wait time or the sub clock oscillation stabilization wait time is generated after the stop mode is cancelled.
3.8.6 State Transition in Standby Mode The operating state and state transition in the clock mode and standby mode in MB90895 series are shown in the diagram. I State Transition Diagram Figure 3.8-8 State Transition Diagram External reset, Watchdog timer reset, Software reset...
CHAPTER 3 CPU 3.8.7 Pin State in Standby Mode, at Reset The state of input/output pins in the standby mode and at reset is shown in each access mode. I State of Input/Output Pins (Single-chip Mode) Table 3.8-6 State of Input/Output Pins (Single-chip Mode) At stop/clock/timebase timer Pin Name At sleep...
CHAPTER 3 CPU 3.8.8 Precautions when Using Low-power Consumption Mode This section explains the precautions when using the low-power consumption modes. I Transition to Standby Mode When an interrupt request is generated from the resource to the CPU, the mode does not transit to each standby mode even after setting the STP and SLP bits in the low-power consumption mode control register (LPMCR) to 1 and the TMD bit to 0 (and also even after interrupt processing).
Page 166
CHAPTER 3 CPU Oscillation stabilization wait time of sub clock In the sub-stop mode, the oscillation of the sub clock stops and the oscillation stabilization wait time of the sub clock is required.The oscillation stabilization wait time of the sub clock is fixed at 2 /SCLK (SCLK: sub clock).
Page 167
CHAPTER 3 CPU Notes on Accessing the Low-Power Consumption Made Control Register (LPMCR) to Enter the Standby Mode To access the low-power consumption mode control register (LPMCR) with assembler language • To set the low power consumption mode control register (LPMCR) to enter the standby mode, use the instruction listed in Table 3.8-2.
Page 168
CHAPTER 3 CPU (3) Define the standby mode transition instruction between #pragma asm and #pragma endasm and insert two NOP and JMP instructions after that instruction. Example: Transition to stop mode #progrma asm MOVI;_IO_LPMCR,#H’58); /* Set LPMCR SLP bit to 1 */ JMP $+3"...
For details on the low power consumption modes, see 3.8 "Low-power Consumption Mode". Flash serial programming mode and flash memory mode Some products in MB90895 series have user-programmable flash memory. The flash serial programming mode is that for serially programming data to flash memory.
CHAPTER 3 CPU 3.9.1 Mode Pins (MD2 to MD0) The mode pins are three external pins of MD2 to MD0, and enable a combination of these pins to set, the following: • Operation modes (RUN mode, flash serial programming mode, flash memory mode) •...
Page 171
CHAPTER 3 CPU Figure 3.9-1 Flow of Mode Pin Setting Setting the pin mode Flash memory programing Flash programing Internal vector mode mode "1" "1" "1" "0" "1" "1" MD2 to MD0: Set to 0=V ss , 1=V cc . And also, do not set to other than above description.
CHAPTER 3 CPU 3.9.2 Mode Data Mode data is used to set the memory access mode.It is automatically read to the CPU by mode fetch. I Mode Data The values of the mode register can be changed only in the reset sequence.The changed mode register values are enabled after the reset sequence.
Page 173
CHAPTER 3 CPU I Setting Mode Data Set the mode data as shown in Figure 3.9-3. Figure 3.9-3 Flow of Mode Data Setting Setting of mode data Single chip mode Single chip mode Mode data 00 Do not set mode data other than above value.
CHAPTER 3 CPU 3.9.3 Memory Access Mode There are two modes in the memory access mode: bus mode and external access mode. • Bus mode: Sets access area (internal) I Bus Modes Figure 3.9-4 shows the memory map in the mode. Figure 3.9-4 Memory map in the mode When ROM mirror is enabled 000000...
CHAPTER 3 CPU 3.9.4 Operations for Selecting Memory Access Mode This section explains selection of the memory access mode in the reset sequence. I Operations for Selecting Memory Access Mode After reset is cancelled, the CPU selects the memory access mode according to the procedure shown in Figure 3.9-5 by referencing the settings of the mode pins and mode data.
CHAPTER 4 I/O PORT This chapter describes the function and operation of the I/O port. 4.1 Overview of I/O Ports 4.2 Registers of I/O Port and Assignment of Pins Serving as External 4.3 Port 1 4.4 Port2 4.5 Port 3 4.6 Port 4 4.7 Port 5 4.8 Port input level select register...
CHAPTER 4 I/O PORT Overview of I/O Ports I/O ports can be used as general-purpose I/O ports (parallel I/O ports). In MB90895 series, there are five ports (34 pins). Each port pin also serves as a peripheral I/O pins. I I/O Port Function The I/O ports enable the port data register (PDR) to output data to the I/O pins from the CPU and fetch signals input to the I/O pins.These also enable the port direction register (DDR) to set a direction for the I/ O pins by bit.
CHAPTER 4 I/O PORT Registers of I/O Port and Assignment of Pins Serving as External Bus The registers related to I/O port setting are listed as follows. I Registers of I/O Ports Table 4.2-1 shows the register list of each port. Table 4.2-1 Registers of Each Port Register Name Read/Write...
CHAPTER 4 I/O PORT Port 1 Port 1 is a general-purpose I/O port that also serves as a peripheral resource I/O pin. When the single-chip mode is set, use port 1 by switching between the resource pin and the general-purpose I/O port. The configuration, pin assignment, block diagram of the pins, and registers for port 1 are shown below.
Page 181
CHAPTER 4 I/O PORT I Block Diagram of Port-1 Pins (in Single Chip Mode) Figure 4.3-1 Block Diagram of Pins of Port 1 Resource output Resource input Port data register (PDR) Resource output acceptance PDR read Output latch PDR write Port direction register (DDR) Direction latch DDR write...
CHAPTER 4 I/O PORT 4.3.1 Registers for Port 1 (PDR1, DDR1) The registers for port 1 are explained. I Function of Registers for Port 1 (in Single Chip Mode) Port 1 data register (PDR1) • Port 1 data register indicates the state of the pins. Port 1 direction register (DDR1) •...
CHAPTER 4 I/O PORT 4.3.2 Operation of Port 1 The operation of port 1 is explained. I Operation of Port 1 (in Single Chip Mode) Operation of output port • When the bit in the port 1 direction register (DDR1) corresponding to the output pin is set to "1", port 0 functions as an output port.
Page 184
CHAPTER 4 I/O PORT Operation in stop mode, timebase timer mode or watch mode • When the pin state specification bit of the low power consumption mode control register (LPMCR: SPL) is "1", at a transition to the stop mode, timebase timer mode or watch mode, the pin enters the high- impedance state.
CHAPTER 4 I/O PORT Port2 Port 2 is a general-purpose I/O port that also serves as a peripheral resource I/O pin. Use port 2 by switching between the resource pin and the general-purpose I/O port. The configuration, pin assignment, block diagram of the pins, and registers for port 2 are shown below.
Page 186
CHAPTER 4 I/O PORT Table 4.4-1 shows pin assignment of port 2. Table 4.4-1 Pin Assignment of Port 2 I/O Type Circu Port Port Function Resource Name Name Outpu Input Type P20/ 16-bit reload TIN0 TIN0 timer 0 input 16-pit reload P21/ TOT0 timer 0...
Page 187
CHAPTER 4 I/O PORT I Block Diagram of Pins of Port 2 (General-purpose I/O Port) Figure 4.4-1 Block Diagram of Pins of Port 2 Resource output Resource input Port data register (PDR) Resource output acceptance PDR read Output latch PDR write Port direction register (DDR) Direction latch DDR write...
CHAPTER 4 I/O PORT 4.4.1 Registers for Port 2 (PDR2, DDR2) The registers for port 2 are explained. I Function of Registers for Port 2 Port 2 data register (PDR2) Port 2 data register indicates the input/output state of the pins. Port 2 direction register (DDR2) •...
CHAPTER 4 I/O PORT 4.4.2 Operation of Port 2 The operation of port 2 is explained. I Operation of Port 2 (General-purpose I/O Port) Operation of output port • When the bit in the port 2 direction register (DDR2) corresponding to the output pin is set to "1", port 2 functions as an output port.
Page 190
CHAPTER 4 I/O PORT Operation at reset • When the CPU is reset, the value of the DDR2 is initialized to "0".Consequently, all output buffers are set to "OFF" (the pin becomes an input port pin), and the pin enters the high-impedance state. •...
CHAPTER 4 I/O PORT Port 3 Port 3 is a general-purpose I/O port that serves as the resource I/O pin. Use port 3 by switching between the resource pin and the general-purpose I/O port. The configuration, pin assignment, block diagram of the pins, and registers for port 3 are shown below.
Page 192
CHAPTER 4 I/O PORT I Block Diagram of Pins of Port 3 (General-purpose I/O Port) Figure 4.5-1 Block Diagram of Pins of Port 3 Resource output Resource input Port data register (PDR) Resource output acceptance PDR read Output latch PDR write Port direction register (DDR) Direction latch DDR write...
CHAPTER 4 I/O PORT 4.5.1 Registers for Port 3 (PDR3, DDR3) The registers for port 3 are explained. I Function of Registers for Port 3 Port 3 data register (PDR3) • Port 3 data register indicates the state of the pins. Port 3 direction register (DDR3) •...
CHAPTER 4 I/O PORT 4.5.2 Operation of Port 3 The operation of port 3 is explained. I Operation of Port 3 (General-purpose I/O Port) Operation of output port • When the bit in the port 3 direction register (DDR3) corresponding to the output pin is set to "1", port 3 functions as an output port.
Page 195
CHAPTER 4 I/O PORT Table 4.5-4 shows the state of the port 3 pins. Table 4.5-4 The state of the port 3 pins Stop Mode, Timebase Timer Mode or Watch Mode Normal Pin Name Sleep mode Operation SPL=0 SPL=1 P30 to P33, General- General- General-purpose I/O...
CHAPTER 4 I/O PORT Port 4 Port 4 is a general-purpose I/O port that also serves as a peripheral resource I/O pin. Use port 4 by switching between the resource pin and the general-purpose I/O port. The configuration, pin assignment, block diagram of the pins, and registers for port 4 are shown below.
Page 197
CHAPTER 4 I/O PORT I Block Diagram of Pins of Port 4 Figure 4.6-1 Block Diagram of Pins of Port 4 Resource input Resource output Port data register (PDR) Resource output acceptance PDR read Output latch PDR write Port direction register (DDR) Direction latch DDR write Standby control (SPL=1)
CHAPTER 4 I/O PORT 4.6.1 Registers for Port 4 (PDR4, DDR4) The registers for port 4 are explained. I Function of Registers for Port 4 Port 4 data register (PDR4) • Port 4 data register indicates the state of the pins. Port 4 direction register (DDR4) •...
CHAPTER 4 I/O PORT 4.6.2 Operation of Port 4 The operation of port 4 is explained. I Operation of Port 4 Operation of output port • When the bit in the port 4 direction register (DDR4) corresponding to the output pin is set to "1", port 4 functions as an output port.
Page 200
CHAPTER 4 I/O PORT output. Operation in stop mode, timebase timer mode or watch mode If the pin state specify bit (SPL) of the low-power consumption mode control register (LPMCR) is set to "1" when the CPU operation mode switches to stop mode, timebase timer mode or watch mode, the pin enters the high-impedance state.In this case, the output buffer is forcibly set to off regardless of the values of the Port 4 direction register (DDR4).
CHAPTER 4 I/O PORT Port 5 Port 5 is a general-purpose I/O port that also serves as an analog input pin. Use port 5 by switching between the analog input pin and the general-purpose I/O port. The configuration, pin assignment, block diagram of the pins, and registers for port 5 are shown below.
Page 202
CHAPTER 4 I/O PORT Table 4.7-1 shows pins assignment of port 5. Table 4.7-1 Pins Assignment of Port 5 I/O Type Circu Port Name Port Function Resource Name Type Input Output Analog input P50/AN0 channel 0 Analog input P51/AN1 channel 1 Analog input P52/AN2 channel 2...
Page 203
CHAPTER 4 I/O PORT I Block Diagram of Pins of Port 5 Figure 4.7-1 Block Diagram of Pins of Port 5 Analog input ADER PDR (Port data register) PDR read Output latch PDR write DDR (Port direction register) Direction latch DDR write Standby control (SPL=1) DDR read...
CHAPTER 4 I/O PORT 4.7.1 Registers for Port 5 (PDR5, DDR5, ADER) The registers for port 5 are explained. I Function of Registers for Port 5 Port 5 data register (PDR5) • Port 5 data register indicates the state of the pins. Port 5 direction register (DDR5) •...
Page 205
CHAPTER 4 I/O PORT Table 4.7-3 Functions of the Registers for Port 5 Register Read/ Register Data At Read At Write Reset Value Name Write Address "0" is set for the output The pin state is latch, and when the pin is Low level.
CHAPTER 4 I/O PORT 4.7.2 Operation of Port 5 The operation of port 5 is explained. I Operation of Port 5 Operation of output port • When the bit in the port 5 direction register (DDR5) corresponding to the output pin is set to 1, port 5 functions as an output port.
Page 207
CHAPTER 4 I/O PORT Operation at reset • When the CPU is reset, the value of the DDR5 is initialized to "0".Consequently, all output buffers are set to "OFF" (the pin becomes an input port pin), and the pin enters the high-impedance state. •...
CHAPTER 4 I/O PORT Port input level select register The port input level select register is used to set the input signal to CMOS hysteresis input, Automotive input, or to CMOS input. I Port input level select register (PILR) PILR:00A2 ILS1 ILS0 Read/Write...
CHAPTER 5 Timebase timer This chapter describes the function and operation of the timebase timer. 5.1 Overview of Timebase Timer 5.2 Block Diagram of Timebase Timer 5.3 Configuration of Timebase Timer 5.4 Interrupt of Timebase Timer 5.5 Explanation of Operations of Timebase Timer Functions 5.6 Precautions when Using Timebase Timer 5.7 Program Example of Timebase Timer...
CHAPTER 5 Timebase timer Overview of Timebase Timer The timebase timer is an 18-bit free-run counter (timebase timer counter) that increments in synchronization with the main clock (half frequency of main oscillation clock). • Four interval times can be selected and an interrupt request can be generated for each interval time.
Page 211
CHAPTER 5 Timebase timer I Clock Supply • The timebase timer supplies an operation clock to the resources such as an oscillation stabilization wait time timer, PPG timer, and watchdog timer. Table 5.1-2 shows the clock cycles supplied from the timebase timer.
CHAPTER 5 Timebase timer Block Diagram of Timebase Timer The timebase timer consists of the following blocks: • Timebase timer counter • Counter clear circuit • Interval timer selector • Timebase timer control register (TBTC) I Block Diagram of Timebase Timer Figure 5.2-1 Block Diagram of Timebase Timer To watchdog To PPG timer...
Page 213
CHAPTER 5 Timebase timer Timebase timer counter The timebase timer counter is an 18-bit up counter that uses a clock with a half frequency of the oscillation clock (HCLK) as a count clock. Counter clear circuit The counter clear circuit clears the value of the timebase timer counter by the following factors: •...
CHAPTER 5 Timebase timer Configuration of Timebase Timer This section explains the registers and interrupt factors of the timebase timer. I List of Registers and Reset Values of Timebase Timer Figure 5.3-1 List of Registers and Reset Values of Timebase Timer Timebase timer control register ×...
CHAPTER 5 Timebase timer 5.3.1 Timebase timer control register (TBTC) The timebase timer control register (TBTC) provides the following settings: • Selecting the interval time of the timebase timer • Clearing the count value of the timebase timer • Enabling or disabling the interrupt request when an overflow occurs •...
Page 216
CHAPTER 5 Timebase timer Table 5.3-1 Functions of Timebase Timer Control Register (TBTC) bit name Function bit8 TBC1, TBC0: These bits set the cycle of the interval timer in the timebase bit9 Interval time select bits timer counter. • The interval time of the timebase timer is set according to the setting of the TBC1 and TBC0 bits.
CHAPTER 5 Timebase timer Interrupt of Timebase Timer The timebase timer generates an interrupt request (interval timer function) when the interval time bit in the timebase timer counter corresponding to the interval time set by the timebase timer control register carries (overflows). I Interrupt of Timebase Timer •...
CHAPTER 5 Timebase timer Explanation of Operations of Timebase Timer Functions The timebase timer operates as an interval timer or an oscillation stabilization wait time timer. It also supplies a clock to peripherals. I Interval Timer Function Interrupt generation at every interval time enables the timebase timer to be used as an interval timer. Operating the timebase timer as an interval timer requires the settings shown in Figure 5.5-1.
Page 219
CHAPTER 5 Timebase timer Example of operation of timebase timer Figure 5.5-2 gives an example of the operation that the timebase timer performs under the following conditions: • A power-on reset occurs. • The mode transits to the sleep mode during the operation of the interval timer. •...
Page 220
CHAPTER 5 Timebase timer I Operation as Oscillation Stabilization Wait Time Timer The timebase timer can be used as the oscillation stabilization wait timer for the main clock and PLL clock. • The oscillation stabilization wait time is the time elapsed from when the timebase timer counter increments from "0"...
Page 221
CHAPTER 5 Timebase timer Table 5.5-1 Clearing Conditions and Oscillation Stabilization Wait Time of Timebase Timer (2/2) Counter TBOF Oscillation Stabilization Wait Operation Clear Clear Time Cancellation of PLL stop mode Transition to PLL clock mode after oscillation stabilization wait time of main clock completed Cancellation of timer mode ×...
CHAPTER 5 Timebase timer Precautions when Using Timebase Timer Precautions when using the timebase timer are shown below. I Precautions when Using Timebase Timer Clearing interrupt request To clear the overflow interrupt request flag bit in the timebase timer control register (TBTC: TBOF = 0), disable interrupts (TBTC: TBIE = 0) or mask the timebase timer interrupt by using the interrupt level mask register in the processor status.
CHAPTER 5 Timebase timer Program Example of Timebase Timer Programming examples for the timebase timer are shown below. Program Example of Timebase Timer Processing specification The 2 /HCLK (HCLK: oscillation clock) interval interrupt is generated repeatedly.In this case, the interval time is approximately 1.0 ms (at 4-MHz operation).
CHAPTER 6 Watchdog timer This chapter describes the function and operation of the watchdog timer. 6.1 Overview of Watchdog Timer 6.2 Configuration of Watchdog Timer 6.3 Watchdog Timer Registers 6.4 Explanation of Operations of Watchdog Timer Functions 6.5 Precautions when Using Watchdog Timer 6.6 Program Examples of Watchdog Timer...
CHAPTER 6 Watchdog timer Overview of Watchdog Timer The watchdog timer is a 2-bit counter that uses the timebase timer or watch timer as a count clock.If the counter is not cleared within a set interval time, the CPU is reset. I Functions of Watchdog Timer •...
CHAPTER 6 Watchdog timer Configuration of Watchdog Timer The watchdog timer consists of the following blocks: • Count clock selector • Watchdog timer counter (2-bit counter) • Watchdog reset generator • Counter clear control circuit • Watchdog timer control register (WDTC) I Block Diagram of Watchdog Timer Figure 6.2-1 Block Diagram of Watchdog Timer Watchdog timer control register (WDTC)
Page 228
CHAPTER 6 Watchdog timer Count clock selector The count clock selector selects the timebase timer output or watch timer output as a count clock input to the watchdog timer.Each timer output has four time intervals that can be set. Watchdog timer counter (2-bit counter) The watchdog timer counter is a 2-bit counter that uses the timebase timer output or watch timer output as a count clock.The clock source output destination is set by the watchdog clock select bit in the watch timer control register (WTC: WDCS).
CHAPTER 6 Watchdog timer Watchdog Timer Registers This section explains the registers used for setting the watchdog timer. I List of Registers and Reset Values of Watchdog Timer Figure 6.3-1 List of Registers and Reset Values of Watchdog Timer Watchdog timer control register (WDTC) Undefined...
CHAPTER 6 Watchdog timer 6.3.1 Watchdog timer control register (WDTC) The watchdog timer control register starts and clears the watchdog timer, sets the interval time, and holds reset factors. I Watchdog timer control register (WDTC) Figure 6.3-2 Watchdog timer control register (WDTC) Reset value XXXXX111 bit1...
Page 231
CHAPTER 6 Watchdog timer Table 6.3-1 Functions of the Watching Timer Control Register (WDTC) bit name Function bit0 WT1, WT0: These bits set the interval time of the watchdog timer. bit1 Interval time select bits 'The time interval when the watch timer is used as the clock source to the watchdog timer (watchdog clock select bit WDCS = 0) is different from when the main clock mode or the PLL clock mode is selected as the clock mode and the WDCS bit in...
CHAPTER 6 Watchdog timer Explanation of Operations of Watchdog Timer Functions After starting, when the watchdog timer reaches the set interval time without the counter being cleared, a watchdog reset occurs. I Operations of Watchdog Timer The operation of the watchdog timer requires the settings shown in Figure 6.4-1. Figure 6.4-1 Setting of Watchdog Time bit7 bit0...
Page 233
CHAPTER 6 Watchdog timer Clearing watchdog timer • When "0" is written once again to the watchdog timer control bit (WDTC: WTE) within the interval time after starting the watchdog timer, the watchdog timer is cleared. If the watchdog timer is not cleared within the interval time, it overflows and the CPU is reset.
Page 234
CHAPTER 6 Watchdog timer Checking reset factors • The reset factor bits in the watchdog timer control register (WDTC: PONR, WRST, ERST, SRST) can be read after a reset to check the reset factors. Note: For details on the reset source bit, see Section 3.6 Reset. Figure 6.4-2 Relationship between Clear Timing and Interval Time of Watchdog Timer [Watchdog timer block diagram] 2-bit counter...
CHAPTER 6 Watchdog timer Precautions when Using Watchdog Timer Take the following precautions when using the watchdog timer. I Precautions when Using Watchdog Timer Stopping watchdog timer • The watchdog timer is stopped by all the reset sources. Interval time •...
CHAPTER 6 Watchdog timer Program Examples of Watchdog Timer Program example of watchdog timer is given below: I Program Examples of Watchdog Timer Processing specification • The watchdog timer is cleared each time in the loop of the main program. •...
CHAPTER 7 16-bit I/O timer This chapter explains the function and operation of the 16- bit input/output timer. 7.1 Overview of 16-bit Input/Output Timer 7.2 Block Diagram of 16-bit Input/Output Timer 7.3 Configuration of 16-bit Input/Output Timer 7.4 Interrupts of 16-bit Input/Output Timer 7.5 Explanation of Operation of 16-bit Free-run Timer 7.6 Explanation of Operation of Input Capture 7.7 Precautions when Using 16-bit Input/Output Timer...
CHAPTER 7 16-bit I/O timer Overview of 16-bit Input/Output Timer The 16-bit input/output timer is a combined module that consists of a 16-bit free-run timer (x 1 unit) and an input capture (x 2 units/4 input pins).The clock cycle of an input signal and a pulse width can be measured based on the 16-bit input/output timer.
CHAPTER 7 16-bit I/O timer Block Diagram of 16-bit Input/Output Timer The 16-bit input/output timer consists of the following modules: • 16-bit free-run timer • Input capture I Block Diagram of 16-bit Input/Output Timer Figure 7.2-1 Block Diagram of 16-bit Input/Output Timer Internal data bus 16-bit Input...
CHAPTER 7 16-bit I/O timer 7.2.1 Block Diagram of 16-bit Free-run Timer The 16-bit free-run timer consists of the following blocks: • Prescaler • Timer counter data register (TCDT) • Timer counter control status register (TCCS) I Block Diagram of 16-bit Free-run Timer Figure 7.2-2 Block Diagram of 16-bit Free-run Timer Output count value Timer counter data register...
Page 241
CHAPTER 7 16-bit I/O timer Timer counter control status register (TCCS) The timer counter control status register (TCCS) selects the division ratio of the machine clock, clears the count value by software, enables or disables the count operation, checks and clears the overflow generation flag, and enables or disables interrupt.
CHAPTER 7 16-bit I/O timer 7.2.2 Block Diagram of Input Capture The input capture consist of the following blocks: • Input capture data registers (IPCP0 to IPCP3) • Input capture control status registers (ICS01, ICS23) • Edge detection circuit I Block Diagram of Input Capture Figure 7.2-3 Block Diagram of Input Capture 16-bit free-run timer Edge detection circuit...
Page 243
CHAPTER 7 16-bit I/O timer I Details of Pins in Block Diagram The 16-bit input/output timer has four input capture input pins. The actual pin names and interrupt request numbers used in the input capture unit are shown in Table 7.2-1. Table 7.2-1 Pins and Interrupt Request Numbers of 16-bit Input/Output Timer Input Pin Actual Pin Name...
CHAPTER 7 16-bit I/O timer Configuration of 16-bit Input/Output Timer This section explains the pins, registers, and interrupt factors of the 16-bit input/output timer. I Pins of 16-bit Input/Output Timer The pins of the 16-bit input/output timer serve as general-purpose I/O ports. Table 7.3-1 shows the pin functions and the pin settings required to use the 16-bit input/output timer.
Page 245
CHAPTER 7 16-bit I/O timer I List of Registers and Reset Values of 16-bit Input/Output Timer Figure 7.3-1 List of Registers and Reset Values of 16-bit Input/Output Timer Timer counter control status register (TCCS) Timer counter data register upper (TCDT: H) Timer counter data register lower (TCDT: L) Input capture control status...
Page 246
CHAPTER 7 16-bit I/O timer I Generation of Interrupt Request from 16-bit Input/Output Timer The 16-bit input/output timer can generate an interrupt request as a result of the following factors: Overflow in 16-bit free-run timer In the 16-bit input/output timer, when the 16-bit free-run timer overflows, the overflow generation flag bit in the timer counter control status register (TCCS: IVF) is set to "1".When an overflow interrupt is enabled (TCCS: IVFE = 1), an interrupt request is generated.
CHAPTER 7 16-bit I/O timer 7.3.1 Timer counter control status register (TCCS) The timer counter control status register (TCCS) selects the count clock and conditions for clearing the counter, clears the counter, enables or disables the count operation or interrupt, and checks the interrupt request flag. I Timer counter control status register (TCCS) Figure 7.3-2 Timer counter control status register (TCCS) Reset value...
Page 248
CHAPTER 7 16-bit I/O timer Table 7.3-2 Functions of Timer Counter Control Status Register (TCCS) bit name Function] bit0 CLK2, CLK1, CLK0: These bits set the count clock to the 16-bit free-run time. bit1 Count clock selection Note: bit2 bits 1)Set the count clock after stopping the count operation (STOP = 1).
CHAPTER 7 16-bit I/O timer 7.3.2 Timer counter data register (TCDT) The timer counter data register (TCDT) is a 16-bit up counter.At read the register value being counted is read.At write while the counter is stopped, any count value can be set. I Timer counter data register (TCDT) Figure 7.3-3 Timer counter data register (TCDT) bit15 bit14 bit13 bit12 bit11 bit10 bit9...
Page 250
CHAPTER 7 16-bit I/O timer Factors clearing timer counter data register (TCDT) The timer counter data register (TCDT) is cleared to 0000 H by the following factors: Of the following events, the overflow clears the register in synchronization with the count clock and each of the other events clears the register on occurrence of that event.
CHAPTER 7 16-bit I/O timer 7.3.3 Input capture control status registers (ICS01, ICS23) The input capture control status registers sets the operation of input captures.The ICS01 register sets the operation of input captures 0 and 1 and the ICS23 sets the operation of input captures 2 and 3.The input capture control status registers provides the following settings: •...
Page 252
CHAPTER 7 16-bit I/O timer Table 7.3-3 Functions of Input Capture Control Status Register (ICS01) bit name Function bit0 EG01, EG00: These bits enable or disable the operation of input capture 0.The bit1 Input capture 0 edge edge detected by input capture 0 is selected when the operation select bits of input capture 0 is enabled.
CHAPTER 7 16-bit I/O timer 7.3.4 Input capture data registers (IPCP0 to IPCP3) The input capture data registers 0 to 3 (IPCP0 to IPCP3) store the counter value of the 16-bit free-run timer read in the timing with the edge detection by the input capture.The counter value of the 16-bit free-run timer is stored in the input capture data registers (IPCP0 to IPCP3) corresponding to the input pins (IN0 to IN3) to which an external signal is input.
CHAPTER 7 16-bit I/O timer Interrupts of 16-bit Input/Output Timer The interrupt factors of the 16-bit input/output timer include an overflow in the 16-bit free-run timer and edge detection by the input capture.Interrupt generation starts EI I Interrupt Control Bits and Interrupt Factors of 16-bit Input/Output Timer Table 7.4-1 shows interrupt control bits and interrupt factors of 16-bit input/output timer.
CHAPTER 7 16-bit I/O timer Explanation of Operation of 16-bit Free-run Timer After a reset, the 16-bit free-run timer starts incrementing from "0000 ".When the counter value is incremented from "FFFF " to "0000 ", an overflow occurs. I Setting of 16-bit Free-run Timer Operation of the 16-bit free-run timer requires the setting shown in Figure 7.5-1 Figure 7.5-1 Setting of 16-bit Free-run Timer bit15 14...
Page 256
CHAPTER 7 16-bit I/O timer I Operation Timing of 16-bit Free-run Timer Figure 7.5-2 shows counter clearing at an overflow. Figure 7.5-2 Counter Clearing at an Overflow Counter value Over flow F F F F BFFF 7 F F F 3 F F F 0 0 0 0 Time...
CHAPTER 7 16-bit I/O timer Explanation of Operation of Input Capture When the input capture detects the edge of the external signal input to the input pins, it stores the count value of the 16-bit free-run timer in the input capture data registers. I Setting of Input Capture Operation of the input capture requires the setting shown in Figure 7.6-1 Figure 7.6-1 Setting of Input Capture...
Page 258
CHAPTER 7 16-bit I/O timer I Operation of Input Capture • When the valid edges of the external signals input to the input pins (IN0 to IN3) are detected, the input capture valid edge detection flag bit (ICS: ICP) corresponding to the input pin is set to 1.At the same time, the count value of the 16-bit free-run timer is stored in the input capture data registers (IPCP) corresponding to the input pins (IN0 to IN3).
Page 259
CHAPTER 7 16-bit I/O timer I Operation Timing of Input Capture Figure 7.6-2 shows the timing of reading the counter value of the 16-bit free-run timer. Figure 7.6-2 Timing of Reading Counter Value of Input Capture φ Counter value Input capture input Available edge Capture signal...
CHAPTER 7 16-bit I/O timer Precautions when Using 16-bit Input/Output Timer This section explains the precautions when using the 16-bit input/output timer. I Precautions when Using 16-bit Input/Output Timer Precautions when setting 16-bit free-run timer • Do not change the count clock select bits (TCCS: CLK2, CLK1, CLK0) during the count operation (TCCS: STOP = 0).
CHAPTER 7 16-bit I/O timer Program Example of 16-bit Input/Output Timer This section gives a program example of the 16-bit input/output timer. I Processing of Program for Measuring Cycle Using Input Capture • The cycle of a signal input to the IN0 pin is measured. •...
CHAPTER 8 16-bit reload timer This chapter explains the functions and the operations of 16-bit reload timer. 8.1 Overview of 16-bit Reload Timer 8.2 Block Diagram of 16-bit Reload Timer 8.3 Configuration of 16-bit Reload Timer 8.4 Interrupts of 16-bit Reload Timer 8.5 Explanation of Operation of 16-bit Reload Timer 8.6 Precautions when Using 16-bit Reload Timer 8.7 Program Example of 16-bit Reload Timer...
(TMRLR) to the TMR to continue the TMR count operation can be selected. • The hardware interrupt corresponds to the EI • MB90895 series has two channels of 16-bit reload timers. I Operation Modes of 16-bit Reload Timer Table 8.1-1 indicates the operation modes of the 16-bit reload timer.
Page 265
CHAPTER 8 16-bit reload timer I Event count mode • When the count clock select bits in the timer control status register (TMCSR: CSL1, CSL0) are set to "11 ", the 16-bit reload timer is set to the event count mode. •...
Page 266
CHAPTER 8 16-bit reload timer I Operation at Underflow When the start trigger is input, the value set in the 16-bit reload register (TMRLR) is reloaded to the 16-bit timer register, starting decrementing in synchronization with the count clock.When the 16-bit timer register (TMR) is decremented from "0000 "...
CHAPTER 8 16-bit reload timer Block Diagram of 16-bit Reload Timer The 16-bit reload timers 0 and 1 composed of the following seven blocks: • Count clock generator • Reload controller • Output controller • Operation controller • 16-bit timer register (TMR) •...
Page 268
CHAPTER 8 16-bit reload timer Details of Pins in Block Diagram There are two channels for 16-bit reload timer. The actual pin names, outputs to resources, and interrupt request numbers for each channel are as follows: 16-bit reload timer 0: TIN pin: P20/TIN0 TOT pin: P21/TOT0 Interrupt request number: #17 (11...
Page 269
CHAPTER 8 16-bit reload timer Timer control status register (TMCSR) The timer control status register (TMCSR) selects the operation mode, sets the operation conditions, selects the start trigger, performs a start using the software trigger, selects the reload operation mode, enables or disables an interrupt request, sets TOT pin output level, and sets TOT output pin.
CHAPTER 8 16-bit reload timer Configuration of 16-bit Reload Timer This section explains the pins, registers, and interrupt factors of the 16-bit reload timer. I Pins of 16-bit Reload Timer The pins of the 16-bit reload timer serve as general-purpose I/O ports.Table 8.3-1 shows the pin functions and the pin settings required to use the 16-bit reload timer.
Page 271
CHAPTER 8 16-bit reload timer I List of Registers and Reset Values of 16-bit Reload Timer Registers of 16-bit reload timer 0 Figure 8.3-1 List of Registers and Reset Values of 16-bit Reload Timer 0 Timer control status register upper (TMCSR0) Timer control status register lower (TMCSR0) 16-bit timer register upper...
Page 272
CHAPTER 8 16-bit reload timer I Generation of Interrupt Request from 16-bit Reload Timer When the 16-bit reload timer is started and the count value of the 16-bit timer register is decremented from "0000 " to "FFFF ", an underflow occurs.When an underflow occurs, the UF bit in the timer control status register is set to "1"...
CHAPTER 8 16-bit reload timer 8.3.1 Timer Control Status Registers (High) (TMCSR0: H, TMCSR1: H) The timer control status registers (High) (TMCSR0: H, TMCSR1: H) set the operation mode and count clock. This section also explains the bit 7 in the timer control status registers (Low) (TMCSR0: L, TMCSR1: L).
Page 274
CHAPTER 8 16-bit reload timer Table 8.3-2 Functions of Timer Control Status Registers (High) (TMCSR0: H, TMCSR1: H) bit name Function bit7 MOD2, MOD1, MOD0: These bits set the operation conditions of the 16-bit reload timer. Operation mode select (Internal clock mode) bit9 bits The MOD2 bit is used to select the function of the input pin.
CHAPTER 8 16-bit reload timer 8.3.2 Timer Control Status Registers (Low) (TMCSR0: L, TMCSR1: L) The timer control status registers (Low) (TMCSR0: L, TMCSR1: L) enables or disables the timer operation, checks the generation of a software trigger or an underflow, enables or disables an underflow interrupt, selects the reload mode, and sets the output of the TOT pin.
Page 276
CHAPTER 8 16-bit reload timer Table 8.3-3 Timer Control Status Registers (Low) (TMCSR0: L, TMCSR1: L) bit name Function bit0 TRG: This bit starts the 16-bit reload timer by software. Software trigger bit The software trigger function works only when the timer operation is enabled (CNTE = 1).
CHAPTER 8 16-bit reload timer 8.3.3 16-bit Timer Registers (TMR0, TMR1) The 16-bit timer registers (TMR0, TMR1) are 16-bit down counters.At read, the value being counted is read. I 16-bit Timer Registers (TMR0, TMR1) Figure 8.3-5 16-bit Timer Registers (TMR0, TMR1) Reset value TMR0 XXXXXXXX...
CHAPTER 8 16-bit reload timer 8.3.4 16-bit Reload Registers (TMRLR0, TMRLR1) The 16-bit reload registers (TMRLR0, TMRLR1) set the value to be reloaded to the 16-bit timer register (TMR).When the start trigger is input, the value set in the 16-bit reload registers (TMRLR0, TMRLR1) is reloaded to the TMR, starting the TMR count operation.
CHAPTER 8 16-bit reload timer Interrupts of 16-bit Reload Timer The 16-bit reload timer generates an interrupt request when the 16-bit timer register (TMR) underflows. I Interrupts of 16-bit Reload Timer When the value of the TMR is decremented from "0000 "...
CHAPTER 8 16-bit reload timer Explanation of Operation of 16-bit Reload Timer This section explains the setting of the 16-bit reload timer and the operation state of the counter. I Setting of 16-bit Reload Timer Setting of internal clock mode Counting the internal clock requires the setting shown in Figure 8.5-1.
Page 281
CHAPTER 8 16-bit reload timer I Operating State of 16-bit Timer Register The operating state of the 16-bit timer register is determined by the timer operation enable bit in the timer control status register (TMCSR: CNTE) and the WAIT signal.The operating states include the stop state, start trigger input wait state (WAIT state), and RUN state.
CHAPTER 8 16-bit reload timer 8.5.1 Operation in Internal Clock Mode In the internal clock mode, three operation modes can be selected by setting the operation mode select bits in the timer control status register (TMCSR: MOD2 to MOD0).When the operation mode and reload mode are set, a rectangular wave or a toggle wave is output from the TOT pin.
Page 283
CHAPTER 8 16-bit reload timer I Operation as 16-bit Timer Register Underflows When the value of the 16-bit timer register (TMR) is decremented from "0000 " to "FFFF " during the TMR count operation, an underflow occurs. • When an underflow occurs, the underflow generation flag bit in the timer control status register (TMCSR: UF) is set to 1.
Page 284
CHAPTER 8 16-bit reload timer Figure 8.5-4 Count Operation in Software Trigger Mode (One-shot Mode) Count clock Reload Reload 0000 FFFF 0000 FFFF Counter data data Data load signal UF bit CNTE bit TRG bit TOT pin Activating trigger input waite T : Machine cycle : It takes 1T time from trigger input to loading data of reload register.
Page 285
CHAPTER 8 16-bit reload timer [External trigger mode (MOD2 to MOD0 = "001 ", "010 ", "011 ")] When the external trigger mode is set, the 16-bit reload timer is started by inputting the external valid edge to the TIN pin.When the 16-bit reload timer is started, the value set in the TMRLR is reloaded to the TMR, starting the TMR count operation.
Page 286
CHAPTER 8 16-bit reload timer [External gate input mode (MOD2 to MOD0 = "1x0 ", "1x1 ")] When the external gate input mode is set, start the 16-bit reload timer by setting the software trigger bit in the timer control status register (TMCSR: TRG) to "1".When the 16-bit reload timer is started, the value set in the 16-bit reload register (TMRLR) is reloaded to the 16-bit timer register (TMR).
CHAPTER 8 16-bit reload timer 8.5.2 Operation in Event Count Mode In the event count mode, after the 16-bit reload timer is started, the edge of the signal input to the TIN pin is detected to perform the count operation of the 16-bit timer register (TMR).When the operation mode and reload mode are set, a rectangular wave or a toggle wave is output from the TOT pin.
Page 288
CHAPTER 8 16-bit reload timer I Operation as 16-bit Timer Register Underflows When the value of the 16-bit timer register (TMR) is decremented from "0000 " to "FFFF " during the TMR count operation, an underflow occurs. • When an underflow occurs, the underflow generation flag bit in the timer control status register (TMCSR: UF) is set to "1".
Page 289
CHAPTER 8 16-bit reload timer I Operation in Event Count Mode The operation of the 16-bit reload timer is enabled by setting the timer operation enable bit in the timer control status register (TMCSR: CNTE) to "1".When the software trigger bit in the timer control status register (TMCSR: TRG) is set to 1, the 16-bit reload timer is started.When the 16-bit reload timer is started, the value set in the 16-bit reload register (TMRLR) is reloaded to the 16-bit timer register (TMR), starting the TMR count operation.After the 16-bit reload timer is started, the edge of the external event clock input...
CHAPTER 8 16-bit reload timer Precautions when Using 16-bit Reload Timer This section explains the precautions when using the 16-bit reload timer. I Precautions when Using 16-bit Reload Timer Precautions when using programs to set timebase timer • Set the 16-bit reload register (TMRLR) after disabling the timer operation (TMCSR: CNTE = 0) •...
CHAPTER 8 16-bit reload timer Program Example of 16-bit Reload Timer This section gives a program example of the 16-bit reload timer operated in the internal clock mode and the event count mode are given below: I Program Example in Internal Clock Mode Processing specification •...
Page 292
CHAPTER 8 16-bit reload timer ;---------Interrupt program--------------------------------- WARI: I:UF0 ;Clear interrupt request flag User processing RETI ;Recovery from interrupt CODE ENDS ;---------Vector setting------------------------------------ VECT CSEG ABS=0FFH 00FFB8H ;Setting vector to interrupt #17 WARI 00FFDCH ;Reset vector setting START ;Setting to single chip mode VECT ENDS START...
Page 293
CHAPTER 8 16-bit reload timer I:DDR2,00H ;Setting P20/TIN0 pin to input CLRB I:CNTE0 ;Temporary stop of counter MOVW I:TMRLR0,#2710H;Reload value set to 10000 times MOVW I:TMCSR0,#0000110000001011B ;Counter operating, external trig ;edge, external output disabled ;One-shot mode selection, interru ;Clear interrupt flag, count star ILM,#07H ;Setting ILM in PS to level 7 CCR,#40H...
CHAPTER 9 Watch timer This section describes the functions and operations of the watch timer. 9.1 Overview of Watch Timer 9.2 Block Diagram of Watch Timer 9.3 Configuration of Watch Timer 9.4 Watch Timer Interrupt 9.5 Explanation of Operation of Watch Timer 9.6 Program Example of Watch Timer...
CHAPTER 9 Watch timer Overview of Watch Timer The watch timer is a 15-bit free-run counter that increments in synchronization with the sub clock. • Seven interval times can be selected and an interrupt request can be generated for each interval time. •...
Page 297
CHAPTER 9 Watch timer I Cycle of Clock Supply The watch timer supplies an operation clock to the oscillation stabilization wait time timer of the sub clock and the watchdog timer.Table 9.1-2 shows the cycles of clocks supplied from the watch timer. Table 9.1-2 Cycle of Clock Supply from Watch Timer Receiver of clock supply Clock Cycle...
CHAPTER 9 Watch timer Block Diagram of Watch Timer The watch timer consists of the following blocks: • Watch timer counter • Counter clear circuit • Interval timer selector • Watch timer control register (WTC) I Block Diagram of Watch Timer Figure 9.2-1 Block Diagram of Watch Timer To watchdog timer Watch timer counter...
Page 299
CHAPTER 9 Watch timer Interval timer selector The interval timer selector sets the overflow flag bit when the watch timer counter reaches the interval time set in the watch timer control register (WTC). Watch timer control register (WTC) The watch timer control register (WTC) selects the interval time, clears the watch timer counter, enables or disables an interrupt, checks the overflow state, and clears the overflow flag bit.
CHAPTER 9 Watch timer Configuration of Watch Timer This section explains the registers and interrupt factors of the watch timer. I List of Registers and Reset Values of Watch Timer Figure 9.3-1 List of Registers and Reset Values of Watch Timer Watch timer control register (WTC) : Undefined I Generation of Interrupt Request from Watch Timer...
CHAPTER 9 Watch timer 9.3.1 Watch timer control register (WTC) This section explains the functions of the watch timer control register (WTC). I Watch timer control register (WTC) Figure 9.3-2 Watch timer control register (WTC) Reset value 1X001000 bit2 bit1 bit0 WTC2 WTC1...
Page 302
CHAPTER 9 Watch timer Table 9.3-1 Functions of Watch Timer Control Register (WTC) bit name Function bit2 WTC2, WTC1, WTC0: These bits set the interval time of the watch timer. Interval time select bits • When the interval time set by the WTC2 to WTC0 bits is bit0 reached, the corresponding bit of the watch timer counter overflows (carries) and the overflow flag bit is set (WTC:...
CHAPTER 9 Watch timer Watch Timer Interrupt When the interval time is reached with the watch timer interrupt enabled, the overflow flag bit is set to 1 and an interrupt request is generated. I Watch Timer Interrupt Table 9.4-1 shows the interrupt control bits and interrupt factors of the watch timer. Table 9.4-1 Interrupt Control Bits of Watch Timer Watch timer Interrupt Factor...
CHAPTER 9 Watch timer Explanation of Operation of Watch Timer The watch timer operates as an interval timer or an oscillation stabilization wait time timer of the sub clock.It also supplies an operation clock to the watchdog timer. I Watch timer counter The watch timer counter continues incrementing in synchronization with the sub clock (SCLK) while the sub clock (SCLK) is operating.
Page 305
CHAPTER 9 Watch timer • The overflow flag bit (WTC: WTOF) is set when the interval time is reached at the starting point of the timing at which the watch timer is finally cleared. Clearing overflow flag bit (WTC: WTOF) When the mode is switched to the stop mode, the watch timer is used as an oscillation stabilization wait time timer of sub clock.
CHAPTER 9 Watch timer Program Example of Watch Timer This section gives a program example of the watch timer. I Program Example of Watch Timer Processing specification An interval interrupt at 2 /SCLK (SCLK: sub clock) is generated repeatedly.The internal time is approximately 1.0s (when sub clock operates at 8.192 kHz).
CHAPTER 10 8/16-bit PPG timer This section describes the functions and operations of the 8-/16-bit PPG timer. 10.1 Overview of 8-/16-bit PPG Timer 10.2 Block Diagram of 8-/16-bit PPG Timer 10.3 Configuration of 8-/16-bit PPG Timer 10.4 Interrupts of 8-/16-bit PPG Timer 10.5 Explanation of Operation of 8-/16-bit PPG Timer 10.6 Precautions when Using 8-/16-bit PPG Timer...
• 8-bit PPG output 2-channel independent operation mode • 16-bit PPG output mode • 8 + 8-bit PPG output mode The MB90895 series has two 8-/16-bit PPG timers.This section explains the functions of PPG0/1. PPG2/3 has the same functions as PPG0/1. I Functions of 8-/16-bit PPG Timer The 8-/16-bit PPG timer consists of four eight-bit reload registers (PRLH0/PRLL0, PRLH1/PRLL1) and two PPG down counters (PCNT0, PCNT1).
Page 309
CHAPTER 10 8/16-bit PPG timer I Operation Modes of 8-/16-bit PPG Timer 8-bit PPG output 2-channel independent operation mode The 8-bit PPG output 2-channel independent operation mode causes the 2-channel modules (PPG0 and PPG1) to each operate as independent 8-bit PPG timers. Table 10.1-1 shows the interval times in the 8-bit PPG output 2-channel independent operation mode.
Page 310
CHAPTER 10 8/16-bit PPG timer 8 + 8-bit PPG output mode The 8 + 8-bit PPG output mode causes the PPG0 of the 2-channel modules (PPG0 and PPG1) to operate as an 8-bit prescaler and the underflow output of the PPG0 to operate as the count clock of the PPG1. Table 10.1-3 Interval Times in 8+8-bit PPG Output Operation Mode shows the interval times in this mode.
10.2 Block Diagram of 8-/16-bit PPG Timer The MB90895 series contains two 8-/16-bit PPG timers (each with two channels). One 8-/16-bit PPG timer consists of two channels of 8-bit PPG timers. This section shows the block diagrams for the 8-/16-bit PPG timer 0 and 8-/16-bit PPG timer 1.The PPG2 has the same function as the PPG0, and PPG3 has the same function...
CHAPTER 10 8/16-bit PPG timer 10.2.1 Block Diagram for 8-/16-bit PPG Timer 0 The 8-/16-bit PPG timer 0 consists of the following blocks. I Block Diagram for 8-/16-bit PPG Timer 0 Figure 10.2-2 Block Diagram for 8-/16-bit PPG Timer 0 "H"...
Page 313
CHAPTER 10 8/16-bit PPG timer Details of Pins in Block Diagram Table 10.2-1 lists the actual pin names and interrupt request numbers of the 8-/16-bit PPG timer. Table 10.2-1 Pins and Interrupt Request Numbers in Block Diagram Channel Output Pin Interrupt Request Number PPG0 P14/PPG0...
CHAPTER 10 8/16-bit PPG timer 10.2.2 Block Diagram of 8-/16-bit PPG Timer 1 The 8-/16-bit PPG timer 1 consists of the following blocks. I Block Diagram of 8-/16-bit PPG Timer 1 Figure 10.2-3 Block Diagram of 8-/16-bit PPG Timer 1 "H"...
Page 315
CHAPTER 10 8/16-bit PPG timer Details of pins in block diagram Table 10.2-2 lists the actual pin names and interrupt request numbers of the 8-/16-bit PPG timer. Table 10.2-2 Pins and Interrupt Request Numbers in Block Diagram Channel Output Pin Interrupt Request Number PPG0 P14/PPG0...
Page 316
CHAPTER 10 8/16-bit PPG timer PPG output control circuit This circuit inverts the pin output level and the output when an underflow occurs.
CHAPTER 10 8/16-bit PPG timer 10.3 Configuration of 8-/16-bit PPG Timer This section explains the pins, registers and interrupt factors of the 8-/16-bit PPG timer. I Pins of 8-/16-bit PPG Timer The pins of the 8-/16-bit PPG timer serve as general-purpose I/O ports. Table 10.3-1 indicates the pin functions and pin settings required to use the 8-/16-bit PPG timer.
Page 318
CHAPTER 10 8/16-bit PPG timer I List of Registers and Reset Values of 8-/16-bit PPG Timer Figure 10.3-1 List of Registers and Reset Values of 8-/16-bit PPG Timer PPG0 operating mode control register : H (PPGC1) PPG0 operating mode control register : L (PPGC0) PPG0/1 count clock select register (PPG01)
CHAPTER 10 8/16-bit PPG timer 10.3.1 PPG0 Operation Mode Control Register (PPGC0) The PPG0 operation mode control register (PPGC0) provides the following settings: • Enabling or disabling operation of 8-/16-bit PPG timer • Pin function switching (Enabling or disabling pulse output) •...
Page 320
CHAPTER 10 8/16-bit PPG timer Table 10.3-2 Functions of PPG0 Operation Mode Control Register (PPGC0) bit name Function bit0 Reserved: reserved bit Always set this bit to "1". bit1 Unused bits Read: The value is undefined. bit2 Write: No effect bit3 PUF0: 8-bit PPG output 2-channel independent operation mode,...
CHAPTER 10 8/16-bit PPG timer 10.3.2 PPG1 Operation Mode Control Register (PPGC1) The PPG1 operation mode control register (PPGC1) provides the following settings: • Enabling or disabling operation of 8-/16-bit PPG timer • Pin function switching (Enabling or disabling pulse output) •...
Page 322
CHAPTER 10 8/16-bit PPG timer Table 10.3-3 Functions of PPG1 Operation Mode Control Register (PPGC1) bit name Function bit8 Reserved: reserved bit Always set this bit to "1". bit9 MD1, MD0: These bits set the operation mode of the 8-/16-bit PPG timer. bit10 Operation mode select (Any mode other than 8-bit PPG output 2-channel...
CHAPTER 10 8/16-bit PPG timer 10.3.3 PPG0/1 count clock select register (PPG01) The PPG0/1 count clock select register (PPG01) selects the count clock of the 8-/16-bit PPG timer. I PPG0/1 count clock select register (PPG01) Figure 10.3-4 PPG0/1 count clock select register (PPG01) Reset value 0 0 0 0 0 0 X X bit4...
Page 324
CHAPTER 10 8/16-bit PPG timer Table 10.3-4 Functions of PPG0/1 Count Clock Select Register (PPG01) bit name Function bit0 Undefined Read: The value is undefined. bit1 Write: No effect bit2 PCM2 to PCM0: These bits set the count clock of the 8-/16-bit PPG timer 0. PPG0 count clock select •...
CHAPTER 10 8/16-bit PPG timer 10.3.4 PPG Reload Registers (PRLL0/PRLH0, PRLL1/PRLH1) The value (reload value) from which the PPG down counter starts counting is set in the PPG reload registers.They are an 8-bit register at both Low level and at High level. I PPG Reload Registers (PRLL0/PRLH0, PRLL1/PRLH1) Figure 10.3-5 PPG Reload Registers (PRLL0/PRLH0, PRLL1/PRLH1) bit15 bit14 bit13 bit12 bit11 bit10 bit9...
CHAPTER 10 8/16-bit PPG timer 10.4 Interrupts of 8-/16-bit PPG Timer The 8-/16-bit PPG timer can generate an interrupt request when the PPG down counter underflows.It corresponds to the EI I Interrupts of 8-/16-bit PPG Timer Table 10.4-1 shows the interrupt control bits and interrupt factor of the 8-/16-bit PPG timer. Table 10.4-1 The interrupt control bits of the 8-/16-bit PPG timer PPG0 PPG1...
Page 327
CHAPTER 10 8/16-bit PPG timer I 8-/16-bit PPG Timer Interrupt and EI For details of the interrupt number, interrupt control register, and interrupt vector address, see 3.5 Interrupt. I 8-/16-bit PPG Timer Interrupt and EI OS Function The 8-/16-bit PPG timer corresponds to the EI OS function.
CHAPTER 10 8/16-bit PPG timer 10.5 Explanation of Operation of 8-/16-bit PPG Timer The 8-/16-bit PPG timer outputs a pulse width at any cycle and at any duty ratio continuously. I Operation of 8-/16-bit PPG Timer Output operation of 8-/16-bit PPG timer •...
CHAPTER 10 8/16-bit PPG timer 10.5.1 8-bit PPG output 2-channel independent operation mode In the 8-bit PPG output 2-channel independent operation mode, the 8-/16-bit PPG timer is set as an 8-bit PPG timer with two independent channels.PPG output operation and interrupt request generation can be performed independently for each channel.
Page 330
CHAPTER 10 8/16-bit PPG timer • When an underflow occurs, the underflow generation flag bit in the channel that causes an underflow is set (PPGC0: PUF0 = 1, PPGC1: PUF1 = 1).If an interrupt request is enabled at the channel that causes an underflow (PPGC0: PIE0 = 1, PPGC1: PIE1 = 1), the interrupt request is generated.
CHAPTER 10 8/16-bit PPG timer 10.5.2 16-bit PPG output mode In the 16-bit PPG output operation mode, the 8-/16-bit PPG timer is set as a 16-bit PPG timer with one channel. I Setting for 16-bit PPG Output Operation Mode Operating the 8-/16-bit PPG timer in the 8+8-bit PPG output operation mode requires the setting shown in Figure 10.5-4.
Page 332
CHAPTER 10 8/16-bit PPG timer Operation in 16-bit PPG output operation mode • When either PPG0 pin output or PPG1 pin output is enabled (PPGC0: PE0 = 1, PPGC1: PE1 = 1), the same pulse wave is output from both the PPG0 and PPG1 pins. •...
Page 333
CHAPTER 10 8/16-bit PPG timer Output waveform in 16-bit PPG output operation mode • The High and Low pulse widths to be output are determined by adding 1 to the value in the PPG reload register and multiplying it by the count clock cycle.For example, if the value in the PPG reload register is "0000 ", the pulse width has one count clock cycle, and if the value is "FFFF ", the pulse width has...
CHAPTER 10 8/16-bit PPG timer 10.5.3 8 + 8-bit PPG output mode The PPG0 operates as an 8-bit prescaler and the PPG1 operates using the PPG output of the PPG0 as a clock source. I Setting for 8+8-bit PPG Output Operation Mode Operating the 8-/16-bit PPG timer in the 8+8-bit PPG output operation mode requires the setting shown in Figure 10.5-6.
Page 335
CHAPTER 10 8/16-bit PPG timer Operation in 8+8-bit PPG output operation mode • The PPG0 operates as the prescaler of the PPG timer and the PPG1 operates using the PPG0 output as a clock source. • When the pin output is enabled (PPGC0: PE0 = 1, PPGC1: PE1 = 1), the PPG0 pulse wave is output from the PPG0 pin and the PPG1 pulse wave is output from the PPG1 pin.
Page 336
CHAPTER 10 8/16-bit PPG timer Output waveform in 8-bit PPG output 2-channel independent operation mode • The High and Low pulse widths to be output are determined by adding 1 to the value in the PPG reload register and multiplying it by the count clock cycle. The equations for calculating the pulse width are shown below: PL=T ×...
CHAPTER 10 8/16-bit PPG timer 10.6 Precautions when Using 8-/16-bit PPG Timer Precautions when Using 8-/16-bit PPG Timer I Precautions when Using 8-/16-bit PPG Timer Effect on 8-/16-bit PPG timer when using timebase timer output • If the output signal of the timebase timer is used as the input signal for the count clock of the 8-/16-bit PPG timer (PPG01: PCM2 to PCM0 = "111 ", PCS2 to PCS0 = "111 "), deviation may occur in the...
Page 338
CHAPTER 10 8/16-bit PPG timer Setting of PPG reload registers when using 16-bit PPG timer • Use a long-word instruction to set the PPG reload registers (PRLL0/PRLH0, PRLL1/PRLH1) or a word instruction to set the word instruction to set the PPG0 and PPG1 (PRLL0 → PRLL1 or PRLH0 → PRLH1) in this order.
CHAPTER 11 Delayed interrupt generation module This chapter explains the functions and operations of the delayed interrupt generation module. 11.1 Overview of Delayed Interrupt Generation Module 11.2 Block Diagram of Delayed Interrupt Generation Module 11.3 Configuration of Delayed Interrupt Generation Module 11.4 Explanation of Operation of Delayed Interrupt Generation Module 11.5 Precautions when Using Delayed Interrupt Generation Module 11.6 Program Example of Delayed Interrupt Generation Module...
CHAPTER 11 Delayed interrupt generation module 11.1 Overview of Delayed Interrupt Generation Module The delayed interrupt generation module generates the interrupt for task switching. The hardware interrupt request can be generated/cancelled by software. I Overview of Delayed Interrupt Generation Module By using the delayed interrupt generation module, a hardware interrupt request can be generated or cancelled by software.
CHAPTER 11 Delayed interrupt generation module 11.3 Configuration of Delayed Interrupt Generation Module This section lists registers and reset values in the delayed interrupt generation module. I List of Registers and Reset Values Figure 11.3-1 List of Registers and Reset Values in Delayed Interrupt Generation Module Delay interrupt request generation/ release register (DIRR) : Undefined...
CHAPTER 11 Delayed interrupt generation module 11.4 Explanation of Operation of Delayed Interrupt Generation Module The delayed interrupt generation module has a function for generating or canceling an interrupt request by software. I Explanation of Operation of Delayed Interrupt Generation Module Using the delayed interrupt generation module requires the setting shown in Figure 11.4-1.
CHAPTER 11 Delayed interrupt generation module 11.5 Precautions when Using Delayed Interrupt Generation Module This section explains the precautions when using the delayed interrupt generation module. I Precautions when Using Delayed Interrupt Generation Module • The interrupt processing is restarted at return from interrupt processing without setting the R0 bit in the delayed interrupt request generate/cancel register (DIRR) to "0"...
CHAPTER 11 Delayed interrupt generation module 11.6 Program Example of Delayed Interrupt Generation Module This section gives a program example of the delayed interrupt generation module. Program Example of Delayed Interrupt Generation Module Processing specification The main program writes "1" to the R0 bit in the delayed interrupt request generate/cancel register (DIRR) to generate a delayed interrupt request and performs task switching.
CHAPTER 12 DTP/external interrupt This chapter explains the functions and operations of DTP/external interrupt. 12.1 Overview of DTP/External Interrupt 12.2 Block Diagram of DTP/External Interrupt 12.3 Configuration of DTP/External Interrupt 12.4 Explanation of Operation of DTP/External Interrupt 12.5 Precautions when Using DTP/External Interrupt 12.6 Program Example of DTP/External Interrupt Function...
CHAPTER 12 DTP/external interrupt 12.1 Overview of DTP/External Interrupt The DTP/external interrupt sends interrupt requests from external peripheral devices or data transfer requests to the CPU to generate an external interrupt request, or starts the OS).RX input of CAN controller can be used as external interrupt input. I DTP/External Interrupt Function The interrupt request input from an external peripheral device to the external interrupt input pins (INT7 to INT4) or RX pin is generated in the same way as interrupts by peripheral resources.
CHAPTER 12 DTP/external interrupt 12.2 Block Diagram of DTP/External Interrupt The block diagram of the DTP/external interrupt is shown below. I Block Diagram of DTP/External Interrupt Figure 12.2-1 Block Diagram of DTP/External Interrupt Detection level setting register (ELVR) served served served served served...
Page 350
CHAPTER 12 DTP/external interrupt DTP/external interrupt input detector This circuit detects interrupt requests or data transfer requests generated from external peripheral devices. The interrupt request flag bit corresponding to the pin whose level or edge set by the detection level setting register (ELVR) is detected is set to 1 (EIRR: ER).
CHAPTER 12 DTP/external interrupt 12.3 Configuration of DTP/External Interrupt This section lists and details the pins, interrupt factors, and registers in the DTP/ external interrupt. I Pins of DTP/External Interrupt The pins used by the DTP/external interrupt serve as general-purpose I/0 ports. Table 12.3-1 lists the pin functions and the pin setting required for use in the DTP/external interrupt Table 12.3-1 Pins of DTP/External Interrupt Pin Name...
CHAPTER 12 DTP/external interrupt 12.3.1 DTP/external interrupt factor register (EIRR) This register holds DTP/external interrupt factors. When a valid signal is input to the DTP/external interrupt pin or RX pin, the corresponding interrupt request flag bit is set to "1". I DTP/external interrupt factor register (EIRR) Figure 12.3-2 DTP/external interrupt factor register (EIRR) Reset value...
CHAPTER 12 DTP/external interrupt 12.3.3 Detection Level Setting Register (ELVR) (High) The detection level setting register (High) sets the levels or edges of input signals that cause interrupt factors in INT7 to INT4 of the DTP/external interrupt pins. I Detection Level Setting Register (ELVR) (High) Figure 12.3-4 Detection Level Setting Register (ELVR) (High) Reset value 00000000...
CHAPTER 12 DTP/external interrupt 12.4 Explanation of Operation of DTP/External Interrupt The DTP/external interrupt circuit has an external interrupt function and a DTP function.The setting and operation of each function is explained. I Setting of DTP/External Interrupt Circuit Using the DTP/external interrupt requires, the setting shown in Figure 12.4-1. Figure 12.4-1 Setting of DTP/External Interrupt Circuit bit15 14 9 bit8 bit7 6...
Page 357
CHAPTER 12 DTP/external interrupt Selecting of DTP or external interrupt function Whether the DTP function or the external interrupt function is executed depends on the setting of the OS enable bit in the corresponding interrupt control register (ICR: ISE). If the ISE bit is set to "1", the EI OS is enabled and the DTP function is executed.
Page 358
CHAPTER 12 DTP/external interrupt Figure 12.4-2 shows operation of DTP/external interrupt. Figure 12.4-2 Operation of DTP/External Interrupt DTP/external interrupt circuit Other request Interrupt controller ELVR Interrupt EIRR processing ENIR Factor OS start-up DTP/external interrupt request generating Memory Peripheral data trnsmission Descriptor renewal Interrupt controller reception judge...
CHAPTER 12 DTP/external interrupt 12.4.1 External Interrupt Function The DTP/external interrupt has an external interrupt function for generating an interrupt request by detecting the signal (edge or level) in the DTP/external interrupt pin or RX pin. I External Interrupt Function •...
CHAPTER 12 DTP/external interrupt 12.4.2 DTP Function The DTP/external interrupt has the DTP function that detects the signal from an external peripheral device through the DTP/external interrupt pin or RX pin to start Extended Intelligent I/O Service (EI OS). I DTP Function The DTP function detects the signal level set by the detection level setting register of the DTP/external interrupt function to start the EI •...
CHAPTER 12 DTP/external interrupt 12.5 Precautions when Using DTP/External Interrupt This section explains the precautions when using the DTP/external interrupt. I Precautions when Using DTP/External Interrupt Circuit Condition of external-connected peripheral device when DTP function is used • When using the DTP function, the peripheral device must automatically clear a data transfer request when data transfer is performed.
Page 362
CHAPTER 12 DTP/external interrupt Figure 12.5-2 DTP/External Interrupt Factor and Interrupt Request Generated when Interrupt Request Enabled DTP/externalinterrupt factor (ehen "H" level detection) Terminated interrupt factor Interrupt request to interrupt controller Being inactive by clearing the DTP/external interrupt request flag bit (EIRR: ER) Precautions on interrupts •...
CHAPTER 12 DTP/external interrupt 12.6 Program Example of DTP/External Interrupt Function This section gives a program example of the DTP/external interrupt function. I Program Example of DTP/External Interrupt Function Processing specification An external interrupt is generated by detecting the rising edge of the pulse input to the INT4 pin. Coding example ICR06 0000B6H...
Page 364
CHAPTER 12 DTP/external interrupt Programming sample of DTP Function Processing specification • Channel 0 of Extended Intelligent I/O Service (EI OS) is started upon detection of the High level of the signal input to the INT4 pin. • RAM data is output to port 0 by DTP processing (EI OS).
Page 365
CHAPTER 12 DTP/external interrupt LOOP: User processing LOOP ;---------Interrupt program------------------------------------- WARI: CLRB I:ER4 ;Clear INT4 interrupt request flag User processing RETI ;Recovery from interrupt processing CODE ENDS ;---------Vector setting------------------------------------------ VECT CSEG ABS=0FFH 00FF9CH ;Setting vector to interrupt number #24(18 WARI 00FFDCH ;Reset vector setting START...
CHAPTER 13 8/10-bit A/D converter This chapter explains the functions and operation of 8-/ 10-bit A/D converter. 13.1 Overview of 8-/10-bit A/D Converter 13.2 Block Diagram of 8-/10-bit A/D Converter 13.3 Configuration of 8-/10-bit A/D Converter 13.4 Interrupt of 8-/10-bit A/D Converter 13.5 Explanation of Operation of 8-/10-bit A/D Converter 13.6 Precautions when Using 8-/10-bit A/D Converter...
CHAPTER 13 8/10-bit A/D converter 13.1 Overview of 8-/10-bit A/D Converter The 8-/10-bit A/D converter converts the analog input voltage to a 8- or 10-bit digital value by using the RC sequential-comparison converter system. • An input signal can be selected from the input signals of the analog input pins for 8 channels.
CHAPTER 13 8/10-bit A/D converter 13.2 Block Diagram of 8-/10-bit A/D Converter The 8-/10-bit A/D converter consists of following blocks. I Block Diagram of 8-/10-bit A/D Converter Figure 13.2-1 Block Diagram of 8-/10-bit A/D Converter A/D control Interrupt requext output status register (ADCS)
Page 370
CHAPTER 13 8/10-bit A/D converter Details of pins in block diagram Table 13.2-1 shows the actual pin names and interrupt request numbers of the 8-/10-bit A/D converter Table 13.2-1 Pins and Interrupt Request Numbers in Block Diagram Pin Name/Interrupt Request Number in Block Actual Pin Name/Interrupt Request Diagram Number...
Page 371
CHAPTER 13 8/10-bit A/D converter Decoder This decoder sets the A/D conversion start channel select bits and the A/D conversion end channel select bits in the A/D control status register (ADCS: ANS2 to ANS0 and ANE2 to ANE0) to select the analog input pin to be used for A/D conversion.
CHAPTER 13 8/10-bit A/D converter 13.3 Configuration of 8-/10-bit A/D Converter This section explains the pins, registers, and interrupt factors of the A/D converter. I Pins of 8-/10-bit A/D Converter The pins of the 8-/10-bit A/D converter serve as general-purpose I/O ports.Listed below are the pin functions and the settings required for use of the 8-/10-bit A/D converter.
Page 373
CHAPTER 13 8/10-bit A/D converter I List of Registers and Reset Values of 8-/10-bit A/D Converter Figure 13.3-1 List of Registers and Reset Values of 8-/10-bit A/D Converter A/D control status register upper (ADCS: H) A/D control status register lower (ADCS: L) A/D data register upper (ADCR: H) A/D data register lower (ADCR: L)
CHAPTER 13 8/10-bit A/D converter 13.3.1 A/D Control Status Register (High) (ADCS: H) The A/D control status register (High) (ADCS: H) provides the following settings: • Starting A/D conversion function by software • Selecting start trigger for A/D conversion • Storing A/D conversion results in A/D data register to enable or disable interrupt request •...
Page 375
CHAPTER 13 8/10-bit A/D converter Table 13.3-2 Function of Each Bit of A/D Control Status Register (High) (ADCS: H) (1/2) bit name Function bit8 Reserved: reserved bit Always set this bit to "0". bit9 STRT: This bits starts the 8-/10-bit A/D converter by software. A/D conversion software When set to "1": Starts 8-/10-bit A/D converter start bit...
Page 376
CHAPTER 13 8/10-bit A/D converter Table 13.3-2 Function of Each Bit of A/D Control Status Register (High) (ADCS: H) (2/2) bit name Function bit15 BUSY: This bit forcibly terminates the 8-/10-bit A/D converter.When read, A/D conversion-on flag this bit indicates whether the 8-/10-bit A/D converter is operating or stopped.
CHAPTER 13 8/10-bit A/D converter 13.3.2 A/D Control Status Register (Low) (ADCS: L) The A/D control status register (Low) (ADCS: L) provides the following settings: • Selecting A/D conversion mode • Selecting start channel and end channel of A/D conversion I A/D Control Status Register (Low) (ADCS: L) Figure 13.3-3 A/D Control Status Register (Low) (ADCS: L) Reset value...
Page 378
CHAPTER 13 8/10-bit A/D converter Table 13.3-3 Function of Each Bit of A/D Control Status Register (Low) (ADCS: L) (1/2) bit name Function bit0 ANE2 to ANE0: These bits set the channel at which A/D conversion terminated. A/D conversion end Start channel <...
Page 379
CHAPTER 13 8/10-bit A/D converter Table 13.3-3 Function of Each Bit of A/D Control Status Register (Low) (ADCS: L) (2/2) bit name Function bit6 MD1, MD0: These bits set the A/D conversion mode. bit7 A/D conversion mode Single-shot conversion mode 1: select bits •...
CHAPTER 13 8/10-bit A/D converter 13.3.3 A/D Data Register (High) (ADCR: H) The higher five bits in the A/D data register (ADCR: H) select the compare time, sampling time and resolution of A/D conversion. Bits 9 and 8 in the A/D data register (ADCR) are explained in Section 13.3-4 A/D Data Register (Low) (ADCR: L).
Page 381
CHAPTER 13 8/10-bit A/D converter Table 13.3-4 Functions of A/D Data Register (High) (ADCR: H) bit name Function bit11 CT1, CT0: These bits set the A/D conversion compare time. bit12 Compare time select bits • These bits set the time required from when analog input is A/ D-converted until it is stored in the data bits (D9 to D0).
CHAPTER 13 8/10-bit A/D converter 13.3.4 A/D Data Register (Low) (ADCR: L) The A/D data register (Low) (ADCR: L) stores the A/D conversion results. Bits 8 and 9 in the A/D data register (ADCR) in this section. I A/D Data Register (Low) (ADCR: L) Figure 13.3-5 A/D Data Register (Low) (ADCR: L) bit9 Reset value...
CHAPTER 13 8/10-bit A/D converter 13.3.5 Analog input enable register (ADER) The analog input enable register (ADER) enables or disables the analog input pins to be used in the 8-/10-bit A/D converter. I Analog input enable register (ADER) Figure 13.3-6 Analog input enable register (ADER) Reset value 11111111 bit0...
Page 384
CHAPTER 13 8/10-bit A/D converter Table 13.3-6 Functions of Analog Input Enable Register (ADER) bit name Function bit0 ADE7 to ADE0: These bits enable or disable the analog input of the pin to be Analog input enable bits used for A/D conversion. When set to "0": Disables analog input bit7 When set to "1": Enables analog input...
CHAPTER 13 8/10-bit A/D converter 13.4 Interrupt of 8-/10-bit A/D Converter When A/D conversion is terminated and its results are stored in the A/D data register (ADCR), the 8-/10-bit A/D converter generates an interrupt request.The EI OS function can be used. I Interrupt of A/D Converter When A/D conversion of the analog input voltage is terminated and its results are stored in the A/D data register (ADCR), the interrupt request flag bit in the A/D control status register (ADCS: INT) is set to...
CHAPTER 13 8/10-bit A/D converter 13.5 Explanation of Operation of 8-/10-bit A/D Converter The 8-/10-bit A/D converter has the following A/D conversion modes.Set each mode according to the setting of the A/D conversion mode select bits in the A/D control status register (ADCS: MD1, MD0).
CHAPTER 13 8/10-bit A/D converter 13.5.1 Single-shot conversion mode In the single conversion mode, A/D conversion is performed sequentially from the start channel to the end channel.The A/D conversion pauses after A/D conversion for the end channel. I Setting of Single-shot Conversion Mode Operating the 8-/10-bit A/D converter in the single conversion mode requires the setting shown in Figure 13.5-1.
Page 388
CHAPTER 13 8/10-bit A/D converter [Conversion order in single-shot conversion mode] Table 13.5-1 gives an example of the conversion order in the single-shot conversion mode. Table 13.5-1 Conversion Order in Single-shot Conversion Mode Start Channel End Channel Conversion Order in Single-shot Conversion Mode →...
CHAPTER 13 8/10-bit A/D converter 13.5.2 Continuous conversion mode In the continuous conversion mode, A/D conversion is performed sequentially from the start channel to the end channel.When A/D conversion for the end channel is terminated, it is continued after returning to the start channel. I Setting of Continuous Conversion mode Operating the 8-/10-bit A/D converter in the continuous conversion mode requires the setting shown in Figure 13.5-2.
Page 390
CHAPTER 13 8/10-bit A/D converter [Conversion order in continuous conversion mode] Table 13.5-2 gives an example of the conversion order in the continuous conversion mode. Table 13.5-2 Conversion Order in Continuous Conversion Mode Start Channel End Channel Conversion Order in Continuous Conversion Mode →...
CHAPTER 13 8/10-bit A/D converter 13.5.3 Pause-conversion mode In the pause-conversion mode, A/D conversion starts and pauses repeatedly for each channel.When the start trigger is input after the A/D conversion pauses at the termination of the A/D conversion for the end channel, A/D conversion is continued after returning to the start channel.
Page 392
CHAPTER 13 8/10-bit A/D converter [When start and end channels are the same] • If the start and end channels have the same channel number (ADCS: ANS2 to ANS0 = ADCS: ANE2 to ANE0), A/D conversion for one channel set as the start channel (= end channel), and pause are repeated. [Conversion order in pause-conversion mode] Table 13.5-3 gives an example of the conversion order in the pause-conversion mode.
CHAPTER 13 8/10-bit A/D converter 13.5.4 Conversion Using EI OS Function The 8-/10-bit A/D converter can transfer the A/D conversion result to memory by using the EI OS function. I Conversion Using EI The use of the EI OS enables the A/D-converted data protection function to transfer multiple data to memory without the loss of converted data even if A/D conversion is performed continuously.
CHAPTER 13 8/10-bit A/D converter 13.5.5 A/D-converted Data Protection Function A/D conversion with the output an interrupt request enabled activates the A/D conversion data protection function. I A/D-converted Data Protection Function in 8-/10-bit A/D Converter The 8-/10-bit A/D converter has only one A/D data register (ADCR) for holding A/D-converted data. When the results of A/D conversion are determined upon completion, data in the A/D data register is updated.Therefore, the A/D conversion results may be lost if the A/D conversion results already stored are not read before data in the A/D data register is rewritten.The A/D-converted data protection function in the...
Page 395
CHAPTER 13 8/10-bit A/D converter Processing flow of A/D conversion data protection function when EI OS used Figure 13.5-5 shows the processing flow of the A/D conversion data protection function when the EI OS is used. Figure 13.5-5 Processing flow of A/D conversion data protection function when EI OS used OS setting A/D sequential conversion...
Page 396
CHAPTER 13 8/10-bit A/D converter Notes: • The A/D conversion data protection function is activated only when an interrupt request is enabled.Set the interrupt request enable bit in the A/D control status register (ADCS: INTE) to "1". • When the EI OS function is used to transfer the A/D conversion results to memory, do not disable output of an interrupt request.If output of an interrupt request is disabled during a pause of A/D conversion (ADCS: INTE = 0), A/D conversion may be restarted to rewrite...
CHAPTER 13 8/10-bit A/D converter 13.6 Precautions when Using 8-/10-bit A/D Converter Precautions when using the 8-/10-bit A/D converter are given below: I Precautions when Using 8-/10-bit A/D Converter Analog input pin • The analog input pins serve as a general-purpose I/O port of the port 5.To use the pin as an analog input pin, set the port-5 direction register (DDR5) and analog input enable register (ADER) to switch it to an analog input pin.
CHAPTER 14 UART0 This chapter explains the functions and operation of the UART0. 14.1 Overview of UART0 14.2 Block Diagram of UART0 14.3 Configuration of UART0 14.4 Interrupt of UART0 14.5 UART0 baud rate 14.6 Explanation of Operation of UART0 14.7 Precautions when using UART0...
CHAPTER 14 UART0 14.1 Overview of UART0 The UART0 is a general-purpose serial-data communication interface for synchronous or asynchronous communication with external devices. • Incorporates a bidirectional communication function (clock synchronous and asynchronous modes) • The master/slave communication function (multiprocessor mode) is incorporated. •...
Page 401
CHAPTER 14 UART0 Table 14.1-2 Operation Mode of UART0 Data length Synchronous Length of Stop Operating mode type With Parity No Parity Normal mode 7 bits or 8 bits Asynchronous 1 bit or 2 bits Multiprocessor Asynchronous mode Clock Clock synchronous None synchronous...
CHAPTER 14 UART0 14.2 Block Diagram of UART0 The UART0 consists of the following block. I Block Diagram of UART0 Figure 14.2-1 Block Diagram of UART0 Control bus Reception interrupt Dedicated request output Transmission baud rate clock generator Transmission 16-bit Clock interrupt Reception...
Page 403
CHAPTER 14 UART0 Details of Pins in Block Diagram The actual pin names and interrupt request numbers used in the UART0 are as follows: SCK pin: P31/SCK0/RD TX pin: P43/TX: P30/SOT0/ALE SIN pin: P32/SIN0/WRL Transmit interrupt number: #39 (27 Receive interrupt number: #40 (28 Clock selector The clock selector selects the transmission/reception clock from among the dedicated baud rate generator, external input clock, and internal clock (clock supplied from 16-bit reload timer 0).
Page 404
CHAPTER 14 UART0 transmission and reception. Serial status register (SSR) The status register checks the transmission/reception status and error status and enables/disables transmission/reception interrupt requests. Serial input data register The register retains the receive data.The serial input is converted and then stored in this register. Serial output data register 0 (SODR0) The register sets the transmit data.Data written to this register is serial-converted and then output.
CHAPTER 14 UART0 14.3 Configuration of UART0 The UART0 pins, interrupt factors, register list and details are shown. I Pins of UART0 The pins used in the UART0 serve also as general-purpose I/O ports. Table 14.3-1 indicates the pin functions and the setting necessary for use in the UART0. Table 14.3-1 Pins of UART0 Pin Name Pin Function...
Page 406
CHAPTER 14 UART0 I List of Registers in UART0 Figure 14.3-1 List of Registers and Reset Values in UART0 Serial control register (SCR0) Serial mode register (SMR0) Serial status register (SSR0) Serial input data register (SIDR0) /serial output data register (SODR0) Note : Function as SIDR0 when reading, function as SODR0 when writing Serial edge select register (SES0) Communication prescaler control...
CHAPTER 14 UART0 14.3.1 Serial control register 0 (SCR0) Serial control register 0 (SCR0) is used to set the parity bit, select the stop bit length and data length, select the frame data format in operation mode 1, clear the reception error flag, and to enable/disable transmission and reception.
Page 408
CHAPTER 14 UART0 Table 14.3-2 Functions of Serial Control Register 0 (SCR0) bit name Function bit8 TXE: The bit enables or disables the UART0 for transmission. transmit enable bit When the bit is set to "0": Transmission is disabled. When the bit is set to "1": Transmission is enabled. Note: When transmission is disabled, the device stops transmitting after transmitting the current data from the serial output data register.
CHAPTER 14 UART0 14.3.2 Serial mode register 0 (SMR0) Serial mode register 0 (SMR0) is used to select the operation mode, select the baud rate clock, and to disable/enable the output of serial data and clock signal to pins. I Serial mode register 0 (SMR0) Figure 14.3-3 Serial mode register 0 (SMR0) Reset value 00000000...
Page 410
CHAPTER 14 UART0 Table 14.3-3 Functions of Serial Mode Register 0 (SMR0) bit name Function bit0 SOE: Enable or disable output of serial data. Serial-data output enable When the bit is set to "0": The pin is set as a general-purpose I/O port. When the bit is set to "1": The pin is set as a serial data output pin.
CHAPTER 14 UART0 14.3.3 Serial status register 0 (SSR0) Serial status register 0 (SSR0) is used to check the reception/transmission status and error status and to enable/disable interrupts. I Serial status register (SSR0) Figure 14.3-4 Serial status register (SSR0) Reset value 00001X00 bit8 Transmission interrupt enable bit...
Page 412
CHAPTER 14 UART0 Table 14.3-4 Function of Serial Status Register 0 (SSR0) bit name Function bit8 TIE: Enable or disable send interrupt. Transmission interrupt When the bit is set to "1": A transmission interrupt request is generated when enable bit the data written to serial output data register 0 is transmitted to the send shift register (SSR0:TDRE=1).
CHAPTER 14 UART0 14.3.4 Serial Input Data Register 0 (SIDR0) and Serial Output Data Register 0 (SODR0) The serial input data register and serial output data register are allocated to the same address.The register functions as the serial data input register at a read; the register functions as the serial data output register at a write.
Page 414
CHAPTER 14 UART0 I Serial output data register 0 (SODR0) Figure 14.3-6 Serial output data register 0 (SODR0) bit0 Reset value XXXXXXXX W : Write only X : Undefined The serial output data register 0 (SODR0) is a data buffer register for transmitting serial data. •...
CHAPTER 14 UART0 14.3.5 Communication Prescaler Control Register 0 (CDCR0) The communication prescaler control register 0 (CDCR0) is used to set the baud rate of the dedicated baud rate generator for the UART0. • Starts/stop the communication prescaler • Sets the division ratio for machine clock I Communication Prescaler Control Register 0 (CDCR0) Figure 14.3-7 Communication Prescaler Control Register Reset value...
CHAPTER 14 UART0 14.3.6 Serial edge select register 0 (SES0) Serial edge select register 0 (SES0) inverts the clock signal of the UART0 using an inverter.The register logically inverts the shift clock signal input to the UART0 from Low level to High level and from falling edge to rising edge, or from High level to Low level and from rising edge to falling edge.The inversion acts on the serial clock output, too.
CHAPTER 14 UART0 14.4 Interrupt of UART0 The UART0 has reception and transmission interrupts and can generate interrupt requests in the following events. • Receive data is loaded to the serial input data register 0 (SIDR0). • A receive error (parity error, overrun error, framing error) occurs. •...
Page 418
OS can be started separately for receive interrupts and transmit interrupts. At reception: MB90895 series cannot use interrupt vectors as it contains no I C interface. At transmission: Since the interrupt control register (ICR14) is shared with the UART0 for reception interrupts, EI OS can be started only when no interrupt is used for transmission by the UART0.
CHAPTER 14 UART0 14.4.1 Generation of Receive Interrupt and Timing of Flag Set Interrupts during reception are one generated upon completion of reception (SSR:RDRF) and one generated upon occurrence of a reception error (SSR:PE, ORE, FRE). I Generation of Receive Interrupt and Timing of Flag Set Receive data load flag and each receive error flag sets When data is received, it is stored in serial input data register 0 (SIDR0) upon detection of the stop bit (in operation mode 0 or 1) or of the data’s last bit (SIDR0: D7) (in operation mode 2).When a reception error...
Page 420
CHAPTER 14 UART0 Reception and timing of flag set are shown in Figure 14.4-1. Figure 14.4-1 Reception and Timing of Flag Set Reception data (operating mode 0) Reception data (operating mode 1) Reception data (operating mode 2) SSR0 : PE, ORE, FRE SSR0 : RDRF Reception interrupt generating : PE flag is disabled to detect in mode 1.
CHAPTER 14 UART0 14.4.2 Generation of Transmit Interrupt and Timing of Flag Set An interrupt during transmission is generated when serial output data register 0 (SODR0) becomes empty, or ready to accommodate the next data to transmit. I Generation of Transmit Interrupt and Timing of Flag Set Set and clear of transmit data empty flag bit The transmit data write flag bit (SSR0: TDRE) is set when the transmit data written to serial output data register 0 (SODR0) is transferred to the transmission shift register, making it ready to write the next data to...
Page 422
CHAPTER 14 UART0 Timing of transmit interrupt request A transmission interrupt request is generated when the transmit data write flag bit (SSR0: TDRE) is set with transmission interrupts enabled (SSR0: TIE = 1). Note: If the transmission in progress is disabled (SCR0: TXE = 1, and reception is also disabled with RXE = 0 in operation mode 1), the transmit data write flag bit is set (SSR0: TDRF = 1), the transmission shift register stops shifting, then the UART0 is disabled.
CHAPTER 14 UART0 14.5 UART0 baud rate The UART0 transmission/reception clock is selected from among the following options: • Dedicated baud rate generator • Internal clock (16-bit reload timer output) • External clock (clock input to SCK pin) I Select of UART0 Baud Rate The UART0 baud rate select circuit comprises as shown in Figure 14.5-1.The clock input source can be selected from among the following three types: Baud rate by dedicated baud rate generator...
CHAPTER 14 UART0 14.5.1 Baud rate by dedicated baud rate generator The baud rate that can be set when the output clock of the dedicated baud rate generator is selected as the transfer clock of the UART0 is shown. I Baud rate by dedicated baud rate generator The baud rate based on the dedicated baud rate generator is set by setting the clock input source select bits (SMR0: CS2 to CS0) to "000 "...
Page 426
CHAPTER 14 UART0 Division ratio based on communication prescaler (common between asynchronous and clock synchronous modes) The frequency divide ratio of the machine clock is set by the divide ratio select bits (CDCR0: DIV3 to DIV0) in the communication prescaler control register. Table 14.5-1 Division Ratio Based on Communication Prescaler Communication Prescaler Control Divide...
CHAPTER 14 UART0 14.5.2 Baud Rate by Internal Timer (16-bit Reload Timer) The setting when selecting the internal clock supplied from the 16-bit reload timer 1 as the clock input source of the UART0 and the baud rate calculation are shown below. I Baud Rate by Internal Timer (16-bit Reload Timer Output) The baud rate based on the internal timer (16-bit reload timer 0 output) is set by setting the clock input source select bits (SMR0: CS2 to CS0) to "110...
Page 429
CHAPTER 14 UART0 Calculation expression for baud rate φ Asynchronous baud rate = × × X (n + 1) φ Clock synchronous baud rate = × X (n + 1) φ: Machine clock X: Count clock frequency divide ratio for 16-bit reload timer (2, 8, 32) n: 16-bit reload register setting value (0 to 65,535) for 16-bit reload timer (0 to 65,535) Example of setting baud rates and reload register setting values (machine clock frequency: 7.3728 MHz)
CHAPTER 14 UART0 14.5.3 Baud rate by external clock This section explains the setting when selecting the external clock as the transmit/ receive clock of the UART0. I Baud rate by external clock The following settings are required for selecting a baud rate depending on the external clock input: •...
CHAPTER 14 UART0 14.6 Explanation of Operation of UART0 The UART0 has the bidirectional serial communication function (operation modes 0 and 2) and master/slave-connection communication function (operation mode 1). I Operation of LIN-UART Operating mode The UART0 has three types of operation modes, they can set the inter-CPU connection mode or data communication mode.
Page 432
CHAPTER 14 UART0 Inter-CPU connection method Either 1-to-1 connection or master/slave type connection can be selected for the inter-CPU controller.In both cases, the data length, parity, synchronous or asynchronous mode, etc., must be the same for all CPUs.The operation modes are selected as follows. •...
CHAPTER 14 UART0 14.6.1 Operation in asynchronous mode (operation mode 0 or 1) When the UART0 is used in operation mode 0 (normal mode) or operation mode 1 (multiprocessor mode), the asynchronous transfer mode is selected. I Operation in Asynchronous Mode Format of transmit/receive data Transmission and reception always begin with the start bit (Low level);...
Page 434
CHAPTER 14 UART0 Transmission • Data to transmit is written to serial output data register 0 (SODR0) with the transmit data write flag bit (SSR0: TDRE) containing "1". • Transmission starts when the transmission enable bit (SCR0:TXE) in the serial control register is set to "1"with the data to transmit written.
Page 435
CHAPTER 14 UART0 Figure 14.6-2 example of normal operating Communication period Non communication period Non communication period Marc level Start bit Stop bit Data (01010101 transmission) Reception clock Sampling clock Reception clock(8-pulse) Sampling clock is built from 1/16 divided of the reception clock. Recognition of maicrocontroller side (01010101 reception)
Page 436
CHAPTER 14 UART0 Parity bit The addition of a parity bit can be set only in operation mode 0.The parity addition enable bit (SCR0: PEN) and parity select bit (SCR0:P) can be used to select whether to use parity and to set the even or odd parity, respectively.
CHAPTER 14 UART0 14.6.2 Operation at clock synchronous mode (operating mode 2) When the UART0 is used in operation mode 2, the transfer mode is clock synchronous. I Operation in Clock Synchronous Mode Format of transmit/receive data In clock synchronous mode, 8-bit data is transmitted and received on an LSB-first basis.The start and stop bits are not added to the transmit/receive data.
Page 438
CHAPTER 14 UART0 Clock Supply In the clock synchronous mode, count of clocks equal to the transmit and receive bits count must be supplied. • When data is transmitted with the internal clock (dedicated baud rate generator or internal timer) selected (SMR0: CS2 to CS0 = "000 "...
Page 439
CHAPTER 14 UART0 Terminating communications Upon completion of transmitting/receiving one frame of data, the receive data load flag bit (SSR0: RDRF) is set to 1.When data is received, check the overrun error flag bit (SSR0: ORE) to ensure that the communication has performed normally.
CHAPTER 14 UART0 14.6.3 Bidirectional Communication Function (Operation Modes 0 and 2) In operation modes 0 and 2, serial bidirectional communication can be performed in a one-to-one connection.Operation modes 0 and 2 use asynchronous and clock- synchronous transfers, respectively. I Bidirectional Communication Function The UART0 requires the settings shown in Figure 14.6-6 to operate in operation mode 0 or 2.
Page 441
CHAPTER 14 UART0 Communication procedure Communications start at any timing from the transmitting end when transmit data is provided.On the transmission side, load transmit data into the serial output data register (SODR0) and set the transmission enable bit (SCR0: TXE) in the serial control register to 1 to start transmission. Figure 14.6-8 gives an example of transferring receive data to the transmitting end to inform the transmitting end of normal reception.
CHAPTER 14 UART0 14.6.4 Master/slave type communication function (multi processor mode) Operation mode 1 allows communication between multiple CPUs connected in a master/slave configuration.Note, however, that the function is available only to the master side. I Master/Slave Mode Communication Function The UART0 requires the settings shown in Figure 14.6-9 to operate in operation mode 1.
Page 443
CHAPTER 14 UART0 Function selection At master/slave type communication, select the operation mode and data transfer type. Since the parity check function cannot be used in operation mode 1, set the parity enable bit (SCR0: PEN) to 0. Table 14.6-3 Select of Master/Slave Communication Function Operating mode Synchro Data...
Page 444
CHAPTER 14 UART0 Communication procedure Communication is started by the master CPU by transmitting address data. The address data is data with the A/D bit set to "1". The address data bit (SCR0: A/D) is added to select the slave CPU that the master CPU communicates with.When the program identifies address data and finds a match with the allocated address, each slave CPU starts communications with the master CPU.
CHAPTER 14 UART0 14.7 Precautions when using UART0 Use of the UART0 requires the following precautions. I Precautions when using UART0 Enabling sending and receiving The UART0 has the transmission enable bit (SCR0: TXE) and reception enable bit (SCR0: RXE) provided for transmission and reception.
CHAPTER 15 UART1 This chapter explains the functions and operation of the UART. Overview of UART1 Block Diagram of UART1 Configuration of UART1 Interrupt of UART1 UART1 Baud Rate Explanation of Operation of UART1 Precautions when Using UART1 Program Example for UART1...
CHAPTER 15 UART1 15.1 Overview of UART1 The UART1 is a general-purpose serial-data communication interface for synchronous or asynchronous communication with external devices. • Incorporates a bidirectional communication function (clock synchronous and asynchronous modes) • Incorporates a master/slave type communication function (in multiprocessor mode: only master) •...
Page 449
CHAPTER 15 UART1 Table 15.1-2 Operation Mode of UART1 Data length Synchronous Length of Stop Operating mode type With Parity No Parity Asynchronous mode (Normal 7 bits or 8 bits Asynchronous mode) 1 bit or 2 bits Multiprocessor mode Asynchronous Synchronous mode Synchronous None...
CHAPTER 15 UART1 15.2 Block Diagram of UART1 The UART1 consists of the following block. I Block Diagram of UART1 Figure 15.2-1 Block Diagram of UART1 Control bus Reception interrupt request output Dedicated baud Transmission rate generator clock Transmission interrupt 16-bit Clock request output...
Page 451
CHAPTER 15 UART1 Details of Pins in Block Diagram The actual pin names and interrupt request numbers used in the UART1 are as follows: SIN1 pin: P40/SIN1 SCK1 pin: P41/SCK1 SOT1 pin: P42/SOT1 Transmit interrupt number 1: #38 (26 Receive interrupt number 1: #37 (25 Clock selector The clock selector selects the transmit/receive clock from the dedicated baud rate generator, external input clock, and internal clock (clock supplied from 16-bit reload timer).
Page 452
CHAPTER 15 UART1 Serial mode register 1 (SMR1) This register: Selects operation mode Selects clock input source (baud rate) Sets dedicated baud rate generator Selects clock speed (clock division value) when using dedicated baud rate generator Enables or disables output of serial data and clock pins Initialize UART Serial control register 1 (SCR1) This register:...
CHAPTER 15 UART1 15.3 Configuration of UART1 The UART1 pins, interrupt factors, register list and details are shown. UART1 Pin The pins used in the UART1 serve as general-purpose I/O port. indicates the pin functions and the setting necessary for use in the UART1. Table 15.3-1 UART1 Pin Pin Name Pin Function...
Page 454
CHAPTER 15 UART1 I List of Registers in UART1 Figure 15.3-1 List of Registers and Reset Values in UART1 Serial control register 1 (SCR1) Serial mode register 1 (SMR1) Serial status register 1 (SSR1) Serial input data register 1 (SIDR1) /serial output data register 1 (SODR1) Note : Function as SIDR1 when reading, function as SODR1 when writing.
CHAPTER 15 UART1 15.3.1 Serial control register 1 (SCR1) The serial control register 1 (SCR1) performs the following: setting parity bit, selecting stop bit length and data length, selecting frame data format in operation mode 1, clearing receive error flag, and enabling/disabling of transmitting/receiving. I Serial control register 1 (SCR1) Figure 15.3-2 Serial control register 1 (SCR1) Reset value...
Page 456
CHAPTER 15 UART1 Table 15.3-2 Functions of Serial Control Register 1 (SCR1) bit name Function bit8 TXE: Enable or disable the UART1 for sending. Transmit enable bit When set to "0": Transmission disabled When set to "1": Transmission enabled Note: When transmitting is disabled during transmitting, transmitting stops after the data in the serial input data register being transmitted is com