MC68HC908SR12 V5 0
MC68HC908SR12 V5 0
MC68HC08SR12
Data Sheet
M68HC08
Microcontrollers
MC68HC908SR12
Rev. 5.0
07/2004
freescale.com
MC68HC908SR12
MC68HC08SR12
Data Sheet
Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
This product incorporates SuperFlash® technology licensed from SST. © Freescale Semiconductor, Inc., 2004
Freescale Semiconductor 3
Revision History
Revision History
Revision Page
Date Description
Level Number(s)
Figure 19-3 . IRQ2 Block Diagram and 19.5 IRQ1 and IRQ2
338, 339
Pins — corrected IRQ2 for BIH and BIL instructions.
4 Freescale Semiconductor
Data Sheet — MC68HC908SR12•MC68HC08SR12
List of Sections
Table of Contents
1.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
1.3 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
4.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
6.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.3 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Appendix A. MC68HC08SR12
A.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .393
List of Figures
List of Tables
1.1 Contents
1.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
1.3 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
1.2 Introduction
The MC68HC908SR12 is a member of the low-cost, high-performance
M68HC08 Family of 8-bit microcontroller units (MCUs). The M68HC08
Family is based on the customer-specified integrated circuit (CSIC)
design strategy. All MCUs in the family use the enhanced M68HC08
central processor unit (CPU08) and are available with a variety of
modules, memory sizes and types, and package types.
1.3 Features
Features of the MC68HC908SR12 include the following:
PORTA
PTA6/T1CH0
DDRA
REGISTERS UNIT (ALU) MODULE 1
PTA5/ATD7 – PTA0/ATD2 ‡
CONTROL AND STATUS REGISTERS — 96 BYTES 2-CHANNEL TIMER INTERFACE
MODULE 2
USER FLASH — 12,288 BYTES
PTB6/IRQ2
TIMEBASE
USER RAM — 512 BYTES MODULE PTB5/T2CH1
PTB4/T2CH0
PORTB
DDRB
PTB3//SCL1/RxD †
MONITOR ROM — 368 BYTES
SERIAL COMMUNICATIONS PTB2/SDA1/TxD †
INTERFACE MODULE PTB1/SCL0 †
USER FLASH VECTORS — 38 BYTES PTB0/SDA0 †
MULTI-MASTER IIC (SMBUS)
OSCILLATORS AND INTERFACE MODULE
CLOCK GENERATOR MODULE PTC7/ATD12 ‡ #
General Description
PORTC
MODULE PTC4/ATD9 ‡
DDRC
OSC1
X-TAL OSCILLATOR PTC3/ATD8 ‡
OSC2
PTC2/PWM2
8-BIT KEYBOARD
CGMXFC PHASE-LOCKED LOOP INTERRUPT MODULE PTC1/PWM1
PTC0/PWM0/CD
PORTD
DDRD
PTD7/KBI7 – PTD0/KBI0 ***
* IRQ1 EXTERNAL IRQ
** IRQ2 MODULE LOW-VOLTAGE
INHIBIT MODULE
OPIN1/ATD0
# OPIN2/ATD1
ANALOG
MODULE POWER-ON RESET
VSSAM MODULE
VREFH 10-BIT ANALOG-TO-DIGITAL
VREFL CONVERTER MODULE * Pin contains integrated pullup device.
PTC5/ATD10
PTC6/ATD11
PTC4/ATD9
PTA5/ATD7
PTA4/ATD6
PTA3/ATD5
PTA2/ATD4
37 PTA1/ATD3
48 CGMXFC
VDDA
VSSA
NC
47
46
45
44
43
42
41
40
39
38
PTC3/ATD8 1 36 VREFH
NC 2 35 VREFL
PTD0/KBI0 3 34 OPIN2/ATD1
VDD 4 33 PTC7/ATD12
OSC1 5 32 PTA0/ATD2
OSC2 6 31 VSSAM
VSS 7 30 OPIN1/ATD0
PTD1/KBI1 8 29 PTB4/T2CH0
IRQ1 9 28 PTB5/T2CH1
PTD2/KBI2 10 27 PTB6/IRQ2
RST 11 26 PTA6/T1CH0
PTD3/KBI3 12 25 PTD7/KBI7
14
15
16
17
18
19
20
21
22
23
NC 24
PTB0/SDA0 13
PTC0/PWM0/CD
PTB2/SDA1/TxD
PTB3/SCL1/RxD
PTC1/PWM1
PTC2/PWM2
PTB1/SCL0
PTD4/KBI4
PTD5/KBI5
PTD6/KBI6
PTA7/T1CH1
NC: No connection
VDDA 1 42 VSSA
PTC5/ATD10 2 41 PTA4/ATD6
PTC4/ATD9 3 40 PTA3/ATD5
PTA5/ATD7 4 39 PTA2/ATD4
CGMXFC 5 38 PTA1/ATD3
PTC3/ATD8 6 37 VREFH
PTD0/KBI0 7 36 VREFL
VDD 8 35 PTA0/ATD2
OSC1 9 34 VSSAM
OSC2 10 33 OPIN1/ATD0
VSS 11 32 PTB4/T2CH0
PTD1/KBI1 12 31 PTB5/T2CH1
IRQ1 13 30 PTB6/IRQ2
PTD2/KBI2 14 29 PTA6/T1CH0
RST 15 28 PTD7/KBI7
PTD3/KBI3 16 27 PTA7/T1CH1
PTB0/SDA0 17 26 PTC2/PWM2
PTB1/SCL0 18 25 PTC1/PWM1
PTB2/SDA1/TxD 19 24 PTC0/PWM0/CD
PTB3/SCL1/RxD 20 23 PTD6/KBI6
PTD4/KBI4 21 22 PTD5/KBI5
VDD and VSS are the power supply and ground pins. The MCU operates
from a single power supply.
MCU
VDD VSS
C1
0.1 µF
C2
VDD
The OSC1 and OSC2 pins are the connections for the on-chip oscillator
circuit. See Section 7. Oscillator (OSC) and Section 8. Clock
Generator Module (CGM).
A logic 0 on the RST pin forces the MCU to a known start-up state. RST
is bidirectional, allowing a reset of the entire system. It is driven low when
any internal reset source is asserted. This pin contains an internal pullup
resistor. See Section 9. System Integration Module (SIM).
VDDA is the power supply pin for the analog circuits of the MCU.
VSSA is the power supply ground pin for the analog circuits of the MCU.
It should be decoupled as per the VSS digital ground pin.
VREFL is the voltage input pin for the ADC voltage low reference. See
Section 15. Analog-to-Digital Converter (ADC).
VREFH is the voltage input pin for the ADC voltage high reference. See
Section 15. Analog-to-Digital Converter (ADC).
OPIN1/ATD0 and OPIN2/ATD1 are input pins to the analog module and
ADC and VSSAM is the negative reference input. See Section 14.
Analog Module and Section 15. Analog-to-Digital Converter (ADC).
2.1 Contents
2.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2.2 Introduction
The CPU08 can address 64k-bytes of memory space. The memory
map, shown in Figure 2-1, includes:
Data registers are shown in Figure 2-2, Table 2-1 is a list of vector
locations.
$0000
I/O Registers
↓
96 Bytes
$005F
$0060
RAM
↓
512 Bytes
$025F
$0260
Unimplemented
↓
48,544 Bytes
$BFFF
$C000
FLASH Memory
↓
12,288 Bytes
$EFFF
$F000
Unimplemented
↓
3,584 Bytes
$FDFF
$FE00 SIM Break Status Register (SBSR)
$FE01 SIM Reset Status Register (SRSR)
$FE02 Reserved
$FE03 SIM Break Flag Control Register (SBFCR)
$FE04 Interrupt Status Register 1 (INT1)
$FE05 Interrupt Status Register 2 (INT2)
$FE06 Interrupt Status Register 3 (INT3)
$FE07 Reserved
$FE08 FLASH Control Register (FLCR)
$FE09 FLASH Block Protect Register (FLBPR)
$FE0A Reserved
$FE0B Reserved
$FE0C Break Address Register High (BRKH)
$FE0D Break Address Register Low (BRKL)
$FE0E Break Status and Control Register (BRKSCR)
$FE0F LVI Status Register (LVISR)
$FE10
Monitor ROM
↓
368 Bytes
$FF7F
$FF80 Mask Option Register
$FF81
Reserved
↓
89 Bytes
$FFD9
$FFDA
FLASH Vectors
↓
38 Bytes
$FFFF
Figure 2-1. Memory Map
Read: SBSW
SIM Break Status Register R R R R R R R
$FE00 Write: Note
(SBSR)
Reset: 0
Note: Writing a logic 0 clears SBSW.
Read: POR PIN COP ILOP ILAD 0 LVI 0
SIM Reset Status Register
$FE01 Write:
(SRSR)
POR: 1 0 0 0 0 0 0 0
Erased: 1 1 1 1 1 1 1 1
Reset: U U U U U U U U
* MOR is a non-volatile FLASH register; write by programming.
3.1 Contents
3.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.2 Introduction
This section describes the 512 bytes of RAM (random-access memory).
NOTE: For correct operation, the stack pointer must point only to RAM
locations.
Within page zero are 160 bytes of RAM. Because the location of the
stack RAM is programmable, all page zero RAM locations can be used
for I/O control and user data or code. When the stack pointer is moved
from its reset location at $00FF out of page zero, direct addressing mode
instructions can efficiently access all page zero RAM locations. Page
zero RAM, therefore, provides ideal locations for frequently accessed
global variables.
Before processing an interrupt, the CPU uses five bytes of the stack to
save the contents of the CPU registers.
During a subroutine call, the CPU uses two bytes of the stack to store
the return address. The stack pointer decrements during pushes and
increments during pulls.
NOTE: Be careful when using nested subroutines. The CPU may overwrite data
in the RAM during a subroutine or during the interrupt stacking
operation.
4.1 Contents
4.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4.2 Introduction
This section describes the operation of the embedded FLASH memory.
This memory can be read, programmed, and erased from a single
external supply. The program and erase operations are enabled through
the use of an internal charge pump.
Address: $FE08
Bit 7 6 5 4 3 2 1 Bit 0
Read: 0 0 0 0
HVEN MASS ERASE PGM
Write:
Reset: 0 0 0 0 0 0 0 0
1. Set the ERASE bit and clear the MASS bit in the FLASH control
register.
2. Write any data to any FLASH address within the page address
range desired.
3. Wait for a time, tnvs (10µs).
4. Set the HVEN bit.
5. Wait for a time, tErase (1ms).
6. Clear the ERASE bit.
7. Wait for a time, tnvh (5µs).
8. Clear the HVEN bit.
9. After time, trcv (1µs), the memory can be accessed again in read
mode.
1. Set both the ERASE bit and the MASS bit in the FLASH control
register.
2. Write any data to any FLASH address within the FLASH memory
address range.
3. Wait for a time, tnvs (10µs).
4. Set the HVEN bit.
5. Wait for a time tMErase (4ms).
6. Clear the ERASE bit.
7. Wait for a time, tnvhl (100µs).
8. Clear the HVEN bit.
9. After time, trcv (1µs), the memory can be accessed again in read
mode.
1. Set the PGM bit. This configures the memory for program
operation and enables the latching of address and data for
programming.
2. Write any data to any FLASH address within the row address
range desired.
3. Wait for a time, tnvs (10µs).
4. Set the HVEN bit.
5. Wait for a time, tpgs (5µs).
6. Write data to the FLASH address to be programmed.
7. Wait for time, tProg (30µs).
8. Repeat step 6 and 7 until all the bytes within the row are
programmed.
9. Clear the PGM bit.
10. Wait for time, tnvh (5µs).
11. Clear the HVEN bit.
12. After time, trcv (1µs), the memory can be accessed again in read
mode.
This program sequence is repeated throughout the memory until all data
is programmed.
3
Wait for a time, tnvs
4
Set HVEN bit
5
Wait for a time, tpgs
6
Write data to the FLASH address
to be programmed
7
Wait for a time, tProg
Completed Y
programming
this row?
9
NOTE: Clear PGM bit
The time between each FLASH address change (step 6 to step 6), or
the time between the last FLASH address programmed 10
to clearing PGM bit (step 6 to step 9) Wait for a time, tnvh
must not exceed the maximum programming
time, tProg max.
11
Clear HVEN bit
This row program algorithm assumes the row/s
to be programmed are initially erased.
12
Wait for a time, trcv
End of Programming
NOTE: When the FLBPR is cleared (all 0’s), the entire FLASH memory is
protected from being programmed and erased. When all the bits are set,
the entire FLASH memory is accessible for program and erase.
Address: $FE09
Bit 7 6 5 4 3 2 1 Bit 0
Read:
BPR7 BPR6 BPR5 BPR4 BPR3 BPR2 BPR1 BPR0
Write:
Reset: 0 0 0 0 0 0 0 0
BPR[7:1]
and so on...
Note:
The end address of the protected range is always $FFFF.
5.1 Contents
5.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
5.2 Introduction
This section describes the configuration registers, CONFIG1 and
CONFIG2; and the mask option register, MOR.
Freescale Semiconductor Configuration and Mask Option Registers (CONFIG & MOR) 73
Configuration and Mask Option
The mask option register selects one of the following oscillator options
as the MCU reference clock:
• Internal oscillator
• RC oscillator
• Crystal oscillator
Addr. Register Name Bit 7 6 5 4 3 2 1 Bit 0
Read: STOP_ STOP_ STOP_ 0
Configuration Register 2 OSCCLK1 OSCCLK0 CDOEN SCIBDSRC
$001D Write: ICLKEN RCLKEN XCLKEN
(CONFIG2)†
Reset: 0 0 0 0 0 0 0 0
Read:
Configuration Register 1 COPRS LVISTOP LVIRSTD LVIPWRD LVI5OR3 SSREC STOP COPD
$001F † Write:
(CONFIG1)
Reset: 0 0 0 0 0†† 0 0 0
Erased: 1 1 1 1 1 1 1 1
* FLASH register. Reset: U U U U U U U U
† One-time writable register after each reset.
†† Reset by POR only. = Unimplemented R = Reserved
The configuration registers can be written once after each reset. All of
the configuration register bits are cleared during reset. Since the various
options affect the operation of the MCU, it is recommended that these
registers be written immediately after reset. The configuration registers
are located at $001D and $001F. The configurations register may be
read at anytime.
74 Configuration and Mask Option Registers (CONFIG & MOR) Freescale Semiconductor
Configuration and Mask Option Registers (CONFIG & MOR)
Configuration Register 1 (CONFIG1)
NOTE: The options except LVI5OR3 are one-time writable by the user after
each reset. The LVI5OR3 bit is one-time writable by the user only after
each POR (power-on reset). The CONFIG registers are not in the
FLASH memory but are special registers containing one-time writable
latches after each reset. Upon a reset, the CONFIG registers default to
predetermined settings as shown in Figure 5-2 and Figure 5-3.
The mask option register (MOR) is used for selecting one of the three
clock options for the MCU. The MOR is a byte located in FLASH
memory, and is written to by a FLASH programming routine.
Address: $001F
Bit 7 6 5 4 3 2 1 Bit 0
Read:
COPRS LVISTOP LVIRSTD LVIPWRD LVI5OR3 SSREC STOP COPD
Write:
Reset: 0 0 0 0 0* 0 0 0
Freescale Semiconductor Configuration and Mask Option Registers (CONFIG & MOR) 75
Configuration and Mask Option
NOTE: Exiting stop mode by pulling reset will result in the long stop recovery.
NOTE: When the LVI is disabled in stop mode (LVISTOP=0), the system
stabilization time for long stop recovery (4096 ICLK cycles) gives a delay
longer than the LVI’s turn-on time. There is no period where the MCU is
not protected from a low power condition. However, when using the
short stop recovery configuration option, the 32 ICLK delay is less than
the LVI’s turn-on time and there exists a period in start-up where the LVI
is not protecting the MCU.
76 Configuration and Mask Option Registers (CONFIG & MOR) Freescale Semiconductor
Configuration and Mask Option Registers (CONFIG & MOR)
Configuration Register 2 (CONFIG2)
Reset: 0 0 0 0 0 0 0 0
Freescale Semiconductor Configuration and Mask Option Registers (CONFIG & MOR) 77
Configuration and Mask Option
0 1 RC oscillator (RCCLK)
1 1 Not used
78 Configuration and Mask Option Registers (CONFIG & MOR) Freescale Semiconductor
Configuration and Mask Option Registers (CONFIG & MOR)
Mask Option Register (MOR)
Address: $FF80
Bit 7 6 5 4 3 2 1 Bit 0
Read:
OSCSEL1 OSCSEL0 R R R R R R
Write:
Erased: 1 1 1 1 1 1 1 1
Reset: U U U U U U U U
R = Reserved
Freescale Semiconductor Configuration and Mask Option Registers (CONFIG & MOR) 79
Configuration and Mask Option
0 0 — — Not used
NOTE: The internal oscillator is a free running oscillator and is available after
each POR or reset. It is turned-off in stop mode by clearing the
STOP_ICLKEN bit in CONFIG2.
80 Configuration and Mask Option Registers (CONFIG & MOR) Freescale Semiconductor
Data Sheet — MC68HC908SR12•MC68HC08SR12
6.1 Contents
6.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.3 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
6.2 Introduction
The M68HC08 CPU (central processor unit) is an enhanced and fully
object-code-compatible version of the M68HC05 CPU. The CPU08
Reference Manual (Freescale document order number CPU08RM/AD)
contains a description of the CPU instruction set, addressing modes,
and architecture.
6.3 Features
• Object code fully upward-compatible with M68HC05 Family
• 16-bit stack pointer with stack manipulation instructions
• 16-bit index register with x-register manipulation instructions
• 8-MHz CPU internal bus frequency
• 64K-byte program/data memory space
• 16 addressing modes
• Memory-to-memory data moves without using accumulator
• Fast 8-bit by 8-bit multiply and 16-bit by 8-bit divide instructions
• Enhanced binary-coded decimal (BCD) data handling
• Modular architecture with expandable internal bus definition for
extension of addressing range beyond 64K-bytes
• Low-power stop and wait modes
7 0
ACCUMULATOR (A)
15 0
H X INDEX REGISTER (H:X)
15 0
STACK POINTER (SP)
15 0
PROGRAM COUNTER (PC)
7 0
V 1 1 H I N Z C CONDITION CODE REGISTER (CCR)
CARRY/BORROW FLAG
ZERO FLAG
NEGATIVE FLAG
INTERRUPT MASK
HALF-CARRY FLAG
TWO’S COMPLEMENT OVERFLOW FLAG
6.4.1 Accumulator
Bit 7 6 5 4 3 2 1 Bit 0
Read:
Write:
In the indexed addressing modes, the CPU uses the contents of the
index register to determine the conditional address of the operand.
The index register can serve also as a temporary data storage location.
Bit Bit
14 13 12 11 10 9 8 7 6 5 4 3 2 1
15 0
Read:
Write:
Reset: 0 0 0 0 0 0 0 0 X X X X X X X X
X = Indeterminate
The stack pointer is a 16-bit register that contains the address of the next
location on the stack. During a reset, the stack pointer is preset to
$00FF. The reset stack pointer (RSP) instruction sets the least
significant byte to $FF and does not affect the most significant byte. The
stack pointer decrements as data is pushed onto the stack and
increments as data is pulled from the stack.
In the stack pointer 8-bit offset and 16-bit offset addressing modes, the
stack pointer can function as an index register to access data on the
stack. The CPU uses the contents of the stack pointer to determine the
conditional address of the operand.
Bit Bit
14 13 12 11 10 9 8 7 6 5 4 3 2 1
15 0
Read:
Write:
Reset: 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
NOTE: The location of the stack is arbitrary and may be relocated anywhere in
RAM. Moving the SP out of page 0 ($0000 to $00FF) frees direct
address (page 0) space. For correct operation, the stack pointer must
point only to RAM locations.
The program counter is a 16-bit register that contains the address of the
next instruction or operand to be fetched.
During reset, the program counter is loaded with the reset vector
address located at $FFFE and $FFFF. The vector address is the
address of the first instruction to be executed after exiting the reset state.
Bit Bit
14 13 12 11 10 9 8 7 6 5 4 3 2 1
15 0
Read:
Write:
The 8-bit condition code register contains the interrupt mask and five
flags that indicate the results of the instruction just executed. Bits 6 and
Bit 7 6 5 4 3 2 1 Bit 0
Read:
V 1 1 H I N Z C
Write:
Reset: X 1 1 X 1 X X X
X = Indeterminate
V — Overflow Flag
The CPU sets the overflow flag when a two's complement overflow
occurs. The signed branch instructions BGT, BGE, BLE, and BLT use
the overflow flag.
1 = Overflow
0 = No overflow
H — Half-Carry Flag
The CPU sets the half-carry flag when a carry occurs between
accumulator bits 3 and 4 during an add-without-carry (ADD) or add-
with-carry (ADC) operation. The half-carry flag is required for binary-
coded decimal (BCD) arithmetic operations. The DAA instruction uses
the states of the H and C flags to determine the appropriate correction
factor.
1 = Carry between bits 3 and 4
0 = No carry between bits 3 and 4
I — Interrupt Mask
When the interrupt mask is set, all maskable CPU interrupts are
disabled. CPU interrupts are enabled when the interrupt mask is
cleared. When a CPU interrupt occurs, the interrupt mask is set
automatically after the CPU registers are saved on the stack, but
before the interrupt vector is fetched.
1 = Interrupts disabled
0 = Interrupts enabled
NOTE: To maintain M6805 Family compatibility, the upper byte of the index
register (H) is not stacked automatically. If the interrupt service routine
modifies H, then the user must stack and unstack H using the PSHH and
PULH instructions.
N — Negative flag
The CPU sets the negative flag when an arithmetic operation, logic
operation, or data manipulation produces a negative result, setting bit
7 of the result.
1 = Negative result
0 = Non-negative result
Z — Zero flag
The CPU sets the zero flag when an arithmetic operation, logic
operation, or data manipulation produces a result of $00.
1 = Zero result
0 = Non-zero result
C — Carry/Borrow Flag
The CPU sets the carry/borrow flag when an addition operation
produces a carry out of bit 7 of the accumulator or when a subtraction
operation requires a borrow. Some instructions — such as bit test and
branch, shift, and rotate — also clear or set the carry/borrow flag.
1 = Carry out of bit 7
0 = No carry out of bit 7
After exiting stop mode, the CPU clock begins running after the oscillator
stabilization delay.
Effect on
Operand
Address
Opcode
Source CCR
Cycles
Operation Description
Mode
Form
V H I N Z C
AIX #opr Add Immediate Value (Signed) to H:X H:X ← (H:X) + (16 « M) – – – – – – IMM AF ii 2
BCC rel Branch if Carry Bit Clear PC ← (PC) + 2 + rel ? (C) = 0 – – – – – – REL 24 rr 3
DIR (b0) 11 dd 4
DIR (b1) 13 dd 4
DIR (b2) 15 dd 4
DIR (b3) 17 dd 4
BCLR n, opr Clear Bit n in M Mn ← 0 – – – – – –
DIR (b4) 19 dd 4
DIR (b5) 1B dd 4
DIR (b6) 1D dd 4
DIR (b7) 1F dd 4
Effect on
Operand
Address
Opcode
Source CCR
Cycles
Operation Description
Mode
Form
V H I N Z C
BCS rel Branch if Carry Bit Set (Same as BLO) PC ← (PC) + 2 + rel ? (C) = 1 – – – – – – REL 25 rr 3
BHCC rel Branch if Half Carry Bit Clear PC ← (PC) + 2 + rel ? (H) = 0 – – – – – – REL 28 rr 3
BHCS rel Branch if Half Carry Bit Set PC ← (PC) + 2 + rel ? (H) = 1 – – – – – – REL 29 rr 3
BIH rel Branch if IRQ Pin High PC ← (PC) + 2 + rel ? IRQ = 1 – – – – – – REL 2F rr 3
BIL rel Branch if IRQ Pin Low PC ← (PC) + 2 + rel ? IRQ = 0 – – – – – – REL 2E rr 3
BLO rel Branch if Lower (Same as BCS) PC ← (PC) + 2 + rel ? (C) = 1 – – – – – – REL 25 rr 3
BLS rel Branch if Lower or Same PC ← (PC) + 2 + rel ? (C) | (Z) = 1 – – – – – – REL 23 rr 3
BLT opr Branch if Less Than (Signed Operands) PC ← (PC) + 2 + rel ? (N ⊕ V) =1 – – – – – – REL 91 rr 3
BMC rel Branch if Interrupt Mask Clear PC ← (PC) + 2 + rel ? (I) = 0 – – – – – – REL 2C rr 3
BMS rel Branch if Interrupt Mask Set PC ← (PC) + 2 + rel ? (I) = 1 – – – – – – REL 2D rr 3
Effect on
Operand
Address
Opcode
Source CCR
Cycles
Operation Description
Mode
Form
V H I N Z C
DIR (b0) 01 dd rr 5
DIR (b1) 03 dd rr 5
DIR (b2) 05 dd rr 5
DIR (b3) 07 dd rr 5
BRCLR n,opr,rel Branch if Bit n in M Clear PC ← (PC) + 3 + rel ? (Mn) = 0 – – – – – R
DIR (b4) 09 dd rr 5
DIR (b5) 0B dd rr 5
DIR (b6) 0D dd rr 5
DIR (b7) 0F dd rr 5
DIR (b0) 00 dd rr 5
DIR (b1) 02 dd rr 5
DIR (b2) 04 dd rr 5
DIR (b3) 06 dd rr 5
BRSET n,opr,rel Branch if Bit n in M Set PC ← (PC) + 3 + rel ? (Mn) = 1 – – – – – R
DIR (b4) 08 dd rr 5
DIR (b5) 0A dd rr 5
DIR (b6) 0C dd rr 5
DIR (b7) 0E dd rr 5
DIR (b0) 10 dd 4
DIR (b1) 12 dd 4
DIR (b2) 14 dd 4
DIR (b3) 16 dd 4
BSET n,opr Set Bit n in M Mn ← 1 – – – – – –
DIR (b4) 18 dd 4
DIR (b5) 1A dd 4
DIR (b6) 1C dd 4
DIR (b7) 1E dd 4
Effect on
Operand
Address
Opcode
Source CCR
Cycles
Operation Description
Mode
Form
V H I N Z C
A ← (H:A)/(X)
DIV Divide – – – – R R INH 52 7
H ← Remainder
Effect on
Operand
Address
Opcode
Source CCR
Cycles
Operation Description
Mode
Form
V H I N Z C
Effect on
Operand
Address
Opcode
Source CCR
Cycles
Operation Description
Mode
Form
V H I N Z C
MOV opr,opr DD 4E dd dd 5
(M)Destination ← (M)Source
MOV opr,X+ DIX+ 5E dd 4
Move 0 – – R R –
MOV #opr,opr IMD 6E ii dd 4
H:X ← (H:X) + 1 (IX+D, DIX+)
MOV X+,opr IX+D 7E dd 4
Effect on
Operand
Address
Opcode
Source CCR
Cycles
Operation Description
Mode
Form
V H I N Z C
SP ← SP + 1; Pull (PCH)
RTS Return from Subroutine – – – – – – INH 81 4
SP ← SP + 1; Pull (PCL)
Effect on
Operand
Address
Opcode
Source CCR
Cycles
Operation Description
Mode
Form
V H I N Z C
Effect on
Operand
Address
Opcode
Source CCR
Cycles
Operation Description
Mode
Form
V H I N Z C
5 BRCLR2 BCLR2 BCS STHX LDHX LDHX CPHX CPHX TPA TSX BIT BIT BIT BIT BIT BIT BIT BIT
3 DIR 2 DIR 2 REL 2 DIR 3 IMM 2 DIR 3 IMM 2 DIR 1 INH 1 INH 2 IMM 2 DIR 3 EXT 3 IX2 4 SP2 2 IX1 3 SP1 1 IX
5 4 3 4 1 1 4 5 3 2 2 3 4 4 5 3 4 2
6 BRSET3 BSET3 BNE ROR RORA RORX ROR ROR ROR PULA LDA LDA LDA LDA LDA LDA LDA LDA
3 DIR 2 DIR 2 REL 2 DIR 1 INH 1 INH 2 IX1 3 SP1 1 IX 1 INH 2 IMM 2 DIR 3 EXT 3 IX2 4 SP2 2 IX1 3 SP1 1 IX
5 4 3 4 1 1 4 5 3 2 1 2 3 4 4 5 3 4 2
7 BRCLR3 BCLR3 BEQ ASR ASRA ASRX ASR ASR ASR PSHA TAX AIS STA STA STA STA STA STA STA
3 DIR 2 DIR 2 REL 2 DIR 1 INH 1 INH 2 IX1 3 SP1 1 IX 1 INH 1 INH 2 IMM 2 DIR 3 EXT 3 IX2 4 SP2 2 IX1 3 SP1 1 IX
5 4 3 4 1 1 4 5 3 2 1 2 3 4 4 5 3 4 2
8 BRSET4 BSET4 BHCC LSL LSLA LSLX LSL LSL LSL PULX CLC EOR EOR EOR EOR EOR EOR EOR EOR
3 DIR 2 DIR 2 REL 2 DIR 1 INH 1 INH 2 IX1 3 SP1 1 IX 1 INH 1 INH 2 IMM 2 DIR 3 EXT 3 IX2 4 SP2 2 IX1 3 SP1 1 IX
5 4 3 4 1 1 4 5 3 2 1 2 3 4 4 5 3 4 2
9 BRCLR4 BCLR4 BHCS ROL ROLA ROLX ROL ROL ROL PSHX SEC ADC ADC ADC ADC ADC ADC ADC ADC
3 DIR 2 DIR 2 REL 2 DIR 1 INH 1 INH 2 IX1 3 SP1 1 IX 1 INH 1 INH 2 IMM 2 DIR 3 EXT 3 IX2 4 SP2 2 IX1 3 SP1 1 IX
5 4 3 4 1 1 4 5 3 2 2 2 3 4 4 5 3 4 2
A BRSET5 BSET5 BPL DEC DECA DECX DEC DEC DEC PULH CLI ORA ORA ORA ORA ORA ORA ORA ORA
3 DIR 2 DIR 2 REL 2 DIR 1 INH 1 INH 2 IX1 3 SP1 1 IX 1 INH 1 INH 2 IMM 2 DIR 3 EXT 3 IX2 4 SP2 2 IX1 3 SP1 1 IX
5 4 3 5 3 3 5 6 4 2 2 2 3 4 4 5 3 4 2
B BRCLR5 BCLR5 BMI DBNZ DBNZA DBNZX DBNZ DBNZ DBNZ PSHH SEI ADD ADD ADD ADD ADD ADD ADD ADD
3 DIR 2 DIR 2 REL 3 DIR 2 INH 2 INH 3 IX1 4 SP1 2 IX 1 INH 1 INH 2 IMM 2 DIR 3 EXT 3 IX2 4 SP2 2 IX1 3 SP1 1 IX
5 4 3 4 1 1 4 5 3 1 1 2 3 4 3 2
C BRSET6 BSET6 BMC INC INCA INCX INC INC INC CLRH RSP JMP JMP JMP JMP JMP
3 DIR 2 DIR 2 REL 2 DIR 1 INH 1 INH 2 IX1 3 SP1 1 IX 1 INH 1 INH 2 DIR 3 EXT 3 IX2 2 IX1 1 IX
5 4 3 3 1 1 3 4 2 1 4 4 5 6 5 4
D BRCLR6 BCLR6 BMS TST TSTA TSTX TST TST TST NOP BSR JSR JSR JSR JSR JSR
INH Inherent REL Relative SP1 Stack Pointer, 8-Bit Offset MSB
Opcode Map
IMM Immediate IX Indexed, No Offset SP2 Stack Pointer, 16-Bit Offset 0 High Byte of Opcode in Hexadecimal
Data Sheet
DIR Direct IX1 Indexed, 8-Bit Offset IX+ Indexed, No Offset with LSB
EXT Extended IX2 Indexed, 16-Bit Offset Post Increment 5 Cycles
DD Direct-Direct IMD Immediate-Direct IX1+ Indexed, 1-Byte Offset with Low Byte of Opcode in Hexadecimal 0 BRSET0 Opcode Mnemonic
IX+D Indexed-Direct DIX+ Direct-Indexed Post Increment 3 DIR Number of Bytes / Addressing Mode
*Pre-byte for stack pointer indexed instructions
99
Central Processor Unit (CPU)
7.1 Contents
7.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
7.2 Introduction
The oscillator module provides the reference clock for the clock
generator module (CGM), the timebase module (TBM), and other MCU
sub-systems.
• Internal oscillator
• RC oscillator
• Crystal (x-tal) oscillator
The reference clock for the CGM and other MCU sub-systems is
selected by:
The reference clock for the timebase module (TBM) is selected by the
two bits, OSCCLK1 and OSCCLK0, in the CONFIG2 register.
MOR CONFIG2
OSCSEL1 OSCCLK1
MUX MUX
OSCSEL0 OSCCLK0
X RC I X RC I
To SIM
(and COP)
BUS CLOCK
From SIM
OSC1 OSC2
Address: $FF80
Bit 7 6 5 4 3 2 1 Bit 0
Read:
OSCSEL1 OSCSEL0 R R R R R R
Write:
Erased: 1 1 1 1 1 1 1 1
Reset: U U U U U U U U
R = Reserved
0 0 — — Not used
NOTE: The internal oscillator is a free running oscillator and is available after
each POR or reset. It is turned-off in stop mode by clearing the
STOP_ICLKEN bit in CONFIG2.
Address: $001D
Bit 7 6 5 4 3 2 1 Bit 0
Read: STOP_ STOP_ STOP_ 0
OSCCLK1 OSCCLK0 CDOEN SCIBDSRC
Write: ICLKEN RCLKEN XCLKEN
Reset: 0 0 0 0 0 0 0 0
0 1 RC oscillator (RCCLK)
1 1 Not used
NOTE: The RCCLK or XCLK is only available if that clock is selected as the
CGM reference clock, whereas the ICLK is always available.
Due to the simplicity of the internal oscillator, it does not have the
accuracy and stability of the RC oscillator or the x-tal oscillator.
Therefore, the ICLK is not suitable where an accurate bus clock is
required and it should not be used as the CGMRCLK to the CGM PLL.
CONFIG2
EN
STOP_ICLKEN
INTERNAL OSCILLATOR
MCU
OSC2
7.5 RC Oscillator
The RC oscillator circuit is designed for use with external R and C to
provide a clock source with tolerance less than 10%.
• CEXT
• REXT
CONFIG2
EN
STOP_RCLKEN
RC OSCILLATOR
MCU
OSC1 OSC2
See Section 24. for component value requirements.
VDD
REXT CEXT
• Crystal, X1
• Fixed capacitor, C1
• Tuning capacitor, C2 (can also be a fixed capacitor)
• Feedback resistor, RB
• Series resistor, RS (optional)
SIMOSCEN XCLK
CONFIG2
STOP_XCLKEN
MCU
OSC1 OSC2
RB
RS*
*RS can be zero (shorted) when used with higher-frequency crystals. X1
Refer to manufacturer’s data.
See Section 24. for component value requirements.
C1 C2
The series resistor (RS) is included in the diagram to follow strict Pierce
oscillator guidelines and may not be required for all ranges of operation,
especially with high frequency crystals. Refer to the crystal
manufacturer’s data for more information.
OSC1 pin is an input to the crystal oscillator amplifier or the input to the
RC oscillator circuit.
When the x-tal oscillator is selected, OSC2 pin is the output of the crystal
oscillator inverting amplifier.
The OSCCLK is the reference clock that drives the timebase module.
See Section 12. Timebase Module (TBM).
The STOP instruction disables the x-tal or the RC oscillator circuit, and
hence the CGMXCLK clock stops running. For continuous x-tal or RC
oscillator operation in stop mode, set the STOP_XCLKEN (for x-tal) or
STOP_RCLKEN (for RC) bit to logic 1 before entering stop mode.
8.1 Contents
8.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
8.2 Introduction
This section describes the clock generator module (CGM). The CGM
generates the base clock signal, CGMOUT, which is based on either the
oscillator clock divided by two or the divided phase-locked loop (PLL)
clock, CGMPCLK, divided by two. CGMOUT is the clock from which the
SIM derives the system clocks, including the bus clock, which is at a
frequency of CGMOUT÷2. The PLL clock, CGMVCLK (an integer
multiple of CGMPCLK) provides clock reference for the PWM and
analog modules.
The PLL is a frequency generator designed for use with a low frequency
crystal (typically 32.768kHz) to generate a base frequency and dividing
to a maximum bus frequency of 8MHz.
8.3 Features
Features of the CGM include:
SIMOSCEN
From SIM
CGMRDV
REFERENCE CGMRCLK
DIVIDER CLOCK A CGMOUT
BCS SELECT ÷2 B S*1 To SIM
R CIRCUIT
VPR[1:0]
VRS[7:0]
L 2E
CGMPCLK
VOLTAGE CGMVCLK
PHASE LOOP
CONTROLLED
DETECTOR FILTER
OSCILLATOR To PWM,
Analog Module
PLL ANALOG
AUTOMATIC CGMINT
LOCK INTERRUPT
MODE
DETECTOR CONTROL To SIM
CONTROL
MUL[11:0] PRE[1:0]
N 2P
Read: PLLF
PLL Control Register PLLIE PLLON BCS PRE1 PRE0 VPR1 VPR0
$0036 Write:
(PTCL)
Reset: 0 0 1 0 0 0 0 0
Read: LOCK 0 0 0 0
PLL Bandwidth Control AUTO ACQ R
$0037 Register Write:
(PBWC)
Reset: 0 0 0 0 0 0 0
Read: 0 0 0 0
PLL Multiplier Select MUL11 MUL10 MUL9 MUL8
$0038 Register High Write:
(PMSH)
Reset: 0 0 0 0 0 0 0 0
Read:
PLL Multiplier Select MUL7 MUL6 MUL5 MUL4 MUL3 MUL2 MUL1 MUL0
$0039 Register Low Write:
(PMSL)
Reset: 0 1 0 0 0 0 0 0
Read:
PLL VCO Range Select VRS7 VRS6 VRS5 VRS4 VRS3 VRS2 VRS1 VRS0
$003A Register Write:
(PMRS)
Reset: 0 1 0 0 0 0 0 0
Read: 0 0 0 0
PLL Reference Divider RDS3 RDS2 RDS1 RDS0
$003B Select Register Write:
(PMDS)
Reset: 0 0 0 0 0 0 0 1
= Unimplemented R = Reserved
NOTES:
1. When AUTO = 0, PLLIE is forced clear and is read-only.
2. When AUTO = 0, PLLF and LOCK read as clear.
3. When AUTO = 1, ACQ is read-only.
4. When PLLON = 0 or VRS7:VRS0 = $0, BCS is forced clear and is read-only.
5. When PLLON = 1, the PLL programming register is read-only.
6. When BCS = 1, PLLON is forced set and is read-only.
The PLL can change the bandwidth or operational mode of the loop filter
manually or automatically. Automatic mode is recommended for most
users.
The PLL also may operate in manual mode (AUTO = 0). Manual mode
is used by systems that do not require an indicator of the lock condition
for proper operation. Such systems typically operate well below
fBUSMAX.
• ACQ is a writable control bit that controls the mode of the filter.
Before turning on the PLL in manual mode, the ACQ bit must be
clear.
• Before entering tracking mode (ACQ = 1), software must wait a
given time, tACQ (See 8.9 Acquisition/Lock Time
Specifications.), after turning on the PLL by setting PLLON in the
PLL control register (PCTL).
• Software must wait a given time, tAL, after entering tracking mode
before selecting the PLL as the clock source to CGMOUT
(BCS = 1).
• The LOCK bit is disabled.
• CPU interrupts from the CGM are disabled.
NOTE: The round function in the following equations means that the real
number should be rounded to the nearest integer number.
⎧ ⎛ f VCLKDES⎞ ⎛ f VCLKDES⎞ ⎫
R = round R MAX × ⎨ ⎜ --------------------------⎟ – integer ⎜ --------------------------⎟ ⎬
⎩ ⎝ f RCLK ⎠ ⎝ f RCLK ⎠ ⎭
3. Calculate N:
⎛ R × f VCLKDES⎞
N = round ⎜ -------------------------------------⎟
⎝ f P
⎠
RCLK × 2
P
2 N
f VCLK = ----------- ( f RCLK )
R
fVCLK
f BUS = ----------
P
-
2 ×4
Frequency Range E
NOTE: The values for P, E, N, L, and R can only be programmed when the PLL
is off (PLLON = 0).
This circuit is used to select either the oscillator clock, CGMXCLK, or the
divided VCO clock, CGMPCLK, as the source of the base clock,
CGMOUT. The two input clocks go through a transition control circuit
that waits up to three CGMXCLK cycles and three CGMPCLK cycles to
change from one clock source to the other. During this time, CGMOUT
is held in stasis. The output of the transition control circuit is then divided
by two to correct the duty cycle. Therefore, the bus clock frequency,
which is one-half of the base clock frequency, is one-fourth the
frequency of the selected clock (CGMXCLK or CGMPCLK).
The BCS bit in the PLL control register (PCTL) selects which clock drives
CGMOUT. The divided VCO clock cannot be selected as the base clock
source if the PLL is not turned on. The PLL cannot be turned off if the
divided VCO clock is selected. The PLL cannot be turned on or off
simultaneously with the selection or deselection of the divided VCO
clock. The divided VCO clock also cannot be selected as the base clock
source if the factor L is programmed to a 0. This value would set up a
condition inconsistent with the operation of the PLL, so that the PLL
would be disabled and the oscillator clock would be forced as the source
of the base clock.
Care should be taken with PCB routing in order to minimize signal cross
talk and noise. (See 8.9 Acquisition/Lock Time Specifications for
routing information, filter network and its effects on PLL performance.)
MCU
VDD
10 kΩ CBYP
0.01 µF
0.1 µF
0.033 µF
Note: Filter network in box can be replaced with a 0.47µF capacitor, but will degrade stability.
The CGMXFC pin is required by the loop filter to filter out phase
corrections. An external filter network is connected to this pin. (See
Figure 8-3.)
NOTE: To prevent noise problems, the filter network should be placed as close
to the CGMXFC pin as possible, with minimum routing distances and no
routing of other signals across the network.
VDDA is a power pin used by the analog portions of the PLL. Connect the
VDDA pin to the same voltage potential as the VDD pin.
NOTE: Route VDDA carefully for maximum noise immunity and place bypass
capacitors as close as possible to the package.
VSSA is a ground pin used by the analog portions of the PLL. Connect
the VSSA pin to the same voltage potential as the VSS pin.
NOTE: Route VSSA carefully for maximum noise immunity and place bypass
capacitors as close as possible to the package.
CGMXCLK is the oscillator output signal. It runs at the full speed of the
oscillator, and is generated directly from the crystal oscillator circuit, the
RC oscillator circuit, or the internal oscillator circuit.
CGMVCLK is the clock output from the VCO. This clock can be used by
the pulse width modulator (PWM) module to generate high frequency
PWM signals. This clock is also used by the analog module as a
reference for signal sampling.
CGMOUT is the clock output of the CGM. This signal goes to the SIM,
which generates the MCU clocks. CGMOUT is a 50 percent duty cycle
clock running at twice the bus frequency. CGMOUT is software
programmable to be either the oscillator output, CGMXCLK, divided by
two or the divided VCO clock, CGMPCLK, divided by two.
The PLL control register (PCTL) contains the interrupt enable and flag
bits, the on/off switch, the base clock selector bit, the prescaler bits, and
the VCO power-of-two range selector bits.
Address: $0036
Bit 7 6 5 4 3 2 1 Bit 0
Read: PLLF
PLLIE PLLON BCS PRE1 PRE0 VPR1 VPR0
Write:
Reset: 0 0 1 0 0 0 0 0
= Unimplemented
NOTE: Do not inadvertently clear the PLLF bit. Any read or read-modify-write
operation on the PLL control register clears the PLLF bit.
NOTE: PLLON and BCS have built-in protection that prevents the base clock
selector circuit from selecting the VCO clock as the source of the base
clock if the PLL is off. Therefore, PLLON cannot be cleared when BCS
is set, and BCS cannot be set when PLLON is clear. If the PLL is off
(PLLON = 0), selecting CGMPCLK requires two writes to the PLL control
register. (See 8.4.8 Base Clock Selector Circuit.)
Address: $0037
Bit 7 6 5 4 3 2 1 Bit 0
Read: LOCK 0 0 0 0
AUTO ACQ R
Write:
Reset: 0 0 0 0 0 0 0
= Unimplemented R = Reserved
The PLL multiplier select registers (PMSH and PMSL) contain the
programming information for the modulo feedback divider.
Address: $0038
Bit 7 6 5 4 3 2 1 Bit 0
Read: 0 0 0 0
MUL11 MUL10 MUL9 MUL8
Write:
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
Address: $0039
Bit 7 6 5 4 3 2 1 Bit 0
Read:
MUL7 MUL6 MUL5 MUL4 MUL3 MUL2 MUL1 MUL0
Write:
Reset: 0 1 0 0 0 0 0 0
NOTE: The multiplier select bits have built-in protection such that they cannot
be written when the PLL is on (PLLON = 1).
The PLL VCO range select register (PMRS) contains the programming
information required for the hardware configuration of the VCO.
Address: $003A
Bit 7 6 5 4 3 2 1 Bit 0
Read:
VRS7 VRS6 VRS5 VRS4 VRS3 VRS2 VRS1 VRS0
Write:
Reset: 0 1 0 0 0 0 0 0
NOTE: The VCO range select bits have built-in protection such that they cannot
be written when the PLL is on (PLLON = 1) and such that the VCO clock
cannot be selected as the source of the base clock (BCS = 1) if the VCO
range select bits are all clear.
Address: $003B
Bit 7 6 5 4 3 2 1 Bit 0
Read: 0 0 0 0
RDS3 RDS2 RDS1 RDS0
Write:
Reset: 0 0 0 0 0 0 0 1
= Unimplemented
NOTE: The reference divider select bits have built-in protection such that they
cannot be written when the PLL is on (PLLON = 1).
8.7 Interrupts
When the AUTO bit is set in the PLL bandwidth control register (PBWC),
the PLL can generate a CPU interrupt request every time the LOCK bit
changes state. The PLLIE bit in the PLL control register (PCTL) enables
CPU interrupts from the PLL. PLLF, the interrupt flag in the PCTL,
becomes set whether interrupts are enabled or not. When the AUTO bit
is clear, CPU interrupts from the PLL are disabled and PLLF reads as
logic 0.
Software should read the LOCK bit after a PLL interrupt request to see
if the request was due to an entry into lock or an exit from lock. When the
PLL enters lock, the divided VCO clock, CGMPCLK, divided by two can
be selected as the CGMOUT source by setting BCS in the PCTL. When
the PLL exits lock, the VCO clock frequency is corrupt, and appropriate
precautions should be taken. If the application is not frequency sensitive,
interrupts should be disabled to prevent PLL interrupt service routines
from impeding software performance or from exceeding stack
limitations.
NOTE: Software can select the CGMPCLK divided by two as the CGMOUT
source even if the PLL is not locked (LOCK = 0). Therefore, software
should make sure the PLL is locked before setting the BCS bit.
The WAIT instruction does not affect the CGM. Before entering wait
mode, software can disengage and turn off the PLL by clearing the BCS
and PLLON bits in the PLL control register (PCTL) to save power. Less
power-sensitive applications can disengage the PLL without turning it
off, so that the PLL clock is immediately available at WAIT exit. This
would be the case also when the PLL is to wake the MCU from wait
mode, such as when the PLL is first enabled and waiting for LOCK or
LOCK is lost.
To protect the PLLF bit during the break state, write a logic 0 to the BCFE
bit. With BCFE at logic 0 (its default state), software can read and write
the PLL control register during the break state without affecting the PLLF
bit.
Typical control systems refer to the acquisition time or lock time as the
reaction time, within specified tolerances, of the system to a step input.
In a PLL, the step input occurs when the PLL is turned on or when it
suffers a noise hit. The tolerance is usually specified as a percent of the
step input or when the output settles to the desired value plus or minus
a percent of the frequency change. Therefore, the reaction time is
constant in this definition, regardless of the size of the step input. For
example, consider a system with a 5 percent acquisition time tolerance.
If a command instructs the system to change from 0Hz to 1MHz, the
acquisition time is the time taken for the frequency to reach
1MHz ±50kHz. 50kHz = 5% of the 1MHz step input. If the system is
operating at 1MHz and suffers a –100kHz noise hit, the acquisition time
is the time taken to return from 900kHz to 1MHz ±5kHz. 5kHz = 5% of
the 100kHz step input.
Other systems refer to acquisition and lock times as the time the system
takes to reduce the error between the actual output and the desired
output to within specified tolerances. Therefore, the acquisition or lock
time varies according to the original error in the output. Minor errors may
not even be registered. Typical PLL applications prefer to use this
definition because the system requires the output frequency to be within
a certain tolerance of the desired frequency regardless of the size of the
initial error.
The most critical parameter which affects the reaction times of the PLL
is the reference frequency, fRDV. This frequency is the input to the phase
detector and controls how often the PLL makes corrections. For stability,
the corrections must be small compared to the desired frequency, so
several corrections are required to reduce the frequency error.
Therefore, the slower the reference the longer it takes to make these
corrections. This parameter is under user control via the choice of crystal
frequency fXCLK and the R value programmed in the reference divider.
(See 8.4.3 PLL Circuits, 8.4.6 Programming the PLL, and 8.6.5 PLL
Reference Divider Select Register.)
CGMXFC CGMXFC
10 kΩ
0.01 µF
0.47 µF
0.033 µF
VSSA VSSA
(a) (b)
9.1 Contents
9.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
9.2 Introduction
This section describes the system integration module (SIM). Together
with the CPU, the SIM controls all MCU activities. A block diagram of the
SIM is shown in Figure 9-1. Table 9-1 is a summary of the SIM
input/output (I/O) registers. The SIM is a system state controller that
coordinates CPU and exception timing. The SIM is responsible for:
Table 9-1 shows the internal signal names used in this section.
MODULE STOP
MODULE WAIT
STOP/WAIT CPU STOP (FROM CPU)
CONTROL CPU WAIT (FROM CPU)
SIMOSCEN (TO CGM, OSC)
÷2
VDD CLOCK
CONTROL CLOCK GENERATORS INTERNAL CLOCKS
INTERNAL
PULLUP
DEVICE
RESET
OSC2
OSCCLK
TO TBM
OSCILLATOR (OSC) MODULE
CGMXCLK
OSC1 TO TIM, ADC
ICLK
SIM COUNTER SIMOSCEN
STOP MODE CLOCK
ENABLE SIGNALS
FROM CONFIG2 SYSTEM INTEGRATION MODULE IT12
CGMRCLK
TO REST
OF MCU
CGMOUT BUS CLOCK IT23
÷2
GENERATORS TO REST
PHASE-LOCKED LOOP (PLL) OF MCU
PTC1
SIMDIV2
MONITOR MODE
USER MODE
CGMVCLK
TO PWM
In user mode, the internal bus frequency is either the oscillator output
(CGMXCLK) divided by four or the divided PLL output (CGMPCLK)
divided by four.
Upon exit from stop mode by an interrupt, break, or reset, the SIM allows
ICLK to clock the SIM counter. The CPU and peripheral clocks do not
become active until after the stop delay timeout. This timeout is
selectable as 4096 or 32 ICLK cycles. (See 9.7.2 Stop Mode.)
In wait mode, the CPU clocks are inactive. The SIM also produces two
sets of clocks for other modules. Refer to the wait mode subsection of
each module to see if the module is active or inactive in wait mode.
Some modules can be programmed to be active in wait mode.
An internal reset clears the SIM counter (see 9.5 SIM Counter), but an
external reset does not. Each of the resets sets a corresponding bit in
the SIM reset status register (SRSR). (See 9.8 SIM Registers.)
The RST pin circuit includes an internal pull-up device. Pulling the
asynchronous RST pin low halts all processing. The PIN bit of the SIM
reset status register (SRSR) is set as long as RST is held low for a
minimum of 67 ICLK cycles, assuming that neither the POR nor the LVI
was the source of the reset. See Table 9-2 for details.
Figure 9-4 shows the relative timing.
ICLK
RST
All internal reset sources actively pull the RST pin low for 32 ICLK cycles
to allow resetting of external peripherals. The internal reset signal IRST
continues to be asserted for an additional 32 cycles (see Figure 9-5). An
internal reset can be caused by an illegal address, illegal opcode, COP
timeout, LVI, or POR (see Figure 9-6).
NOTE: For LVI or POR resets, the SIM cycles through 4096 + 32 ICLK cycles
during which the SIM forces the RST pin low. The internal reset signal
then follows the sequence from the falling edge of RST shown in
Figure 9-5.
IRST
32 CYCLES 32 CYCLES
ICLK
The active reset feature allows the part to issue a reset to peripherals
and other chips within a system built around the MCU.
When power is first applied to the MCU, the power-on reset module
(POR) generates a pulse to indicate that power-on has occurred. The
external reset pin (RST) is held low while the SIM counter counts out
4096 + 32 ICLK cycles. Thirty-two ICLK cycles later, the CPU and
memories are released from reset to allow the reset vector sequence to
occur.
At power-on, these events occur:
• A POR pulse is generated.
• The internal reset signal is asserted.
• The SIM enables CGMOUT.
• Internal clocks to the CPU and modules are held inactive for 4096
ICLK cycles to allow stabilization of the oscillator.
• The RST pin is driven low during the oscillator stabilization time.
• The POR bit of the SIM reset status register (SRSR) is set and all
other bits in the register are cleared.
OSC1
PORRST
4096 32 32
CYCLES CYCLES CYCLES
ICLK
CGMOUT
RST
IRST
An input to the SIM is reserved for the COP reset signal. The overflow of
the COP counter causes an internal reset and sets the COP bit in the
SIM reset status register (SRSR). The SIM actively pulls down the RST
pin for all internal reset sources.
The COP module is disabled if the RST pin or the IRQ1 pin is held at
VTST while the MCU is in monitor mode. The COP module can be
disabled only through combinational logic conditioned with the high
voltage signal on the RST or the IRQ1 pin. This prevents the COP from
becoming disabled as a result of external noise. During a break state,
VTST on the RST pin disables the COP module.
The SIM decodes signals from the CPU to detect illegal instructions. An
illegal instruction sets the ILOP bit in the SIM reset status register
(SRSR) and causes a reset.
If the stop enable bit, STOP, in the mask option register is logic 0, the
SIM treats the STOP instruction as an illegal opcode and causes an
illegal opcode reset. The SIM actively pulls down the RST pin for all
internal reset sources.
The low-voltage inhibit module (LVI) asserts its output to the SIM when
the VDD voltage falls to the LVITRIPF voltage. The LVI bit in the SIM reset
status register (SRSR) is set, and the external reset pin (RST) is held low
while the SIM counter counts out 4096 + 32 ICLK cycles. Thirty-two ICLK
cycles later, the CPU is released from reset to allow the reset vector
sequence to occur. The SIM actively pulls down the RST pin for all
internal reset sources.
The monitor mode entry module reset asserts its output to the SIM when
monitor mode is entered in the condition where the reset vectors are
blank ($FF). (See Section 10. Monitor ROM (MON).) When MODRST
gets asserted, an internal reset occurs. The SIM actively pulls down the
RST pin for all internal reset sources.
The power-on reset module (POR) detects power applied to the MCU.
At power-on, the POR circuit asserts the signal PORRST. Once the SIM
is initialized, it enables the clock generation module (CGM) to drive the
bus clock state machine.
The SIM counter also is used for stop mode recovery. The STOP
instruction clears the SIM counter. After an interrupt, break, or reset, the
SIM senses the state of the short stop recovery bit, SSREC, in the
configuration register 1 (CONFIG1). If the SSREC bit is a logic 1, then
the stop recovery is reduced from the normal delay of 4096 ICLK cycles
down to 32 ICLK cycles. This is ideal for applications using canned
oscillators that do not require long start-up times from stop mode.
External crystal applications should use the full stop recovery time, that
is, with SSREC cleared.
External reset has no effect on the SIM counter. (See 9.7.2 Stop Mode
for details.) The SIM counter is free-running after all reset states. (See
9.4.2 Active Resets from Internal Sources for counter control and
internal reset recovery sequences.)
• Interrupts:
– Maskable hardware CPU interrupts
– Non-maskable software interrupt instruction (SWI)
• Reset
• Break interrupts
9.6.1 Interrupts
MODULE
INTERRUPT
I-BIT
R/W
MODULE
INTERRUPT
I-BIT
IAB SP – 4 SP – 3 SP – 2 SP – 1 SP PC PC + 1
R/W
Interrupts are latched, and arbitration is performed in the SIM at the start
of interrupt processing. The arbitration result is a constant that the CPU
uses to determine which vector to fetch. Once an interrupt is latched by
the SIM, no other interrupt can take precedence, regardless of priority,
until the latched interrupt is serviced (or the I bit is cleared).
(See Figure 9-10.)
FROM RESET
BREAK
I BIT SET? YES
INTERRUPT?
NO
YES
I-BIT SET?
NO
IRQ1 YES
INTERRUPT?
NO
FETCH NEXT
INSTRUCTION
SWI YES
INSTRUCTION?
NO
RTI YES
INSTRUCTION? UNSTACK CPU REGISTERS
NO
EXECUTE INSTRUCTION
CLI
INT1 PSHH
INT2 PSHH
The LDA opcode is prefetched by both the INT1 and INT2 RTI
instructions. However, in the case of the INT1 RTI prefetch, this is a
redundant operation.
NOTE: To maintain compatibility with the M6805 Family, the H register is not
pushed on the stack during interrupt entry. If the interrupt service routine
modifies the H register or uses the indexed addressing mode, software
should save the H register and then restore it prior to exiting the routine.
NOTE: A software interrupt pushes PC onto the stack. A software interrupt does
not push PC – 1, as a hardware interrupt does.
Address: $FE04
Bit 7 6 5 4 3 2 1 Bit 0
Write: R R R R R R R R
Reset: 0 0 0 0 0 0 0 0
R = Reserved
Address: $FE05
Bit 7 6 5 4 3 2 1 Bit 0
Write: R R R R R R R R
Reset: 0 0 0 0 0 0 0 0
R = Reserved
Address: $FE06
Bit 7 6 5 4 3 2 1 Bit 0
Write: R R R R R R R R
Reset: 0 0 0 0 0 0 0 0
R = Reserved
9.6.2 Reset
All reset sources always have equal and highest priority and cannot be
arbitrated.
The SIM controls whether status flags contained in other modules can
be cleared during break mode. The user can select whether flags are
protected from being cleared by properly initializing the break clear flag
enable bit (BCFE) in the SIM break flag control register (SBFCR).
Protecting flags in break mode ensures that set flags will not be cleared
while in break mode. This protection allows registers to be freely read
and written during break mode without losing status flag information.
Setting the BCFE bit enables the clearing mechanisms. Once cleared in
break mode, a flag remains cleared even when break mode is exited.
Status flags with a 2-step clearing mechanism — for example, a read of
one register followed by the read or write of another — are protected,
even when the first step is accomplished prior to entering break mode.
Upon leaving break mode, execution of the second step will clear the flag
as normal.
In wait mode, the CPU clocks are inactive while the peripheral clocks
continue to run. Figure 9-15 shows the timing for wait mode entry.
A module that is active during wait mode can wake up the CPU with an
interrupt if the interrupt is enabled. Stacking for the interrupt begins one
cycle after the WAIT instruction during which the interrupt occurred. In
wait mode, the CPU clocks are inactive. Refer to the wait mode
subsection of each module to see if the module is active or inactive in
wait mode. Some modules can be programmed to be active in wait
mode.
R/W
NOTE: Previous data can be operand data or the WAIT opcode, depending on the
last instruction.
Figure 9-16 and Figure 9-17 show the timing for WAIT recovery.
EXITSTOPWAIT
32 32
CYCLES CYCLES
RST
ICLK
In stop mode, the SIM counter is reset and the system clocks are
disabled. An interrupt request from a module can cause an exit from stop
mode. Stacking for interrupts begins after the selected stop recovery
time has elapsed. Reset or break also causes an exit from stop mode.
The SIM disables the clock generator module output (CGMOUT) in stop
mode, stopping the CPU and peripherals. Stop recovery time is
selectable using the SSREC bit in the configuration register 1
(CONFIG1). If SSREC is set, stop recovery is reduced from the normal
delay of 4096 ICLK cycles down to 32. This is ideal for applications using
canned oscillators that do not require long start-up times from stop
mode.
NOTE: External crystal applications should use the full stop recovery time by
clearing the SSREC bit.
A break interrupt during stop mode sets the SIM break stop/wait bit
(SBSW) in the SIM break status register (SBSR).
The SIM counter is held in reset from the execution of the STOP
instruction until the beginning of stop recovery. It is then used to time the
recovery period. Figure 9-18 shows stop mode entry timing.
NOTE: To minimize stop current, all pins configured as inputs should be driven
to a logic 1 or logic 0.
CPUSTOP
R/W
NOTE: Previous data can be operand data or the STOP opcode, depending on the last
instruction.
ICLK
INT/BREAK
The SIM break status register (SBSR) contains a flag to indicate that a
break caused an exit from stop mode or wait mode.
Address: $FE00
Bit 7 6 5 4 3 2 1 Bit 0
Read: SBSW
R R R R R R R
Write: Note
Reset: 0
Note: Writing a logic 0 clears SBSW. R = Reserved
This status bit is set when a break interrupt causes an exit from wait
mode or stop mode. Clear SBSW by writing a logic 0 to it. Reset clears
SBSW.
1 = Stop mode or wait mode was exited by break interrupt
0 = Stop mode or wait mode was not exited by break interrupt
SBSW can be read within the break interrupt routine. The user can
modify the return address on the stack by subtracting 1 from it. The
following code is an example.
This code works if the H register has been pushed onto the stack in the break
service routine software. This code should be executed at the end of the break
service routine software.
HIBYTE EQU
LOBYTE EQU
If not SBSW, do RTI
BRCLR SBSW,SBSR, RETURN ; See if wait mode or stop mode was exited by
; break.
TST LOBYTE,SP ;If RETURNLO is not zero,
BNE DOLO ;then just decrement low byte.
DEC HIBYTE,SP ;Else deal with high byte, too.
DOLO DEC LOBYTE,SP ;Point to WAIT/STOP opcode.
RETURN PULH ;Restore H register.
RTI
This register contains six flags that show the source of the last reset
provided all previous reset status bits have been cleared. Clear the SIM
reset status register by reading it. A power-on reset sets the POR bit and
clears all other bits in the register.
Address: $FE01
Bit 7 6 5 4 3 2 1 Bit 0
Write:
Reset: 1 0 0 0 0 0 0 0
= Unimplemented
The SIM break control register contains a bit that enables software to
clear status bits while the MCU is in a break state.
Address: $FE03
Bit 7 6 5 4 3 2 1 Bit 0
Read:
BCFE R R R R R R R
Write:
Reset: 0
R = Reserved
10.1 Contents
10.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
10.2 Introduction
This section describes the monitor ROM (MON) and the monitor mode
entry methods. The monitor ROM allows complete testing of the MCU
through a single-wire interface with a host computer. Monitor mode entry
can be achieved without use of the higher test voltage, VTST, as long as
vector addresses $FFFE and $FFFF are blank, thus reducing the
hardware requirements for in-circuit programming.
10.3 Features
Features of the monitor ROM include:
68HC908SR12
RST
0.1 µF
VTST
(SEE NOTE 3) RESET VECTORS
$FFFE
10 kΩ
(SEE NOTES 2 $FFFF
AND 3)
C SW2
IRQ1
D
CGMXFC
0.01 µF
4.9152MHz/9.8304MHz 10 kΩ
0.033 µF
C SW3
OSC1
6–30 pF (SEE NOTE 2)
1 20
MC145407
+ + D OSC2
10 MΩ
10 µF 10 µF
SW4
3 18 C (SEE NOTE 2) VSS
32.768 kHz XTAL
4 17 330 kΩ VSSA
D
+ VSSAM
10 µF 10 µF VDD 6–30 pF
+ 2 19 VREFL
DB-25 VDD
2 5 16
VDD
3 6 15 VDDA
VREFH
7 0.1 µF
VDD
VDD
1 14
MC74HC125
2 3 10 kΩ
PTA0
6 5
4 PTC1
VDD
7 VDD
A PTA1
SW1
(SEE NOTE 1) PTA2
B
Notes:
1. For monitor mode entry when SW2 at position C (IRQ1 = VTST):
SW1: Position A — Bus clock = CGMXCLK ÷ 4
SW1: Position B — Bus clock = CGMXCLK ÷ 2
2. SW2, SW3, and SW4: Position C — Enter monitor mode using off-chip oscillator only.
SW2, SW3, and SW4: Position D — Enter monitor mode using 32.768kHz XTAL and internal PLL.
3. See Table 24-5 for IRQ1 voltage level requirements.
4. See Table 10-1 for other monitor mode entry configurations.
The monitor code allows enabling the PLL to generate the internal clock,
provided the reset vector is blank ($FF), when the device is being
clocked by a low-frequency crystal. This entry method, which is enabled
when IRQ1 is held low out of reset, is intended to support serial
communication/programming at 9600 baud in monitor mode by stepping
up the external frequency (assumed to be 32.768 kHz) by a fixed amount
to generate the desired internal frequency (2.4576 MHz).
If the reset vector is not blank (not $FF), the frequency stepping feature
is not supported, because IRQ1 cannot be held low for monitor mode
entry. With a non-blank reset vector, entry into monitor mode requires
VTST on IRQ1.
Table 10-1 shows the pin conditions for entering monitor mode. As
specified in the table, monitor mode may be entered after a POR and will
allow communication at 9600 baud provided one of the following sets of
conditions is met:
VTST VDD X 0 1 1 0 4.9152 2.4576 OFF Disabled 9600 PTA1 and PTA2
or MHz(2) MHz voltages only
VTST required if
IRQ1 = VTST;
PTC1 determines
frequency divider
VTST VDD X 0 1 1 1 9.8304 2.4576 OFF Disabled 9600 PTA1 and PTA2
or MHz(2) MHz voltages only
VTST required if
Monitor ROM (MON)
IRQ1 = VTST;
PTC1 determines
frequency divider
VDD VDD Blank X X 1 X 9.8304 2.4576 OFF Disabled 9600 External frequency
"$FFFF" MHz(3) MHz always divided by 4
Functional Description
Notes:
If VTST is applied to IRQ1 and PTC1 is low upon monitor mode entry
(above condition set 1), the bus frequency is a divide-by-two of the input
clock. If PTC1 is high with VTST applied to IRQ1 upon monitor mode
entry, the bus frequency will be a divide-by-four of the input clock.
Holding the PTC1 pin low when entering monitor mode causes a bypass
of a divide-by-two stage at the oscillator only if VTST is applied to IRQ1.
In this event, the CGMOUT frequency is equal to the CGMXCLK
frequency, and the OSC1 input directly generates internal bus clocks. In
this case, the OSC1 signal must have a 50% duty cycle at maximum bus
frequency.
NOTE: If the reset vector is blank and monitor mode is entered, the chip will see
an additional reset cycle after the initial POR reset. Once the part has
been programmed, the traditional method of applying a voltage, VTST, to
IRQ1 must be used to enter monitor mode.
Figure 10-2 shows a simplified diagram of the monitor mode entry when
the reset vector is blank and just 1 x VDD voltage is applied to the IRQ1
pin. An external oscillator of 9.8304 MHz is required for a baud rate of
9600, as the internal bus frequency is automatically set to the external
frequency divided by four.
POR RESET
YES
MONITOR MODE
EXECUTE
MONITOR
CODE
POR NO
TRIGGERED?
YES
Once out of reset, the MCU waits for the host to send eight security
bytes. (See 10.5 Security.) After the security bytes, the MCU sends a
break signal (10 consecutive logic 0s) to the host, indicating that it is
ready to receive a command.
In monitor mode, the MCU uses different vectors for reset, SWI
(software interrupt), and break interrupt than those for user mode. The
alternate vectors are in the $FE page instead of the $FF page and allow
code execution from the internal monitor firmware instead of user code.
NOTE: Exiting monitor mode after it has been initiated by having a blank reset
vector requires a power-on reset (POR). Pulling RST low will not exit
monitor mode in this situation.
Table 10-2 summarizes the differences between user mode and monitor
mode.
NEXT
START START
BIT BIT 0 BIT 1 BIT 2 BIT 3 BIT 4 BIT 5 BIT 6 BIT 7 STOP BIT
BIT
A start bit (logic 0) followed by nine logic 0 bits is a break signal. When
the monitor receives a break signal, it drives the PTA0 pin high for the
duration of two bits and then echoes back the break signal.
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
If monitor mode was entered with VDD on IRQ1, then the divide by ratio
is set at 1024, regardless of PTC1. If monitor mode was entered with VSS
on IRQ, then the internal PLL steps up the external frequency, presumed
to be 32.768 kHz, to 2.4576 MHz. These latter two conditions for monitor
mode entry require that the reset vector is blank.
10.4.5 Commands
The monitor ROM firmware echoes each received byte back to the PTA0
pin for error checking. An 11-bit delay at the end of each command
allows the host to send a break character to cancel the command. A
delay of two bit times occurs before each echo and before READ,
IREAD, or READSP data is returned. The data returned by a read
command appears after the echo of the last byte of the command.
NOTE: Wait one bit time after each echo before sending the next byte.
FROM
HOST
4 1 4 1 4 1 3, 2 4
ECHO RETURN
Notes:
1 = Echo delay, 2 bit times
2 = Data return delay, 2 bit times
3 = Cancel command delay, 11 bit times
4 = Wait 1 bit time before sending next byte.
FROM
HOST
Data
Returns contents of specified address
Returned
Opcode $4A
Command Sequence
SENT TO
MONITOR
ECHO RETURN
Data
Returned None
Opcode $49
Command Sequence
FROM
HOST
ECHO
Data
Returns contents of next two addresses
Returned
Opcode $1A
Command Sequence
FROM
HOST
ECHO RETURN
Data
None
Returned
Opcode $19
Command Sequence
FROM
HOST
ECHO
Operand None
Opcode $0C
Command Sequence
FROM
HOST
SP SP
READSP READSP HIGH LOW
ECHO RETURN
Operand None
Data None
Returned
Opcode $28
Command Sequence
FROM
HOST
RUN RUN
ECHO
The MCU executes the SWI and PSHH instructions when it enters
monitor mode. The RUN command tells the MCU to execute the PULH
and RTI instructions. Before sending the RUN command, the host can
modify the stacked CPU registers to prepare to run the host program.
The READSP command returns the incremented stack pointer value,
SP + 1. The high and low bytes of the program counter are at addresses
SP + 5 and SP + 6.
SP
HIGH BYTE OF INDEX REGISTER SP + 1
CONDITION CODE REGISTER SP + 2
ACCUMULATOR SP + 3
LOW BYTE OF INDEX REGISTER SP + 4
HIGH BYTE OF PROGRAM COUNTER SP + 5
LOW BYTE OF PROGRAM COUNTER SP + 6
SP + 7
10.5 Security
A security feature discourages unauthorized reading of FLASH locations
while in monitor mode. The host can bypass the security feature at
monitor mode entry by sending eight security bytes that match the bytes
at locations $FFF6–$FFFD. Locations $FFF6–$FFFD contain user-
defined data.
During monitor mode entry, the MCU waits after the power-on reset for
the host to send the eight security bytes on pin PTA0. If the received
bytes match those at locations $FFF6–$FFFD, the host bypasses the
security feature and can read all FLASH locations and execute code
from FLASH. Security remains bypassed until a power-on reset occurs.
If the reset was not a power-on reset, security remains bypassed and
security code entry is not required. (See Figure 10-8.)
VDD
RST
COMMAND
BYTE 1
BYTE 2
BYTE 8
FROM HOST
PTA0
1 4 1 1 2 4 1
FROM MCU
COMMAND ECHO
BYTE 1 ECHO
BYTE 2 ECHO
BYTE 8 ECHO
BREAK
NOTES:
1 = Echo delay, 2 bit times.
2 = Data return delay, 2 bit times.
4 = Wait 1 bit time before sending next byte.
Upon power-on reset, if the received bytes of the security code do not
match the data at locations $FFF6–$FFFD, the host fails to bypass the
security feature. The MCU remains in monitor mode, but reading a
FLASH location returns an invalid value and trying to execute code from
FLASH causes an illegal address reset. After receiving the eight security
bytes from the host, the MCU transmits a break character, signifying that
it is ready to receive a command.
NOTE: The MCU does not transmit a break character until after the host sends
the eight security bits.
11.1 Contents
11.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
11.2 Introduction
This section describes the timer interface (TIM) module. The TIM is a
two-channel timer that provides a timing reference with input capture,
output compare, and pulse-width-modulation functions. Figure 11-1 is a
block diagram of the TIM.
This particular MCU has two timer interface modules which are denoted
as TIM1 and TIM2.
11.3 Features
Features of the TIM include:
NOTE: References to either timer 1 or timer 2 may be made in the following text
by omitting the timer number. For example, TCH0 may refer generically
to T1CH0 and T2CH0, and TCH1 may refer to T1CH1 and T2CH1.
PRESCALER SELECT
INTERNAL
BUS CLOCK PRESCALER
TSTOP
PS2 PS1 PS0
TRST
TOV0
CHANNEL 0 ELS0B ELS0A CH0MAX PORT
T[1,2]CH0
LOGIC
16-BIT COMPARATOR
TCH0H:TCH0L CH0F
16-BIT LATCH INTERRUPT
LOGIC
MS0A CH0IE
MS0B
TOV1
CHANNEL 1 ELS1B ELS1A CH1MAX PORT
T[1,2]CH1
INTERNAL BUS
LOGIC
16-BIT COMPARATOR
TCH1H:TCH1L CH1F
16-BIT LATCH INTERRUPT
LOGIC
MS1A CH1IE
NOTE: References to either timer 1 or timer 2 may be made in the following text
by omitting the timer number. For example, TSC may generically refer to
both T1SC and T2SC.
Read: TOF 0 0
Timer 1 Status and Control TOIE TSTOP PS2 PS1 PS0
$0020 Write: 0 TRST
Register (T1SC)
Reset: 0 0 1 0 0 0 0 0
Read:
Timer 1 Counter Modulo Bit 15 14 13 12 11 10 9 Bit 8
$0023 Write:
Register High (T1MODH)
Reset: 1 1 1 1 1 1 1 1
Read:
Timer 1 Counter Modulo Bit 7 6 5 4 3 2 1 Bit 0
$0024 Write:
Register Low (T1MODL)
Reset: 1 1 1 1 1 1 1 1
Read: CH0F
Timer 1 Channel 0 Status CH0IE MS0B MS0A ELS0B ELS0A TOV0 CH0MAX
$0025 and Control Register Write: 0
(T1SC0)
Reset: 0 0 0 0 0 0 0 0
Read:
Timer 1 Channel 0 Bit 15 14 13 12 11 10 9 Bit 8
$0026 Write:
Register High (T1CH0H)
Reset: Indeterminate after reset
Read:
Timer 1 Channel 0 Bit 7 6 5 4 3 2 1 Bit 0
$0027 Write:
Register Low (T1CH0L)
Reset: Indeterminate after reset
Read: CH1F 0
Timer 1 Channel 1 Status CH1IE MS1A ELS1B ELS1A TOV1 CH1MAX
$0028 and Control Register Write: 0
(T1SC1)
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
Read:
Timer 1 Channel 1 Bit 15 14 13 12 11 10 9 Bit 8
$0029 Write:
Register High (T1CH1H)
Reset: Indeterminate after reset
Read:
Timer 1 Channel 1 Bit 7 6 5 4 3 2 1 Bit 0
$002A Write:
Register Low (T1CH1L)
Reset: Indeterminate after reset
Read: TOF 0 0
Timer 2 Status and Control TOIE TSTOP PS2 PS1 PS0
$002B Write: 0 TRST
Register (T2SC)
Reset: 0 0 1 0 0 0 0 0
Read:
Timer 2 Counter Modulo Bit 15 14 13 12 11 10 9 Bit 8
$002E Write:
Register High (T2MODH)
Reset: 1 1 1 1 1 1 1 1
Read:
Timer 2 Counter Modulo Bit 7 6 5 4 3 2 1 Bit 0
$002F Write:
Register Low (T2MODL)
Reset: 1 1 1 1 1 1 1 1
Read: CH0F
Timer 2 Channel 0 Status CH0IE MS0B MS0A ELS0B ELS0A TOV0 CH0MAX
$0030 and Control Register Write: 0
(T2SC0)
Reset: 0 0 0 0 0 0 0 0
Read:
Timer 2 Channel 0 Bit 15 14 13 12 11 10 9 Bit 8
$0031 Write:
Register High (T2CH0H)
Reset: Indeterminate after reset
= Unimplemented
Read:
Timer 2 Channel 0 Bit 7 6 5 4 3 2 1 Bit 0
$0032 Write:
Register Low (T2CH0L)
Reset: Indeterminate after reset
Read: CH1F 0
Timer 2 Channel 1 Status CH1IE MS1A ELS1B ELS1A TOV1 CH1MAX
$0033 and Control Register Write: 0
(T2SC1)
Reset: 0 0 0 0 0 0 0 0
Read:
Timer 2 Channel 1 Bit 15 14 13 12 11 10 9 Bit 8
$0034 Write:
Register High (T2CH1H)
Reset: Indeterminate after reset
Read:
Timer 2 Channel 1 Bit 7 6 5 4 3 2 1 Bit 0
$0035 Write:
Register Low (T2CH1L)
Reset: Indeterminate after reset
= Unimplemented
The TIM clock source can be one of the seven prescaler outputs. The
prescaler generates seven clock rates from the internal bus clock. The
prescaler select bits, PS[2:0], in the TIM status and control register
select the TIM clock source.
With the input capture function, the TIM can capture the time at which an
external event occurs. When an active edge occurs on the pin of an input
capture channel, the TIM latches the contents of the TIM counter into the
TIM channel registers, TCHxH:TCHxL. The polarity of the active edge is
programmable. Input captures can generate TIM CPU interrupt
requests.
With the output compare function, the TIM can generate a periodic pulse
with a programmable polarity, duration, and frequency. When the
counter reaches the value in the registers of an output compare channel,
the TIM can set, clear, or toggle the channel pin. Output compares can
generate TIM CPU interrupt requests.
Setting the MS0B bit in TIM channel 0 status and control register (TSC0)
links channel 0 and channel 1. The output compare value in the TIM
channel 0 registers initially controls the output on the TCH0 pin. Writing
to the TIM channel 1 registers enables the TIM channel 1 registers to
synchronously control the output after the TIM overflows. At each
subsequent overflow, the TIM channel registers (0 or 1) that control the
output are the ones written to last. TSC0 controls and monitors the
buffered output compare function, and TIM channel 1 status and control
register (TSC1) is unused. While the MS0B bit is set, the channel 1 pin,
TCH1, is available as a general-purpose I/O pin.
NOTE: In buffered output compare operation, do not write new output compare
values to the currently active channel registers. User software should
track the currently active channel to prevent writing a new value to the
active channel. Writing to the active channel registers is the same as
generating unbuffered output compares.
As Figure 11-3 shows, the output compare value in the TIM channel
registers determines the pulse width of the PWM signal. The time
between overflow and output compare is the pulse width. Program the
TIM to clear the channel pin on output compare if the state of the PWM
pulse is logic 1. Program the TIM to set the pin if the state of the PWM
pulse is logic 0.
The value in the TIM counter modulo registers and the selected
prescaler output determines the frequency of the PWM output. The
frequency of an 8-bit PWM signal is variable in 256 increments. Writing
$00FF (255) to the TIM counter modulo registers produces a PWM
period of 256 times the internal bus clock period if the prescaler select
value is $000. See 11.10.1 TIM Status and Control Register.
PERIOD
PULSE
WIDTH
TCHx
The value in the TIM channel registers determines the pulse width of the
PWM output. The pulse width of an 8-bit PWM signal is variable in 256
increments. Writing $0080 (128) to the TIM channel registers produces
a duty cycle of 128/256 or 50%.
NOTE: In PWM signal generation, do not program the PWM channel to toggle
on output compare. Toggling on output compare prevents reliable 0%
duty cycle generation and removes the ability of the channel to self-
correct in the event of software error or noise. Toggling on output
compare also can cause incorrect PWM signal generation when
changing the PWM pulse width to a new, much larger value.
Setting the MS0B bit in TIM channel 0 status and control register (TSC0)
links channel 0 and channel 1. The TIM channel 0 registers initially
control the pulse width on the TCH0 pin. Writing to the TIM channel 1
registers enables the TIM channel 1 registers to synchronously control
the pulse width at the beginning of the next PWM period. At each
subsequent overflow, the TIM channel registers (0 or 1) that control the
pulse width are the ones written to last. TSC0 controls and monitors the
buffered PWM function, and TIM channel 1 status and control register
(TSC1) is unused. While the MS0B bit is set, the channel 1 pin, TCH1,
is available as a general-purpose I/O pin.
NOTE: In buffered PWM signal generation, do not write new pulse width values
to the currently active channel registers. User software should track the
currently active channel to prevent writing a new value to the active
channel. Writing to the active channel registers is the same as
generating unbuffered PWM signals.
NOTE: In PWM signal generation, do not program the PWM channel to toggle
on output compare. Toggling on output compare prevents reliable 0%
duty cycle generation and removes the ability of the channel to self-
correct in the event of software error or noise. Toggling on output
compare can also cause incorrect PWM signal generation when
changing the PWM pulse width to a new, much larger value.
5. In the TIM status control register (TSC), clear the TIM stop bit,
TSTOP.
Setting MS0B links channels 0 and 1 and configures them for buffered
PWM operation. The TIM channel 0 registers (TCH0H:TCH0L) initially
control the buffered PWM output. TIM status control register 0 (TSCR0)
controls and monitors the PWM signal from the linked channels.
Setting the channel x maximum duty cycle bit (CHxMAX) and setting the
TOVx bit generates a 100% duty cycle output. (See 11.10.4 TIM
Channel Status and Control Registers.)
11.6 Interrupts
The following TIM sources can generate interrupt requests:
• TIM overflow flag (TOF) — The TOF bit is set when the TIM
counter reaches the modulo value programmed in the TIM counter
modulo registers. The TIM overflow interrupt enable bit, TOIE,
enables TIM overflow CPU interrupt requests. TOF and TOIE are
in the TIM status and control register.
• TIM channel flags (CH1F:CH0F) — The CHxF bit is set when an
input capture or output compare occurs on channel x. Channel x
TIM CPU interrupt requests are controlled by the channel x
interrupt enable bit, CHxIE. Channel x TIM CPU interrupt requests
are enabled when CHxIE = 1. CHxF and CHxIE are in the TIM
channel x status and control register.
The TIM remains active after the execution of a WAIT instruction. In wait
mode, the TIM registers are not accessible by the CPU. Any enabled
CPU interrupt request from the TIM can bring the MCU out of wait mode.
If TIM functions are not required during wait mode, reduce power
consumption by stopping the TIM before executing the WAIT instruction.
The TIM is inactive after the execution of a STOP instruction. The STOP
instruction does not affect register conditions or the state of the TIM
counter. TIM operation resumes when the MCU exits stop mode after an
external interrupt.
To protect status bits during the break state, write a logic 0 to the BCFE
bit. With BCFE at logic 0 (its default state), software can read and write
I/O registers during the break state without affecting status bits. Some
status bits have a 2-step read/write clearing procedure. If software does
the first step on such a bit before the break, the bit cannot change during
the break state as long as BCFE is at logic 0. After the break, doing the
second step clears the status bit.
Bit 7 6 5 4 3 2 1 Bit 0
Read: TOF 0 0
TOIE TSTOP PS2 PS1 PS0
Write: 0 TRST
Reset: 0 0 1 0 0 0 0 0
= Unimplemented
NOTE: Do not set the TSTOP bit before entering wait mode if the TIM is required
to exit wait mode.
NOTE: Setting the TSTOP and TRST bits simultaneously stops the TIM counter
at a value of $0000.
The two read-only TIM counter registers contain the high and low bytes
of the value in the TIM counter. Reading the high byte (TCNTH) latches
the contents of the low byte (TCNTL) into a buffer. Subsequent reads of
TCNTH do not affect the latched TCNTL value until TCNTL is read.
Reset clears the TIM counter registers. Setting the TIM reset bit (TRST)
also clears the TIM counter registers.
NOTE: If you read TCNTH during a break interrupt, be sure to unlatch TCNTL
by reading TCNTL before exiting the break interrupt. Otherwise, TCNTL
retains the value latched during the break.
Bit 7 6 5 4 3 2 1 Bit 0
Write:
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
Bit 7 6 5 4 3 2 1 Bit 0
Write:
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
The read/write TIM modulo registers contain the modulo value for the
TIM counter. When the TIM counter reaches the modulo value, the
overflow flag (TOF) becomes set, and the TIM counter resumes counting
from $0000 at the next timer clock. Writing to the high byte (TMODH)
inhibits the TOF bit and overflow interrupts until the low byte (TMODL) is
written. Reset sets the TIM counter modulo registers.
Bit 7 6 5 4 3 2 1 Bit 0
Read:
Bit 15 14 13 12 11 10 9 Bit 8
Write:
Reset: 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 Bit 0
Read:
Bit 7 6 5 4 3 2 1 Bit 0
Write:
Reset: 1 1 1 1 1 1 1 1
NOTE: Reset the TIM counter before writing to the TIM counter modulo registers.
Bit 7 6 5 4 3 2 1 Bit 0
Read: CH0F
CH0IE MS0B MS0A ELS0B ELS0A TOV0 CH0MAX
Write: 0
Reset: 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 Bit 0
Read: CH1F 0
CH1IE MS1A ELS1B ELS1A TOV1 CH1MAX
Write: 0
Reset: 0 0 0 0 0 0 0 0
When ELSxB:ELSxA = 0:0, this read/write bit selects the initial output
level of the TCHx pin. See Table 11-3. Reset clears the MSxA bit.
1 = Initial output level low
0 = Initial output level high
NOTE: Before changing a channel function by writing to the MSxB or MSxA bit,
set the TSTOP and TRST bits in the TIM status and control register
(TSC).
NOTE: Before enabling a TIM channel register for input capture operation, make
sure that the TCHx pin is stable for at least two bus clocks.
NOTE: When TOVx is set, a TIM counter overflow takes precedence over a
channel x output compare if both occur at the same time.
PERIOD
TCHx
These read/write registers contain the captured TIM counter value of the
input capture function or the output compare value of the output
compare function. The state of the TIM channel registers after reset is
unknown.
In input capture mode (MSxB:MSxA = 0:0), reading the high byte of the
TIM channel x registers (TCHxH) inhibits input captures until the low
byte (TCHxL) is read.
Bit 7 6 5 4 3 2 1 Bit 0
Read:
Bit 15 14 13 12 11 10 9 Bit 8
Write:
Bit 7 6 5 4 3 2 1 Bit 0
Read:
Bit 7 6 5 4 3 2 1 Bit 0
Write:
Bit 7 6 5 4 3 2 1 Bit 0
Read:
Bit 15 14 13 12 11 10 9 Bit 8
Write:
Bit 7 6 5 4 3 2 1 Bit 0
Read:
Bit 7 6 5 4 3 2 1 Bit 0
Write:
12.1 Contents
12.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
12.2 Introduction
This section describes the timebase module (TBM). The TBM will
generate periodic interrupts at user selectable rates using a counter
clocked by the selected OSCCLK clock from the oscillator module. This
TBM version uses 18 divider stages, eight of which are user selectable.
12.3 Features
Features of the TBM module include:
• Software programmable 8s, 4s, 2s, 1s, 2ms, 1ms, 0.5ms, and
0.25ms periodic interrupt using 32.768-kHz OSCCLK clock
• User selectable oscillator clock source enable during stop mode to
allow periodic wake-up from stop
The reference clock OSCCLK is derived from the oscillator module, see
7.3.2 TBM Reference Clock Selection.
TBON
OSCCLK ÷2 ÷2 ÷2 ÷2 ÷2 ÷2 ÷2 ÷2 ÷2 ÷2 ÷2
From OSC module
(See Section 7. Oscillator (OSC).) ÷8 ÷ 16 ÷ 32 ÷ 64 ÷ 2048
TBMINT
TACK
TBR0
TBR2
TBR1
÷2 ÷2 ÷2 ÷2 ÷2 ÷2 ÷2
TBIF TBIE
000
R
001
010
011
100 SEL
101
110
111
Address: $0046
Bit 7 6 5 4 3 2 1 Bit 0
Read: TBIF 0
TBR2 TBR1 TBR0 TBIE TBON R
Write: TACK
Reset: 0 0 0 0 0 0 0 0
= Unimplemented R = Reserved
12.6 Interrupts
The timebase module can interrupt the CPU on a regular basis with a
rate defined by TBR2–TBR0. When the timebase counter chain rolls
over, the TBIF flag is set. If the TBIE bit is set, enabling the timebase
interrupt, the counter chain overflow will generate a CPU interrupt
request. The interrupt vector is defined in Table 2-1 . Vector
Addresses.
If the timebase functions are not required during wait mode, reduce the
power consumption by stopping the timebase before enabling the WAIT
instruction.
The timebase module may remain active after execution of the STOP
instruction if the oscillator has been enabled to operate during stop mode
through the stop mode oscillator enable bit (STOP_ICLKEN,
STOP_RCLKEN, or STOP_XCLKEN) for the selected oscillator in the
CONFIG2 register. The timebase module can be used in this mode to
generate a periodic walk-up from stop mode.
If the oscillator has not been enabled to operate in stop mode, the
timebase module will not be active during STOP mode. In stop mode the
timebase register is not accessible by the CPU.
If the timebase functions are not required during stop mode, reduce the
power consumption by stopping the timebase before enabling the STOP
instruction.
13.1 Contents
13.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
13.2 Introduction
This section describes the pulse width modulator (PWM) module. The
PWM module provides three 8-bit PWM output channels, with an
independent 8-bit counter for each channel. The PWM period is equal to
1
256 × --------------- seconds, where PCLK is the PWM counter clock.
P CLK
For a 32MHz PWM counter clock, the PWM period is 8µs (a PWM
frequency of 125kHz). The automatic phase control feature allows
phase delays between the channels.
Figure 13-2 shows the structure of the PWM module.
NOTE: The CGM’s PLL must be running (enabled by setting PLLON bit in the
PLL control register) if the CGMVCLK is selected for the PWM module
input clock. (See Section 8. Clock Generator Module (CGM).)
13.3 Features
Features of the PWM include the following:
INTERNAL BUS
PWMCLK A CGMOUT
CHANNEL 0 ÷2 ÷2 ÷2 FROM CGM
PWMCR B1 CGMVCLK
S
8-BIT PWM PCLK1 WHEN PCLKSEL=0,
DATA REGISTER MUX PWMCLK=CGMOUT.
PCLK0 PCLKSEL
PWMR0 IF CGMVCLK IS SELECTED,
PWMCCR CGM’S PLL MUST BE RUNNING.
PCLK
8-BIT
DATA REGISTER 8-BIT COUNTER 8-BIT COUNTER 8-BIT COUNTER
BUFFER
TO TO
CHANNEL 1 CHANNEL 2
ZERO
COMPARATOR
DETECTOR
A IS SELECTED
WHEN S=0
TO/FROM
PTC0 PCH0 CDIF CDOEN
LOGIC
PWMCR FROM CONFIG2
ANALOG
MODULE
PWM1 B1 PTC1/PWM1
PWM2 B1 PTC2/PWM2
TO/FROM A PIN TO/FROM A PIN
S S
PTC1 PTC2
LOGIC LOGIC
A IS SELECTED A IS SELECTED
WHEN S=0 WHEN S=0
PCH1 PCH2
PWMCR PWMCR
1 1
The PWM period is equal to 256 × --------------- , resolution is --------------- , where
P CLK P CLK
PCLK is the PWM counter clock. The value in the PWM data register
(PWMDR) defines the period where the PWM output is high, the low
period is equal to 256 minus that value. Each PWM channel has its own
counter and I/O control bits so it can be turned on and off independently.
Figure 13-3 shows the PWM output waveforms for a channel with
different values in the PWM data register.
PWMDR = 256
T 255 × T
PWMDR = 1
255 × T T
PWMDR = 255
1
NOTE: T =
PCLK
Figure 13-4 shows the phase delays between the PWM output signals.
256 × T 256 × T
PWM2
PWM1
PWM0
When phase control is enabled, the PWM2 counter will start counting
immediately, but the PWM1 and PWM0 counters will be held at zero.
After the PWM2 counter reaches the phase value, PH[0:6], the PWM1
counter is released and starts counting. Finally, when the PMW1 counter
reaches the phase value, PH[0:6], PWM0 is released and starts
counting. It is possible to change the value of PH[0:6] after the PWM1
counter has started and before the start of the PWM0 counter. This way,
difference phases can be set between PWM2 and PWM1; PWM1 and
PWM0.
The PH[0:6] value is used once to determine the start-up time of the
different PWM counters. After that, all PWM counters become free
running counters and the phase between the counters will remain
unchanged. Changing the value of PH[0:6] after all PWM counters are
running has no effect. The counters must first be disabled by clearing the
PWM enable bits, PWMEN[0:2], to logic 0, before a new phase value is
effective.
If PWM functions are not required during wait mode, reduce power
consumption by disabling the PWM before executing the WAIT
instruction.
Address: $0051
Read: 0 0
PWMEN2 PWMEN1 PWMEN0 PCH2 PCH1 PCH0
Write:
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
0 0 PTC0
PTC0/PWM0/CD 0 1 PWM0
1 X CD
The PWM clock control register (PWMCCR) selects and defines the
clock to the PWM counter, PCLK.
Address: $0052
Read: 0 0 0 0 0
PCLKSEL PCLK1 PCLK0
Write:
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
0 0 Source clock ÷ 1
0 1 Source clock ÷ 2
1 0 Source clock ÷ 4
1 1 Source clock ÷ 8
Address: $0053
Read:
0PWMD7 0PWMD6 0PWMD5 0PWMD4 0PWMD3 0PWMD2 0PWMD1 0PWMD0
Write:
Reset: 0 0 0 0 0 0 0 0
Address: $0054
Read:
1PWMD7 1PWMD6 1PWMD5 1PWMD4 1PWMD3 1PWMD2 1PWMD1 1PWMD0
Write:
Reset: 0 0 0 0 0 0 0 0
Address: $0055
Read:
2PWMD7 2PWMD6 2PWMD5 2PWMD4 2PWMD3 2PWMD2 2PWMD1 2PWMD0
Write:
Reset: 0 0 0 0 0 0 0 0
The value of each PWM data register is continuously compared with the
content of a PWM counter to determine the state of each PWM channel
output pin.
A new value written to the PWM data register will not be effective until
the end of the current PWM period. Upon the end of the current PWM
period, the contain of the PWM data register is loaded into the PWM data
buffer, the value of the PWM data buffer controls the PWM output.
Address: $0056
Read:
PHEN PHD6 PHD5 PHD4 PHD3 PHD2 PHD1 PHD0
Write:
Reset: 0 0 0 0 0 0 0 0
14.1 Contents
14.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
14.2 Introduction
This section describes the analog module. The analog module is
designed to be use in conjunction with the analog-to-digital converter
module for monitoring temperature, charge and discharge currents in
smart battery applications.
NOTE: The analog module uses clock signals from the CGM’s PLL, therefore
the PLL must be running — PLLON bit in the PLL control register must
be set. (See Section 8. Clock Generator Module (CGM).)
14.3 Features
The features of the analog module include the following:
• Temperature sensor
• Current flow detection amplifier
• Two-stage amplifier
ATD1
BATT +
ATD0 TO ADC ANALOG MODULE
ADCICLK
FROM ADC
INTERNAL
BATT – INTERNAL
TEMPERATURE
SENSOR REFERENCE
–
OPCH[1:0] DOF
TSOUT
BATT + +
CGMVCLK
FROM CGM
IN3
IN2 OPOUT
2-STAGE TO ADC
OPIN1/ AMP
IN1
ISENSE ATD0
IN0
RSENSE
0.01Ω OPIFR OPIF
–9mV D Q TO IRQ
– CDIF LOGIC
VSSA +
VDET R
Read:
Analog Module Control PWR1 PWR0 OPCH1 OPCH0 AMIEN DO2 DO1 DO0
$000E Register Write:
(AMCR)
Reset: 0 0 0 0 0 0 0 0
Read:
Analog Module Gain GAINB3 GAINB2 GAINB1 GAINB0 GAINA3 GAINA2 GAINA1 GAINA0
$000F Control Register Write:
(AMGCR)
Reset: 0 0 0 0 0 0 0 0
= Unimplemented U = Unaffected
The two-stage amplifier is used to amplify small input signals from the
on-chip temperature sensor or external voltage sources such as external
thermistor and current sensing resistor, for temperature and current
monitoring. The amplified signal, OPOUT, is fed to the ADC module for
analog-to-digital conversion. The gain of the two-stage amplifier is
defined by the GAINAx and GAINBx bits in the analog module gain
control register (AMGCR) (see Figure 14-1).
The AMCLK clock is the analog amplifier clock, which is divided from the
ADC clock, ADCICLK.
The time for the two-stage amplifier to amplify the input signal to the
desired output is dependent on the gain setting in both stages of the two-
stage amplifier. The amplifier response time is determined by the
formula:
The current detect flag, CDIF, can be configured for direct control to
other external circuitry. When the CDOEN bit in CONFIG2 is set, the
status of CDIF is reflected on the PTC0/PWM0/CD pin. (See 5.5
Configuration Register 2 (CONFIG2) and 18.5 Port C.)
14.5 Interrupts
When the AMIEN bit is set, the analog module is capable of generating
CPU interrupt requests. The interrupt vector is defined in Table 2-1 .
Vector Addresses.
In stop mode, the temperature sensor and the two-stage amplifier are
disabled, but the current flow detection amplifier (when enabled)
continues to operate if the oscillator is enabled in stop mode. When
AMIEN is set, CDIF can be used to wake-up the MCU from the stop
mode.
Address: $000E
Bit 7 6 5 4 3 2 1 Bit 0
Read:
PWR1 PWR0 OPCH1 OPCH0 AMIEN DO2 DO1 DO0
Write:
Reset: 0 0 0 0 0 0 0 0
0 1 On Off Off
1 0 Off Off On
1 1 On On On
The analog module gain control register (AMGCR) selects the two gains
for the two-stage amplifier.
Address: $000F
Bit 7 6 5 4 3 2 1 Bit 0
Read:
GAINB3 GAINB2 GAINB1 GAINB0 GAINA3 GAINA2 GAINA1 GAINA0
Write:
Reset: 0 0 0 0 0 0 0 0
Address: $0010
Bit 7 6 5 4 3 2 1 Bit 0
Reset: 0 0 U 0 0 0 U 0
= Unimplemented U = Unaffected
0 0 2
0 1 4
1 0 8
1 1 16
Set AMCDIV1 and AMCDIV0 bits to zero for optimum analog module
performance.
15.1 Contents
15.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
15.2 Introduction
This section describes the analog-to-digital converter (ADC). The ADC
is a 14-channel 10-bit linear successive approximation ADC.
15.3 Features
Features of the ADC module include:
When the input voltage to the ADC equals VREFH, the ADC converts the
signal to $3FF (full scale). If the input voltage equals VREFL, the ADC
converts it to $000. Input voltages between VREFH and VREFL is a
straight-line linear conversion. All other input voltages will result in $3FF
if greater than VREFH and $000 if less than VREFL.
NOTE: Input voltage should not exceed the analog supply voltages.
INTERNAL
DATA BUS
READ DDRAx/DDRCx
DISABLE
WRITE DDRAx/DDRCx
DDRAx/DDRCx
RESET
WRITE PTAx/PTCx
PTAx/PTCx PTAx/PTCx
READ PTAx/PTCx
ATD2–ATD12
(11 CHANNELS)
DISABLE
ADC DATA REGISTERS OPIN1
ADRH0 ADRL0
OPIN2
ADRL1
ADRL2 VREFH
ADRL3
VREFL
OPOUT
FROM
ADC ANALOG MODULE
CONVERSION VOLTAGE IN
INTERRUPT COMPLETE (VADIN) CHANNEL
ADC
LOGIC SELECT
ADCH[4:0]
ADIV[2:0] ADICLK
Conversion starts after a write to the ADSCR. One conversion will take
between 16 and 17 ADC clock cycles, therefore:
16 to17 ADC cycles
Conversion time =
ADC frequency
The ADC conversion time is determined by the clock source chosen and
the divide ratio selected. The clock source is either the bus clock or
CGMXCLK and is selectable by the ADICLK bit located in the ADC clock
register. The divide ratio is selected by the ADIV[2:0] bits.
NOTE: The ADC frequency must be between fADIC minimum and fADIC
maximum to meet ADC specifications. (See 24.12 5.0V ADC Electrical
Characteristics.)
Since an ADC cycle may comprised of several bus cycles (two in the
previous example) and the start of a conversion is initiated by a bus cycle
write to the ADSCR, from zero to two additional bus cycles may occur
before the start of the initial ADC cycle. This results in a fractional ADC
cycle and is represented as the 17th cycle.
NOTE: When OPOUT is selected as the ADC input, VADIN, the conversion time
is the accumulation of the op-amp settling time and the normal ADC
conversion time. After writing to the ADSCR to initiate a conversion
cycle, the ADC module sends a signal to the analog module for a
OPOUT output. A signal will be sent back to the ADC by the analog
module to indicate that OPOUT signal is ready for sampling. Upon
receiving this signal, the ADC module starts its normal conversion cycle.
(See 24.12 5.0V ADC Electrical Characteristics.)
In auto-scan mode, the ADC input channel is selected by the value of the
2-bit up-counter, instead of the channel select bits, ADCH[4:0]. The
value of the counter also defines the data register ADRLx to be used to
store the conversion result. When ASCAN bit is set, a write to ADC
status and control register (ADSCR) will reset the auto-scan up-counter
and ADC conversion will start on the channel 0 up to the channel number
defined by the integer value of AUTO[1:0]. After a channel conversion is
completed, data is stored in ADRLx and the COCO-bit will be set. The
counter value will be incremented by 1 and a new conversion will start.
This process will continue until the counter value reaches the value of
AUTO[1:0]. When this happens, it indicates that the current channel is
the last channel to be converted. Upon the completion on the last
channel, the counter value will not be incremented and no further
conversion will be performed. To start another auto-scan cycle, a write
to ADSCR must be performed.
NOTE: The system only provides 8-bit data storage in auto-scan code, user
must clear MODE[1:0] bits to select 8-bit truncation mode before
entering auto-scan mode.
• Left justified
• Right justified
• Left justified sign data mode
• 8-bit truncation
All four of these modes are controlled using MODE0 and MODE1 bits
located in the ADC clock control register (ADICLK).
Left justification will place the eight most significant bits (MSB) in the
corresponding ADC data register high (ADRH). This may be useful if the
result is to be treated as an 8-bit result where the least significant two
bits, located in the ADC data register low (ADRL) can be ignored.
However, you must read ADRL after ADRH or else the interlocking will
prevent all new conversions from being stored.
Right justification will place only the two MSBs in the corresponding ADC
data register high (ADRH) and the eight LSB bits in ADC data register
low (ADRL). This mode of operation typically is used when a 10-bit
unsigned result is desired.
Left justified sign data mode is similar to left justified mode with one
exception. The MSB of the 10-bit result, AD9 located in ADRH is
complemented. This mode of operation is useful when a result,
represented as a signed magnitude from mid-scale, is needed.
Finally, 8-bit truncation mode will place the eight MSBs in ADC data
register low (ADRL). The two LSBs are dropped. This mode of operation
is used when compatibility with 8-bit ADC designs are required. No
interlocking between ADRH and ADRL is present.
Reading ADRH in any 10-bit mode latches the contents of ADRL until
ADRL is read. Until ADRL is read all subsequent ADC results will be lost.
This register interlocking can also be reset by a write to the ADC status
and control register, or ADC clock control register. A power-on reset or
reset will also clear the interlocking. Note that an external conversion
request will not reset the lock.
15.4.8 Monotonicity
15.5 Interrupts
When the AIEN bit is set, the ADC module is capable of generating a
CPU interrupt after each ADC conversion or after an auto-scan
conversion cycle. A CPU interrupt is generated if the COCO bit is at
logic 0. The COCO bit is not used as a conversion complete flag when
interrupts are enabled. The interrupt vector is defined in Table 2-1 .
Vector Addresses.
The ADC continues normal operation in wait mode. Any enabled CPU
interrupt request from the ADC can bring the MCU out of wait mode. If
the ADC is not required to bring the MCU out of wait mode, power down
the ADC by setting the ADCH[4:0] bits to logic 1’s before executing the
WAIT instruction.
VADIN is the input voltage signal from one of the fourteen channels to the
ADC module.
The ADC analog portion uses VDDA as its power pin. Connect the VDDA
pin to the same voltage potential as VDD. External filtering may be
necessary to ensure clean VDDA for good results.
NOTE: Route VDDA carefully for maximum noise immunity and place bypass
capacitors as close as possible to the package.
The ADC analog portion uses VSSA as its ground pin. Connect the VSSA
pin to the same voltage potential as VSS.
VREFH is the power supply for setting the reference voltage VREFH.
Connect the VREFH pin to the same voltage potential as VDDA. There will
be a finite current associated with VREFH (see Section 24. Electrical
Specifications).
NOTE: Route VREFH carefully for maximum noise immunity and place bypass
capacitors as close as possible to the package.
VREFL is the lower reference supply for the ADC. Connect the VREFL pin
to the same voltage potential as VSSA. There will be a finite current
associated with VREFL (see Section 24. Electrical Specifications).
Address: $0057
Read: COCO
AIEN ADCO ADCH4 ADCH3 ADCH2 ADCH1 ADCH0
Write:
Reset: 0 0 0 1 1 1 1 1
= Unimplemented
NOTE: Care should be taken when using a port pin as both an analog and a
digital input simultaneously to prevent switching noise from corrupting
the analog signal.
NOTE: Recovery from the disabled state requires one conversion cycle to
stabilize.
The ADC clock control register (ADICLK) selects the clock frequency for
the ADC.
Address: $0058
Read: 0 0
ADIV2 ADIV1 ADIV0 ADICLK MODE1 MODE0
Write: R
Reset: 0 0 0 0 0 1 0 0
= Unimplemented R = Reserved
The ADC data register 0 consist of a pair of 8-bit registers: high byte
(ADRH0), and low byte (ADRL0). This pair form a 16-bit register to store
the 10-bit ADC result for the selected ADC result justification mode.
In 8-bit truncated mode, the ADRL0 holds the eight most significant bits
(MSBs) of the 10-bit result. The ADRL0 is updated each time an ADC
conversion completes. In 8-bit truncated mode, ADRL0 contains no
interlocking with ADRH0. (See Figure 15-5 . ADRH0 and ADRL0 in 8-
Bit Truncated Mode.)
In right justified mode the ADRH0 holds the two MSBs, and the ADRL0
holds the eight least significant bits (LSBs), of the 10-bit result. ADRH0
and ADRL0 are updated each time a single channel ADC conversion
completes. Reading ADRH0 latches the contents of ADRL0. Until
ADRL0 is read all subsequent ADC results will be lost.
(See Figure 15-6 . ADRH0 and ADRL0 in Right Justified Mode.)
In left justified mode the ADRH0 holds the eight most significant bits
(MSBs), and the ADRL0 holds the two least significant bits (LSBs), of the
10-bit result. The ADRH0 and ADRL0 are updated each time a single
channel ADC conversion completes. Reading ADRH0 latches the
contents of ADRL0. Until ADRL0 is read all subsequent ADC results will
be lost. (See Figure 15-7 . ADRH0 and ADRL0 in Left Justified Mode.)
In left justified sign mode the ADRH0 holds the eight MSBs with the MSB
complemented, and the ADRL0 holds the two least significant bits
(LSBs), of the 10-bit result. The ADRH0 and ADRL0 are updated each
time a single channel ADC conversion completes. Reading ADRH0
latches the contents of ADRL0. Until ADRL0 is read all subsequent ADC
results will be lost. (See Figure 15-8 . ADRH0 and ADRL0 in Left
Justified Sign Data Mode.)
Figure 15-8. ADRH0 and ADRL0 in Left Justified Sign Data Mode
Write: R R R R R R R R
Reset: 0 0 0 0 0 0 0 0
R = Reserved
The ADC auto-scan control register (ADASCR) enables and controls the
ADC auto-scan function.
Address: $005E
Read: 0 0 0 0 0
AUTO1 AUTO0 ASCAN
Write:
Reset: 0 0 0 0 0 0 0 0
= Unimplemented R = Reserved
0 0 ATD0 only
0 1 ATD0 to ATD1
1 0 ATD0 to ATD2
1 1 ATD0 to ATD3
16.1 Contents
16.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
16.2 Introduction
This section describes the serial communications interface (SCI)
module, which allows high-speed asynchronous communications with
peripheral devices and other MCUs.
NOTE: When the SCI is enabled, the TxD pin is an open-drain output and
requires a pullup resistor to be connected for proper SCI operation.
16.3 Features
Features of the SCI module include the following:
• Full-duplex operation
• Standard mark/space non-return-to-zero (NRZ) format
• 32 programmable baud rates
• Programmable 8-bit or 9-bit character length
• Separately enabled transmitter and receiver
• Separate receiver and transmitter CPU interrupt requests
• Programmable transmitter output polarity
SCI I/O (input/output) lines are implemented by sharing parallel I/O port
pins. The full name of an SCI input or output reflects the name of the
shared port pin. Table 16-1 shows the full names and the generic names
of the SCI I/O pins. The generic pin names appear in the text of this
section.
NOTE: When the SCI is enabled, the TxD pin is an open-drain output and
requires a pullup resistor to be connected for proper SCI operation.
The baud rate clock source for the SCI can be selected via the
configuration bit, SCIBDSRC, of the CONFIG2 register ($001D). Source
selection values are shown in Figure 16-1.
INTERNAL BUS
TRANSMITTER
INTERRUPT
INTERRUPT
INTERRUPT
INTERRUPT
RECEIVER
CONTROL
CONTROL
CONTROL
CONTROL
ERROR
DMA
RECEIVE TRANSMIT
RxD TxD
SHIFT REGISTER SHIFT REGISTER
TXINV
SCTIE
R8
TCIE
T8
SCRIE
ILIE
DMARE
TE
SCTE DMATE
RE
TC
RWU
SCRF OR ORIE
SBK
IDLE NF NEIE
FE FEIE
PE PEIE
LOOPS
LOOPS ENSCI
SCIBDSRC M
FROM BKF
CONFIG ENSCI WAKE
RPF
ILTY
SL PRE- BAUD PEN
CGMXCLK A ÷4
X SCALER DIVIDER
IT12 B PTY
SL = 0 => X = A
SL = 1 => X = B
÷ 16 DATA SELECTION
CGMXCLK is from CGM module CONTROL
IT12 = fBUS
Read:
SCI Control Register 1 LOOPS ENSCI TXINV M WAKE ILTY PEN PTY
$0013 Write:
(SCC1)
Reset: 0 0 0 0 0 0 0 0
Read:
SCI Control Register 2 SCTIE TCIE SCRIE ILIE TE RE RWU SBK
$0014 Write:
(SCC2)
Reset: 0 0 0 0 0 0 0 0
Read: R8
SCI Control Register 3 T8 DMARE DMATE ORIE NEIE FEIE PEIE
$0015 Write:
(SCC3)
Reset: U U 0 0 0 0 0 0
Read: R7 R6 R5 R4 R3 R2 R1 R0
SCI Data Register
$0018 Write: T7 T6 T5 T4 T3 T2 T1 T0
(SCDR)
Reset: Unaffected by reset
Read: 0 0
SCI Baud Rate Register SCP1 SCP0 R SCR2 SCR1 SCR0
$0019 Write:
(SCBR)
Reset: 0 0 0 0 0 0 0 0
16.5.2 Transmitter
The baud rate clock source for the SCI can be selected via the
configuration bit, SCIBDSRC. Source selection values are shown in
Figure 16-4.
SCIBDSRC
FROM
CONFIG2
SL
CGMXCLK A
X
IT12 B
SL = 0 => X = A
SL = 1 => X = B INTERNAL BUS
PRE- BAUD
÷4 SCALER DIVIDER ÷ 16 SCI DATA REGISTER
SCP1
11-BIT
START
STOP
SCP0 TRANSMIT
SHIFT REGISTER
SCR1
H 8 7 6 5 4 3 2 1 0 L TxD
SCR2
SCR0
MSB
TRANSMITTER CPU INTERRUPT REQUEST
TXINV
M
LOAD FROM SCDR
PEN PARITY
SHIFT ENABLE
GENERATION
PREAMBLE
PTY
BREAK
ALL 0s
T8 ALL 1s
DMATE TRANSMITTER
DMATE CONTROL LOGIC
SCTIE
SCTE
SCTE SBK
DMATE
SCTE
LOOPS
SCTIE
SCTIE ENSCI
TC
TC TE
TCIE
TCIE
The transmitter can accommodate either 8-bit or 9-bit data. The state of
the M bit in SCI control register 1 (SCC1) determines character length.
When transmitting 9-bit data, bit T8 in SCI control register 3 (SCC3) is
the ninth bit (bit 8).
1. Enable the SCI by writing a logic 1 to the enable SCI bit (ENSCI)
in SCI control register 1 (SCC1).
2. Enable the transmitter by writing a logic 1 to the transmitter enable
bit (TE) in SCI control register 2 (SCC2).
3. Clear the SCI transmitter empty bit by first reading SCI status
register 1 (SCS1) and then writing to the SCDR.
4. Repeat step 3 for each subsequent transmission.
The SCI transmitter empty bit, SCTE, in SCS1 becomes set when the
SCDR transfers a byte to the transmit shift register. The SCTE bit
indicates that the SCDR can accept new data from the internal data bus.
If the SCI transmit interrupt enable bit, SCTIE, in SCC2 is also set, the
SCTE bit generates a transmitter CPU interrupt request.
When the transmit shift register is not transmitting a character, the TxD
pin goes to the idle condition, logic 1. If at any time software clears the
ENSCI bit in SCI control register 1 (SCC1), the transmitter and receiver
relinquish control of the port pin.
Writing a logic 1 to the send break bit, SBK, in SCC2 loads the transmit
shift register with a break character. A break character contains all logic
0s and has no start, stop, or parity bit. Break character length depends
on the M bit in SCC1. As long as SBK is at logic 1, transmitter logic
continuously loads break characters into the transmit shift register. After
software clears the SBK bit, the shift register finishes transmitting the
last break character and then transmits at least one logic 1. The
automatic logic 1 at the end of a break character guarantees the
recognition of the start bit of the next character.
An idle character contains all logic 1s and has no start, stop, or parity bit.
Idle character length depends on the M bit in SCC1. The preamble is a
synchronizing idle character that begins every transmission.
If the TE bit is cleared during a transmission, the TxD pin becomes idle
after completion of the transmission in progress. Clearing and then
setting the TE bit during a transmission queues an idle character to be
sent after the character currently being transmitted.
NOTE: When queueing an idle character, return the TE bit to logic 1 before the
stop bit of the current character shifts out to the TxD pin. Setting TE after
the stop bit appears on TxD causes data previously written to the SCDR
to be lost.
Toggle the TE bit for a queued idle character when the SCTE bit
becomes set and just before writing the next byte to the SCDR.
These conditions can generate CPU interrupt requests from the SCI
transmitter:
16.5.3 Receiver
The receiver can accommodate either 8-bit or 9-bit data. The state of the
M bit in SCI control register 1 (SCC1) determines character length.
When receiving 9-bit data, bit R8 in SCI control register 2 (SCC2) is the
ninth bit (bit 8). When receiving 8-bit data, bit R8 is a copy of the eighth
bit (bit 7).
After a complete character shifts into the receive shift register, the data
portion of the character transfers to the SCDR. The SCI receiver full bit,
SCRF, in SCI status register 1 (SCS1) becomes set, indicating that the
received byte can be read. If the SCI receive interrupt enable bit, SCRIE,
in SCC2 is also set, the SCRF bit generates a receiver CPU interrupt
request.
INTERNAL BUS
SCIBDSRC SCR1
FROM
CONFIG2 SCP1 SCR2 SCI DATA REGISTER
SCP0 SCR0
SL
CGMXCLK A PRE- BAUD
X ÷4 ÷ 16
START
IT12 B SCALER DIVIDER
STOP
11-BIT
SL = 0 => X = A RECEIVE SHIFT REGISTER
SL = 1 => X = B DATA
RxD H 8 7 6 5 4 3 2 1 0 L
RECOVERY
ALL 0s
BKF
ALL 1s
MSB
RPF
ERROR CPU INTERRUPT REQUEST
M
CPU INTERRUPT REQUEST
SCRF RWU
DMA SERVICE REQUEST
WAKE WAKEUP
IDLE
ILTY LOGIC
PEN PARITY R8
PTY CHECKING
IDLE
ILIE
ILIE
DMARE
SCRF
SCRIE
SCRIE
DMARE
SCRF
SCRIE
DMARE
DMARE
OR
OR
ORIE
ORIE
NF
NF
NEIE
NEIE
FE
FE
FEIE
FEIE
PE
PE
PEIE
PEIE
The receiver samples the RxD pin at the RT clock rate. The RT clock is
an internal signal with a frequency 16 times the baud rate. To adjust for
baud rate mismatch, the RT clock is resynchronized at the following
times (see Figure 16-6):
To locate the start bit, data recovery logic does an asynchronous search
for a logic 0 preceded by three logic 1s. When the falling edge of a
possible start bit occurs, the RT clock begins to count to 16.
RxD
RT
CLOCK
RT10
RT11
RT12
RT13
RT14
RT15
RT16
RT CLOCK
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT2
RT3
RT4
RT5
RT6
RT7
RT8
RT9
RT1
RT2
RT3
RT4
STATE
RT CLOCK
RESET
To verify the start bit and to detect noise, data recovery logic takes
samples at RT3, RT5, and RT7. Table 16-2 summarizes the results of
the start bit verification samples.
Start bit verification is not successful if any two of the three verification
samples are logic 1s. If start bit verification is not successful, the RT
clock is reset and a new search for a start bit begins.
To determine the value of a data bit and to detect noise, recovery logic
takes samples at RT8, RT9, and RT10. Table 16-3 summarizes the
results of the data bit samples.
NOTE: The RT8, RT9, and RT10 samples do not affect start bit verification. If
any or all of the RT8, RT9, and RT10 start bit samples are logic 1s
following a successful start bit verification, the noise flag (NF) is set and
the receiver assumes that the bit is a start bit.
To verify a stop bit and to detect noise, recovery logic takes samples at
RT8, RT9, and RT10. Table 16-4 summarizes the results of the stop bit
samples.
If the data recovery logic does not detect a logic 1 where the stop bit
should be in an incoming character, it sets the framing error bit, FE, in
SCS1. A break character also sets the FE bit because a break character
has no stop bit. The FE bit is set at the same time that the SCRF bit is
set.
MSB STOP
RECEIVER
RT CLOCK
RT10
RT11
RT12
RT13
RT14
RT15
RT16
RT1
RT2
RT3
RT4
RT5
RT6
RT7
RT8
DATART9
SAMPLES
For an 8-bit character, data sampling of the stop bit takes the receiver
9 bit times × 16 RT cycles + 10 RT cycles = 154 RT cycles.
With the misaligned character shown in Figure 16-7, the receiver counts
154 RT cycles at the point when the count of the transmitting device is
9 bit times × 16 RT cycles + 3 RT cycles = 147 RT cycles.
The maximum percent difference between the receiver count and the
transmitter count of a slow 8-bit character with no errors is
154 – 147 × 100 = 4.54%
--------------------------
154
For a 9-bit character, data sampling of the stop bit takes the receiver
10 bit times × 16 RT cycles + 10 RT cycles = 170 RT cycles.
With the misaligned character shown in Figure 16-7, the receiver counts
170 RT cycles at the point when the count of the transmitting device is
10 bit times × 16 RT cycles + 3 RT cycles = 163 RT cycles.
The maximum percent difference between the receiver count and the
transmitter count of a slow 9-bit character with no errors is
170 – 163 × 100 = 4.12%
--------------------------
170
RECEIVER
RT CLOCK
RT10
RT11
RT12
RT13
RT14
RT15
RT16
RT1
RT2
RT3
RT4
RT5
RT6
RT7
RT8
RT9
DATA
SAMPLES
For an 8-bit character, data sampling of the stop bit takes the receiver
9 bit times × 16 RT cycles + 10 RT cycles = 154 RT cycles.
With the misaligned character shown in Figure 16-8, the receiver counts
154 RT cycles at the point when the count of the transmitting device is
10 bit times × 16 RT cycles = 160 RT cycles.
The maximum percent difference between the receiver count and the
transmitter count of a fast 8-bit character with no errors is
154 – 160 × 100 = 3.90% ·
--------------------------
154
For a 9-bit character, data sampling of the stop bit takes the receiver
10 bit times × 16 RT cycles + 10 RT cycles = 170 RT cycles.
With the misaligned character shown in Figure 16-8, the receiver counts
170 RT cycles at the point when the count of the transmitting device is
11 bit times × 16 RT cycles = 176 RT cycles.
The maximum percent difference between the receiver count and the
transmitter count of a fast 9-bit character with no errors is
170 – 176 × 100 = 3.53%
--------------------------
170
So that the MCU can ignore transmissions intended only for other
receivers in multiple-receiver systems, the receiver can be put into a
standby state. Setting the receiver wakeup bit, RWU, in SCC2 puts the
receiver into a standby state during which receiver interrupts are
disabled.
full bit, SCRF. The idle line type bit, ILTY, determines whether the
receiver begins counting logic 1s as idle character bits after the
start bit or after the stop bit.
NOTE: With the WAKE bit clear, setting the RWU bit after the RxD pin has been
idle may cause the receiver to wake up immediately.
The following sources can generate CPU interrupt requests from the SCI
receiver:
• SCI receiver full (SCRF) — The SCRF bit in SCS1 indicates that
the receive shift register has transferred a character to the SCDR.
SCRF can generate a receiver CPU interrupt request. Setting the
SCI receive interrupt enable bit, SCRIE, in SCC2 enables the
SCRF bit to generate receiver CPU interrupts.
• Idle input (IDLE) — The IDLE bit in SCS1 indicates that 10 or 11
consecutive logic 1s shifted in from the RxD pin. The idle line
interrupt enable bit, ILIE, in SCC2 enables the IDLE bit to generate
CPU interrupt requests.
The following receiver error flags in SCS1 can generate CPU interrupt
requests:
If SCI module functions are not required during wait mode, reduce power
consumption by disabling the module before executing the WAIT
instruction.
Because the internal clock is inactive during stop mode, entering stop
mode during an SCI transmission or reception results in invalid data.
To protect status bits during the break state, write a logic 0 to the BCFE
bit. With BCFE at logic 0 (its default state), software can read and write
I/O registers during the break state without affecting status bits. Some
status bits have a 2-step read/write clearing procedure. If software does
the first step on such a bit before the break, the bit cannot change during
the break state as long as BCFE is at logic 0. After the break, doing the
second step clears the status bit.
Address: $0013
Bit 7 6 5 4 3 2 1 Bit 0
Read:
LOOPS ENSCI TXINV M WAKE ILTY PEN PTY
Write:
Reset: 0 0 0 0 0 0 0 0
NOTE: Setting the TXINV bit inverts all transmitted values, including idle, break,
start, and stop bits.
NOTE: Changing the PTY bit in the middle of a transmission or reception can
generate a parity error.
Address: $0014
Bit 7 6 5 4 3 2 1 Bit 0
Read:
SCTIE TCIE SCRIE ILIE TE RE RWU SBK
Write:
Reset: 0 0 0 0 0 0 0 0
NOTE: Writing to the TE bit is not allowed when the enable SCI bit (ENSCI) is
clear. ENSCI is in SCI control register 1.
NOTE: Writing to the RE bit is not allowed when the enable SCI bit (ENSCI) is
clear. ENSCI is in SCI control register 1.
NOTE: Do not toggle the SBK bit immediately after setting the SCTE bit.
Toggling SBK before the preamble begins causes the SCI to send a
break character instead of a preamble.
• Stores the ninth SCI data bit received and the ninth SCI data bit to
be transmitted
• Enables these interrupts:
– Receiver overrun interrupts
– Noise error interrupts
– Framing error interrupts
• Parity error interrupts
Address: $0015
Bit 7 6 5 4 3 2 1 Bit 0
Read: R8
T8 DMARE DMATE ORIE NEIE FEIE PEIE
Write:
Reset: U U 0 0 0 0 0 0
= Unimplemented U = Unaffected
R8 — Received Bit 8
When the SCI is receiving 9-bit characters, R8 is the read-only ninth
bit (bit 8) of the received character. R8 is received at the same time
that the SCDR receives the other 8 bits.
When the SCI is receiving 8-bit characters, R8 is a copy of the eighth
bit (bit 7). Reset has no effect on the R8 bit.
T8 — Transmitted Bit 8
When the SCI is transmitting 9-bit characters, T8 is the read/write
ninth bit (bit 8) of the transmitted character. T8 is loaded into the
transmit shift register at the same time that the SCDR is loaded into
the transmit shift register. Reset has no effect on the T8 bit.
CAUTION: The DMA module is not included on this MCU. Writing a logic 1 to
DMARE or DMATE may adversely affect MCU performance.
CAUTION: The DMA module is not included on this MCU. Writing a logic 1 to
DMARE or DMATE may adversely affect MCU performance.
Address: $0016
Bit 7 6 5 4 3 2 1 Bit 0
Write:
Reset: 1 1 0 0 0 0 0 0
= Unimplemented
bit in SCC3 is also set. The data in the shift register is lost, but the data
already in the SCDR is not affected. Clear the OR bit by reading SCS1
with OR set and then reading the SCDR. Reset clears the OR bit.
1 = Receive shift register full and SCRF = 1
0 = No receiver overrun
Software latency may allow an overrun to occur between reads of
SCS1 and SCDR in the flag-clearing sequence. Figure 16-13 shows
the normal flag-clearing sequence and an example of an overrun
caused by a delayed flag-clearing sequence. The delayed read of
SCDR does not clear the OR bit because OR was not set when SCS1
was read. Byte 2 caused the overrun and is lost. The next flag-
clearing sequence reads byte 3 in the SCDR instead of byte 2.
In applications that are subject to software latency or in which it is
important to know which byte is lost due to an overrun, the flag-
clearing routine can check the OR bit in a second read of SCS1 after
reading the data register.
SCRF = 1
SCRF = 0
SCRF = 1
SCRF = 0
SCRF = 1
SCRF = 0
BYTE 1 BYTE 2 BYTE 3 BYTE 4
SCRF = 1
SCRF = 0
SCRF = 0
SCRF = 1
SCRF = 1
OR = 1
OR = 1
OR = 0
OR = 1
BYTE 1 BYTE 2 BYTE 3 BYTE 4
Address: $0017
Bit 7 6 5 4 3 2 1 Bit 0
Write:
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
The SCI data register (SCDR) is the buffer between the internal data bus
and the receive and transmit shift registers. Reset has no effect on data
in the SCI data register.
Address: $0018
Bit 7 6 5 4 3 2 1 Bit 0
Read: R7 R6 R5 R4 R3 R2 R1 R0
Write: T7 T6 T5 T4 T3 T2 T1 T0
The baud rate register (SCBR) selects the baud rate for both the receiver
and the transmitter.
Address: $0019
Bit 7 6 5 4 3 2 1 Bit 0
Read: 0 0
SCP1 SCP0 R SCR2 SCR1 SCR0
Write:
Reset: 0 0 0 0 0 0 0 0
= Unimplemented R = Reserved
00 1
01 3
10 4
11 13
000 1
001 2
010 4
011 8
100 16
101 32
110 64
111 128
where:
SCI clock source = fBUS or CGMXCLK
(selected by SCIBDSRC bit in CONFIG2 register)
PD = prescaler divisor
BD = baud rate divisor
Table 16-8 shows the SCI baud rates that can be generated with a
4.9152-MHz bus clock when fBUS is selected as SCI clock source.
17.1 Contents
17.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
17.2 Introduction
The multi-master IIC (MMIIC) interface is a two wire, bidirectional serial
bus which provides a simple, efficient way for data exchange between
devices. The interface is designed for internal serial communication
between the MCU and other IIC devices. It has hardware generated
START and STOP signals; and byte by byte interrupt driven software
algorithm.
The two channels are multiplexed; only one channel is active at any one
time.
17.3 Features
Features of the MMIC module include:
1. START signal,
2. slave address transmission,
3. data transfer, and
4. STOP signal.
SCL 1 1 0 0 0 0 1 1 1 1 0 1 0 0 1 1
SDA
SCL 1 1 0 0 0 0 1 1 1 1 0 1 0 0 1 1
SDA
ACK No ACK
START Repeated STOP
signal START signal
signal
When the bus is free, (i.e. no master device is engaging the bus — both
SCL and SDA lines are at logic high) a master may initiate
communication by sending a START signal. As shown in Figure 17-2, a
START signal is defined as a high to low transition of SDA while SCL is
high. This signal denotes the beginning of a new data transfer (each data
transfer may contain several bytes of data) and wakes up all slaves.
The first byte transferred immediately after the START signal is the slave
address transmitted by the master. This is a 7-bit calling address
followed by a R/W-bit. The R/W-bit dictates to the slave the desired
direction of the data transfer. A logic 0 indicates that the master wishes
to transmit data to the slave; a logic 1 indicates that the master wishes
to receive data from the slave.
Only the slave with a matched address will respond by sending back an
acknowledge bit by pulling SDA low on the 9th clock cycle.
(See Figure 17-2.)
Each data byte is 8 bits. Data can be changed only when SCL is low and
must be held stable when SCL is high as shown in Figure 17-2. The
MSB is transmitted first and each byte has to be followed by an
acknowledge bit. This is signalled by the receiving device by pulling the
SDA low on the 9th clock cycle. Therefore, one complete data byte
transfer requires 9 clock cycles.
If the slave receiver does not acknowledge the master, the SDA line
should be left high by the slave. The master can then generate a STOP
signal to abort the data transfer or a START signal (repeated START) to
commence a new transfer.
If the master receiver does not acknowledge the slave transmitter after
a byte has been transmitted, it means an “end of data” to the slave. The
slave should release the SDA line for the master to generate a STOP or
START signal.
SCL1
SCL2
SCL
17.6.8 Handshaking
The packet error code (PEC) for the MMIIC interface is in the form a
cyclic redundancy code (CRC). The PEC is generated by hardware for
every transmitted and received byte of data. The transmission of the
generated PEC is controlled by user software.
The CRC data register, MMCRCDR, contains the generated PEC byte,
with three other bits in the MMIIC control registers and status register
monitoring and controlling the PEC byte.
Address: $0048
Bit 7 6 5 4 3 2 1 Bit 0
Read:
MMAD7 MMAD6 MMAD5 MMAD4 MMAD3 MMAD2 MMAD1 MMEXTAD
Write:
Reset: 1 0 1 0 0 0 0 0
1 1 0 1 0 1 0 1
Bit 7 6 5 4 3 2 Bit 1
1 1 0 1 0 1 0
0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 Bit 1
0 0 0 1 1 0 0
Note that bit-0 of the 8-bit calling address is the MMRW bit from the
calling master.
Address: $0049
Bit 7 6 5 4 3 2 1 Bit 0
Read: 0 0
MMEN MMIEN MMTXAK REPSEN MMCRCBYTE SDASCL1
Write: MMCLRBB
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
Address: $004A
Bit 7 6 5 4 3 2 1 Bit 0
Reset: 0 0 0 0 0 0 0 Unaffected
= Unimplemented
Address: $004B
Bit 7 6 5 4 3 2 1 Bit 0
Write: 0 0
Reset: 0 0 0 0 1 0 1 0
= Unimplemented
Address: $004C
Bit 7 6 5 4 3 2 1 Bit 0
Read:
MMTD7 MMTD6 MMTD5 MMTD4 MMTD3 MMTD2 MMTD1 MMTD0
Write:
Reset: 0 0 0 0 0 0 0 0
When the MMIIC module is enabled, MMEN = 1, data written into this
register depends on whether module is in master or slave mode.
In slave mode, the data in MMDTR will be transferred to the output circuit
when:
If the calling master does not return an acknowledge bit (MMRXAK = 1),
the module will release the SDA line for master to generate a STOP or
repeated START condition. The data in the MMDTR will not be
transferred to the output circuit until the next calling from a master. The
transmit buffer empty flag remains cleared (MMTXBE = 0).
If the slave does not return an acknowledge bit (MMRXAK = 1), the
master will generate a STOP or repeated START condition. The data in
the MMDTR will not be transferred to the output circuit. The transmit
buffer empty flag remains cleared (MMTXBE = 0).
The sequence of events for slave transmit and master transmit are
illustrated in Figure 17-12.
Address: $004D
Bit 7 6 5 4 3 2 1 Bit 0
Write:
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
• the calling address from the master when the address match flag
is set (MMATCH = 1); or
• the last data received when MMATCH = 0.
When the MMDRR is read by the CPU, the receive buffer full flag is
cleared (MMRXBF = 0), and the next received data is loaded to the
MMDRR. Each time when new data is loaded to the MMDRR, the
MMRXIF interrupt flag is set, indicating that new data is available in
MMDRR.
The sequence of events for slave receive and master receive are
illustrated in Figure 17-12.
Address: $004E
Bit 7 6 5 4 3 2 1 Bit 0
Write:
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
When the MMIIC module is enabled, MMEN = 1, and the CRC buffer full
flag is set (MMCRCBF = 1), data in this read-only register contains the
generated CRC byte for the last byte of received or transmitted data.
A CRC byte is generated for each received and transmitted data byte
and loaded to the CRC data register. The MMCRCBF bit will be set to
indicate the CRC byte is ready in the CRC data register.
Reading the CRC data register clears the MMCRCBF bit. If the CRC
data register is not read, the MMCRCBF bit will be cleared by hardware
before the next CRC byte is loaded.
Address: $004F
Bit 7 6 5 4 3 2 1 Bit 0
Read: 0 0 0 0 0
MMBR2 MMBR1 MMBR0
Write:
Reset: 0 0 0 0 0 1 0 0
= Unimplemented
The three bits in the frequency divider register (MMFDR) selects the
divider to divide the bus clock to the desired baud rate for the MMIIC data
transfer.
NOTE: The frequency of the MMIIC baud rate is only guaranteed for 100kHz to
10kHz. The divider is available for the flexibility on bus frequency
selection.
1 7 1 1 1
START Slave Address W ACK Command Code ACK PEC ACK STOP
START Slave Address R ACK Data Byte ACK PEC NAK STOP
START Slave Address W ACK Command Code ACK Data Byte ACK STOP
START Slave Address W ACK Command Code ACK Data Byte ACK PEC ACK STOP
START Slave Address W ACK Command Code ACK Data Byte Low ACK Data Byte High ACK STOP
START Slave Address W ACK Command Code ACK Data Byte Low ACK Data Byte High ACK
START Slave Address W ACK Command Code ACK START Slave Address R ACK Data Byte NAK STOP
START Slave Address W ACK Command Code ACK START Slave Address R ACK Data Byte ACK
START Slave Address W ACK Command Code ACK START Slave Address R ACK Data Byte Low ACK
START Slave Address W ACK Command Code ACK START Slave Address R ACK Data Byte Low ACK
START Slave Address W ACK Command Code ACK Data Byte Low ACK Data Byte High ACK
START Slave Address R ACK Data Byte Low ACK Data Byte High NAK STOP
START Slave Address W ACK Command Code ACK Data Byte Low ACK Data Byte High ACK
START Slave Address R ACK Data Byte Low ACK Data Byte High ACK STOP PEC NAK STOP
START Slave Address W ACK Command Code ACK Byte Count = N ACK Data Byte 1 ACK
START Slave Address W ACK Command Code ACK Byte Count = N ACK Data Byte 1 ACK
START Slave Address W ACK Command Code ACK START Slave Address R ACK Byte Count = N ACK
Data Byte 1 ACK Data Byte 2 ACK Data Byte N NAK STOP
START Slave Address W ACK Command Code ACK START Slave Address R ACK Byte Count = N ACK
Data Byte 1 ACK Data Byte 2 ACK Data Byte N ACK PEC NAK STOP
SLAVE MODE
START Address 0 ACK Command ACK START Address 1 ACK TX Data1 ACK ACK TX DataN NAK STOP
OPERATION: OPERATION:
Read and decode received command OPERATION: Last data is going to be sent
OPERATION:
Prepare for Slave mode FLAGS: Transmit data FLAGS:
MMRXIF set FLAGS: MMTXIF set
ACTION:
MMATCH clear MMTXIF set MMRXAK clear
1. Load slave address to MMADR
2. Clear MMTXAK ACTION: ACTION: ACTION:
3. Clear MMAST Load Data1 to MMDTR Load Data2 to MMDTR Load dummy ($FF) to MMDTR
18.1 Contents
18.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
18.2 Introduction
Thirty-one (31) bidirectional input-output (I/O) pins form four parallel
ports. All I/O pins are programmable as inputs or outputs.
NOTE: Connect any unused I/O pins to an appropriate logic level, either VDD or
VSS. Although the I/O ports do not require termination for proper
operation, termination reduces excess current consumption and the
possibility of electrostatic damage.
18.3 Port A
Port A is an 8-bit special function port that shares six of its port pins with
the analog-to-digital converter (ADC) module and two of its port pins with
the timer interface module 1 (TIM1). See Section 15. Analog-to-Digital
Converter (ADC) and Section 11. Timer Interface Module (TIM).
The port A data register contains a data latch for each of the eight port A
pins.
Address: $0000
Bit 7 6 5 4 3 2 1 Bit 0
Read:
PTA7 PTA6 PTA5 PTA4 PTA3 PTA2 PTA1 PTA0
Write:
Alternative Function: T1CH1 T1CH0 ATD7 ATD6 ATD5 ATD4 ATD3 ATD2
Additional Function: LED drive LED drive LED drive LED drive LED drive LED drive
NOTE: Care must be taken when reading port A while applying analog voltages
to ATD[7:2] pins. If the appropriate ADC channel is not enabled,
excessive current drain may occur if analog voltages are applied to the
PTAx/ATDx pin, while PTA is read as a digital input. Those ports not
selected as analog input channels are considered digital I/O ports.
Address: $0004
Bit 7 6 5 4 3 2 1 Bit 0
Read:
DDRA7 DDRA6 DDRA5 DDRA4 DDRA3 DDRA2 DDRA1 DDRA0
Write:
Reset: 0 0 0 0 0 0 0 0
NOTE: Avoid glitches on port A pins by writing to the port A data register before
changing data direction register A bits from 0 to 1. Figure 18-4 shows
the port A I/O logic.
RESET
When DDRAx is a logic 1, reading address $0000 reads the PTAx data
latch. When DDRAx is a logic 0, reading address $0000 reads the
voltage level on the pin. The data latch can always be written, regardless
of the state of its data direction bit.
The port-A LED control register (LEDA) controls the direct LED drive
capability on PTA5–PTA0 pins. Each bit is individually configurable and
requires that the data direction register, DDRA, bit be configured as an
output.
Address: $000C
Bit 7 6 5 4 3 2 1 Bit 0
Read: 0 0
LEDA5 LEDA4 LEDA3 LEDA2 LEDA1 LEDA0
Write:
Reset: 0 0 0 0 0 0 0 0
18.4 Port B
Port B is a 7-bit special function port that shares four of its port pins with
the multi-master IIC (MMIIC) interface module, two of its port pins with
the serial communications interface (SCI) module, two of its port pins
with the timer interface module 2 (TIM2), and one of its port pins with the
IRQ module. See Section 17. Multi-Master IIC Interface (MMIIC),
Section 16. Serial Communications Interface (SCI), Section 11.
Timer Interface Module (TIM), and Section 19. External Interrupt
(IRQ).
The port B data register contains a data latch for each of the eight port B
pins.
Address: $0001
Bit 7 6 5 4 3 2 1 Bit 0
Read: 0
PTB6 PTB5 PTB4 PTB3 PTB2 PTB1 PTB0
Write:
RxD TxD
Alternative Functions: IRQ2 T2CH1 T2CH0 SCL0 SDA0
SCL1 SDA1
These four pins are open-drain when configured as
output pins. Pullup resistors must be connected
when configured as outputs.
0 0 X PTB2, PTB3
PTB2/SDA1/TxD 0 1 0 PTB2, PTB3
1 X X TxD, RxD
Address: $0005
Bit 7 6 5 4 3 2 1 Bit 0
Read: 0
DDRB6 DDRB5 DDRB4 DDRB3 DDRB2 DDRB1 DDRB0
Write:
Reset: 0 0 0 0 0 0 0 0
NOTE: Avoid glitches on port B pins by writing to the port B data register before
changing data direction register B bits from 0 to 1. Figure 18-8 shows
the port B I/O logic.
RESET
When DDRBx is a logic 1, reading address $0001 reads the PTBx data
latch. When DDRBx is a logic 0, reading address $0001 reads the
voltage level on the pin. The data latch can always be written, regardless
of the state of its data direction bit.
18.5 Port C
Port C is an 8-bit special function port that shares three of its port pins
with the pulse width modulator module, five of its port pins with the
analog-to-digital converter module, and one of its pins with the analog
module. See Section 13. Pulse Width Modulator (PWM), Section 15.
Analog-to-Digital Converter (ADC), and Section 14. Analog Module.
The port C data register contains a data latch for each of the six port C
pins.
NOTE: Bit 7 and bit 6 of PTC are not available in a 42-pin shrink dual in-line
package.
Address: $0002
Bit 7 6 5 4 3 2 1 Bit 0
Read:
PTC7 PTC6 PTC5 PTC4 PTC3 PTC2 PTC1 PTC0
Write:
Alternative Function: ATD12 ATD11 ATD10 ATD9 ATD8 PWM2 PWM1 PWM0
CD
Additional Function: LED drive LED drive LED drive LED drive LED drive
NOTE: Care must be taken when reading port C while applying analog voltages
to ATD[12:8] pins. If the appropriate ADC channel is not enabled,
excessive current drain may occur if analog voltages are applied to the
PTCx/ATDx pin, while PTC is read as a digital input. Those ports not
selected as analog input channels are considered digital I/O ports.
0 0 PTC0
PTC0/PWM0/CD 0 1 PWM0
1 X CD
Address: $0006
Bit 7 6 5 4 3 2 1 Bit 0
Read:
DDRC7 DDRC6 DDRC5 DDRC4 DDRC3 DDRC2 DDRC1 DDRC0
Write:
Reset: 0 0 0 0 0 0 0 0
NOTE: Avoid glitches on port C pins by writing to the port C data register before
changing data direction register C bits from 0 to 1. Figure 18-11 shows
the port C I/O logic.
NOTE: For those devices packaged in a 42-pin shrink dual in-line package,
PTC6 and PTC7 are not connected. DDRC6 and DDRC7 should be set
to a 1 to configure PTC6 and PTC7 as outputs.
RESET
When DDRCx is a logic 1, reading address $0002 reads the PTCx data
latch. When DDRCx is a logic 0, reading address $0002 reads the
voltage level on the pin. The data latch can always be written, regardless
of the state of its data direction bit.
The port-C LED control register (LEDC) controls the direct LED drive
capability on PTC7–PTC3 pins. Each bit is individually configurable and
requires that the data direction register, DDRD, bit be configured as an
output.
Address: $000D
Bit 7 6 5 4 3 2 1 Bit 0
Read: 0 0 0
LEDC7 LEDC6 LEDC5 LEDC4 LEDC3
Write:
Reset: 0 0 0 0 0 0 0 0
18.6 Port D
Port D is an 8-bit special function port that shares all of its pins with the
keyboard interrupt module. See Section 20. Keyboard Interrupt
Module (KBI).
The port D data register contains a data latch for each of the eight port D
pins.
Address: $0003
Bit 7 6 5 4 3 2 1 Bit 0
Read:
PTD7 PTD6 PTD5 PTD4 PTD3 PTD2 PTD1 PTD0
Write:
Alternative Function: KBI7 KBI6 KBI5 KBI4 KBI3 KBI2 KBI1 KBI0
Address: $0007
Bit 7 6 5 4 3 2 1 Bit 0
Read:
DDRD7 DDRD6 DDRD5 DDRD4 DDRD3 DDRD2 DDRD1 DDRD0
Write:
Reset: 0 0 0 0 0 0 0 0
NOTE: Avoid glitches on port D pins by writing to the port D data register before
changing data direction register D bits from 0 to 1. Figure 18-15 shows
the port D I/O logic.
RESET
When DDRDx is a logic 1, reading address $0003 reads the PTDx data
latch. When DDRDx is a logic 0, reading address $0003 reads the
voltage level on the pin. The data latch can always be written, regardless
of the state of its data direction bit.
19.1 Contents
19.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
19.2 Introduction
The external interrupt (IRQ) module provides two maskable interrupt
inputs: IRQ1 and IRQ2.
19.3 Features
Features of the IRQ module include:
NOTE: References to either IRQ1 or IRQ2 may be made in the following text by
omitting the IRQ number. For example, IRQF may refer generically to
IRQ1F and IRQ2F, and IMASK may refer to IMASK1 and IMASK2.
Interrupt signals on the IRQ pin are latched into the IRQ latch. An
interrupt latch remains set until one of the following actions occurs:
The vector fetch or software clear may occur before or after the interrupt
pin returns to logic 1. As long as the pin is low, the interrupt request
remains pending. A reset will clear the latch and the MODE1 control bit,
thereby clearing the interrupt even if the pin stays low.
When set, the IMASK bit in the INTSCR mask all external interrupt
requests. A latched interrupt request is not presented to the interrupt
priority logic unless the IMASK bit is clear.
NOTE: The interrupt mask (I) in the condition code register (CCR) masks all
interrupt requests, including external interrupt requests.
ACK1
RESET
INTERNAL ADDRESS BUS
TO CPU FOR
VECTOR BIL/BIH
FETCH INSTRUCTIONS
DECODER
VDD
INTERNAL VDD
IRQ1F
PULLUP
DEVICE CLR
D Q SYNCHRO- IRQ1
NIZER INTERRUPT
IRQ1 CK
REQUEST
IRQ1
FF
IMASK1
MODE1
HIGH TO MODE
VOLTAGE SELECT
DETECT LOGIC
ACK2
RESET
INTERNAL ADDRESS BUS
VECTOR
FETCH
DECODER
VDD
INTERNAL
PULLUP
DEVICE
VDD
IRQ2F
PTBPUE6
CLR
D Q SYNCHRO- IRQ2
NIZER INTERRUPT
IRQ2 CK
REQUEST
IRQ2
FF
IMASK2
MODE2
If the MODE bit is set, the IRQ pin is both falling-edge-sensitive and low-
level-sensitive. With MODE set, both of the following actions must occur
to clear IRQ:
The vector fetch or software clear and the return of the IRQ pin to logic 1
may occur in any order. The interrupt request remains pending as long
as the IRQ pin is at logic 0. A reset will clear the latch and the MODE
control bit, thereby clearing the interrupt even if the pin stays low.
If the MODE bit is clear, the IRQ pin is falling-edge-sensitive only. With
MODE clear, a vector fetch or software clear immediately clears the IRQ
latch.
The IRQF bit in the INTSCR register can be used to check for pending
interrupts. The IRQF bit is not affected by the IMASK bit, which makes it
useful in applications where polling is preferred.
Use the BIH or BIL instruction to read the logic level on the IRQ1 pin.
NOTE: The BIH and BIL instructions do not read the logic level on the IRQ2 pin.
NOTE: When using the level-sensitive interrupt trigger, avoid false interrupts by
masking interrupt requests in the interrupt routine.
The IRQ1 pin has a permanent internal pullup device connected, while
the IRQ2 pin has an optional pullup device that can be enabled or
disabled by the PTBPUE6 bit in the INTSCR2 register.
To allow software to clear the IRQ latch during a break interrupt, write a
logic 1 to the BCFE bit. If a latch is cleared during the break state, it
remains cleared when the MCU exits the break state.
To protect CPU interrupt flags during the break state, write a logic 0 to
the BCFE bit. With BCFE at logic 0 (its default state), writing to the ACK
bit in the IRQ status and control register during the break state has no
effect on the IRQ interrupt flags.
The IRQ1 status and control register (INTSCR1) controls and monitors
operation of IRQ1. The INTSCR1 has the following functions:
Address: $001E
Bit 7 6 5 4 3 2 1 Bit 0
Read: 0 0 0 0 IRQ1F 0
IMASK1 MODE1
Write: ACK1
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
The IRQ2 status and control register (INTSCR2) controls and monitors
operation of IRQ2. The INTSCR2 has the following functions:
Address: $001C
Bit 7 6 5 4 3 2 1 Bit 0
Read: 0 0 0 IRQ2F 0
PTBPUE6 IMASK2 MODE2
Write: ACK2
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
20.1 Contents
20.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
20.2 Introduction
The keyboard interrupt module (KBI) provides eight independently
maskable external interrupts which are accessible via PTD0–PTD7.
When a port pin is enabled for keyboard interrupt function, an internal
30kΩ pullup device is also enabled on the pin.
20.3 Features
Features of the keyboard interrupt module include the following:
Read: 0 0 0 0 KEYF 0
Keyboard Status IMASKK MODEK
$001A and Control Register Write: ACKK
(KBSCR)
Reset: 0 0 0 0 0 0 0 0
Read:
Keyboard Interrupt Enable KBIE7 KBIE6 KBIE5 KBIE4 KBIE3 KBIE2 KBIE1 KBIE0
$001B Write:
Register (KBIER)
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
INTERNAL BUS
VECTOR FETCH
KBI0 DECODER
ACKK
VDD
RESET KEYF
. CLR
D Q
KBIE0 SYNCHRONIZER Keyboard
. CK Interrupt
TO PULLUP ENABLE Request
.
KEYBOARD IMASKK
KBI7 INTERRUPT FF
MODEK
KBIE7
TO PULLUP ENABLE
If the MODEK bit is set, the keyboard interrupt pins are both falling edge-
and low level-sensitive, and both of the following actions must occur to
clear a keyboard interrupt request:
NOTE: Setting a keyboard interrupt enable bit (KBIEx) forces the corresponding
keyboard interrupt pin to be an input, overriding the data direction
register. However, the data direction register bit must be a logic 0 for
software to read the pin.
When a keyboard interrupt pin is enabled, it takes time for the internal
pull-up to reach a logic 1. Therefore a false interrupt can occur as soon
as the pin is enabled.
Address: $001A
Bit 7 6 5 4 3 2 1 Bit 0
Read: 0 0 0 0 KEYF 0
IMASKK MODEK
Write: ACKK
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
Address: $001B
Bit 7 6 5 4 3 2 1 Bit 0
Read:
KBIE7 KBIE6 KBIE5 KBIE4 KBIE3 KBIE2 KBIE1 KBIE0
Write:
Reset: 0 0 0 0 0 0 0 0
The keyboard interrupt module remains active in wait mode. Clearing the
IMASKK bit in the keyboard status and control register enables keyboard
interrupt requests to bring the MCU out of wait mode.
To protect the latch during the break state, write a logic 0 to the BCFE
bit. With BCFE at logic 0 (its default state), writing to the keyboard
acknowledge bit (ACKK) in the keyboard status and control register
during the break state has no effect.
21.1 Contents
21.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
21.2 Introduction
The computer operating properly (COP) module contains a free-running
counter that generates a reset if allowed to overflow. The COP module
helps software recover from runaway code. Prevent a COP reset by
clearing the COP counter periodically. The COP module can be disabled
through the COPD bit in the configuration register 1 (CONFIG1).
COP TIMEOUT
STOP INSTRUCTION
INTERNAL RESET SOURCES
RESET VECTOR FETCH
COPCTL WRITE
COP CLOCK
NOTE: Service the COP immediately after reset and before entering or after
exiting STOP Mode to guarantee the maximum time before the first COP
counter overflow.
A COP reset pulls the RST pin low for 32 ICLK cycles and sets the COP
bit in the SIM reset status register (SRSR).
In monitor mode, the COP is disabled if the RST pin or the IRQ1 is held
at VTST. During the break state, VTST on the RST pin disables the COP.
NOTE: Place COP clearing instructions in the main program and not in an
interrupt subroutine. Such an interrupt subroutine could keep the COP
from generating a reset even while the main program is not working
properly.
21.4.1 ICLK
Writing any value to the COP control register (COPCTL) (see 21.5 COP
Control Register) clears the COP counter and clears bits 12 through 5
of the prescaler. Reading the COP control register returns the low byte
of the reset vector.
The power-on reset (POR) circuit clears the COP prescaler 4096 ICLK
cycles after power-up.
An internal reset clears the COP prescaler and the COP counter.
A reset vector fetch occurs when the vector address appears on the data
bus. A reset vector fetch clears the COP prescaler.
The COPD signal reflects the state of the COP disable bit (COPD) in the
CONFIG1 register. (See Figure 21-2 and Section 5. Configuration
and Mask Option Registers (CONFIG & MOR).)
The COPRS signal reflects the state of the COP rate select bit (COPRS)
in the CONFIG1 register.
Address: $001F
Bit 7 6 5 4 3 2 1 Bit 0
Read:
COPRS LVISTOP LVIRSTD LVIPWRD LVI5OR3 SSREC STOP COPD
Write:
Reset: 0 0 0 0 0* 0 0 0
Address: $FFFF
Bit 7 6 5 4 3 2 1 Bit 0
21.6 Interrupts
The COP does not generate CPU interrupt requests.
The COP remains active during wait mode. To prevent a COP reset
during wait mode, periodically clear the COP counter in a CPU interrupt
routine.
Stop mode turns off the ICLK input to the COP and clears the COP
prescaler. Service the COP immediately before entering or after exiting
stop mode to ensure a full COP timeout period after entering or exiting
stop mode.
22.1 Contents
22.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
22.2 Introduction
This section describes the low-voltage inhibit (LVI) module, which
monitors the voltage on the VDD pin and can force a reset when the VDD
voltage falls below the LVI trip falling voltage, VTRIPF.
22.3 Features
Features of the LVI module include:
VDD
STOP INSTRUCTION
LVISTOP
FROM CONFIG1
FROM CONFIG1
LVIRSTD
LVIPWRD
FROM CONFIG
LVIOUT
LVI5OR3
TO LVISR
FROM CONFIG1
NOTE: After a power-on reset (POR) the LVI’s default mode of operation is 3V.
If a 5V system is used, the user must set the LVI5OR3 bit to raise the
trip point to 5V operation. Note that this must be done after every power-
on reset since the default will revert back to 3V mode after each power-
on reset. If the VDD supply is below the 5V mode trip voltage but above
the 3V mode trip voltage when POR is released, the MCU will operate
because VTRIPF defaults to 3V mode after a POR. So, in a 5V system
care must be taken to ensure that VDD is above the 5V mode trip voltage
after POR is released.
NOTE: If the user requires 5V mode and sets the LVI5OR3 bit after a power-on
reset while the VDD supply is not above the VTRIPF for 5V mode, the
MCU will immediately go into reset. The LVI in this case will hold the
MCU in reset until either VDD goes above the rising 5V trip point, VTRIPR,
which will release reset or VDD decreases to approximately 0V which will
re-trigger the power-on reset and reset the trip point to 3V operation.
An LVI reset also drives the RST pin low to provide low-voltage
protection to external peripheral devices.
In applications that can operate at VDD levels below the VTRIPF level,
software can monitor VDD by polling the LVIOUT bit. In the configuration
register 1 (CONFIG1), the LVIPWRD bit must be at logic 0 to enable the
LVI module, and the LVIRSTD bit must be at logic 1 to disable LVI
resets.
Once the LVI has triggered (by having VDD fall below VTRIPF), the LVI
will maintain a reset condition until VDD rises above the rising trip point
voltage, VTRIPR. This prevents a condition in which the MCU is
continually entering and exiting reset if VDD is approximately equal to
VTRIPF. VTRIPR is greater than VTRIPF by the hysteresis voltage, VHYS.
The LVI5OR3 bit in the CONFIG1 register selects whether the LVI is
configured for 5V or 3V protection.
NOTE: The MCU is guaranteed to operate at a minimum supply voltage. The trip
point (VTRIPF [5 V] or VTRIPF [3 V]) may be lower than this.
(See Section 24. Electrical Specifications for the actual trip point
voltages.)
Address: $FE0F
Bit 7 6 5 4 3 2 1 Bit 0
Read: LVIOUT 0 0 0 0 0 0 0
Write:
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
If enabled in stop mode (LVISTOP = 1), the LVI module remains active
in stop mode. If enabled to generate resets (LVIRSTD = 0), the LVI
module can generate a reset and bring the MCU out of stop mode.
23.1 Contents
23.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
23.2 Introduction
This section describes the break module. The break module can
generate a break interrupt that stops normal program flow at a defined
address to enter a background program.
23.3 Features
Features of the break module include:
IAB15–IAB8
8-BIT COMPARATOR
IAB15–IAB0
CONTROL BREAK
8-BIT COMPARATOR
IAB7–IAB0
The BCFE bit in the SIM break flag control register (SBFCR) enables
software to clear status bits during the break state.
If enabled, the break module is active in wait mode. In the break routine,
the user can subtract one from the return address on the stack if SBSW
is set (see Section 9. System Integration Module (SIM)). Clear the
SBSW bit by writing logic 0 to it.
A break interrupt causes exit from stop mode and sets the SBSW bit in
the break status register.
The break status and control register (BRKSCR) contains break module
enable and status bits.
Address: $FE0E
Bit 7 6 5 4 3 2 1 Bit 0
Read: 0 0 0 0 0 0
BRKE BRKA
Write:
Reset: 0 0 0 0 0 0 0 0
= Unimplemented
The break address registers (BRKH and BRKL) contain the high and low
bytes of the desired breakpoint address. Reset clears the break address
registers.
Address: $FE0C
Bit 7 6 5 4 3 2 1 Bit 0
Read:
Bit 15 14 13 12 11 10 9 Bit 8
Write:
Reset: 0 0 0 0 0 0 0 0
Address: $FE0D
Bit 7 6 5 4 3 2 1 Bit 0
Read:
Bit 7 6 5 4 3 2 1 Bit 0
Write:
Reset: 0 0 0 0 0 0 0 0
The SIM break status register (SBSR) contains a flag to indicate that a
break caused an exit from wait mode. The flag is useful in applications
requiring a return to wait mode after exiting from a break interrupt.
Address: $FE00
Bit 7 6 5 4 3 2 1 Bit 0
Read: SBSW
R R R R R R R
Write: Note
Reset: 0
Note: Writing a logic 0 clears SBSW. R = Reserved
This status bit is set when a break interrupt causes an exit from wait
mode or stop mode. Clear SBSW by writing a logic 0 to it. Reset clears
SBSW.
1 = Stop mode or wait mode was exited by break interrupt
0 = Stop mode or wait mode was not exited by break interrupt
SBSW can be read within the break interrupt routine. The user can
modify the return address on the stack by subtracting 1 from it. The
following code is an example.
; This code works if the H register has been pushed onto the stack in the break
; service routine software. This code should be executed at the end of the break
; service routine software.
HIBYTE EQU 5
LOBYTE EQU 6
BRCLR SBSW,SBSR, RETURN ; See if wait mode or stop mode was exited by
; break.
The SIM break flag control register (SBFCR) contains a bit that enables
software to clear status bits while the MCU is in a break state.
Address: $FE03
Bit 7 6 5 4 3 2 1 Bit 0
Read:
BCFE R R R R R R R
Write:
Reset: 0
R = Reserved
24.1 Contents
24.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
24.2 Introduction
This section contains electrical and timing specifications.
Input voltage
All pins (except IRQ1) VIN VSS –0.3 to VDD +0.3 V
IRQ1 pin VSS –0.3 to 8.5
Notes:
1. Voltages referenced to VSS.
NOTE: This device contains circuitry to protect the inputs against damage due
to high static voltages or electric fields; however, it is advised that normal
precautions be taken to avoid application of any voltage higher than
maximum-rated voltages to this high-impedance circuit. For proper
operation, it is recommended that VIN and VOUT be constrained to the
range VSS ≤ (VIN or VOUT) ≤ VDD. Reliability of operation is enhanced if
unused inputs are connected to an appropriate logic voltage level (for
example, either VSS or VDD.)
Thermal resistance
42-pin SDIP 60 °C/W
θJA
48-pin LQFP 80 °C/W
Notes:
1. Power dissipation is a function of temperature.
2. K constant unique to the device. K can be determined for a known TA and measured PD.
With this value of K, PD and TJ can be determined for any value of TA.
Capacitance COUT — — 12
pF
Ports (as input or output) CIN — — 8
Pullup resistors(8)
PTD[0:7] configured as KBI[0:7] RPU1 24 35 42 kΩ
RST, IRQ1, IRQ2 RPU2 24 35 42 kΩ
Capacitance COUT — — 12
pF
Ports (as input or output) CIN — — 8
Pullup resistors(8)
PTD[0:7] configured as KBI[0:7] RPU1 24 35 42 kΩ
RST, IRQ1, IRQ2 RPU2 24 35 42 kΩ
Notes:
1. VSS = 0 Vdc; timing shown with respect to 20% VDD and 70% VDD, unless otherwise noted.
2. Some modules may require a minimum frequency greater than dc for proper operation; see appropriate table for this
information.
3. Minimum pulse width reset is guaranteed to be recognized. It is possible for a smaller pulse width to cause a reset.
Notes:
1. VSS = 0 Vdc; timing shown with respect to 20% VDD and 70% VDD, unless otherwise noted.
2. Some modules may require a minimum frequency greater than dc for proper operation; see appropriate table for this
information.
3. Minimum pulse width reset is guaranteed to be recognized. It is possible for a smaller pulse width to cause a reset.
Notes:
1. No more than 10% duty cycle deviation from 50%.
2. Fundamental mode crystals only.
3. Consult crystal manufacturer’s data.
4. Not Required for high frequency crystals.
CEXT = 10 pF MCU
Bus Frequency, fOP (MHz)
4
5V @ 25°C
OSC1
3
VDD
2 REXT CEXT
fRCCLK = fOP × 4
0
0 2 4 6 8 10
Resistor REXT (kΩ)
Notes:
1. No more than 10% duty cycle deviation from 50%.
2. Fundamental mode crystals only.
3. Consult crystal manufacturer’s data.
4. Not Required for high frequency crystals.
CEXT = 10 pF MCU
2.5
Bus Frequency, fOP (MHz)
3V @ 25°C
OSC1
2
1.5 VDD
REXT CEXT
1
0.5
fRCCLK = fOP × 4
0
0 5 10 15 20
Resistor REXT (kΩ)
Includes quantization.
Absolute accuracy AAD — ± 1.5 LSB
±0.5 LSB = ±1 ADC step.
ADC voltage
VREFH — VDDA + 0.1 V
reference high
ADC voltage
VREFL VSSA – 0.1 — V
reference low
tADIC
Conversion time tADC 16 17
cycles
tADIC
Sample time tADS 5 —
cycles
Includes quantization.
Absolute accuracy AAD — ± 1.5 LSB
±0.5 LSB = ±1 ADC step.
ADC voltage
VREFH — VDDA + 0.1 V
reference high
ADC voltage
VREFL VSSA – 0.1 — V
reference low
tADIC
Conversion time tADC 16 17
cycles
tADIC
Sample time tADS 5 —
cycles
Temperature slope
VDD =5V ± 10%, GAINA=2, GAINB=6 1.275 1.338 1.372
ADC steps/°C
VDD =3V ± 10%, GAINA=2, GAINB=4 1.048 1.089 1.146
Notes:
1. The current detect comparator is designed for VDD =5V ± 10% only.
SDA
SCL
fRCLK ×
PLL jitter (2) fJ 0 — 0.025% × Hz
2P N/4
Notes:
1. Test condition: VDD = 5.0Vdc / 3.0Vdc, VSS = 0 Vdc. Reference frequency = 32.768kHz, locking to 4MHz bus frequency.
2. Deviation of average bus frequency over 2ms. N = VCO multiplier.
Notes:
1. fRead is defined as the frequency range for which the FLASH memory can be read.
2. If the page erase time is longer than tErase (Min.), there is no erase-disturb, but it reduces the endurance of the FLASH
memory.
3. If the mass erase time is longer than tMErase (Min.), there is no erase-disturb, but is reduces the endurance of the FLASH
memory.
4. It is defined as the time it needs before the FLASH can be read after turning off the high voltage charge pump, by clearing
HVEN to logic 0.
5. thv is the cumulative high voltage programming time to the same row before next erase, and the same address can not be
programmed twice before next erase.
6. The minimum row endurance value specifies each row of the FLASH memory is guaranteed to work for at least this many
erase/program cycles.
7. The minimum row endurance value specifies each row of the FLASH memory is guaranteed to work for at least this many
erase/program cycle.
8. The FLASH is guaranteed to retain data over the entire operating temperature range for at least the minimum time
specified.
25.1 Contents
25.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
25.2 Introduction
This section gives the dimensions for:
4X
NOTES:
0.200 AB T–U Z 1. DIMENSIONING AND TOLERANCING PER ASME
Y14.5M, 1994.
DETAIL Y 2. CONTROLLING DIMENSION: MILLIMETER.
9 A P 3. DATUM PLANE AB IS LOCATED AT BOTTOM OF
LEAD AND IS COINCIDENT WITH THE LEAD
A1 WHERE THE LEAD EXITS THE PLASTIC BODY AT
THE BOTTOM OF THE PARTING LINE.
48 37
4. DATUMS T, U, AND Z TO BE DETERMINED AT
DATUM PLANE AB.
5. DIMENSIONS S AND V TO BE DETERMINED AT
1 36 SEATING PLANE AC.
6. DIMENSIONS A AND B DO NOT INCLUDE MOLD
T U PROTRUSION. ALLOWABLE PROTRUSION IS
0.250 PER SIDE. DIMENSIONS A AND B DO
INCLUDE MOLD MISMATCH AND ARE
DETERMINED AT DATUM PLANE AB.
B V 7. DIMENSION D DOES NOT INCLUDE DAMBAR
PROTRUSION. DAMBAR PROTRUSION SHALL
AE AE NOT CAUSE THE D DIMENSION TO EXCEED
B1 0.350.
V1 8. MINIMUM SOLDER PLATE THICKNESS SHALL BE
12 25
0.0076.
9. EXACT SHAPE OF EACH CORNER IS OPTIONAL.
13 24 MILLIMETERS
DIM MIN MAX
Z A 7.000 BSC
S1 A1 3.500 BSC
T, U, Z B 7.000 BSC
B1 3.500 BSC
S C 1.400 1.600
DETAIL Y D 0.170 0.270
4X E 1.350 1.450
F 0.170 0.230
0.200 AC T–U Z G 0.500 BSC
H 0.050 0.150
J 0.090 0.200
K 0.500 0.700
L 1° 5°
G 0.080 AC M 12° REF
AB N 0.090 0.160
P 0.250 BSC
R 0.150 0.250
S 9.000 BSC
S1 4.500 BSC
V 9.000 BSC
AD V1 4.500 BSC
AC W 0.200 REF
AA 1.000 REF
BASE METAL M°
TOP & BOTTOM
R
GAUGE PLANE
N J
0.250
C E
F
D
0.080 M AC T–U Z
SECTION AE–AE H W
L°
DETAIL AD K
AA
–A– NOTES:
1. DIMENSIONING AND TOLERANCING PER ANSI
Y14.5M, 1982.
2. CONTROLLING DIMENSION: INCH.
42 22 3. DIMENSION L TO CENTER OF LEAD WHEN
FORMED PARALLEL.
4. DIMENSIONS A AND B DO NOT INCLUDE MOLD
–B– FLASH. MAXIMUM MOLD FLASH 0.25 (0.010).
INCHES MILLIMETERS
1 21 DIM MIN MAX MIN MAX
L A 1.435 1.465 36.45 37.21
B 0.540 0.560 13.72 14.22
26.1 Contents
26.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
26.2 Introduction
This section contains ordering numbers for the MC68HC908SR12.
Appendix A. MC68HC08SR12
A.1 Contents
A.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
A.2 Introduction
This section introduces the MC68HC08SR12, the ROM part equivalent
to the MC68HC908SR12. The entire data book apply to this ROM
device, with exceptions outlined in this appendix.
MC68HC08SR12 MC68HC908SR12
PORTA
PTA6/T1CH0
DDRA
REGISTERS UNIT (ALU) MODULE 1
PTA5/ATD7 – PTA0/ATD2 ‡
CONTROL AND STATUS REGISTERS — 96 BYTES 2-CHANNEL TIMER INTERFACE
MODULE 2
USER ROM — 12,288 BYTES
PTB6/IRQ2
TIMEBASE
USER RAM — 512 BYTES MODULE PTB5/T2CH1
PTB4/T2CH0
PORTB
DDRB
PTB3//SCL1/RxD †
MONITOR ROM — 368 BYTES
SERIAL COMMUNICATIONS PTB2/SDA1/TxD †
INTERFACE MODULE PTB1/SCL0 †
USER ROM VECTORS — 38 BYTES PTB0/SDA0 †
MULTI-MASTER IIC (SMBUS)
OSCILLATORS AND INTERFACE MODULE
CLOCK GENERATOR MODULE PTC7/ATD12 ‡ #
PTC6/ATD11 ‡ #
MC68HC08SR12
INTERNAL OSCILLATOR
PULSE WIDTH MODULATOR PTC5/ATD10 ‡
RC OSCILLATOR
PORTC
MODULE PTC4/ATD9 ‡
DDRC
OSC1
X-TAL OSCILLATOR PTC3/ATD8 ‡
OSC2
PTC2/PWM2
8-BIT KEYBOARD
CGMXFC PHASE-LOCKED LOOP INTERRUPT MODULE PTC1/PWM1
PTC0/PWM0/CD
PORTD
DDRD
PTD7/KBI7 – PTD0/KBI0 ***
* IRQ1 EXTERNAL IRQ
** IRQ2 MODULE LOW-VOLTAGE
INHIBIT MODULE
OPIN1/ATD0
# OPIN2/ATD1
ANALOG
MODULE POWER-ON RESET
VSSAM MODULE
VREFH 10-BIT ANALOG-TO-DIGITAL
* Pin contains integrated pullup device.
VREFL CONVERTER MODULE
** Pin contains configurable pullup device.
*** Pin contains integrated pullup device for KBI functions.
MC68HC08SR12
VDD
VSS † Pin is open-drain when configured as output.
VDDA POWER ‡ High current drive pin (for LED).
Data Sheet
$0000
I/O Registers
↓
96 Bytes
$005F
$0060
RAM
↓
512 Bytes
$025F
$0260
Unimplemented
↓
48,544 Bytes
$BFFF
$C000
ROM
↓
12,288 Bytes
$EFFF
$F000
Unimplemented
↓
3,584 Bytes
$FDFF
$FE00 SIM Break Status Register (SBSR)
$FE01 SIM Reset Status Register (SRSR)
$FE02 Reserved
$FE03 SIM Break Flag Control Register (SBFCR)
$FE04 Interrupt Status Register 1 (INT1)
$FE05 Interrupt Status Register 2 (INT2)
$FE06 Interrupt Status Register 3 (INT3)
$FE07 Reserved
$FE08 Reserved
$FE09 Reserved
$FE0A Reserved
$FE0B Reserved
$FE0C Break Address Register High (BRKH)
$FE0D Break Address Register Low (BRKL)
$FE0E Break Status and Control Register (BRKSCR)
$FE0F LVI Status Register (LVISR)
$FE10
Monitor ROM
↓
368 Bytes
$FF7F
$FF80 Mask Option Register
$FF81
Reserved
↓
89 Bytes
$FFD9
$FFDA
ROM Vectors
↓
38 Bytes
$FFFF
Figure A-2. MC68HC08SR12 Memory Map
Stop(5)
25°C (with OSC, TBM, current sense, LVI) IDD — 50 150 µA
25°C (with OSC, TBM, current sense) — 12 40 µA
25°C (with OSC, TBM) — 9 30 µA
25°C — 2 10 µA
–40°C to 85°C (with OSC, TBM, current sense, LVI) — — 180 µA
–40°C to 85°C (with OSC, TBM, current sense) — — 50 µA
–40°C to 85°C (with OSC, TBM) — — 40 µA
–40°C to 85°C — — 15 µA
Capacitance COUT — — 12
pF
Ports (as input or output) CIN — — 8
Pullup resistors(8)
PTD[0:7] configured as KBI[0:7] RPU1 24 35 42 kΩ
RST, IRQ1, IRQ2 RPU2 24 35 42 kΩ
Capacitance COUT — — 12
pF
Ports (as input or output) CIN — — 8
Pullup resistors(8)
PTD[0:7] configured as KBI[0:7] RPU1 24 35 42 kΩ
RST, IRQ1, IRQ2 RPU2 24 35 42 kΩ
Low-voltage inhibit, trip voltage
VLVI3 2.32 2.49 2.68 V
(No hysteresis implemented for 3V LVI)
Schmitt trigger input low level trip voltage
VSCMTL — 0.8 — V
RST, IRQ1, IRQ2, KBI[0:7]
Schmitt trigger input high level trip voltage
VSCMTH — 1.2 — V
RST, IRQ1, IRQ2, KBI[0:7]
Notes:
1. VDD = 2.7 to 3.3 Vdc, VSS = 0 Vdc, TA = TL to TH, unless otherwise noted.
2. Typical values reflect average measurements at midpoint of voltage range, 25 °C only.
3. Run (operating) IDD measured using external square wave clock source. All inputs 0.2 V from rail. No dc loads. Less than
100 pF on all outputs. CL = 20 pF on OSC2. All ports configured as inputs. OSC2 capacitance linearly affects run IDD.
Measured with all modules enabled.
4. Wait IDD measured using external square wave clock source. All inputs 0.2 V from rail. No dc loads. Less than 100 pF on
all outputs. CL = 20 pF on OSC2. All ports configured as inputs. OSC2 capacitance linearly affects wait IDD.
5. STOP IDD measured with OSC1 grounded, no port pins sourcing current.
6. Maximum is highest voltage that POR is guaranteed.
7. If minimum VDD is not reached before the internal POR reset is released, RST must be driven low externally until minimum
VDD is reached.
8. RPU1 and RPU2 are measured at VDD = 5.0V.
Notes:
1. SDIP = Shrink Dual In-Line Package.
2. LQFP = Low Quad Flat Pack.
Japan:
Freescale Semiconductor Japan Ltd.
Technical Information Center
3-20-1, Minami-Azabu, Minato-ku
Tokyo 106-8573, Japan
81-3-3440-3569
Asia/Pacific:
Freescale Semiconductor Hong Kong Ltd.
2 Dai King Street
Tai Po Industrial Estate
Tai Po, N.T., Hong Kong
852-26668334
Home Page:
www.freescale.com
Information in this document is provided solely to enable system and software implementers to use Freescale
Semiconductor products. There are no express or implied copyright licenses granted hereunder to design or fabricate any
integrated circuits or integrated circuits based on the information in this document.
Freescale Semiconductor reserves the right to make changes without further notice to any products herein. Freescale
Semiconductor makes no warranty, representation or guarantee regarding the suitability of its products for any particular
purpose, nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or
circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages.
“Typical” parameters that may be provided in Freescale Semiconductor data sheets and/or specifications can and do vary
in different applications and actual performance may vary over time. All operating parameters, including “Typicals”, must
be validated for each customer application by customer’s technical experts. Freescale Semiconductor does not convey any
license under its patent rights nor the rights of others. Freescale Semiconductor products are not designed, intended, or
authorized for use as components in systems intended for surgical implant into the body, or other applications intended to
support or sustain life, or for any other application in which the failure of the Freescale Semiconductor product could create
a situation where personal injury or death may occur. Should Buyer purchase or use Freescale Semiconductor products for
any such unintended or unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and its officers,
employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and
reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such
unintended or unauthorized use, even if such claim alleges that Freescale Semiconductor was negligent regarding the
design or manufacture of the part.
Learn More: For more information about Freescale products, please visit www.freescale.com
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names
are the property of their respective owners.
© Freescale Semiconductor, Inc. 2004
MC68HC908SR12
Rev. 5
07/2004