SH79F166A

SH79F166A
166
A
SH79F
SH79F166
166A
Enhanced 8051 Microcontroller with 10bit ADC
1. Features
пїЅ
пїЅ
пїЅ
пїЅ
пїЅ
пїЅ
пїЅ
пїЅ
пїЅ
пїЅ
пїЅ
пїЅ
пїЅ
8bits micro-controller with Pipe-line structured 8051
compatible instruction set
Flash ROM: 16K Bytes
RAM: internal 256 Bytes, external 256 Bytes, LCD RAM
19Bytes
EEPROM-like: 1K Bytes
Operation Voltage:
fOSC = 32.768kHz - 12MHz, VDD = 2V - 5.5V
Oscillator (code option)
- Crystal oscillator: 32.768kHz
- Crystal oscillator: 2MHz - 12MHz
- Ceramic oscillator: 2MHz - 12MHz
- Internal RC: 12MHz (В±2%)/128K
41 CMOS bi-directional I/O pins
Built-in pull-up resistor for input pin
Four 16-bit timer/counters T2, T3,T4 and T5
One 12-bit PWM
Powerful interrupt sources:
- Timer2, 3, 4, 5
- INT0, 1, 2, 3
- INT40, INT41, INT42, INT43
- ADCпјЊEUARTпјЊSCM
- PWM
пїЅ
пїЅ
пїЅ
пїЅ
пїЅ
пїЅ
пїЅ
пїЅ
пїЅ
пїЅ
EUART
8channels 10-bits Analog Digital Converter (ADC),
with comparator function built-in
Buzzer
LED driver:
- 8 X 8 dots (1/8 duty)
- 4 X 8 dots (1/4 duty)
LCD driver:
- 8 X 19 dots (1/8 duty 1/4 bias)
- 4 X 19 dots (1/4 duty 1/3 bias)
Low Voltage Reset (LVR) function (enabled by
code option)
- LVR voltage level 1: 4.3V
- LVR voltage level 2: 2.1V
CPU Machine cycle:
1 oscillator clock
Watch Dog Timer (WDT)
Warm-up Timer
Support Low power operation modes:
- Idle Mode
- Power-Down Mode
Flash Type
Package: QFP44/LQFP44
2. General Description
The SH79F166A is a high performance 8051 compatible micro-controller, regard to its build-in Pipe-line instruction fetch
structure, that helps the SH79F166A can perform more fast operation speed and higher calculation performance, if compare
SH79F166A with standard 8051 at same clock speed.
The SH79F166A retains most features of the standard 8051. These features include internal 256 bytes RAM, UART and
Int0-3.In addition, the SH79F166A provides external 256 bytes RAM, It also contains 16K bytes Flash memory block both for
program and data. Also the ADC and PWM timer functions are incorporated in SH79F166A.
For high reliability and low cost issues, the SH79F166A builds in Watchdog Timer, Low Voltage Reset function. And
SH79F166A also supports two power saving modes to reduce power consumption.
1
V2.1
166A
SH79F
SH79F166A
3. Block Diagram
V DD
R eset circuit
Power
RST
Pipelined 8051 archit ecture
Watch Dog
16K Bytes
Flash ROM
Port 5
C onfiguration I/Os
Internal 256 Bytes
External 256 Bytes
(Exclude System
R egis ter)
Port 4
C onfiguration I/Os
Port 3
C onfiguration I/Os
Tim er2 (16bit )
Tim er3 (16bit )
Tim er4 (16bit )
Tim er5( 16bit )
Port 2
C onfiguration I/Os
External Interrupt
P5.0 - P5.3
P4.0 - P4.4
P3.0 - P3.7
P2.0 - P2.7
Port 1
C onfiguration I/Os
P1.0 - P1.7
12-bit PW M
Port 0
C onfiguration I/Os
P0.0 - P0.7
Internal
Oscilator
oscilator fail
detector
EUART0
XTAL1
Oscilator
10-bit ADC
XTAL2
XTALX1
COM1 - 8
SEG1 - 19
Oscilator X
LCD/LED Driv er
XTALX2
buzzer
Jtag ports
(for debug)
2
166A
SH79F
SH79F166A
4. Pin Configuration
P1.6/SEG7/LED_S7
P1.5/SEG6/LED_S6
P1.4/SEG5/LED_S5
P1.3/SEG4/LED_S4/TCK
P1.2/SEG3/LED_S3/TDI
P1.1/SEG2/LED_S2/TMS
P1.0/SEG1/LED_S1/TDO
P3.0/COM1/LED_C1
P3.1/COM2/LED_C2
P3.2/COM3/LED_C3
P3.3/COM4/LED_C4
QFP44:
33
31
30
29
28
27
26
25 24
23
34
22
35
21
36
20
37
19
38
18
AF
SH79F166
SH79F166A
39
17
40
16
41
15
42
14
43
13
44
12
1
2
3
4
5
6
7
8
9
10
11
PWM01/SEG19/P0.2
PWM0/T4/P0.3
T2EX/INT0/P0.4
T2/INT1/P0.5
XTALX2/INT2/P0.6
XTALX1/INT3/P0.7
Vss
XTAL1/P5.0
XTAL2/P5.1
RST/P5.2
BUZ/T3/P5.3
LED_S8/SEG8/P1.7
RXD/SEG9/P2.0
TXD/SEG10/P2.1
SEG11/P2.2
SEG12/P2.3
SEG13/P2.4
FLT/SEG14/P2.5
SEG15/P2.6
SEG16/P2.7
SEG17/P0.0
SEG18/P0.1
32
QFP44 Pin Configuration Diagram
3
P3.4/COM5/LED_C5/AN4
P3.5/COM6/LED_C6/AN5
P3.6/COM7/LED_C7/AN6
P3.7/COM8/LED_C8/AN7
P4.0/INT40/AN0
P4.1/INT41/AN1
P4.2/INT42/AN2
P4.3/INT43/AN3
P4.4/AVREF
NC
VDD
166A
SH79F
SH79F166A
P1.6/SEG7/LED_S7
P1.5/SEG6/LED_S6
P1.4/SEG5/LED_S5
P1.3/SEG4/LED_S4/TCK
P1.2/SEG3/LED_S3/TDI
P1.1/SEG2/LED_S2/TMS
P1.0/SEG1/LED_S1/TDO
P3.0/COM1/LED_C1
P3.1/COM2/LED_C2
P3.2/COM3/LED_C3
P3.3/COM4/LED_C4
LQFP44:
33
LED_S8/SEG8/P1.7
RXD/SEG9/P2.0
TXD/SEG10/P2.1
SEG11/P2.2
SEG12/P2.3
SEG13/P2.4
FLT/SEG14/P2.5
SEG15/P2.6
SEG16/P2.7
SEG17/P0.0
SEG18/P0.1
32
31
30
29
28
27
26
25 24
23
34
22
35
21
36
20
37
19
38
18
AP
SH79F166
SH79F166A
39
17
40
16
41
15
42
14
43
13
44
12
2
3
4
5
6
7
8
9
10
11
PWM01/SEG19/P0.2
PWM0/T4/P0.3
T2EX/INT0/P0.4
T2/INT1/P0.5
XTALX2/INT2/P0.6
XTALX1/INT3/P0.7
Vss
XTAL1/P5.0
XTAL2/P5.1
RST/P5.2
BUZ/T3/P5.3
1
P3.4/COM5/LED_C5/AN4
P3.5/COM6/LED_C6/AN5
P3.6/COM7/LED_C7/AN6
P3.7/COM8/LED_C8/AN7
P4.0/INT40/AN0
P4.1/INT41/AN1
P4.2/INT42/AN2
P4.3/INT43/AN3
P4.4/AVREF
NC
VDD
LQFP44 Pin Configuration Diagram
Note:
The out most pin function has the highest priority, and the inner most pin function has the lowest priority (Refer to Pin
Configuration Diagram. This means when one pin is occupied by a higher priority function (if enabled) cannot be used as the
lower priority functional pin, even when the lower priority function is also enabled. Until the higher priority function is closed by
software, can the corresponding pin be released for the lower priority function use.
4
166A
SH79F
SH79F166A
Table 4.1 Pin F unction
Pin No.
Pin Name
Default function
Pin No.
Pin Name
Default function
1
PWM01/SEG19/P0.2
P0.2
23
LED_C4/COM4/P3.3
P3.3
2
PWM0/T4/P0.3
P0.3
24
LED_C3/COM3/P3.2
P3.2
*3
T2EX/INT0/P0.4
P0.4
25
LED_C2/COM2/P3.1
P3.1
*4
T2/INT1/P0.5
P0.5
26
LED_C1/COM1/P3.0
P3.0
5
XTALX2/INT2/P0.6
P0.6
27
LED_S1/SEG1/P1.0
P1.0
6
XTALX1/INT3/P0.7
P0.7
28
LED_S2/SEG2/P1.1
P1.1
7
VSS
----
29
LED_S3/SEG3/P1.2
P1.2
8
XTAL1/P5.0
----
30
LED_S4/SEG4/P1.3
P1.3
9
XTAL2/P5.1
10
————
RST/P5.2
----
31
LED_S5/SEG5/P1.4
P1.4
————
RST
32
LED_S6/SEG6/P1.5
P1.5
11
BUZ/T3/P5.3
P5.3
33
LED_S7/SEG7/P1.6
P1.6
12
VDD
----
34
LED_S8/SEG8/P1.7
P1.7
13
NC
----
35
RXD/SEG9/P2.0
P2.0
14
AVREF/P4.4
P4.4
36
TXD/SEG10/P2.1
P2.1
15
AN3/INT43/P4.3
P4.3
37
SEG11/P2.2
P2.2
16
AN2/INT42/P4.2
P4.2
38
SEG12/P2.3
P2.3
17
AN1/INT41/P4.1
P4.1
39
SEG13/P2.4
P2.4
18
AN0/INT40/P4.0
P4.0
40
FLT/SEG14/P2.5
P2.5
19
AN7/LED_C8/COM8/P3.7
P3.7
41
SEG15/P2.6
P2.6
20
AN6/LED_C7/COM7/P3.6
P3.6
42
SEG16/P2.7
P2.7
21
AN5/LED_C6/COM6/P3.5
P3.5
43
SEG17/P0.0
P0.0
22
AN4/LED_C5/COM5/P3.4
P3.4
44
SEG18/P0.1
P0.1
* Note: P0.4, P0.5 are configured as N-channel open drain I/O
5
166A
SH79F
SH79F166A
5. Pin Description
Pin No.
Type
Description
I/O PORT
P0.0 - P0.7
I/O
8 bit General purpose CMOS I/O
P1.0 - P1.7
I/O
8 bit General purpose CMOS I/O
P2.0 - P2.7
P3.0 - P3.7
I/O
I/O
8 bit General purpose CMOS I/O
8 bit General purpose CMOS I/O
P4.0 - P4.4
I/O
5 bit General purpose CMOS I/O
P5.0 - P5.3
I/O
4 bit General purpose CMOS I/O
T2
T3
I/O
I
Timer2 external input
Timer3 external input
Timer
T4
I/O
Timer4 external input/Comparator output
T2EX
I
Timer2 Reload/Capture/Direction Control
PWM
PWM0
O
Output pin for 12-bit PWM timer
PWM01
FLT
O
I
Output pin for 12-bit PWM timer with fixed phase relationship of PWM0
PWM Fault Detect input
RXD
TXD
I
O
EUART data input
EUART data output
AN0 - AN7
I
ADC input channel
AVREF
I
External ADC reference voltage input
EUART
ADC
LCD
COM1 - COM8
O
Common signal output for LCD display
SEG1 - SEG19
O
Segment signal output for LCD display
LED_C1 - LED_C8
LED_S1 - LED_S8
O
O
Common signal output for LED display
Segment signal output for LED display
LE D
Interrupt & Reset & Clock & Power
INT0 - INT3
I
External interrupt 0-3 input source
INT40 - INT43
I
External interrupt 40-43 input source
RST
I
The device will be reset by A low voltage on this pin longer than 10us, an internal
resistor about 30kО© to VDD, So using only an external capacitor to GND can cause
a power-on reset.
XTAL1
I
Oscillator input
————
XTAL2
O
Oscillator output
XTALX1
I
OscillatorX input
XTALX2
O
OscillatorX output
V SS
P
Ground
VDD
P
Power supply (2.0 - 5.5V)
(to be continued)
6
166A
SH79F
SH79F166A
(continue)
Pin No.
Type
Description
BUZ
O
Buzzer output pin
TDO (P1.0)
O
Debug interface: Test data out
TMS (P1.1)
I
Debug interface: Test mode select
TDI (P1.2)
I
Debug interface: Test data in
TCK (P1.3)
I
Debug interface: Test clock in
Buzzer
Programmer
Note
Noteпјљ
When P1.0-1.3 used as debug interface, functions of P1.0-1.3 are blocked.
7
166A
SH79F
SH79F166A
6. SFR Mapping
The SH79F166A provides 256 bytes of internal RAM to contain general-purpose data memory and Special Function Register
(SFR). The SFR of the SH79F166A fall into the following categories:
CPU C ore R egisters:
ACC, B, PSW, SP, DPL, DPH
Enhanced C PU C ore Registers:
AUXC, DPL1, DPH1, INSCON, XPAGE
Power and Clock Control Registers: PCON, SUSLO
Flash R egisters:
IB_OFFSET, IB_DATA, IB_CON1, IB_CON2, IB_CON3, IB_CON4, IB_CON5,
FLASHCON
Data Memory R egister:
XPAGE
Hardware Watchdog Timer R egisters: RSTSTAT
System Clock Control Register:
CLKCON
Interrupt System R egisters:
IEN0, IEN1, IENC, IPH0, IPL0, IPH1, IPL1, EXF0, EXF1
I/O Port R egisters:
P0, P1, P2, P3, P4, P5, P0CR, P1CR, P2CR, P3CR, P4CR, P5CR, P0PCR, P1PCR,
P2PCR, P3PCR, P4PCR, P5PCR, P0OS
Timer Registers:
TCON, T2CON, T2MOD, TH2, TL2, RCAP2L, RCAP2H, T3CON, TH3, TL3,
T4CON, TH4, TL4, SWTHL, T5CON, TH5, TL5
EUART R egisters:
SCON, SBUF, SADEN, SADDR, PCON, RxCON
ADC R egisters:
ADCON, ADT, ADCH, ADDL, ADDH
LCD Registers:
DISPCON, DISPCLK0, DISPCLK1, P0SS, P1SS, P2SS, P3SS
LED R egisters:
DISPCON, DISPCLK0, DISPCLK1, P1SS, P3SS
Buzzer R egisters:
BUZCON
PWM R egisters:
PWMEN , PWMEN1, PWMLO, PWM0C, PWM0PL, PWM0PH, PWM0DL, PWM0DH
LPD R egisters:
LPDCON
8
166A
SH79F
SH79F166A
Table 6.1 CPU Core SFRs
Mnem
Add
Nam e
POR/WDT/LVR
Value
/PIN Reset
ResetValue
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
ACC
E0H
Accumulator
00000000
ACC.7
ACC.6
ACC.5
ACC.4
ACC.3
ACC.2
ACC.1
ACC.0
B
F0H
B Register
00000000
B.7
B.6
B.5
B.4
B.3
B.2
B.1
B.0
AUXC
F1H
C Register
00000000
C.7
C.6
C.5
C.4
C.3
C.2
C.1
C.0
PSW
D0H
Program Status Word
00000000
CY
AC
F0
RS1
RS0
OV
F1
P
SP
81H
Stack Pointer
00000111
SP.7
SP.6
SP.5
SP.4
SP.3
SP.2
SP.1
SP.0
DPL
82H
Data Pointer Low byte
00000000
DPL0.7
DPL0.6
DPL0.5
DPL0.4
DPL0.3
DPL0.2
DPL0.1
DPL0.0
DPH
83H
Data Pointer High byte
00000000
DPH0.7
DPH0.6
DPH0.5
DPH0.4
DPH0.3
DPH0.2
DPH0.1
DPH0.0
DPL1
84H
Data Pointer 1 Low byte
00000000
DPL1.7
DPL1.6
DPL1.5
DPL1.4
DPL1.3
DPL1.2
DPL1.1
DPL1.0
DPH1
85H
Data Pointer 1 High byte
00000000
DPH1.7
DPH1.6
DPH1.5
DPH1.4
DPH1.3
DPH1.2
DPH1.1
DPH1.0
INSCON
86H
Data pointer select
-0--00-0
-
BKS0
-
-
DIV
MUL
-
DPS
Table 6.2 Power and Clock control SFRs
Mnem
Add
Nam e
POR/WDT/LVR
Value
/PIN Reset
ResetValue
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
PCON
87H
Power Control
00--0000
SMOD
SSTAT
-
-
GF1
GF0
PD
IDL
SUSLO
8EH
Suspend Mode Control
00000000
SUSLO.7
SUSLO.6
SUSLO.5
SUSLO.4
SUSLO.3
SUSLO.2
SUSLO.1
SUSLO.0
9
166A
SH79F
SH79F166A
Table 6.3 Flash control SFRs
Mnem
Add
Nam e
POR/WDT/LVR
/PIN Reset Value
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
IB_OFF
SET
FBH
Bank0
Low byte offset of flash memory
for programming
00000000
IB_OFF
SET.7
IB_OFF
SET.6
IB_OFF
SET.5
IB_OFF
SET.4
IB_OF F
SET.3
IB_OFF
SET.2
IB_OFF
SET.1
IB_OFF
SET.0
IB_DATA
FCH
Bank0
Data Register for programming
flash memory
00000000
IB_DATA.7 IB_DATA.6 IB_DATA.5 IB_DATA.4 IB_DATA.3 IB_DATA.2 IB_DATA.1 IB_DATA.0
IB_CON1
F2H
Bank0
Flash Memory Control Register 1
00000000
IB_CON1.7 IB_CON1.6 IB_CON1.5 IB_CON1.4 IB_CON1.3 IB_CON1.2 IB_CON1.1 IB_CON1.0
IB_CON2
F3H
Bank0
Flash Memory Control Register 2
----0000
-
-
-
-
IB_CON2.3 IB_CON2.2 IB_CON2.1 IB_CON2.0
IB_CON3
F4H
Bank0
Flash Memory Control Register 3
----0000
-
-
-
-
IB_CON3.3 IB_CON3.2 IB_CON3.1 IB_CON3.0
IB_CON4
F5H
Bank0
Flash Memory Control Register 4
----0000
-
-
-
-
IB_CON4.3 IB_CON4.2 IB_CON4.1 IB_CON4.0
IB_CON5
F6H
Bank0
Flash Memory Control Register 5
----0000
-
-
-
-
IB_CON5.3 IB_CON5.2 IB_CON5.1 IB_CON5.0
XPA GE
F7H
Bank0
Memory Page
--000000
-
-
XPAGE.5
XPAGE.4
XPAGE.3
XPAGE.2
XPAGE.1
XPAGE.0
FLASHCON
A7H
Bank0
Flash access control
-------0
-
-
-
-
-
-
-
FAC
4 WDT SFR
Table 6.
6.4
Mnem
Add
Nam e
POR/WDT/LVR
Value
/PIN Reset
ResetValue
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
RSTSTAT
B1H
Bank0
Watchdog Timer Control
*-*** 000
WDOF
-
PO RF
LVRF
CLRF
WDT.2
WDT.1
WDT.0
*Note: RSTSTAT initial value is determined by different RESET.
5 CLKCON SFR
Table 6.
6.5
Mnem
Add
Nam e
POR/WDT/LVR
Value
/PIN Reset
ResetValue
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
CLKCON
B2H
Bank0
System Clock Control Register
111000--
32k_
SPDUP
CLKS1
CLKS0
SCMIF
HFON
FS
-
-
10
166A
SH79F
SH79F166A
Table 6.6 Interrupt SFRs
Mnem
Add
Nam e
POR/WDT/LVR
Value
/PIN Reset
ResetValue
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
IEN 0
A8H
Bank0
Interrupt Enable Control 0
0000-000
EA
EA DC
ET2
ES
-
EX1
ET5
EX0
IEN 1
A9H
Bank0
Interrupt Enable Control 1
0000000-
ESCM/ELPD
ET4
EPWM
ET3
EX4
EX3
EX2
-
IE NC
BAH
Bank0
Interrupt 4channel enable control
----0000
-
-
-
-
EXS43
EXS42
EXS41
EXS40
IE NC1
BBH
Bank0
Interrupt channel enable control 1
------00
-
-
-
-
-
-
ESCM1
ELPD
IP H0
B4H
Bank0
Interrupt Priority Control High 0
-000-000
-
PADCH
PT2H
PSH
-
PX1H
PT5H
PX0H
IP L0
B8H
Bank0
Interrupt Priority Control Low 0
-000-000
-
PADCL
PT2L
PSL
-
PX1L
PT5L
PX0L
IP H1
B5H
Bank0
Interrupt Priority Control High 1
0000000-
PSCMH
PT4H
PPWMH
PT3H
PX4H
PX3H
PX2H
-
IPL1
B9H
Bank0
Interrupt Priority Control Low 1
0000000-
PSCML
PT4L
PPWML
PT3L
PX4L
PX3L
PX2L
-
EX F0
E8H
Bank0
External interrupt Control 0
00000000
IT4.1
IT4.0
IT3.1
IT3.0
IT2.1
IT2.0
IE3
IE2
EX F1
D8H
Bank0
External interrupt Control 1
----0000
-
-
-
-
IF43
IF42
IF41
IF40
11
166A
SH79F
SH79F166A
7 Port SFRs
Table 6.
6.7
Mnem
P0
P1
P2
P3
P4
P5
P0CR
P1CR
P2CR
P3CR
P4CR
P5CR
P0PCR
P1PCR
P2PCR
P3PCR
P4PCR
P5PCR
P0OS
Add
80H
Bank0
90H
Bank0
A0H
Bank0
B0H
Bank0
C0H
Bank0
80H
Bank1
E1H
Bank0
E2 H
Bank0
E3 H
Bank0
E4 H
Bank0
E5H
Bank0
E1H
Bank1
E9 H
Bank0
EAH
Bank0
EBH
Bank0
EC H
Bank0
EDH
Bank0
E9H
Bank1
EFH
Bank0
Nam e
POR/WDT/LVR
Value
/PIN Reset
ResetValue
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
8-bit Port 0
00000000
P0.7
P0.6
P0.5
P0.4
P0.3
P0.2
P0.1
P0.0
8-bit Port 1
00000000
P1.7
P1.6
P1.5
P1.4
P1.3
P1.2
P1.1
P1.0
8-bit Port 2
00000000
P2.7
P2.6
P2.5
P2.4
P2.3
P2.2
P2.1
P2.0
8-bit Port 3
00000000
P3.7
P3.6
P3.5
P3.4
P3.3
P3.2
P3.1
P3.0
5-bit Port 4
---00000
-
-
-
P4.4
P4.3
P4.2
P4.1
P4.0
4-bit Port 5
----0000
-
-
-
-
P5.3
P5.2
P5.1
P5.0
Port0 input/output direction control
00000000
P0CR.7
P0CR.6
P0CR.5
P0CR.4
P0CR.3
P0CR.2
P0CR.1
P0CR.0
Port1 input/output direction control
00000000
P1CR.7
P1CR.6
P1CR.5
P1CR.4
P1CR.3
P1CR.2
P1CR.1
P1CR.0
Port2 input/output direction control
00000000
P2CR.7
P2CR.6
P2CR.5
P2CR.4
P2CR.3
P2CR.2
P2CR.1
P2CR.0
Port3 input/output direction control
00000000
P3CR.7
P3CR.6
P3CR.5
P3CR.4
P3CR.3
P3CR.2
P3CR.1
P3CR.0
Port4 input/output direction control
---00000
-
-
-
P4CR.4
P4CR.3
P4CR.2
P4CR.1
P4CR.0
Port5 input/output direction control
----0000
-
-
-
-
P5CR.3
P5CR.2
P5CR.1
P5CR.0
Internal pull-high enable for Port0
00000000
P0PCR.7
P0PCR.6
P0PCR.5
P0PCR.4
P0PCR.3
P0PCR.2
P0PCR.1
P0PCR.0
Internal pull-high enable for Port1
00000000
P1PCR.7
P1PCR.6
P1PCR.5
P1PCR.4
P1PCR.3
P1PCR.2
P1PCR.1
P1PCR.0
Internal pull-high enable for Port2
00000000
P2PCR.7
P2PCR.6
P2PCR.5
P2PCR.4
P2PCR.3
P2PCR.2
P2PCR.1
P2PCR.0
Internal pull-high enable for Port3
00000000
P3PCR.7
P3PCR.6
P3PCR.5
P3PCR.4
P3PCR.3
P3PCR.2
P3PCR.1
P3PCR.0
Internal pull-high enable for Port4
---00000
-
-
-
P4PCR.4
P4PCR.3
P4PCR.2
P4PCR.1
P4PCR.0
Internal pull-high enable for Port5
----0000
-
-
-
-
P5PCR.3
P5PCR.2
P5PCR.1
P5PCR.0
Output mode control
--00----
-
-
P0OS.5
P0OS.4
-
-
-
-
12
166A
SH79F
SH79F166A
Table 6.8 Timer SFRs
Mnem
Add
Nam e
POR/WDT/LVR
Value
/PIN Reset
ResetValue
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
TCON
88H
Bank0
Timer/Counter Control
----0000
-
-
-
-
IE1
IT1
IE0
IT0
T2CON
C8H
Bank0
Timer/Counter 2 Control
00000000
TF2
EXF2
RCLK
TCLK
EX EN2
TR2
--------
------------
C/ T 2
CP/ R L 2
T2MO D
C9H
Bank0
Timer/Counter 2 Mode
------00
-
-
-
-
-
-
T2OE
DCEN
RCAP2L
CA H
Bank0
Timer/Counter 2 Reload
/Caprure Low Byte
00000000
RCAP2L.7
RCAP2L.6
RCAP2L.5
RCAP2L.4
RCAP2L.3
RCAP2L.2
RCAP2L.1
RCAP2L.0
RCA P2H
CBH
Bank0
Timer/Counter 2 Reload
/Caprure High Byte
00000000
RCAP2H.7
RCA P2H.6
RCAP2H.5
RCAP2H.4
RCAP2H.3
RCA P2H.2
RCAP2H.1
RCAP2H.0
TL2
CCH
Bank0
Timer/Counter 2 Low Byte
00000000
TL2.7
TL2.6
TL2.5
TL2.4
TL2.3
TL2.2
TL2.1
TL2.0
TH2
CDH
Bank0
Timer/Counter 2 High Byte
00000000
TH2.7
TH2.6
TH2.5
TH2.4
TH2.3
TH2.2
TH2.1
TH2.0
T3CON
88H
Bank1
Timer/Counter 3 Control
0-00-000
TF3
-
T3PS.1
T3PS.0
-
TR3
T3CLKS.1
T3CLKS.0
SWTHL
89H
Bank1
Timer/Counter data switch
------00
-
-
-
-
-
-
T5HLCON
T3HLCON
TL3
8CH
Bank1
Timer/Counter 3 Low Byte
00000000
TL3.7
TL3.6
TL3.5
TL3.4
TL3.3
TL3.2
TL3.1
TL3.0
TH3
8DH
Bank1
Timer/Counter 3 High Byte
00000000
TH3.7
TH3.6
TH3.5
TH3.4
TH3.3
TH3.2
TH3.1
TH3.0
T4CON
C8H
Bank1
Timer/Counter 4 Control
00000000
TF4
TC4
T4PS1
T4PS0
T4M1
T4M0
TR4
T4CLKS
TL4
CCH
Bank1
Timer/Counter 4 Low Byte
00000000
TL4.7
TL4.6
TL4.5
TL4.4
TL4.3
TL4.2
TL4.1
TL4.0
TH4
CDH
Bank1
Timer/Counter 4 High Byte
00000000
TH4.7
TH4.6
TH4.5
TH4.4
TH4.3
TH4.2
TH4.1
TH4.0
T5CON
C0H
Bank1
Timer/Counter 5 Control
0-000-0-
TF5
-
T5PS1
T5PS0
-
-
TR5
-
TL5
CEH
Bank1
Timer/Counter 5 Low Byte
00000000
TL5.7
TL5.6
TL5.5
TL5.4
TL5.3
TL5.2
TL5.1
TL5.0
TH5
CF H
Bank1
Timer/Counter 5 High Byte
00000000
TH5.7
TH5.6
TH5.5
TH5.4
TH5.3
TH5.2
TH5.1
TH5.0
13
166A
SH79F
SH79F166A
Table 6.9 EUART SFRs
Mnem
Add
Nam e
POR/WDT/LVR
Value
/PIN Reset
ResetValue
Bit7
SCON
98H
Bank0
Serial Control
00000000
SM0/FE
SBUF
99H
Bank0
Serial Data Buffer
00000000
SBUF.7
SBUF.6
SA DEN
9BH
Bank0
Slave Address Mask
00000000
SADEN.7
SADDR
9AH
Bank0
Slave Address
00000000
PCON
87H
Bank0
Power & serial Control
RxCON
9FH
Bank0
Rxd pin Schmidt voltage Control
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
REN
TB8
RB8
TI
RI
SBUF.5
SBUF.4
SBUF.3
SBUF.2
SBUF.1
SBUF.0
SADEN.6
SADEN.5
SADEN.4
SADEN.3
SADEN.2
SADEN.1
SADEN.0
SADDR.7
SADDR.6
SADDR.5
SADDR.4
SADDR.3
SADDR.2
SADDR.1
SADDR.0
00--0000
SMOD
SSTAT
-
-
GF1
GF0
PD
IDL
------00
-
-
-
-
-
-
RxCON1
RxCON0
SM1/RXOV SM2/TXCOL
0 ADC SFRs
Table 6.1
6.10
Mnem
Add
Nam e
POR/WDT/LVR
Value
/PIN Reset
ResetValue
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
ADCON
93H
Bank0
A DC Control
00000000
ADON
ADCIF
EC
REFC
SCH2
SCH1
SCH0
GO/DO N E
ADT
94H
Bank0
ADC Time Configuration
000-0000
TA DC2
TADC1
TADC0
-
TS3
TS2
TS1
TS0
ADCH
95H
Bank0
ADC Channel Configuration
00000000
CH7
CH6
CH5
CH4
CH3
CH2
CH1
CH0
ADDL
96H
Bank0
ADC Data Low Byte
------00
-
-
-
-
-
-
A1
A0
ADDH
97H
Bank0
ADC Data High Byte
00000000
A9
A8
A7
A6
A5
A4
A3
A2
----------------
11 Buzzer SFR
Table 6.
6.1
Mnem
Add
Nam e
POR/WDT/LVR
Value
/PIN Reset
ResetValue
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
BUZCO N
BDH
Bank0
Buzzer output control
----0000
-
-
-
-
BCA2
BCA1
BCA0
BZEN
14
166A
SH79F
SH79F166A
2 LCD SFRs
Table 6.1
6.12
Mnem
Add
Nam e
POR/WDT/LVR
Value
/PIN Reset
ResetValue
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
DISPCON
ABH
Bank0
LCD Control
00000000
DISPSEL
LCDON
ELCC
DUTY
VOL3
VOL2
VOL1
VOL0
DISPCON1
ADH
Bank0
LCD Control 1
---00000
-
-
-
RLCD
FCCTL1
FCCTL 0
MO D1
MO D0
DISPCLK0
ACH
Bank0
LCD clock 0
00000000
DCK0.7
DCK0.6
DCK0.5
DCK0.4
DCK0.3
DCK0.2
DCK0.1
DCK0.0
DISPCLK1
AAH
Bank0
LCD clock 1
-------0
-
-
-
-
-
-
-
DCK1.0
P0SS
B6H
Bank0
P0 mode Select
-----000
-
-
-
-
-
P0S2
P0S1
P0S0
P1SS
9CH
Bank0
P1 mode Select
00000000
P1S7
P1S6
P1S5
P1S4
P1S3
P1S2
P1S1
P1S0
P2SS
9DH
Bank0
P2 mode Select
00000000
P2S7
P2S6
P2S5
P2S4
P2S3
P2S2
P2S1
P2S0
P3SS
9EH
Bank0
P3 mode Select
00000000
P3S7
P3S6
P3S5
P3S4
P3S3
P3S2
P3S1
P3S0
Table 6.1
3 LED SFRs
6.13
Mnem
Add
Nam e
POR/WDT/LVR
Value
/PIN Reset
ResetValue
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
DISPCON
ABH
Bank0
LED Control
00-0----
DISPSEL
LEDO N
-
DUTY
-
-
-
-
DISPCLK0
ACH
Bank0
LED clock 0
00000000
DCK0.7
DCK0.6
DCK0.5
DCK0.4
DCK0.3
DCK0.2
DCK0.1
DCK0.0
DISPCLK1
AAH
Bank0
LED clock 1
-------0
-
-
-
-
-
-
-
DCK1.0
P1SS
9CH
Bank0
P1 mode Select
00000000
P1S7
P1S6
P1S5
P1S4
P1S3
P1S2
P1S1
P1S0
P3SS
9EH
Bank0
P3 mode Select
00000000
P3S7
P3S6
P3S5
P3S4
P3S3
P3S2
P3S1
P3S0
15
166A
SH79F
SH79F166A
4 PWM SFRs
Table 6.1
6.14
Mnem
Add
Name
POR/WDT/LVR
Value
/PIN Reset
ResetValue
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
PW MEN
CF H
Bank0
PWM timer enable
-0--0--0
-
EF LT
-
-
EPWM01
-
-
EPWM0
PWMEN1
B7H
Bank0
PWM output enable
-------0
-
-
-
-
-
-
-
PWM0
PWMLO
E7H
Bank0
PWM register Lock
00000000
PWMLO.7
PWMLO.6
PWMLO.5
PWMLO.4
PWMLO.3
PWMLO.2
PWMLO.1
PWMLO.0
PWM0C
D2H
Bank0
12-bit PWM Control
00-00000
PWM0IE
PWM0IF
-
FLTS
FLTC
PWM0S
TnCK01
TnCK00
PWM0PL
D3H
12-bit PWM Period Control low byte
Bank0
00000000
PP0.7
PP0.6
PP0.5
PP.4
PP0.3
PP0.2
PP0.1
PP0.0
PWM0PH
D4H
Bank0
12-bit PWM Period Control high
byte
----0000
-
-
-
-
PP0.11
PP0.10
PP0.9
PP0.8
PWM0DL
D5H
Bank0
12-bit PWM Duty Control low byte
00000000
PD0.7
PD0.6
PD0.5
PD0.4
PD0.3
PD0.2
PD0.1
PD0.0
PWM0DH
D6H
12-bit PWM Duty Control high byte
Bank0
----0000
-
-
-
-
PD0.11
PD0.10
PD0.9
PD0.8
PWM0DT
D1H
Bank0
PWM01 Dead time control
00000000
DT0.7
DT0.6
DT0.5
DT0.4
DT0.3
DT0.2
DT0.1
DT0.0
15 LPD SFR
Table 6.
6.1
Mnem
Add
Nam e
POR/WDT/LVR
Value
/PIN Reset
ResetValue
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
LPDCON
B3H
Bank0
LPD control
00000000
LPDEN
LPDF
LPDMD
LPDIF
LPDS3
LPDS2
LPDS1
LPDS0
Note: - :Unimplemented
16
166A
SH79F
SH79F166A
SFR Map
Bank0
Bit
addressable
0/8
Non Bit addressable
1/9
2/A
F8H
3/B
IB_OFFSET
4/C
IB_DATA
5/D
B
AUXC
IB_CON1
IB_CON2
IB_CON3
IB_CON4
E8H
EXF0
P0PCR
P1PCR
P2PCR
P3PCR
E0H
ACC
P0CR
P1CR
P2CR
P3CR
D8H
EXF1
D0H
PSW
PWM0DT
PWM0C
PWM0PL
PWM0PH
PWM0DL
C8H
T2CON
T2MOD
RCAP2L
RCAP2H
TL2
TH2
C0H
P4
B8H
IPL0
IPL1
IENC
IENC1
B0H
P3
RSTSTAT
CLKCON
LPDCON
A8H
IEN0
IEN1
DISPCLK1
DISPCON
SBUF
SADDR
SADEN
P1SS
P2SS
ADCON
ADT
P2
98H
SCON
7/F
FFH
F0H
A0H
6/E
IB_CON5
XPAGE
F7H
P4PCR
P0OS
EFH
P4CR
PWMLO
E7H
DFH
PWM0DH
D7H
PWMEN
CFH
C7H
BUZCON
IPH0
IPH1
BFH
P0SS
PWMEN1
DISPCLK0 DISPCON1
B7H
AFH
FLASHCON A7H
P3SS
RxCON
9FH
ADCH
ADDL
ADDH
97H
PCON
8FH
87H
90H
P1
88H
80H
TCON
P0
SP
DPL
DPH
DPL1
DPH1
SUSLO
INSCON
0/8
1/9
2/A
3/B
4/C
5/D
6/E
7/F
5/D
6/E
7/F
Bank1
Bit
addressable
0/8
Non Bit addressable
1/9
2/A
3/B
4/C
F8H
F0H
FFH
B
E8H
E0H
ACC
AUXC
XPAGE
EFH
P5CR
E7H
D8H
DFH
D0H
PSW
C8H
T4CON
C0H
T5CON
B8H
IPL0
D7H
TL4
TL5
TH5
IPL1
CFH
BFH
IPH0
IEN0
TH4
C7H
B0H
A8 H
F7H
P5PCR
IPH1
B7H
IEN1
AFH
A0 H
A7H
98H
90H
9FH
97H
88H
T3CON
SWTHL
TL3
TH3
SUSLO
80H
P5
SP
DPL
DPH
DPL1
DPH1
INSCON
PCON
0/8
1/9
2/A
3/B
4/C
5/D
6/E
7/F
Note: The unused addresses of SFR are not available.
17
8FH
87H
166A
SH79F
SH79F166A
7. Normal Function
7.1 CPU
7.1.1 CPU Core SFR
Feature
пїЅ CPU core registers: ACC, B, PSW, SP, DPL, DPH
Accumulator
ACC is the Accumulator register. The mnemonics for accumulator-specific instructions, however, refer to the Accumulator
simply as A.
B Register
The B register is used during multiply and divide operations. For other instructions it can be treated as another scratch pad
register.
Stack Pointer (SP)
The Stack Pointer Register is 8 bits wide, It is incremented before data is stored during PUSH, CALL executions and it is
decremented after data is out of stack during POP, RET, RETI executions. The stack may reside anywhere in on-chip internal
RAM (00H-FFH). On reset, the Stack Pointer is initialized to 07H causing the stack to begin at location 08H.
Program Status Word Register (PSW)
The PSW register contains program status information.
Table 7.1 PSW Register
D0H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
PSW
CY
AC
F0
RS1
RS0
OV
F1
P
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
Description
7
CY
Carry flag b it
0: no carry or borrow in an arithmetic or logic operation
1: a carry or borrow in an arithmetic or logic operation
6
AC
Auxiliary Carry flag b it
0: an auxiliary carry or borrow in an arithmetic or logic operation
1: an auxiliary carry or borrow in an arithmetic or logic operation
5
F0
F0 flag bit
Available to the user for general purposes
R0-R7 Register bank select bits
00: Bank0 (Address to 00H-07H)
01: Bank1 (Address to 08H-0FH)
10: Bank2 (Address to 10H-17H)
11: Bank3 (Address to 18H-1FH)
4-3
RS[1:0]
2
OV
Overflow flag bit
0: no overflow happen
1: an overflow happen
1
F1
F1 flag bit
Available to the user for general purposes
0
P
Parity flag bit
0: an even number of “one” bits in the Accumulator
1: an odd number of “one” bits in the Accumulator
Data Pointer Register (DPTR
DPTR))
DPTR consists of a high byte (DPH) and a low byte (DPL). Its intended function is to hold a 16-bit address, but it may be
manipulated as a 16-bit register or as two independent 8-bit registers.
18
166A
SH79F
SH79F166A
7.1.2 Enhanced C PU core SFRs
пїЅ Extended 'MUL' and 'DIV' instructions: 16bit*8bit, 16bit/8bit
пїЅ Dual Data Pointer
пїЅ Enhanced CPU core registers: AUXC, DPL1, DPH1, INSCON
The SH79F166A has modified 'MUL' and 'DIV' instructions. These instructions support 16 bit operand. A new register - the
register is applied to hold the upper part of the operand/result.
The AUXC register is used during 16 bit operand multiply and divide operations. For other instructions it can be treated as
another scratch pad register.
After reset, the CPU is in standard mode, which means that the 'MUL' and 'DIV' instructions are operating like the standard
8051 instructions. To enable the 16 bit mode operation, the corresponding enable bit in the INSCON register must be set.
Operation
MUL
DIV
A
Result
B
AUXC
INSCON.2 = 0; 8 bit mode
(A)*(B)
Low Byte
High Byte
---
INSCON.2 = 1; 16 bit mode
(AUXC A)*(B)
Low Byte
Middle Byte
High Byte
INSCON.3 = 0; 8 bit mode
(A)/(B)
Quotient Low Byte
Remainder
---
INSCON.3 = 1; 16 bit mode
(AUXC A)/(B)
Quotient Low Byte
Remainder
Quotient High Byte
Dual Data Pointer
Using two data pointers can accelerate data memory moves. The standard data pointer is called DPTR and the new data
pointer is called DPTR1.
DPTR1 is the same with DPTR, which consists of a high byte (DPH1) and a low byte (DPL1). Its intended function is to hold a
16-bit address, but it may be manipulated as a 16-bit register or as two independent 8-bit registers.
The DPS bit in INSTCON register is used to choose the active pointer. The user can switch data pointers by toggling the DPS
b it. And all DPTR-related instructions will use the currently selected data pointer.
7.1.3 Register
Table 7.2 Data Pointer Select Register
86H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
INSCON
-
BKS0
-
-
D IV
MUL
-
DPS
R /W
-
R/W
-
-
R/W
R/W
-
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
0
-
-
0
0
-
0
Bit Number
Bit Mnemonic
Description
6
BKS0
3
DIV
16 bit/8 bit Divide Selection Bit
0: 8 bit Divide
1: 16 bit Divide
2
MUL
16 bit/8 bit Multiply Selection Bit
0: 8 bit Multiply
1: 16 bit Multiply
0
DPS
Data Pointer Selection Bit
0: Data pointer
1: Data pointer1
SFR B ank Selection Bit
0: SFR Bank0 selected
1: SFR Bank1 selected
19
166A
SH79F
SH79F166A
7.2 RAM
7.2.1 Feature
s
Features
SH79F166A provides both internal RAM and external RAM for random data storage. The internal data memory is mapped into
four separated segments:
пїЅ The Lower 128 bytes of RAM (addresses 00H to 7FH) are directly and indirectly addressable.
пїЅ The Upper 128 bytes of RAM (addresses 80H to FFH) are indirectly addressable only.
пїЅ The Special Function Registers (SFR, addresses 80H to FFH) are directly addressable only.
пїЅ The 256 bytes of external RAM(addresses 00H to FFH) are indirectly accessed by MOVX instructions.
The Upper 128 bytes occupy the same address space as SFR, but they are physically separate from SFR space. When an
instruction accesses an internal location above address 7FH, the CPU can distinguish whether to access the upper 128 bytes
data RAM or to access SFR by different addressing mode of the instruction.
Note: the unused address is unavailable in SFR.
1F2H
LCD RAM
1E0H
RESERVED
0FFH
0FFH
Upper
128 bytes
Internal
Ram
indirect accesses
0FFH
80H
Extenal
RAM
SFR
Bank0
direct accesses
80H
7FH
0FFH
Lower
128 bytes
Internal
Ram
direct or indirect
accesses
00H
00H
SFR
Bank1
direct accesses
80H
The Internal and External RAM C onfiguration
The SH79F166A provides traditional method for accessing of external RAM. Use MOVXA, @Ri or MOVX @Ri, A; to access
external low 256 bytes RAM; MOVX A, @DPTR or MOVX @DPTR, A also to access external 256 bytes RAM.
In SH79F166A the user can also use XPAGE register to access external RAM only with MOVX A, @Ri or MOVX @Ri, A
instructions. The user can use XPAGE to represent the high byte address of RAM above 256 Bytes.
But SH79F166A only has 256 bytes external RAM, XPAGE must be set as 0.
In Flash SSP mode, the XPAGE can also be used as sector selector (Refer to SSP Function).
7.2.2 Register
Table 7.3 Data Memory Page Register
F7H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
XPAGE
-
-
XPAGE.5
XPAGE.4
XPAGE.3
XPAGE.2
XPAGE.1
XPAGE.0
R /W
-
-
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
-
0
0
0
0
0
0
Bit Number
Bit Mnemonic
5-0
XPAGE
XPAGE[[5: 0]
Description
RAM Page Selector
20
166A
SH79F
SH79F166A
7.3 Flash Program Memory
7.3.1 Features
пїЅ The program memory consists 16 X 1KB sectors, total 16KB
пїЅ Programming and erase can be done over the full operation voltage range
пїЅ Write, read and erase operation are all supported by In-Circuit Programming (ICP)
пїЅ Fast mass/sector erase and programming
пїЅ Minimum program/erase cycles: 100000
пїЅ Minimum years data retention: 10
пїЅ Low power consumption
FFFFH
Reserved
3FF FH
03FFH
EEPROM Like Data Block
Program Memory Block
0000H
0000H
Information Block
Program Memory Block
The SH79F166A embeds 16K flash program memory for program code. The flash program memory provides electrical erasure
and programming and supports In-Circuit Programming (ICP) mode and Self-Sector Programming (SSP) mode.
21
166A
SH79F
SH79F166A
7.3.2 Flash O peration in ICP Mode
ICP mode is performed without removing the micro-controller from the system. In ICP mode, the user system must be
power-off, and the programmer can refresh the program memory through ICP programming interface. The ICP programming
interface consists of 6 wires (VDD, GND, TCK, TDI, TMS, TDO).
At first the four JTAG pins (TDO, TDI, TCK, TMS) are used to enter the programming mode. Only after the three pins are
inputted the specified waveform, the CPU will enter the programming mode. For more detail description please refers to the
FLASH Programmer’s user guide.
The ICP mode supports the following operations
operations::
(1) Code-Protect Control mode Programming
SH79F166A implements code-protect function to offer high safeguard for customer code. Two modes are available for each
sector.
protect control mode 0: Used to enable/disable the write/read operation (except mass erase) from any
Codeode-p
programmer.
protect control mode 1: Used to enable/disable the read operation through MOVC instruction from other sectors; or
Codeode-p
the sector erase/write operation through SSP Function.
To enable the wanted protect mode, the user must use the Flash Programmer to set the corresponding protect b it.
(2) Mass Erase
The mass erase operation will erase all the contents of program code, code option, code protect bit and customer code ID,
regardless the status of code-protect control mode. (The Flash Programmer supplies customer code ID setting function for
customer to distinguish their product.)
Mass erase is only available in Flash Programmer.
(3) Sector Erase
The sector erase operation will erase the contents of program code of selected sector . This operation can be done by Flash
Programmer or the user’s program.
If done by the Flash Programmer, the code-protect control mode 0 of the selected sector must be disabled.
(4) EEPROM-Like Erase
The EEPROM-Like erase operation will erase the contents of program code of EEPROM-Like. This operation can be done
by Flash Programmer or the user’s program.
e/Read Code
(5) Writ
Write
The Write/Read Code operation will write the customer code into the Flash Programming Memory or read the customer
code from the Flash Programming Memory. This operation can be done by Flash Programmer or the user’s program.
If done by the user’s program, the code-protect control mode 1 of the selected sector must be disabled. But the program can
read/write its own sector regardless of its security bit.
If done by the Flash Programmer, the code-protect control mode 0 of the selected sector must be disabled.
e/Read EEPROM-Like
(6) Writ
Write
The Write/Read EEPROM-Like operation will write the customer data into the EEPROM-Like or read the customer data
from the EEPROM-Like. This operation can be done by Flash Programmer or the user’s program.
Operation
ICP
SSP
Code Protection
Yes
No
Sector Erase
Yes
(without security bit)
Yes
(without security bit)
Mass Erase
Yes
No
EEPROM-like Erase
Yes
Yes
Write/Read
Yes
(without security bit)
Yes
(without security bit or its own sector)
EEPROM-like Write/Read
Yes
Yes
22
166A
SH79F
SH79F166A
In ICP modeпјЊall the flash operations are completed by the programmer through 6-wire interface. Since the program timing is
very sensitive, five jumpers are needed (VDD, TDO, TDI, TCK, TMS) to separate the program pins from the application circuit as
the following diagram.
Flash
Programmer
MCU
VDD
TMS
TCK
TDI
TDO
GND
To Application
Circuit
Jumper
The recommended steps are as following:
(1) The jumpers must be open to separate the programming pins from the application circuit before programming.
(2) Connect the programming interface with programmer and begin programming.
(3) Disconnect programmer and short these jumpers after programming is complete.
23
166A
SH79F
SH79F166A
7.4 SSP Function
The SH79F166A provides SSP (Self Sector Programming) function, each sector can be sector erased or programmed by the
user’s code if the selected sector is not be protected. But once sector has been programmed, it cannot be reprogrammed
before sector erase.
The SH79F166A builds in a complex control flow to prevent the code from carelessly modification. If the dedicated conditions
are not met (IB_CON2-5), the SSP will be terminated.
7.4.1 SSP R egister
Table 7.4 Offset Register for Programming
F7H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
XPAGE
-
-
XPAGE.5
XPAGE.4
XPAGE.3
XPAGE.2
XPAGE.1
XPAGE.0
R /W
-
-
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
-
0
0
0
0
0
0
For Flash memory, one sector is 1024 bytes
Bit Number
Bit Mnemonic
Description
5-2
XPAGE[5
XPAGE[5:: 2]
Sector of the flash memory to be programmed, 000000---means sector 0, and so on
1-0
XPAGE[1
XPAGE[1:: 0]
High Address of Offset of the flash memory sector to be programmed
For EEPROM-like memory, one sector is 256 bytes
Bit Number
Bit Mnemonic
Description
5-2
XPAGE[5
XPAGE[5:: 2]
Reserved
1-0
XPAGE[1
XPAGE[1:: 0]
Sector of the flash memory to be programmed, 00---means sector 0, and so on
Table 7.5 Offset of Flash Memory for Programming
FBH
FBH,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
IB_OFFSET
IB_OFF
SET.7
IB_OFF
SET.6
IB_OFF
SET.5
IB_OFF
SET.4
IB_OFF
SET.3
IB_OFF
SET.2
IB_OFF
SET.1
IB_OFF
SET.0
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
(POR/WDT/LVR
/PIN
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
7-0
Bit Mnemonic
Description
IB_OFFSET[7
IB_OFFSET[7:: 0] Low Address of Offset of the flash memory sector to be programmed
Table 7.6 Data Register for Programming
FCH
FCH,, Bank0
Bit7
IB_DATA
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
IB_DATA.7 IB_DATA.6 IB_DATA.5 IB_DATA.4 IB_DATA.3 IB_DATA.2 IB_DATA.1 IB_DATA.0
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
(POR/WDT/LVR/PIN
POR/WDT/LVR/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7-0
IB_DATA[7
IB_DATA[7:: 0]
Description
Data to be programmed
24
166A
SH79F
SH79F166A
Table 7.7 SSP Type select Register
F2H
F2H,, Bank0
Bit7
IB_CON1
7-0
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
IB_CON1.7 IB_CON1.6 IB_CON1.5 IB_CON1.4 IB_CON1.3 IB_CON1.2 IB_CON1.1 IB_CON1.0
R/W
Reset Value
(POR/WDT/LVR/PIN
POR/WDT/LVR/PIN))
Bit Number
Bit6
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
0
0
0
0
0
0
0
0
Bit Mnemonic
IB_CON1[7
IB_CON1[7:: 0]
Description
SSP Type select
0xE6: Sector Erase
0x6E: Sector Programming
Table 7.8 SSP Flow Control Register1
F3H
F3H,, Bank0
IB_CON2
Bit7
-
Bit6
-
Bit5
-
Bit4
-
R /W
Reset Value
(POR/WDT/LVR/PIN
POR/WDT/LVR/PIN))
-
-
-
-
R/W
R/W
R/W
R/W
-
-
-
-
0
0
0
0
Bit Number
Bit Mnemonic
3-0
IB_CON2[3
IB_CON2[3:: 0]
Bit3
Bit1
Bit2
Bit0
IB_CON2.3 IB_CON2.2 IB_CON2.1 IB_CON2.0
Description
Must be 05H, else Flash Programming will terminate
Table 7.9 SSP Flow Control Register2
F4H
F4H,, Bank0
IB_CON3
Bit7
-
Bit6
-
Bit5
-
Bit4
-
R /W
Reset Value
(POR/WDT/LVR/PIN
POR/WDT/LVR/PIN))
-
-
-
-
R/W
R/W
R/W
R/W
-
-
-
-
0
0
0
0
Bit Number
Bit Mnemonic
3-0
IB_CON3[3
IB_CON3[3:: 0]
Bit3
Bit2
Bit1
Bit0
IB_CON3.3 IB_CON3.2 IB_CON3.1 IB_CON3.0
Description
Must be 0AH else Flash Programming will terminate
Table 7.10 SSP Flow Control Register3
F5H
F5H,, Bank0
IB_CON4
Bit7
-
Bit6
-
Bit5
-
Bit4
-
R /W
Reset Value
(POR/WDT/LVR/PIN
POR/WDT/LVR/PIN))
-
-
-
-
R/W
R/W
R/W
R/W
-
-
-
-
0
0
0
0
Bit2
Bit1
Bit0
Bit Number
Bit Mnemonic
3-0
4[3:0]
IB_CON
IB_CON4
Bit2
Bit3
Bit1
Bit0
IB_CON4.3 IB_CON4.2 IB_CON4.1 IB_CON4.0
Description
Must be 09H, else Flash Programming will terminate
Table 7.11 SSP Flow Control Register4
F6H
F6H,, Bank0
Bit7
Bit6
Bit5
Bit4
IB_CON5
R /W
Reset Value
(POR/WDT/LVR/PIN
POR/WDT/LVR/PIN))
-
-
-
-
-
-
-
-
Bit Number
Bit Mnemonic
3-0
5[3:0]
IB_CON
IB_CON5
Bit3
IB_CON5.3 IB_CON5.2 IB_CON5.1 IB_CON5.0
R/W
R/W
R/W
R/W
0
Description
Must be 06H, else Flash Programming will terminate
25
0
0
0
166A
SH79F
SH79F166A
4.2 Flash C ontrol F low
7.
7.4.2
Set IB_OFFSET
Set XPAGE
Set IB_DATA
Set IB_CON1
S0
IB_CON2[3:0]в‰ 5H
IB_CON2в‰ 5H
Set IB_CON2[3:0]=5H
S1
IB_CON3в‰ AH
IB_CON2в‰ 5H
Set IB_CON3=AH
ELSE
S2
IB_CON3в‰ AH
Set IB_CON4=9H
Reset
IB_CON1-5
IB_CON4в‰ 9H
S3
Set IB_CON5=6H
S4
Sector Erase
IB_CON1=E6H
&IB_CON2[3:0]=5H
&IB_CON3=AH
&IB_CON4=9H
&IB_CON5=6H
IB_CON1=6EH
&IB_CON2[3:0]=5H
&IB_CON3=AH
&IB_CON4=9H
&IB_CON5=6H
Programming
26
166A
SH79F
SH79F166A
7.4.3 SSP Programming Notice
To successfully complete SSP programming, the user’s software must following the steps below:
(1) For Code/Data Programming:
1. Disable interrupt;
2. Fill in the XPAGE, IB_OFFSET for the corresponding address;
3. Fill in IB_DATA if programming is wanted;
4. Fill in IB_CON1-5 sequentially;
5. Add 4 nops for more stable operation;
6. Code/Data programming, CPU will be in IDLE mode;
7. Go to Step 2 if more data are to be programmed;
8. Clear XPAGE; enable interrupt if necessary.
(2) For Sector E rase:
1. Disable interrupt;
2. Fill in the XPAGE for the corresponding sector;
3. Fill in IB_CON1-5 sequentially;
4. Add 4 NOPs for more stable operation;
5. Sector Erase, CPU will be in IDLE mode;
6. Go to step 2 if more sectors are to be erased;
7. Clear XPAGE; enable interrupt if necessary.
(3) For Code Reading:
Just Use “MOVC A, @A+DPTR” or “MOVC A, @A+PC ”.
(4) For EEPROM-Like
EEPROM-Like::
Steps is same as code programming,the diffenrences are:
1.Set FAC bit in FLASHCON register before programming or erase EEPROM-Like;
2.One sector of EEPROM-Like is 256 bytes.not 1024 bytes.
12 Flash Access Control Register
Table 7.
7.12
A7H
A7H,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
FLASHCON
-
-
-
-
-
-
-
FAC
R /W
-
-
-
-
-
-
-
R/W
Reset Value
(POR/WDT/LVR/PIN
POR/WDT/LVR/PIN))
-
-
-
-
-
-
-
0
Bit Number
Bit Mnemonic
0
FAC
Description
FAC: Flash access control
0: MOVC or SSP access main memory
1: MOVC or SSP access EEPROM-like
27
166A
SH79F
SH79F166A
7.5 System Clock and Oscillator
7.5.1 F eature
s
eatures
пїЅ Four oscillator types: 32.768kHz crystal, crystal oscillator, ceramic oscillator and 12MHz/128kHz internal RC
пїЅ 4 Oscillator pin (XTAL1, XTAL2, XTALX1, XTALX2)
пїЅ Built-in 12MHz Internal RC
пїЅ Built-in 32.768kHz speed up circuit
пїЅ Built-in system clock prescaler
7.5.2 Clock Definition
The SH79F166A have several internal clocks defined as below:
OSCCLK: the oscillator clock from one of the four oscillator types (32.768kHz crystal oscillator, crystal oscillatorпјЊceramic
oscillator and interal RC) f OSC is defined as the OSCCLK frequency. t OSC is defined as the OSCCLK period.
OSCXCLK
OSCXCLK:: the oscillator clock from one of the three oscillator types (crystal oscillator, ceramic oscillator and interal RC) f OSCx is
defined as the OSCXCLK frequency. t OSCX is defined as the OSCXCLK period.
Note: OSCXCLK does not exist when code option OP_OSC is not 0011, 0110, 1010, 1101. (32.768kHz oscillator/128kHz
internal RC is not selected, Refer to code option section for details)
WDTCLK: the internal WDT RC clock. fWDT is defined as the WDTCLK frequency. t WDT is defined as the WDTCLK period.
OSCSCLK: the input of system clock prescaler. It can be OSCCLK or OSCXCLK. fOSCS is defined as the OSCSCLK frequency.
tOSCS is defined as the OSCSCLK period.
SYSCLK: system clock, the output of system clock prescaler. It is the CPU instruction clock. f SYS is defined as the SYSCLK
frequency. tSYS is defined as the SYSCLK period.
7.5.3 Description
SH79F166A has four oscillator types: 32.768kHz crystal oscillator, crystal oscillator (2MHz-1 2MHz), ceramic Oscillator
(2MHz-1 2MHz) and internal RC (12MHz,), which is selected by code option OP_OSC (Refer to code option section for details).
SH79F166A have 4 Oscillator pin (XTAL1, XTAL2, XTALX1, XTALX2 ) and can generates one or two clock sources from four
oscillator types. It is selected by code option OP_OSC (Refer to code option section for details). The oscillator generates the
basic clock pulse that provides the system clock to supply CPU and on-chip peripherals.
28
166A
SH79F
SH79F166A
7.5.4 Register
Table 7.13 System Clock Control Register
B2H
B2H,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
CLKCON
32k_SPDUP
CLKS1
CLKS0
SCMIF
HFON
FS
-
-
R /W
R/W
R/W
R/W
R
R/W
R/W
-
-
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
1
1
1
0
0
0
-
-
Bit Number
7
6-5
3
2
Bit Mnemonic
Description
k_SPDUP
32
32k
kHz oscillator speed up mode control bit
32.768
32.768k
0: 32.768kHz oscillator normal mode, cleared by software.
1: 32.768kHz oscillator speed up mode, set by hardware or software.
This control bit is set by hardware automatically in all kinds of RESET such as
Power on reset, watch dog reset etc. to speed up the 32.768kHz Oscillator
oscillating, shorten the 32.768kHz oscillator start-oscillating time.
And this bit also can be set or cleared by software if necessary. Such as set before
entering Power-down mode and cleared when Power-down mode wakes up.
It should be noticed that turning off 32.768kHz oscillator speed up (clear this bit)
could reduce the system power consumption.
Only when code option OP_OSC is 1010 or 1101, this bit is valid. (32.768kHz
oscillator is selected, Refer to code option section for details)
CLKS[1:0]
SYSCLK Prescale
Prescalerr Register
00: fSYS = f OSCS
01: fSYS = f OSCS/2
10: fSYS = f OSCS/4
11: fSYS = f OSCS/12
If 32.768kHz oscillator is selected as OSCSCLK, these control bits is invalid.
HFON
OSCXCLK On control Register
0: Cleared to turn off OSCXCLK
1: Set to turn on OSCXCLK
Only when code option OP_OSC is 0010пјЊ0011пјЊ0101пјЊ1010,1101. this bit is valid.
(32.768kHz oscillator/128kHz internal RC is selected, Refer to code option
section for details)
FS
cy Select Register
Frequen
Frequency
0: 32.768kHz/128kHz is selected as OSCSCLK
1: OSCXCLK is selected as OSCSCLK
Only when code option OP_OSC is 0010пјЊ0011пјЊ0101пјЊ1010,1101. this bit is valid.
(32.768kHz oscillator/128kHz internal RC is selected, Refer to code option
section)
Note:
1. If code option OP_OSC is 0011, 1010, OSCXCLK is Internal 12M RC; if code option OP_OSC is 0110 or 1101, OSCXCLK is
crystal or ceramic at XTALX.
2. HFON and FS is valid only when code option OP_OSC is 0011, 0110, 1010, 1101.
3. When OSCXCLK is used as OSCSCLK (that is HFON = 1 and FS = 1), HFON is can’t be cleared by software.
4. When OSCSCLK changed from 32.768kHz/128kHz to OSCXCLK, if OSCXCLK is off, the steps below must be done in
sequence:
a. Set HFON = 1 to turn on the OSCXCLK
b. Wait at least Oscillator Warm-up timer (Refer to Warm-up Timer section for details)
c. Set FS = 1 to select OSCXCLK as OSCSCLK
5. When OSCSCLK changed from OSCXCLK to 32.768kHz/128kHz, the steps below must be done in sequence:
a. Clear FS to turn off the OSCXCLK
b. Add one nop
c. Clear HFON
29
166A
SH79F
SH79F166A
7.5.5 Oscillator Type
(1) OP_OSC = 0000, 0011: internal RC, XTAL and XTALX are shared with IO
XTALX1
XTALX2
XTAL1
XTAL2
(2) OP_OSC = 1010: 32.768kHz Crystal Oscillator at XTAL, Internal RC can be enabled, XTALX shared with I/O
XTALX1
XTALX2
C1
XTAL1
32.768k Hz
XTAL2
C2
(3) OP_OSC = 1101: 32.768kHz Crystal Oscillator at XTAL, 2M - 12M Crystal/Ceramic Oscillator at XTALX*
C1
XTALX1
Crys tal/
Ceramic
XTALX2
C2
XTAL1
C1
32.768kHz
XTAL2
C2
(4) OP_OSC = 1110: 2M - 12M Crystal/Ceramic oscillator at XTAL*, XTALX shared with I/O
XTALX1
XTALX2
C1
XTAL1
Crys tal/
Ceramic
XTAL2
C2
(5) OP_OSC = 0110: 128kHz internal RC, 2M - 12M Crystal/Ceramic resonator at XTAL*, XTALX shared with I/O
XTALX1
XTALX2
C1
XTAL1
Crys tal/
Ceramic
XTAL2
C2
*: If the environment humidity is bigger, use the high frequency oscillator, advice plus 510k feedback resistance.
30
166A
SH79F
SH79F166A
6 Capacitor Selection for Oscillator
7.5.
7.5.6
Ceramic Resonators
Frequency
C1
C2
3.58MHz
-
-
4MHz
-
-
Crystal Oscillator
Frequency
C1
C2
32.768kHz
10 - 12pF
10 - 12pF
4MHz
8 - 15pF
8 - 15pF
12MHz
8 - 15pF
8 - 15pF
Notes:
(1) Capacitor values are used for design guidance only!
(2) These capacitors were tested with the crystals listed above for basic start-up and operation. They are not optimized.
(3) Be careful for the stray capacitance on PCB board, the user should test the performance of the oscillator over the expected
VDD and the temperature range for the application.
Before selecting crystal/ceramic, the user should consult the crystal/ceramic manufacturer for appropriate value of external
component to get best performance, visit http://www.sinowealth.comfor more recommended manufactures.
31
166A
SH79F
SH79F166A
7.6 System Clock Monitor (SCM)
In order to enhance the system reliability, SH79F166A contains a system clock monitor (SCM) module. If the system clock fails
(for example the oscillator stops oscillating), the built-in SCM will switch the OSCCLK to the internal 32k WDTCLK and set
system clock monitor bit (SCMIF) to 1. And the SCM interrupt will be generated when EA and ESCM is enabled. If the OSCCLK
comes back, SCM will switch the OSCCLK back to the oscillator and clears the SCMIF automatically.
s:
Note
Notes
The SCMIF is read only register; it can be clear to 0 or set to 1 by hardware only.
If SCMIF is cleared, the SCM switches the system clock to the state before system clock fail automatically.
If Internal RC is selected as OSCCLK by code option (Refer to code option section for detail), the SCM can not work.
14 System Clock Control Register
Table 7.
7.14
B2H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
CLKCON
-
-
-
SCMIF
-
-
-
-
R /W
-
-
-
R
-
-
-
-
Reset Value
(POR/WDT/LVR/PIN
POR/WDT/LVR/PIN))
-
-
-
0
-
-
-
-
Bit Number
Bit Mnemonic
4
SCMIF
Description
System Clock Monitor bit
0: Clear by hardware to indicate system clock is normal
1: Set by hardware to indicate system clock fails
32
166A
SH79F
SH79F166A
7 I/O Port
7.
7.7
7.
7.1 F eature
s
7.7
eatures
пїЅ 41 bi-directional I/O ports
пїЅ Share with alternative functions
The SH79F166A has 41 bi-directional I/O ports. The PORT data is put in Px register. The PORT control register (PxCRy)
controls the PORT as input or output. Each I/O port has an internal pull-high resistor, which is controlled by PxPCRy when the
PORT is used as input (x = 0-5, y = 0-7).
For SH79F166A, some I/O pins can share with alternative functions. There exists a priority rule in CPU to avoid these functions
be conflict when all the functions are enabled. (Refer to Port Share Section for details).
7.2 Register
7.
7.7
Table 7.15 Port Control Register
E1H - E5H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
P0CR (E1H
E1H,, Bank0
Bank0))
P0CR.7
P0CR.6
P0CR.5
P0CR.4
P0CR.3
P0CR.2
P0CR.1
P0CR.0
P1CR (E2H
E2H,, Bank0
Bank0))
P1CR.7
P1CR.6
P1CR.5
P1CR.4
P1CR.3
P1CR.2
P1CR.1
P1CR.0
P2CR (E3H
E3H,, Bank0
Bank0))
P2CR.7
P2CR.6
P2CR.5
P2CR.4
P2CR.3
P2CR.2
P2CR.1
P2CR.0
P3CR (E4H
E4H,, Bank0
Bank0))
P3CR.7
P3CR.6
P3CR.5
P3CR.4
P3CR.3
P3CR.2
P3CR.1
P3CR.0
P4CR (E5H
E5H,, Bank0
Bank0))
-
-
-
P4CR.4
P4CR.3
P4CR.2
P4CR.1
P4CR.0
P5CR (E1H
E1H,, Bank1
Bank1))
-
-
-
-
P5CR.3
P5CR.2
P5CR.1
P5CR.0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7-0
CR y
Px
PxC
x = 0-5
-5,, y = 0-7
Description
Port input/output direction control Register
0: input mode
1: output mode
Table 7.16 Port Pull up Resistor Control Register
E9H - EC H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
P0PCR (E9H
E9H,, Bank0
Bank0))
P0PCR.7
P0PCR.6
P0PCR.5
P0PCR.4
P0PCR.3
P0PCR.2
P0PCR.1
P0PCR.0
P1PCR (EAH
EAH,, Bank0
Bank0)) P1PCR.7
P1PCR.6
P1PCR.5
P1PCR.4
P1PCR.3
P1PCR.2
P1PCR.1
P1PCR.0
P2PCR (EBH
EBH,, Bank0
Bank0)) P2PCR.7
P2PCR.6
P2PCR.5
P2PCR.4
P2PCR.3
P2PCR.2
P2PCR.1
P2PCR.0
P3PCR (ECH
ECH,, Bank0
Bank0)) P3PCR.7
P3PCR.6
P3PCR.5
P3PCR.4
P3PCR.3
P3PCR.2
P3PCR.1
P3PCR.0
P4PCR (EDH
EDH,, Bank0
Bank0))
-
-
-
P4PCR.4
P4PCR.3
P4PCR.2
P4PCR.1
P4PCR.0
P5PCR (E9H
E9H,, Bank1
Bank1))
-
-
-
-
P5PCR.3
P5PCR.2
P5PCR.1
P5PCR.0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
(POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7-0
PCR
Px
PxP
CRyy
5, y = 0-7
x = 00-5
Description
Input Port internal pull-high resistor enable/disable control
0: internal pull-high resistor disabled
1: internal pull-high resistor enabled
33
166A
SH79F
SH79F166A
Table 7.17 Port Data Register
80H - C 0H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
P0 (80H
80H,, Bank0
Bank0))
P0.7
P0.6
P0.5
P0.4
P0.3
P0.2
P0.1
P0.0
P1 (90H
90H,, Bank0
Bank0))
P1.7
P1.6
P1.5
P1.4
P1.3
P1.2
P1.1
P1.0
P2 (A0H
A0H,, Bank0
Bank0))
P2.7
P2.6
P2.5
P2.4
P2.3
P2.2
P2.1
P2.0
P3 (B0H
B0H,, Bank0
Bank0))
P3.7
P3.6
P3.5
P3.4
P3.3
P3.2
P3.1
P3.0
P4 (C0H
C0H,, Bank0
Bank0))
-
-
-
P4.4
P4.3
P4.2
P4.1
P4.0
P5 (80H
80H,, Bank1
Bank1))
-
-
-
-
P5.3
P5.2
P5.1
P5.0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
7-0
Bit Mnemonic
Description
Px
Px..y
x = 0-5
-5,, y = 0-7 Port Data Register
Table 7.18 Port mode select Register
EFH
EFH,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
P0OS
-
-
P0OS.5
P0OS.4
-
-
-
-
R /W
-
-
R/W
R/W
-
-
-
-
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
-
0
0
-
-
-
-
Bit Number
Bit Mnemonic
5-4
P0OS.x
x = 5-4
Description
Port output mode select
0: Port output mode is CMOS
1: Port output mode is N-channel open drain
Note: P0.4, P0.5 are configured as N-channel open drain I/O, but voltage provided for this pin can’t exceed VDD+0.3V.
34
166A
SH79F
SH79F166A
7.3 Port Diagram
7.
7.7
SFEN
PxPCRy
Output Mode
VDD
Input Mode
VDD
0 = ON
1 = OFF
(Pull-up)
PxCRy
I/O Pad
Write
Data Bus
Data
Register
Read Port Data Register
Read
Read Data Register/Pad Selection
0: From Pad
1: From data register
0 = OFF
1 = ON
Second
Function
Read Port Pad
Note:
(1) The input source of reading input port operation is from the input pin directly.
(2) The input source of reading output port operation has two paths, one is from the port data Register, and the other is from the
output pin directly. The read Instruction distinguishes which path is selected: The read-modify-write instruction is for the
reading of the data register in output mode, and the other instructions are for reading of the output pin directly.
(3) The destination of writing port operation is the data register regardless the port shared as the second function or not.
7. 4 Port Share
7.
7.7
The 41 bi-directional I/O ports can also share second or third special function. But the share priority should obey the Outer
Most Inner Lest rule:
The out most pin function in Pin Configuration has the highest priority, and the inner most pin function has the lowest priority.
This means when one pin is occupied by a higher priority function (if enabled), it cannot be used as the lower priority functional
pin, even the lower priority function is also enabled. Only until the higher priority function is closed by hardware or software, can
the corresponding pin be released for the lower priority function use. Also the function that need pull up resister is also
controlled by the same rule.
When port share function is enabled, the user can modify PxCR, PxPCR (x = 0-5), but these operations will have no effect on
the port status until the second function was disabled.
When port share function is enabled, any read or write operation to port will only affect the data register while the port pin keeps
unchanged until all the share functions are disabled.
0:
PORT
PORT0
- LCD Segment 17-19 (P0.0-P0.2)
- PWM01: PWM01 output (P0.2)
- PWM0: PWM0 output (P0.3)
- INT0: external inturrupt0 (P0.4)
- INT1: external inturrupt1 (P0.5)
- INT2: external inturrupt2 (P0.6)
- INT3: external inturrupt3 (P0.7)
- T2: Timer2 external input/baud-rate clock output (P0.5)
- T2EX: Timer2 reload/capture control (P0.4)
- T4: Timer4 external input/baud-rate clock output (P0.3)
- XTALX1 : XTAL input (P0.7)
- XTALX2 : XTAL output (P0.6)
35
166A
SH79F
SH79F166A
Table 7.19 PORT0 Share Table
Pin No.
43
44
1
2
3
Priority
Function
Enable bit
1
SEG17
2
P0.0
1
SEG18
2
P0.1
1
PWM01
01 bit in PWMEN register
Set EPWM
EPWM01
2
SEG19
2 bit in P0SS register
Clear DISPSEL bit in DISPCON register and set P0S
P0S2
Clear DISPSEL bit in DISPCON register and set P0S0 bit in P0SS register
Above condition is not met
1 bit in P0SS register
Clear DISPSEL bit in DISPCON register and set P0S
P0S1
Above condition is not met
3
P0.2
1
PWM0
Above condition is not met
2
T4
3
P0.3
Above condition is not met
1
T2EX
In mode0, 2, 3, set EXEN2 bit in T2CON register, or in mode 1 set DCEN bit in
MOD register or in mode1, clear DCEN bit and set EXEN2 bit (Auto Pull up)
T2
T2MOD
2
INT0
Set EX0 bit in IEN0 Register and Port0.4 is in input mode
3
P0.4
Above condition is not met
1
T2
2
INT1
Set EX1 bit in IEN0 Register and Port0.5 is in input mode
3
P0.5
Above condition is not met
1
XTALX2
Selected by Code Option
2
INT2
Set EX2 bit in IEN1 Register and Port0.6 is in input mode
3
P0.6
Above condition is not met
1
XTALX1
Selected by Code Option
2
INT3
Set EX3 bit in IEN1 Register and Port0.7 is in input mode
3
P0.7
Above condition is not met
0 bit in PWMEN register
Set EPWM
EPWM0
Set TR4 bit and T4CLKS bit in T 4CON register (Auto Pull up) or clear T4CLKS
bit and set TC4 bit or set TR4 bit in Mode2
--------
4
5
6
--------
Set TR2 bit and C/ T 2 bit in T2CON register (Auto Pull up) or clear C/ T 2 bit and
set T2OE bit in T2MOD register
1:
PORT
ORT1
- LED Segment 1-8 (P1.0-P1.7)
- LCD Segment 1-8 (P1.0-P1.7)
Table 7.20 PORT1 Share Table
Pin No.
27-34
Priority
Function
1
LED S1-8
2
3
Enable bit
P1S7 bit in P0SS register
Set DISPSEL bit in DISPCON register and set P1S00-P
P1S7 bit in P0SS register
LCD SEG1-8 Clear DISPSEL bit in DISPCON register and set P1S00-P
P1.0-P1.7
Above condition is not met
36
166A
SH79F
SH79F166A
2:
PORT
ORT2
- RXD: EUART data input (P2.0)
- TXD: EUART data output (P2.1)
- FLT: Fault input pin (P2.5)
- LCD Segment 9-16 (P2.0-P2.7)
Table 7.21 PORT2 Share Table
Pin No.
35
36
37
38
39
40
41
42
Priority
Function
1
RXD
2
3
SEG9
P2.0
Enable bit
Set REN bit in SCON Register (Auto Pull up)
Clear DISPSEL bit in DISPCON register and set P2S0 bit in P2SS register
Above condition is not met
When Write to SBUF Register
1
TXD
2
SEG10
3
P2.1
1
SEG11
2
P2.2
1
SEG12
2
P2.3
1
SEG13
2
P2.4
Above condition is not met
1
FLT
Set EFLT bit in PWMEN register
2
SEG14
3
P2.5
1
SEG15
Clear DISPSEL bit in DISPCON register and set P2S6 bit in P2SS register
2
1
P2.6
SEG16
Above condition is not met
Clear DISPSEL bit in DISPCON register and set P2S7 bit in P2SS register
2
P2.7
Clear DISPSEL bit in DISPCON register and set P2S1 bit in P2SS register
Above condition is not met
Clear DISPSEL bit in DISPCON register and set P2S2 bit in P2SS register
Above condition is not met
Clear DISPSEL bit in DISPCON register and set P2S3 bit in P2SS register
Above condition is not met
Clear DISPSEL bit in DISPCON register and set P2S4 bit in P2SS register
Clear DISPSEL bit in DISPCON register and set P2S5 bit in P2SS register
Above condition is not met
Above condition is not met
3:
PORT
ORT3
- LED COM1-COM8 (P3.0-P3.7)
- LCD COM1-COM8 (P3.0-P3.7)
- AN4-AN7: ADC input channel (P3.4-P3.7)
Table 7.22 PORT3 Share Table
Pin No.
19-22
Priority
Function
1
AN7-AN4
7-4 bit in ADCH Register and
Set CH
CH7-4
set ADON bit in ADCON Register, and set SCH [2:0]
2
LED_C8
-LED_C5
Set P3S7-P3S4 bits in P3SS register and set DISPSEL bit and DUTY bit in
DISPCON register
3
23-26
Enable bit
Set P3S7-P3S4 bits in P3SS register, clear DISPSEL bit and set DUTY bit in
COM8-COM5 DISPCON register
4
P3.7-P3.4
Above condition is not met
1
LED_C4
-LED_C1
3-P3S
0 bits in P3SS register and set DISPSEL bit and DUTY bit in
Set P3S
P3S3
-P3S0
DISPCON register
2
3
P3S3-P3S0
P3SS register, clear DISPSEL bit and set DUTY bit in
COM4-COM1 Set P3S3-P3S0 bits in
DISPCON register
P3.3-P3.0
Above condition is not met
37
166A
SH79F
SH79F166A
PORT4
PORT4::
- INT40-INT43 (P4.0-P4.3): External interrupt input
- AN0-AN3 (P4.0-P4.3): ADC input channel
- AVR EF (P4.4): ADC reference voltage
Table 7.23 PORT4 Share Table
Pin No.
14
15-18
Priority
Function
1
AVREF
2
P4.4
1
AN3-AN0
2
INT43-INT40
3
P4.3-P4.0
Enable bit
Set REFC bit in ADCON register
Above condition is not met
3-0 bit in ADCH Register and
Set CH
CH3-0
set ADON bit in ADCON Register, and set SCH [2:0]
Set EX4 bit in IEN1 register and EXS43-40 bit in IENC register, P4.3-P4.0 in
input mode
Above condition is not met
PORT5
PORT5::
- XTAL1 (P5.0): XTAL input
- XTAL2 (P5.1): XTAL output
———
- RST (P5.2): system reset pin
- BUZ (P5.3): Buzzer output
- T3 (P5.3): Timer3 external input
Table 7.24 PORT5 Share Table
Pin No.
8
9
10
11
Priority
Function
Enable bit
1
XTAL1
Selected by Code Option
2
P5.0
Above condition is not met
1
XTAL2
Selected by Code Option
2
P5.1
Above condition is not met
1
———
RST
P5.2
Selected by Code Option
2
1
BUZ
Set BZEN bit in BUZCON register
2
T3
3
P5.3
Above condition is not met
Set TR3 bit in T3CON register and T3CLKS[1
T3CLKS[1:: 0] = 01 (Auto Pull up)
Above condition is not met
38
166A
SH79F
SH79F166A
8 Timer
7.
7.8
7.
8.1 Feature
s
7.8
Features
пїЅ The SH79F166A has four timers (Timer2, 3, 4, 5)
пїЅ Timer2 is compatible with the standard 8052 and has up or down counting and programmable clock output function
пїЅ Timer3 is a 16-bit auto-reload timer and can operate even in Power-Down mode
пїЅ Timer4 is a 16-bit auto-reload timer and can be selected as a baud-rate generator
пїЅ Timer5 is a 16-bit auto-reload timer
2
7.8.2 Timer
Timer2
The Timer 2 is implemented as a 16-bit register accessed as two cascaded data registers: TH2 and TL2. It is controlled by the
register T2CON and T2MOD. The Timer2 interrupt can be enabled by setting the ET2 bit in the IEN0 register. (Refer to Interrupt
Section for details)
———
C/ T2 selects system clock (timer operation) or external pin T2 (counter operation) as the timer clock input. Setting TR2 allows
Timer 2/Counter 2 Data Register to increment by the selected input.
Timer2 Modes
Timer2 has 4 operating modes: Capture/Reload, Auto-reload mode with up or down counter, Baud Rate Generator and
Programmable clock-output. These modes are selected by the combination of RCLK, TCLK and CP/RL2.
5 Timer2 Mode select
Table 7.2
7.25
———
C/ T2
X
X
X
T2OE
DCEN
TR2
0
0
0
X
0
1
1
1
1
CP/RL2 RCLK
1
0
0
X
0
X
1
X
0
1
X
1
X
1
1
X
1
X
X
X
0
TCLK
Mode
0
0
0
X
1
0
X
1
X
0
16 bit capture
1
16 bit auto-reload timer
2
Baud-Rate generator
3
Programmable clock-output only
3
Programmable clock-output, with Baud-rate
generator
X
0
0
0
1
X
0
1
X
X
X
X
X
X
Not recommending
Timer2 stop, the T2EX path still enable
Mode0: 16 bit Capture
In the capture mode, two options are selected by bit EXEN2 in T2CON.
If EXEN2 = 0, Timer2 is a 16-bit timer or counter which will set TF2 on overflow to generate an interrupt if ET2 is enabled.
If EXEN2 = 1, Timer2 performs the same operation, but a 1-to-0 transition at external input T2EX also causes the current value
in TH2 and TL2 to be captured into RCAP2H and RCAP2L respectively, In addition, a 1-to-0 transition at T2EX causes bit EXF2
in T2CON to be set. The EXF2 bit, like TF2, can also generate an interrupt if ET2 is enabled.
S ystem Clock
=0
Increment Mode
C/T2
TL2
=1
T2
TH2
TF2
0:S witch O ff
1:Switch On
TR2
Overflow flag
CP / RL2
&
EXEN2
T2EX
+
RCAP2L
RCAP2H
0:S witch O ff
1:Switch On
EXF2
Block Diagram of 16 bit Capcture m ode (Mode 0) of Tim er2
39
External falling
edge flag
Interrupt
Request
166A
SH79F
SH79F166A
Mode1: 16 bit auto-reload T imer
Timer2 can be programmed to count up or down when configured in its 16-bit auto-reload mode. This feature is invoked by the
DCEN (Down Counter Enable) bit in T2MOD. After reset, the DCEN bit is set to 0 so that Timer2 will default to count up. When
DCEN is set, Timer2 can count up or down, depending on the value of the T2EX pin.
When DCEN = 0, two options are selected by bit EXEN2 in T2CON.
If EXEN2 = 0, Timer2 counts up to 0FFFFH and then sets the TF2 bit upon overflow. The overflow also causes the timer
registers to be reloaded with the 16-bit value in RCAP2H and RCAP2L, which are pressed by software.
If EXEN2 = 1, a 16-bit reload can be triggered either by an overflow or by a 1-to-0 transition at external input T2EX. This
transition also sets the EXF2 bit. Both the TF2 and EXF2 bits can generate an interrupt if ET2 is enabled.
S ystem Clock
Increment Mode
=0
C/T2
TL2
TH2
TF2
=1
T2
Overflow
Flag
0:S witch O ff
1:Switch On
TR2
+
RCAP2L
EXEN2
RCAP2H
+
0:S witch O ff
1:Switch On
T2EX
Interrupt
Request
External Falling
Edge flag
EXF2
The Block Diagram of Auto Relode Mode (
Mode 1 )of Tim er2 (DCEN= 0)
Setting the DCEN bit enables Timer2 to count up or down. When DCEN = 1, the T2EX pin controls the direction of the count,
and EXEN2’s control is invalid.
A logical “1” at T2EX makes Timer2 count up. The timer will overflow at 0FFFFH and set the TF2 bit. This overflow also causes
the 16-bit value in RCAP2H and RCAP2L to be reloaded into the timer registers, TH2 and TL2, respectively.
A logical “0” at T2EX makes Timer2 count down. The timer underflows when TH2 and TL2 equal the values stored in RCAP2H
and RCAP2L. The underflow sets the TF2 bit and causes 0FFFFH to be reloaded into the timer registers.
The EXF2 bit toggles whenever Timer2 overflows or underflows and can be used as a 17th bit of resolution. In this operating
mode, EXF2 does not flag an interrupt.
FFH
FFH
TL2
TH2
System
Clock
=0
C/T2
=1
T2
TR2
T2EX
TF2
Overflow
Flag
0:S witch O ff
1:Switch On
1. T2EX=1пјЊ Timer2 is up counter
2.T2EX=0пјЊ Timer2 is down co unter
RCAP2L
Toggle
RCAP2H
EXF2
The Block Diagram of Auto-Reload Mode ( Mode 1) of Tim er2 (
40
DCEN=1)
Interrupt
Request
166A
SH79F
SH79F166A
Mode2: Baud-Rate G enerator
Timer2 is selected as the baud rate generator by setting TCLK and/or RCLK in T2CON. The baud rates for transmit and receive
can be different if Timer2 is used for the receiver or transmitter and Timer4 is used for the other.
Setting RCLK and/or TCLK will put Timer2 into its baud rate generator mode, which is similar to the auto-reload mode.
Over flow of Timer2 will causes the Timer2 registers to be reloaded with the 16-bit value in registers RCAP2H and RCAP2L that
preset by software. But this will not generate an interrupt.
If EXEN2 is set, a 1-to-0 transition in T2EX will set EXF2 but will not cause a reload. Thus when Timer 2 is in use as a baud rate
generator, T2EX can be used as an extra external interrupt.
The baud rates in EUART Modes1 and 3 are determined by Timer2’s overflow rate according to the following equation.
BaudRate =
1
2 Г— 16
BaudRate =
fSYS
Г—
———
; C/ T2 = 0
65536 в€’ [RCAP2H,RCAP2L]
———
fT2
1
Г—
; C/ T2 = 1
16 65536 в€’ [RCAP2H, RCAP2L]
Timer4
overflow
S ystem Clock
SMOD
=1
=0
/2
/2
=0
C/ T2
T2
=1
TR2
TL2
TH2
RCLK
=1
=0
UART receiver
clock source
/16
0:S witch O ff
1:Switch On
TCLK
=1
=0
RCAP2L
RCAP2H
UART transiver
clock source
/16
T2EX
EXEN2
0:S witch O ff
1:Switch On
EXF2
The Block Diagram of Baud-Rate G enerator ( Mode 2 ) of Tim er2
41
Timer2 Interrupt
Request
166A
SH79F
SH79F166A
Mode3: Programmable Clock O utput
———
A 50% duty cycle clock can be programmed to come out on P0.5. To configure the Timer2 as a clock generator, bit C/ T2 must
be cleared and bit T2OE must be set. Bit TR2 starts and stops the timer.
In this mode T2 will output a 50% duty cycle clock:
Clock
Out Frequency =
fSYS
1
Г—
2 Г— 2 65536 в€’ [RCA P2H, RCA P2L]
Timer2 overflow will not generate an interrupt, so it is possible to use Timer2 as a baud-rate generator and a clock output
simultaneously with the same frequency.
System Clock
/2
=0
C/ T2
TL2
TH2
RCAP2L
RCAP2H
=1
TR2
0:Switch Off
1:Switch On
C/ T2
T2OE
0:Switch Off
1:Switch On
T2
/2
T2EX
EXEN2
0:Switch Off
1:Switch On
EXF2
Timer2 Interrupt
Request
The Block Diagram of Programmable Clock output (Mode 3) of Timer2
Note:
(1) Both TF2 and EXF2 can cause timer2 interrupt request, and they have the same vector address.
(2) TF2 and EXF2 are set as 1 by hardware while event occurs. But they can also be set by software at any time. Only the
software and the hardware reset will be able to clear TF2 & EXF2 to 0.
(3) When EA = 1 & ET2 = 1, setting TF2 or EXF2 as 1 will cause a timer2 interrupt.
(4) While Timer2 is used as baud rate generator,writing TH2/TL2, writing RCAPH2/RCAPL2 will affect the accuracy of baud
rate, thus might make cause communication error.
42
166A
SH79F
SH79F166A
Registers
Table 7.26 Timer2 Control Register
C8H
C8H,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
———
Bit0
——— —
T2CON
TF2
EXF2
RCLK
TCLK
EXEN2
TR2
C/ T2
CP/RL2
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7
TF2
6
EXF2
External event input (falling edge) from T2EX pin detected flag bit
0: No external event input (Must be cleared by software)
1: Detected external event input (Set by hardware if EXEN2 = 1)
5
RCLK
EUART
0 Receive Clock control bit
EUART0
0: Timer 4 generates receiveing baud-rate
1: Timer 2 generates receiveing baud-rate
4
TCLK
EUART
0 Transmit Clock control bit
EUART0
0: Timer4 generates transmitting baud-rate
1: Timer 2 generates transmitting baud-rate
3
EXEN2
External event input (falling edge) from T2EX pin used as Reload/Capture
trigger enable/disable control bit
0: Ignore events on T2EX pin
1: Cause a capture or reload when a negative edge on T2EX pin is detected,
when Timer 2 is not used to clock the EUART (T2EX always has a pull up
resistor)
2
TR2
1
C/ T2
0
CP/RL2
———
————
Description
Timer2 overflow flag bit
0: No overflow
1: Overflow (Set by hardware if RCLK = 0 & TCLK = 0)
Timer2 start/stop control bit
0: Stop Timer2
1: Start Timer2
Timer2 Timer/Counter mode selected bit
0: Timer Mode, T2 pin is used as I/O port
1: Counter Mode, the internal pull-up resister is turned on
Capture/Reload mode selected bit
0: 16 bits timer/counter with reload function
1: 16 bits timer/counter with capture function
43
166A
SH79F
SH79F166A
Table 7.27 Timer2 Mode Control Register
C9H
C9H,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
T2MOD
-
-
-
-
-
-
T2OE
DCEN
R /W
-
-
-
-
-
-
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
-
-
-
-
-
0
0
Bit1
Bit0
Bit Number
Bit Mnemonic
Description
1
T2OE
Timer2 Output Enable bit
0: Set P0.5/T2 as clock input or I/O port
1: Set P0.5/T2 as clock output (Baud-Rate generator mode)
0
DCEN
Down Counter Enable bit
0: Disable Timer2 as up/down counter, Timer2 is an up counter
1: Enable Timer2 as up/down counter
Table 7.28 Timer2 Reload/Capture & Data Registers
CAH-CDH
CAH-CDH,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
RCAP2L
RCAP2L.7 RCAP2L.6 RCAP2L.5 RCAP2L.4 RCAP2L.3 RCAP2L.2 RCAP2L.1 RCAP2L.0
RCAP2H
RCAP2H.7 RCAP2H.6 RCAP2H.5 RCAP2H.4 RCAP2H.3 RCAP2H.2 RCAP2H.1 RCAP2H.0
TL2
TL2.7
TL2.6
TL2.5
TL2.4
TL2.3
TL2.2
TL2.1
TL2.0
TH2
TH2.7
TH2.6
TH2.5
TH2.4
TH2.3
TH2.2
TH2.1
TH2.0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7-0
RCAP2L.x
RCAP2H.x
7-0
TL2.x
TH2.x
Description
Timer2 Reload/Capturer Data, x = 0 - 7
Timer2 Low & High byte counter, x = 0 - 7
44
166A
SH79F
SH79F166A
8. 3 Timer
3
7.
7.8
Timer3
Timer3 is a 16-bit auto-reload timer. It is accessed as two cascaded Data Registers: TH3 and TL3. It is controlled by the T3CON
register. The Timer3 interrupt can be enabled by setting ET3 bit in IEN1 register (Refer to Interrupt Section for details).
Timer3 has only one operating mode: 16-bit Counter/Timer with auto-reload. Timer3 also supports the following features:
selectable pre-scaler setting and Operation during CPU Power-Down mode.
Timer3 consists of a 16-bit counter/reload register (TH3, TL3). When writing to TH3 and TL3, they are used as timer load
register. When reading from TH3 and TL3, they are used as timer counter register. Setting the TR3 bit enables Timer 3 to count
up. The Timer will overflow from 0xFFFF to 0x0000 and set the TF3 bit. This overflow also causes the 16-bit value written in
timer load register to be reloaded into the timer counter register. Writing to TH3 also can cause the 16-bit value written in timer
load register to be reloaded into the timer counter register.
Read or write operation to TH3 and TL3 should follow these steps:
Write operation: Low nibble first, High nibble to update the counter
Read operation: High nibble first, Low nibble followed.
T3PS[1:0]
Increment Mode
System Clock
T3
32.768kHz
Crystal
00
01
10
Prescaler
1,8,64,256
Interrupt
Request
16-bit Counter
TF3
Overflow
Flag
T3CLKS[1:0]
TR3
0:Switch Off
1:Switch On
TL3
TH3
The Block Diagram of Timer3
Timer3 can operate even in Power-Down mode.
When OP_OSC[3:0] (Refer to Code Option Section for details) is 1010, 1101, 0011 or 0110, T3CLKS [1:0] can select 00, 01 or
10. When OP_OSC[3:0] is not 1010, 1101, 0011 or 0110, T3CLKS[1:0] can select 00 or 01, and 10 will be an invalid value.
If T3CLKS[1:0] is 00, Timer 3 can’t work in Power Down mode. If T3CLKS[1:0] is 01 and external clock input from T3 Pin,
Timer3 can work in CPU normal operating or Power Down mode. If T3CLKS[1:0] is 10 and OP_OSC[3:0] is 1010, 1101, 0011
or 0110, Timer3 can work in CPU normal operating or Power Down mode (entering Power Down mode when system clock is
high frequency). If T3CLKS[3:0] is 10 and OP_OSC[2:0] is not1010, 1101, 0011 or 0110, Timer3 can’t work. It can be described
in the following table.
3 ::0]
0]
OP_OSC[
OP_OSC[3
1010, 1101, 0011 or 0110
Not 1010, 1101, 0011 or 0110
T3CLKS[1
T3CLKS[1:: 0]
Can work in normal mode
Can work in Power Down mode
00
YES
NO
01
YES
YES
10
YES
YES
00
YES
NO
01
YES
YES
10
NO
NO
Note
Note::
(1) When TH3 and TL3 read or written, must make sure TR3 = 0.
(2) When T3 is selected as Timer3 clock source and TR3 is set 0 to 1, the first T3 down edge will be ignored.
45
166A
SH79F
SH79F166A
Registers
Table 7.29 Timer3 Control Register
88H
88H,, Bank1
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
T3CON
TF3
-
T3PS.1
T3PS.0
-
TR3
R /W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
R/W
-
R/W
R/W
-
R/W
R/W
R/W
0
-
0
0
-
0
0
0
Bit Number
Bit Mnemonic
7
TF3
Bit0
Description
Timer3 overflow flag bit
0: No overflow (cleared by hardware)
1: Overflow (Set by hardware)
5-4
T3PS[1
T3PS[1:: 0]
2
TR3
1-0
Bit1
T3CLKS.1 T3CLKS.0
Timer3 input clock Prescaler Select bits
00: 1/1
01: 1/8
10: 1/64
11: 1/256
Timer3 start/stop control bit
0: Stop Timer3
1: Start Timer3
T3CLKS[1
T3CLKS[1:: 0]
Timer3 Clock Source select bits
00: System clock, T3 pin is used as I/O port
01: External clock from pin T3, auto pull-up
10: 32.768kHz from external Crystal
11: reserved
Table 7.30 Timer3 Reload/Counter Data Registers
8CH-8DH
8CH-8DH,, Bank1
TL3
Bit7
TL3.7
Bit6
TL3.6
Bit5
TL3.5
Bit4
TL3.4
Bit3
TL3.3
Bit2
TL3.2
Bit1
TL3.1
Bit0
TL3.0
TH3
TH3.7
TH3.6
TH3.5
TH3.4
TH3.3
TH3.2
TH3.1
TH3.0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit1
Bit0
Bit Number
7-0
Bit Mnemonic
TL3.x
TH3.x
Description
Timer3 Low & High byte counter, x = 0 - 7
Table 7.31 Timer3 Reload/Count Data Register
89H , Bank1
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
SWTHL
-
-
-
-
-
-
R /W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
-
-
-
-
-
R/W
R/W
-
-
-
-
-
-
0
0
Bit Number
Bit Mnemonic
0
T3HLCON
Description
0: when read TH3,TL3,return T3 count data
1: when read TH3,TL3,return T3 reload register data
46
T5HLCON T3HLCON
166A
SH79F
SH79F166A
8. 4 Timer
4
7.
7.8
Timer4
Timer4 is a 16-bit auto-reload timer. It is accessed as two cascaded data registers: TH4 and TL4. It is controlled by the T4CON
register. The Timer 4 interrupt can be enabled by setting ET4 bit in IEN1 register (Refer to interrupt Section for details).
When writing to TH4 and TL4, they are used as timer load register. When reading from TH4 and TL4, they are used as timer
counter register. Setting the TR4 bit enables Timer 4 to count up. The timer will overflow from 0xFFFF to 0x0000 and set the
TF4 b it. This overflow also causes the 16-bit value written in timer load register to be reloaded into the timer counter register.
Writing to TH4 also can cause the 16-bit value written in timer load register to be reloaded into the timer counter register.
Read or write operation to TH4 and TL4 should follow these steps:
Write operation:Low nibble first,High nibble to update the counter.
Read operation:High nibble first,Low nibble followed.
Timer4 Modes
Timer4 has three operating modes: 16-bit auto-reload counter/timer, Baud Rate Generator and 16 bit auto-reload timer with T4
edge trig. These modes are selected by T4M[1:0] bits in T4CON Register.
R eload C ounter/
Timer
Mode0: 16 bit Autouto-R
ounter/T
Timer4 operates as 16-bit counter/timer in Mode 0. The TH4 register holds the high eight bits of the 16-bit counter/timer, TL4
holds the low eight bits. As the 16-bit timer register increments and overflows from 0xFFFF to 0x0000, the timer overflow flag
TF4 (T4CON.7) is set and the 16-bit value in timer load register are reloaded into timer counter register, and an interrupt will
occur if Timer 4 interrupts is enabled. The T4CLKS bit (T4CON.0) selects the counter/timer's clock source.
If T4CLKS = 1, external clock from the Pin T4 is selected as Timer4 clock, after prescaled, it will increase the Counter/Timer4
Data register. Else if T4CLKS = 0, the system clock is selected as Timer4 clock.
Setting the TR4 bit (T4CON.1) enables the timer. Setting TR4 does not force the timer to reset. The timer load register should
be loaded with the desired initial value before the timer is enabled.
In Compare mode, the T4 pin is automatically set as output mode by hardware. the internal counter is constantly countered
from TH4 and TL4 register value to 0xFFFF. When an overflow occurs, the T4 pin will be inverted. At the same time, interrupt
flag bit of Time4 is set. Timer4 must be running in Timer mode (T4CLKS = 0) when compare function enabled.
System Clock
T4PS[1:0]
Increment Mode
=0
T4CLKS
=1
T4
TR4
Prescaler
1,8,64,256
16 bit Counter
Interrupt
Request
TF4
Overflow
Flag
0:Switch Off
1:Switch On
T4
TL4
TH4
T4CLKS=0
TC4=1
The Block Diagram of Mode 0 of Timer 4
Mode1: Baud-Rate G enerator
Timer4 is selected as the baud rate generator by setting T4MOD bit in T4CON register. The baud rates for transmit and receive
can be different if Timer2 is used for the receiver or transmitter and Timer4 is used for the other.
The mode is similar to the auto-reload mode.Overflow of Timer4 will causes the Timer4 counter register to be reloaded with the
16-bit value in timer load register. But this will not generate an interrupt.
The baud rates in EUART mode1 and mode3 are determined by Timer4’s overflow rate according to the following equation.
1
f /PRESCALER пјЊthe clock source of Timer4 is system clock.
BaudRate =
Г— T4
2 Г— 16 65536 в€’ [TH4, TL 4]
BaudRate =
1
f /PRESCALER
пјЊ the clock source of Timer4 is input clock of T4 pin.
Г— T4
16 65536 в€’ [T H 4,T L4]
Here, TH4 and TL4 stand for Timer4 reload register.
47
166A
SH79F
SH79F166A
R eload T imer with T4 E dge Trig
Mode2: 16 bit Autouto-R
Timer4 operates as 16-bit timer in Mode2. The TH4 register holds the high eight bits of the 16-bit counter/timer, TL4 holds the
low eight bits. As the 16-bit timer register increments and overflows from 0xFFFF to 0x0000, the timer overflow flag TF4
(T4CON.7) is set and the 16-bit value in timer load register are reloaded into timer counter register, and an interrupt will occur if
Timer4 interrupts is enabled. The T4CLKS bit (T4CON.0) is 0 always. Only the system clock is selected as Timer4 clock.
In Mode2, After Setting the TR4 bit (T4CON.1), Timer4 does not start counting but waits the trig signal (rising or falling edge
controlled by T4M[1:0]) from T4. An active trig signal will start the Timer4. When Timer 4 overflows from 0XFFFF to 0x0000, TF4
will be set, TH4 and TL4 will be reloaded from timer load register, and Timer4 holds and waits the next trig edge.
When Timer4 is working, an active trig signal maybe come, if TC bit equals 0, the trig signal will be ignored; if TC bit equals 1,
Timer4 will be re-trigged.
Setting TR4 does not force the timer to reset. The timer register should be loaded with the desired initial value before the timer
is enabled.
T4PS[1:0]
Increment Mode
System Clock
T4
Prescaler
1,8,64,256
control
M2_en
TC4
Interrupt
Request
16 bit Counter
TF4
Overflow
Flag
TR4
0:Switch Off
1:Switch On
TL4
TH4
+
The Block Diagram of Mode 2 of Timer 4
control
: M2_en set to 1 when T4 edge trig, M2_en set to 0 when counter overflow
Note
Note::
(1) When Timer4 is running (TR4 = 1) as a timer in the baud rate generator mode, TH4 or TL4 should not be written to. Because
a write might overlap a reload and cause write and/or reload errors. So, the timer 4 must be turned off (TR4 = 0) before
accessing the TH4 or TL4 registers.
(2) When Timer4 is used as a counter, the frequency of input signal of T4 pin must be less than half of system clock.
48
166A
SH79F
SH79F166A
Registers
Table 7.32 Timer4 Control Register
C8H
C8H,, Bank1
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
T4CON
TF4
TC4
T4PS1
T4PS0
T4M1
T4M0
TR4
T4CLKS
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7
TF4
Timer4 overflow flag bit
0: No overflow (cleared by hardware)
1: Overflow (Set by hardware)
TC4
Compare function Enable bit
When T4M[1:0] = 00
0: Disable compare function of Timer4
1: Enable compare function of Timer4
When T4M[1:0] = 10 or 11
0: Timer4 can’t be re-trigged
1: Timer4 can be re-trigged
T4PS[1
T4PS[1:: 0]
Timer4 input clock Prescale Select bits
00: 1/1
01: 1/8
10: 1/64
11: 1/256
3-2
T4M[1
T4M[1:: 0]
Timer4 Mode Select bit
00: Mode0, 16-bit auto-reload up counter/timer
01: Mode1, baud-rate generator for EUART
10: Mode2 with rising edge trig from pin T4 (system clock only, T4CLKS is invalid)
11: Mode2 with falling edge trig from pin T4 (system clock only, T4CLKS is invalid)
1
TR4
6
5-4
0
Description
Timer4 start/stop control bi
bitt
0: Stop Timer4
1: Start Timer4
T4CLKS
Timer4 Clock Source select bit
0: System clock, T4 pin is used as I/O port
1: External clock from pin T4 (On the falling edge), the internal pull-up resister is
turned on
Table 7.33 Timer4 Reload/Counter Data Registers
CCH-CDH
CCH-CDH,, Bank1
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
TL4
TL4.7
TL4.6
TL4.5
TL4.4
TL4.3
TL4.2
TL4.1
TL4.0
TH4
TH4.7
TH4.6
TH4.5
TH4.4
TH4.3
TH4.2
TH4.1
TH4.0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
7-0
Bit Mnemonic
4.x
TL
TL4
TH
4.x
TH4
Description
Timer4 Low & High byte counter, x = 0 - 7
49
166A
SH79F
SH79F166A
8. 5 Timer
5
7.
7.8
Timer5
Timer5 is a 16-bit auto-reload timer. It is accessed as two cascaded data registers: TH5 and TL5. It is controlled by the T5CON
register. The interrupt can be enabled by setting ET5 bit in IEN0 register (Refer to interrupt Section for details).
When writing to TH5 and TL5, they are used as timer load register. When reading from TH5 and TL5, they are used as timer
counter register. Setting the TR5 bit enables Timer5 to count up. The timer will overflow from 0xFFFF to 0x0000 and set the TF5
b it. This overflow also causes the 16-bit value written in timer load register to be reloaded into the timer counter register. Writing
to TH4 also can cause the 16-bit value written in timer load register to be reloaded into the timer counter register.
Read or write operation to TH5 and TL5 should follow these steps:
Write operation:Low nibble first,High nibble to update the counter.
Read operation:High nibble first,Low nibble followed.
Timer5 Modes
Timer5 has one operating modes: 16-bit auto-reload counter/timer.
R eload C ounter/
Timer
Mode0: 16 bit Autouto-R
ounter/T
Timer5 operates as 16-bit counter/timer in Mode 0. The TH5 register holds the high eight bits of the 16-bit counter/timer, TL5
holds the low eight bits. As the 16-bit timer register increments and overflows from 0xFFFF to 0x0000, the timer overflow flag
TF5 (T5CON.7) is set and the 16-bit value in timer load register are reloaded into timer counter register, and an interrupt will
occur if Timer 5 interrupts is enabled. The T4CLKS bit (T4CON.0) selects the counter/timer's clock source.
Setting the TR5 bit (T5CON.1) enables the timer. Setting TR5 does not force the timer to reset. The timer load register should
be loaded with the desired initial value before the timer is enabled.
T5PS[1:0]
Increment Mode
System Clock
TR5
Prescaler
1,8,64,256
Interrupt
Request
16 bit Counter
TF5
Overflow
Flag
0:Switch Off
1:Switch On
TL5
The Block Diagram of Mode 0 of Timer 5
50
TH5
166A
SH79F
SH79F166A
Registers
Table 7.34 Timer5 Control Register
C0H , Bank1
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
T5CON
TF5
-
T5PS1
T5PS0
-
-
TR5
-
R /W
R/W
-
R/W
R/W
-
-
R/W
-
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
-
0
0
-
-
0
-
Bit Number
Bit Mnemonic
Description
7
5
TF
TF5
5 overflow flag bit
Timer
Timer5
0: No overflow (cleared by hardware)
1: Overflow (Set by hardware)
5-4
T5PS[1
PS[1:: 0]
5 input clock Prescale Select bits
Timer
Timer5
00: 1/1
01: 1/8
10: 1/64
11: 1/256
1
5
TR
TR5
5 start/stop control bi
Timer
Timer5
bitt
0: Stop Timer5
1: Start Timer5
Table 7.35 Timer5 Reload/Counter Data Registers
C E H-C
FH , Bank1
H-CF
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
5
TL
TL5
TL5.7
TL5.6
TL5.5
TL5.4
TL5.3
TL5.2
TL5.1
TL5.0
5
TH
TH5
TH5.7
TH5.6
TH5.5
TH5.4
TH5.3
TH5.2
TH5.1
TH5.0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
(POR/WDT/LVR
/PIN
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit1
Bit0
Bit Number
Bit Mnemonic
5.x
TL
TL5
7-0
Description
5 Low & High byte counter, x = 0 - 7
Timer
Timer5
5.x
TH
TH5
Table 7.36 Timer5 Reload/Count Data Register
H , Bank1
89
89H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
SWTHL
-
-
-
-
-
-
R /W
-
-
-
-
-
-
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
-
-
-
-
-
0
0
Bit Number
Bit Mnemonic
1
T5HLCON
Description
0: when read TH5, TL5, return T5 count data
1: when read TH5, TL5, return T5 reload register data
51
T5HLCON T3HLCON
166A
SH79F
SH79F166A
9 Interrupt
7.
7.9
7.
9.1 Feature
7.9
пїЅ 14 interrupt sources
пїЅ 4 interrupt priority levels
The SH79F166A provides total 14 interrupt sources: 5 external interrupts (INT0/1/2/3/4; INT4 including INT40-43, which share
the same vector address), 4 timer interrupts (Timer2, 3, 4, 5), one EUART interrupt, ADC Interrupt, PWM interrupts, SCM
interrupt and LPD interrupt.
7.9.2 Interrupt Enable C ontrol
Each interrupt source can be individually enabled or disabled by setting or clearing the corresponding bit in the interrupt enable
registers IEN0 or IEN1. The IEN0 register also contains global interrupt enable bit, EA, which can enable/disable all the
interrupts at once. Generally, after reset, all interrupt enable bits are set to 0, which means that all the interrupts are disabled.
Table 7.37 Primary Interrupt Enable Register
A8H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
IEN0
EA
EADC
ET2
ES0
-
EX1
ET5
EX0
R /W
R/W
R/W
R/W
R/W
-
R/W
R/W
R/W
Reset Value
(POR/WDT/LVR/PIN
POR/WDT/LVR/PIN))
0
0
0
0
-
0
0
0
Bit Number
Bit Mnemonic
Description
7
EA
6
EADC
5
ET2
Timer
2 overflow interrupt enable bit
Timer2
0: Disable Timer2 overflow interrupt
1: Enable Timer2 overflow interrupt
4
ES0
EUART interrupt enable bit
0: Disable EUART interrupt
1: Enable EUART interrupt
2
EX1
External interrupt1 enable bit
0: Disable external interrupt1
1: Enable external interrupt1
1
5
ET
ET5
5 overflow interrupt enable bit
Timer
Timer5
0: Disable Timer5 overflow interrupt
1: Enable Timer5 overflow interrupt
0
EX0
External interrupt0 enable bit
0: Disable external interrupt0
1: Enable external interrupt0
A ll interrupt enable bit
0: Disable all interrupt
1: Enable all interrupt
ADC interrupt enable bit
0: Disable ADC interrupt
1: Enable ADC interrupt
52
166A
SH79F
SH79F166A
Table 7.38 Secondary Interrupt Enable Register
A9H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
IEN1
ESCM/ELPD
ET4
EPWM
ET3
EX4
EX3
EX2
-
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
-
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
-
Bit Number
Bit Mnemonic
Description
7
/ELPD
ESCM
ESCM/ELPD
6
ET4
5
EPWM
4
ET3
Ti mer3 overflow
interrupt enable bit
overflowinterrupt
0: Disable timer3 overflow interrupt
1: Enable timer3 overflow interrupt
3
EX4
4 enable bit
External interrupt
interrupt4
0: Disable external interrupt4
1: Enable external interrupt4
2
EX3
3 enable bit
External interrupt
interrupt3
0: Disable external interrupt3
1: Enable external interrupt3
1
E X2
2 enable bit
Enternal interrupt
interrupt2
0: Disenable external interrupt2
1: Enable external interrupt2
SCM/LPD interrupt enable bit
0: Disable SCM/LPD interrupt
1: Enable SCM/LPD interrupt
4 overflow
interrupt enable bit
Timer
Timer4
overflowinterrupt
0: Disable Timer4 overflow interrupt
1: Enable Timer4 overflow interrupt
PWM interrupt enable bit
0: Disable PWM interrupt
1: Enable PWM interrupt
Note:
(1) To enable External interrupt0/1/2/3/4, the corresponding port must be set to input mode before using it.
(2) To enable PWM timer interrupt, the EPWM bit here should be set. Also, the PWM0IE in PWM interrupt control register
should be set.
53
166A
SH79F
SH79F166A
Table 7.39 Interrupt channel Enable Register
BAH
BAH,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
IENC
-
-
-
-
EXS43
EXS42
EXS41
EXS40
R /W
-
-
-
-
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
-
-
-
0
0
0
0
Bit Number
Bit Mnemonic
3-0
EXS4x
(x = 3-0
3-0))
Description
External interrupt4 channel select bit (x = 3-0
3-0))
0: Disable external interrupt 4x
1: Enable external interrupt 4x
Table 7.40 Interrupt channel Enable Register1
BB H , Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
1
IENC
IENC1
-
-
-
-
-
-
ESCM1
ELPD
R /W
-
-
-
-
-
-
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
-
-
-
-
-
0
0
Bit Number
Bit Mnemonic
Description
1
ESCM1
SCM interrupt enable bit
0: Disable SCM interrupt
1: Enable SCM interrupt
0
ELPD
LPD interrupt enable bit
0: Disable LPD interrupt
1: Enable LPD interrupt
54
166A
SH79F
SH79F166A
3 Interrupt Flag
7.9.
7.9.3
Each Interrupt source has its own interrupt flag, when interrupt occurs, corresponding flag will be set by hardware, the interrupt
flag bits are listed in Table bellow.
/2/3
For external interrupt (INT0/1
(INT0/1/2/3
/2/3)), when an external interrupt0/1/2/3 is generated, if the interrupt was edge trigged, the flag
(IE0-3 in TCON) that generated this interrupt is cleared by hardware when the service routine is vectored. If the interrupt was
level trigged, then the requesting external source directly controls the request flag, rather than the on-chip hardware.
When an external interrupt4 is generated, the flag (IF4x (x = 0-3) in EXF1 register) that generated this interrupt should be
cleared by user’s program because the same vector entrance was used in INT4. But if INT4 is setup as level trigged, the flag
can’t be cleared by user’s program, it only be controlled by peripheral signal level that connect to INT source pin.
The timer 2 interrupt is generated by the logical OR of flag TF2 and bit EXF2 in T2CON register, which is set by hardware.
None of these flags can be cleared by hardware when the service routine is vectored. In fact, the service routine may have to
determine whether it was TF2 or EXF2 that generated the interrupt, so the flag must be cleared by software.
The timer 3 interrupt is generated when they overflow, the flag TF3 in T3CON register, which is set by hardware, and will be
automatically cleared by hardware when the service routine is vectored.
The timer 4 interrupt is generated when they overflow, the flag TF4 in T4CON register, which is set by hardware, and will be
automatically cleared by hardware when the service routine is vectored.
The timer 5 interrupt is generated when they overflow, the flag TF5 in T4CON register, which is set by hardware, and will be
automatically cleared by hardware when the service routine is vectored.
The EUART interrupt is generated by the logical OR of flag RI and TI in SCON register, which is set by hardware. Neither of
these flags can be cleared by hardware when the service routine is vectored. In fact, the service routine will normally have to
determine whether it was the receive interrupt flag or the transmission interrupt flag that generated the interrupt, so the flag
must be cleared by software.
The ADC interrupt is generated by ADCIF bit in ADCON. If an interrupt is generated, the converted result in ADCDH/ADCDL
will be valid. If continuous compare function in ADC module is Enable, ADCIF will not be set at each conversion, but set if
converted result is larger than compare value. The flag must be cleared by software.
The SCM interrupt is generated by SCMIF in SCM register, which is set by hardware. And the flag can only be cleared by
hardware.
The LPD interrupt is generated by LPDF in LPDCON register. And the flag can only be cleared by hardware.
The PWM interrupts are generated by PWM0IF in PWM0C. The flags can be cleared by software.
Table 7.41 Enternal Interrupt Flag Register
88H
88H,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
TCON
-
-
-
-
IE1
IT1
IE0
IT0
R /W
-
-
-
-
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
-
-
-
0
0
0
0
Bit Number
Bit Mnemonic
Description
1, 3
IEx
(x = 0, 1)
External interrupt x request flag bit
0: No interrupt pending
1: Interrupt is pending
0, 2
ITx
(x = 0, 1)
External interrupt x trigger mode selection bit
0: Low level trigger
1: Falling edge trigger
55
166A
SH79F
SH79F166A
Table 7.42 External Interrupt Flag Register
E8H
E8H,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
EXF0
IT4.1
IT4.0
IT3.1
IT3.0
IT2.1
IT2.0
IE3
IE2
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
Description
IT4[1
IT4[1:: 0]
External interrupt4 trigger mode selection bit
00: Low Level trigger
01: Trigger on falling edge
10: Trigger on rising edge
11: Trigger on both edge
IT4 [1:0] is effect on external interrupt 4x at the same mode
IT3[1
IT3[1:: 0]
External interrupt3 trigger mode selection bit
00: Low Level trigger
01: Trigger on falling edge
10: Trigger on rising edge
11: Trigger on both edge
3-2
IT2[1
IT2[1:: 0]
External interrupt2 trigger mode selection bit
00: Low Level trigger
01: Trigger on falling edge
10: Trigger on rising edge
11: Trigger on both edge
1
IE3
External interrupt3 request flag bit
0: No interrupt pending
1: Interrupt is pending
0
IE2
External interrupt2 request flag bit
0: No interrupt pending
1: Interrupt is pending
7-6
5-4
Table 7.43 External Interrupt Flag Register1
D8H
D8H,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
EXF1
-
-
-
-
IF43
IF42
IF41
IF40
R /W
-
-
-
-
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
-
-
-
0
0
0
0
Bit Number
Bit Mnemonic
3-0
IF4x
(x = 3-0
3-0))
Description
External interrupt4 request flag bit
0: No interrupt pending
1: Interrupt is pending
IF4x is cleared by software
56
166A
SH79F
SH79F166A
4 Interrupt Vector
7.9.
7.9.4
When an interrupt occurs, the program counter is pushed onto the stack and the corresponding interrupt vector address is
loaded into the program counter. The interrupt vector addresses are listed in Interrupt Summary table
able.
5 Interrupt Priority
7.9.
7.9.5
Each interrupt source can be individually programmed to one of four priority levels by setting or clearing corresponding bits in
the interrupt priority control registers IPL0, IPH0, IPL1, and IPH1. But the OVL NMI interrupt has the highest Priority Level
(except RESET) of all the interrupt sources, with no IPH/IPL control. The interrupt priority service is described below.
An interrupt service routine in progress can be interrupted by a higher priority interrupt, but can not by another interrupt with the
same or lower priority.
The highest priority interrupt service cannot be interrupted by any other interrupt source. If two requests of different priority
levels are received simultaneously, the request of higher priority level is serviced.
If requests of the same priority level are pending at the start of an instruction cycle, an internal polling sequence determines
which request is serviced.
Interrupt Priority
Priority bits
IPHx
IPLx
Interrupt Lever Priority
0
0
Level 0 (lowest priority)
0
1
Level 1
1
0
Level 2
1
1
Level 3 (highest priority)
Table 7.44 Interrupt Priority Control Registers
B8H
B8H,, B4H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
IPL0
-
PADCL
PT2L
PS0L
-
PX1L
PT5L
PX0L
IPH0
-
PADCH
PT2H
PS0H
-
PX1H
PT5H
PX0H
R /W
-
R/W
R/W
R/W
-
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
0
0
0
-
0
0
0
B9H
B9H,, B5H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
IPL1
PSCML
PT4L
PPWML
PT3L
PX4L
PX3L
PX2L
-
IPH1
PSCMH
PT4H
PPWMH
PT3H
PX4H
PX3H
PX2H
-
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
-
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
-
Bit Number
Bit Mnemonic
7 -0
PxxxL/H
Description
Corresponding interrupt source xxx ’s priority level selection bits
57
166A
SH79F
SH79F166A
6 Interrupt Handling
7.9.
7.9.6
The interrupt flags are sampled and polled at the fetch cycle of each machine cycle. All interrupts are sampled at the rising edge
of the clock. If one of the flags was set, the CPU will find it and the interrupt system will generate a LCALL to the appropriate
service routine, provided this hardware-generated LCALL is not blocked by any of the following conditions:
An interrupt of equal or higher priority is already in progress.
The current cycle is not in the final cycle of the instruction in progress. This ensures that the instruction in progress is completed
before vectoring to any service routine.
The instruction in progress is RETI. This ensures that if the instruction in progress is RETI then at least one more instruction
except RETI will be executed before any interrupt is vectored to; this delay guarantees that the CPU can observe the changes
of the interrupt status.
Note:
Since priority change normally needs 2 instructions, it is recommended to disable corresponding Interrupt Enable flag to avoid
interrupt between these 2 instructions during the change of priority.
If the flag is no longer active when the blocking condition is removed, the denied interrupt will not be serviced. Every polling
cycle interrogates only the valid interrupt requests.
The polling cycle/LCALL sequence is illustrated below:
C1
C2
Interrupt
Polled
C3
C3~Cn
Interrupt
Signal
Generated
Interrupt
Pending
Cn~Cn+7
Long Call to
Interrupt Vector Service
Cn+8
Interrupt
service
Interrupt
Latched
Interrupt Response Timing
The hardware-generated LCALL pushes the contents of the program counter onto the stack (but it does not save the PSW) and
reloads the program counter with corresponding address that depends on the source of the interrupt being vectored too, as
shown in Interrupt Summary table.
Interrupt service execution proceeds from that location until the RETI instruction is encountered. The RETI instruction informs
the processor that the interrupt routine is no longer in progress, and then pops the top two bytes from the stack and reloads the
program counter. Execution of the interrupted program continues from the point where it was stopped. Note that the RETI
instruction is very important because it informs the processor that the program left the current interrupt service. A simple RET
instruction would also have returned execution to the interrupted program, but it would have left the interrupt control system
thinking an interrupt with this priority was still in progress. In this case, no interrupt of the same or lower priority level would be
acknowledged.
7 Interrupt Response Time
7.9.
7.9.7
If an interrupt is recognized, its request flag is set in every machine cycle after recognize. The value will be polled by the circuitry
until the next machine cycle; the CPU will generate an interrupt at the third machine cycle. If the request is active and conditions
are right for it to be acknowledged, hardware LCALL to the requested service routine will be the next instruction to be executed.
Else the interrupt will pending. The call itself takes 7 machine cycles. Thus a minimum of 3+7 complete machine cycles will
elapse between activation and external interrupt request and the beginning of execution of the first instruction of the service
routine.
A longer response time would be obtained if the request was blocked by one of the above three previously listed conditions. If
an interrupt of equal or higher priority is already in progress, the additional wait time obviously depends on the nature of the
other interrupt’s service routine.
If the instruction in progress is not in its final cycle and the instruction in progress is RETIпјЊthe additional wait time is 8 machine
cycles. For a single interrupt system, if the next instruction is 20 machine cycles long (the longest instructions D IV & MUL are 20
machine cycles long for 16 bit operation), adding the LCALL instruction 7 machine cycles the total response time is 2+8+20+7
machine cycles.
Thus interrupt response time is always more than 10 machine cycles and less than 37 machine cycles.
58
166A
SH79F
SH79F166A
8 External Interrupt Inputs
7.9.
7.9.8
The SH79F166A has 5 external interrupt inputs. External interrupt0-3 each has one vector address. External interrupt 4 has 4
inputs; all of them share one vector address. These external interrupts can be programmed to be level-triggered or
edge-triggered by clearing or setting bit IT1 or IT0 in register TCON and register EXF1. If ITn = 0 (n = 0 - 1), external interrupt
0/1 is triggered by a low level detected at the INT0/1 pin. If ITn = 1 (n = 0 - 1), external interrupt 0/1 is edge triggered. In this
mode if consecutive samples of the INT0/1 pin show a high level in one cycle and a low level in the next cycle, interrupt request
flag in register r EXF1 is set, causing an interrupt request. Since the external interrupt pins are sampled once each machine
cycle, an input high or low level should be held for at least one machine cycle to ensure proper sampling.
If the external interrupt is edge-triggered, the external source has to hold the request pin high for at least one machine cycle,
and then hold it low for at least one machine cycle. This is to ensure that the transition is detected and that interrupt request flag
is set. Notice that IE0-1 is automatically cleared by CPU when the service routine is called while IF4x should be cleared by
software. External interrupt4 operates in the similar ways except have different registers and have more selection of trigger.
If the external interrupt is level-triggered, the external source must hold the request active until the requested interrupt is
generated, which will take 2 machine cycles. If the external interrupt is still asserted when the interrupt service routine is
completed, another interrupt will be generated. It is not necessary to clear the interrupt flag IEx (x = 0, 1, 2, 3) when the interrupt
is level sensitive, it simply tracks the input pin level.
If an external interrupt is enabled when the SH79F166A is put into Power down or Idle mode, the interrupt occurrence will cause
the processor to wake up and resume operation.
Note
Note: IE0-3 is automatically cleared by CPU when the service routine is called while IF40-43 should be cleared by software.
1 Machine Cyle
High-Level Threshold
Low-Level Threshold
>1 Machine Cycle
Low-Level Threshold
>2 Machine Cycle
9. 9 Interrupt Summary
7.
7.9
Source
Vector
Address
Enable bits
Flag bits
Polling Priority
Interrupt number
uage
(c lang
language
uage))
Reset
0000H
-
-
0 (higest)
-
INT0
0003H
EX0
IE0
2
0
Timer5
INT1
000BH
0013H
ET5
EX1
TF5
IE1
3
4
1
2
EUART
0023H
ES
RI+TI
5
4
Timer2
002BH
ET2
TF2+EXF2
6
5
ADC
0033H
EADC
ADCIF
7
6
INT2
0043H
EX2
IE2
9
8
INT3
004BH
EX3
IE3
10
9
INT4
0053H
EX4+IENC
IF43-40
11
10
Timer3
005BH
ET3
TF3
12
11
PWM
0063H
EPWM
PWMIF
13
12
Timer4
006BH
ET4
TF4
14
13
SCM/LPD
0073H
ESC M+ESC M1/EL PD
SCMIF/LPDF
15 (Lowest)
14
59
166A
SH79F
SH79F166A
8. Enhanced Function
8.1 Normal Resistor LCD Driver
The LCD driver contains a controller, a duty cycle generator with 4/8 Common signal pins and 19 Segment driver pins. Segment
1-19 and COM1-COM4 can also be used as I/O port, it is controlled by the P0SS, P1SS & P3SS register.
The 28 bytes display data RAM is addressed to 1E0H-1F2H, which could be used as data memory if needed. LCD COM1-8 can
also be used as LED.
The MCU consists normal display topologies with contrast adjustment which supports both 1/4duty-1/3bias and 1/8duty-1/4
bias driving mode, DISPEDL (DISPCON.7) must be cleared before LCD working.When ELCC in DISPCON is set, the LCD
supply power V LCD is selected by VOL[3:0]. When ELCC is cleared, VLCD equals to VDD.
When MCU enters the Power-Down mode, the LCD will be turned off. If 32.768kHz crystal/128kHz works in Power-down mode,
the LCD is still working.but the data of LCD RAM keeps the value.During the Power on Reset or Pin Reset or LVR Reset or
Watch-dog Reset, the LCD will be turned off, and Common and Segment will output low.
The features of the LCD Normal Display Mode include the following:
- LCD clock is decided by code option OP_OSC
- When OP_OSC[3:0] is 1010, 1101, LCD clock source is 32.768kHz, DISPCLK register is invalid, LCD frame is 64Hz.
- When OP_OSC[3:0] is 0011, 0110, LCD clock source is 128kHz, DISPCLK register is invalid, LCD frame is 64Hz.
- When OP_OSC[3:0] is 0000, LCD clock source is internal RC (12MHz), LCD clock = internal RC (12MHz)/DISPCLK, LCD
frame = LCD clock/512.
- When OP_OSC[3:0] is 1110, LCD clock source is crystal or ceramic, LCD clock = crystal or ceramic frenquncy/DISPCLK.
- 1/4duty -1/3 bias or 1/5 duty - 1/3 bias by configuring the DUTY bit in LCDCON register.
- LCD frame = LCD clock/512.
- 16 levels contrast adjustment by configuring the CONTR[2:0] bits in LCDCON1 register.
- LCD bias resistor (RLCD) can be selected as 20K/75K/300KО© in 1/3 bias mode, 15K/56K/225K in 1/4 bias mode
The relatively high current drain through the 20k resistor will get better LCD display effect, but it may not be suitable for some
low current consume application. Lowering this current is possible by configucring the OP_RLCD[2:0] for switching the RLCD
value to 75/300K.
Therefore, SH79F166A provides both the low power consumption and display effect of the display mode:fast charge mode.
Set MOD[1:0] = 10 to select this mode. When refresh the display data 20k bias resistors are selected to provide larger
current.When keep the display data 75/300K bias resistors are selected to save drive current. Charging time is selected as 1/8гЂЃ
1/16гЂЃ1/32 or 1/64 of LCD com period by FCCTL[1:0] in DISPCLK1 register.
60
166A
SH79F
SH79F166A
LCD Waveform (1/4duty, 1/3bias)
61
166A
SH79F
SH79F166A
COM8
VDD
V3
COM7
COM1 V2
COM6
V1
0
COM5
VDD
COM4
COM3
V3
COM2
COM2
COM1
V2
V1
0
V DD
V3
COM3
V2
V1
0
V DD
V3
COM4
V2
V1
SEGn
0
V DD
V3
SEGn
V2
V1
0
V DD
V3
V2
V1
COM1- SEGn 0
- V1
- V2
- V3
- V DD
8duty, 1/
4bias)
LCD waveform (1/
(1/8
1/4
62
166A
SH79F
SH79F166A
8.1.1 Registers
Table 8.1 LCD Control Register
ABH
ABH,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
DISPCON
DISPSEL
LCDON
ELCC
DUTY
VOL3
VOL2
VOL1
VOL0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7
DISPSEL
6
LCDON
5
ELCC
LCD contrast on/off control bit
0: disable contrast
1: enable contrast
4
DUTY
LCD duty selection bit
0: 1/4 duty, 1/3 bias
1: 1/8 duty, 1/4 bias
3-0
VOL[3
VOL[3:: 0]
Description
/LED control bit
LCD
LCD/LED
0: select LCD driver
1: select LED drive
LCD on/off control bit
0: Disable LCD driver
1: Enable LCD drive
LCD contrast control bits
0000: VLCD = 0.531 V DD
0001: VLCD = 0.563 V DD
0010: VLCD = 0.594 V DD
0011: VLCD = 0.625 V DD
0100: VLCD = 0.656 V DD
0101: VLCD = 0.688 V DD
0110: VLCD = 0.719 V DD
0111: VLCD =0.750 V DD
1000: VLCD = 0.781 V DD
1001: VLCD = 0.813 V DD
1010: VLCD = 0.844 V DD
1011: VLCD = 0.875 V DD
1100: VLCD = 0.906 V DD
1101: VLCD = 0.938 V DD
1111/1110: VLCD = 1.000 V DD
Note:
SH79F166A has LCD and LED driver, but can not work in the same time. When DISPSEL = 1, LCD is disable, DISPSEL = 0,
LED is disable.
63
166A
SH79F
SH79F166A
Table 8.2 LCD Control Register1
ADH
ADH,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
DISPCON1
-
-
-
RLCD
FCCTL1
FCCTL2
MOD1
MOD0
R /W
-
-
-
R/W
R/W
R/W
R/W
R/W
Reset Value
(POR/WDT/LVR/PIN)
-
-
-
0
0
0
0
0
Bit Number
1-0
Bit Mnemonic
MOD[1:0]
3-2
1:0]
FCCTL[
FCCTL[1:0]
4
RLCD
Description
LCD D rive mode control bit
00: traditional mode, bias resistor sum is 225K/900K
01: traditional mode, bias resistor sum is 60K
10: fast charge mode, bias resistor sum switch between 60K and 225K/900K
Fast charge time control bit
00: 1/8 LCD com period
01: 1/16 LCD com period
10: 1/32 LCD com period
11: 1/64 LCD com period
LCD bias resistor control bit
0: LCD bias resistor sum is 225K
1: LCD bias resistor sum is 900K
Table 8.3 LCD CONTRAST Register
ACH
ACH,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
DISPCLK0
DCK0.7
DCK0.6
DCK0.5
DCK0.4
DCK0.3
DCK0.2
DCK0.1
DCK0.0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
AA H , Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
1
DISPCLK
DISPCLK1
-
-
-
-
-
-
-
DCK1.0
R /W
-
-
-
-
-
-
-
R/W
Reset Value
/PIN)
(POR/WDT/LVR
POR/WDT/LVR/PIN)
-
-
-
-
-
-
-
0
Bit Number
Bit Mnemonic
0
7-0
DCK1.0
DCK0[7:0]
Description
LCD clock select
0x000: LCD clock = OSCCLK
Others: LCD clock/DISPCLK
Note:
Only when OP_OSC[2:0] is 0000, 1110, DISPCLK register is available.
When [DISPCLK 1, DISPCLK 0] = 0X000, LCD clock = OSCCLK
LCD frame = LCD clock/512.
For example:
When LCD is COM4, OP_OSC[3:0] = 1110, oscillator is 12MHz to get 64HZ LCD frame, DISPCLK = 12M/512/64 = 0x16E, LCD
frame = 12M/366/512 = 64.04Hz in fact.
64
166A
SH79F
SH79F166A
Table 8.4 P0 Mode Select Register
B6H
B6H,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
P0SS
-
-
-
-
-
P0S2
P0S1
P0S0
R /W
-
-
-
-
-
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
-
-
-
-
0
0
0
Bit Number
Bit Mnemonic
2-0
P0S[2
P0S[2:: 0]
Description
P0 mode select
0: P0.0-P0.2 is I/O
1: P0.0-P0.2 is Segment (Segment17-19)
Table 8.5 P1 Mode Select Register
9CH
9CH,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
P1SS
P1S7
P1S6
P1S5
P1S4
P1S3
P1S2
P1S1
P1S0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7-0
P1S[7
P1S[7:: 0]
Description
P1 mode select
0: P1.0-P1.7 is I/O
1: P1.0-P1.7 is Segment (Segment1-8)
Table 8.6 P2 Mode Select Register
9DH
9DH,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
P2SS
P2S7
P2S6
P2S5
P2S4
P2S3
P2S2
P2S1
P2S0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7-0
P2S[7
S[7:: 0]
Description
P2 mode select bit
0: P2.0-P2.7 is I/O
1: P2.0-P2.7 share as Segment (Segment9-16)
Table 8.7 P3 Mode Select Register
9EH
9EH,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
P3SS
P3S7
P3S6
P3S5
P3S4
P3S3
P3S2
P3S1
P3S0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7-0
P3S[7
S[7:: 0]
Description
P3 mode select bit
0: P3.0-P3.7 is I/O
1: P3.0-P3.7 share as Common (COM1-COM8)
65
166A
SH79F
SH79F166A
2 Configuration of LCD RAM
8.1.
8.1.2
LCD 1/4 duty, 1/3 bias (COM1 - 4, SEG1 - 19
19))
ess
Addr
Addre
1E0H
1E1H
1E2H
1E3H
1E4H
1E5H
1E6H
1E7H
1E8H
1E9H
1EAH
1EBH
1ECH
1EDH
1EEH
1EFH
1F0H
1F1H
1F2H
7
-
6
-
5
-
4
-
3
COM4
SEG1
SEG2
SEG3
SEG4
SEG5
SEG6
SEG7
SEG8
SEG9
SEG10
SEG11
SEG12
SEG13
SEG14
SEG15
SEG16
SEG17
SEG18
SEG19
2
COM3
SEG1
SEG2
SEG3
SEG4
SEG5
SEG6
SEG7
SEG8
SEG9
SEG10
SEG11
SEG12
SEG13
SEG14
SEG15
SEG16
SEG17
SEG18
SEG19
1
COM2
SEG1
SEG2
SEG3
SEG4
SEG5
SEG6
SEG7
SEG8
SEG9
SEG10
SEG11
SEG12
SEG13
SEG14
SEG15
SEG16
SEG17
SEG18
SEG19
0
COM1
SEG1
SEG2
SEG3
SEG4
SEG5
SEG6
SEG7
SEG8
SEG9
SEG10
SEG11
SEG12
SEG13
SEG14
SEG15
SEG16
SEG17
SEG18
SEG19
5
COM6
SEG1
SEG2
SEG3
SEG4
SEG5
SEG6
SEG7
SEG8
SEG9
SEG10
SEG11
SEG12
SEG13
SEG14
SEG15
SEG16
SEG17
SEG18
SEG19
4
COM5
SEG1
SEG2
SEG3
SEG4
SEG5
SEG6
SEG7
SEG8
SEG9
SEG10
SEG11
SEG12
SEG13
SEG14
SEG15
SEG16
SEG17
SEG18
SEG19
3
COM4
SEG1
SEG2
SEG3
SEG4
SEG5
SEG6
SEG7
SEG8
SEG9
SEG10
SEG11
SEG12
SEG13
SEG14
SEG15
SEG16
SEG17
SEG18
SEG19
2
COM3
SEG1
SEG2
SEG3
SEG4
SEG5
SEG6
SEG7
SEG8
SEG9
SEG10
SEG11
SEG12
SEG13
SEG14
SEG15
SEG16
SEG17
SEG18
SEG19
1
COM2
SEG1
SEG2
SEG3
SEG4
SEG5
SEG6
SEG7
SEG8
SEG9
SEG10
SEG11
SEG12
SEG13
SEG14
SEG15
SEG16
SEG17
SEG18
SEG19
0
COM1
SEG1
SEG2
SEG3
SEG4
SEG5
SEG6
SEG7
SEG8
SEG9
SEG10
SEG11
SEG12
SEG13
SEG14
SEG15
SEG16
SEG17
SEG18
SEG19
8 duty , 1/
4 bias (COM1 - 8, SEG
1 - 19
LCD 1/
1/8
1/4
SEG1
19))
ess
Addr
Addre
1E0H
1E1H
1E2H
1E3H
1E4H
1E5H
1E6H
1E7H
1E8H
1E9H
1EAH
1EBH
1ECH
1EDH
1EEH
1EFH
1F0H
1F1H
1F2H
7
COM8
SEG1
SEG2
SEG3
SEG4
SEG5
SEG6
SEG7
SEG8
SEG9
SEG10
SEG11
SEG12
SEG13
SEG14
SEG15
SEG16
SEG17
SEG18
SEG19
6
COM7
SEG1
SEG2
SEG3
SEG4
SEG5
SEG6
SEG7
SEG8
SEG9
SEG10
SEG11
SEG12
SEG13
SEG14
SEG15
SEG16
SEG17
SEG18
SEG19
66
166A
SH79F
SH79F166A
2 LED D river
8.
8.2
The LED driver contains a controller, a duty cycle generator with 4/8 Common signal pins and 8 Segment driver pins. Segment
1-8 can also be used as I/O port,When DISPSEL bit is set, LED function is enable,and LCD is disable. It is controlled by the
P0SS, P1SS register.
When MCU enters the Power-Down mode, the LED will be turned off, If 32.768kHz crystal or 128k internal RC works in
Power-down mode,the LED is still working. When OP_LEDCOM = 0 Common and Segment will output low. When
OP_LEDCOM = 1 Common and Segment will output high.
2.1 Register
8.
8.2
Table 8.8 LED Control Register
ABH
ABH,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
DISPCON
DISPSEL
LEDON
-
DUTY
-
-
-
-
R /W
R/W
R/W
-
R/W
-
-
-
-
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
-
0
-
-
-
-
Bit Number
Bit Mnemonic
Description
7
DISPSEL
6
L E DON
LED on/off control bit
0: Disable LED driver
1: Enable LED drive
4
DUTY
LED duty selection bit
0: 1/4 duty
1: 1/8 duty
/LED control bit
LCD
LCD/LED
0: select LCD driver
1: select LCD drive
Note:
SH79F166A has LCD and LED driver,but can not work in the same time.When DISPSEL = 1, LCD is disable, DISPSEL = 0,
LED is disable.
Table 8.9 LED Clock Control Register
ACH
ACH,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
DISPCLK0
DCK0.7
DCK0.6
DCK0.5
DCK0.4
DCK0.3
DCK0.2
DCK0.1
DCK0.0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
AA H , Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
1
DISPCLK
DISPCLK1
-
-
-
-
-
-
-
DCK1.0
R /W
-
-
-
-
-
-
-
R/W
Reset Value
/PIN)
(POR/WDT/LVR
POR/WDT/LVR/PIN)
-
-
-
-
-
-
-
0
Bit Number
Bit Mnemonic
0
7-0
DCK1.0
DCK0[7:0]
Description
LED clock select
0x000: LED clock = OSCCLK
Others: LED clock/DISPCLK
Note:
Only when OP_OSC[2:0] is 000, 101 and 110, DISPCLK register is available.
67
166A
SH79F
SH79F166A
Table 8.10 P1 Mode Select Register
9CH
9CH,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
P1SS
P1S7
P1S6
P1S5
P1S4
P1S3
P1S2
P1S1
P1S0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7-0
P1S[7
P1S[7:: 0]
Description
P1 mode select (x = 0-7
0-7))
0: P1.0-P1.7 are I/O
1: P1.0-P1.7 are Segment (LED_S1-LED_S8)
Table 8.11 P3 Mode Select Register
9EH
9EH,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
P3SS
P3S7
P3S6
P3S5
P3S4
P3S3
P3S2
P3S1
P3S0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7-0
P3S[7
P3S[7:: 0]
Description
P3 mode select (x = 0-7
0-7))
0: P3.0-P3.7 are I/O
1: P3.0-P3.7 are COM (LED_C1-LED_C8)
8.
2. 2 Configuration of L E D RAM
8.2
LE D 1/4 duty (LED_C1 - 4, LED_S1 - 8)
Addr
ess
Addre
7
6
5
4
3
2
1
0
1E0H
COM1
SEG8
SEG7
SEG6
SEG5
SEG4
SEG3
SEG2
SEG1
1E1H
COM2
SEG8
SEG7
SEG6
SEG5
SEG4
SEG3
SEG2
SEG1
1E2H
1E3H
COM3
COM4
SEG8
SEG8
SEG7
SEG7
SEG6
SEG6
SEG5
SEG5
SEG4
SEG4
SEG3
SEG3
SEG2
SEG2
SEG1
SEG1
LE D 1/8 duty (LED_C1 - 8, LED_S1 - 8)
7
6
5
4
3
2
1
0
1E0H
1E1H
ess
Addr
Addre
COM1
COM2
SEG8
SEG8
SEG7
SEG7
SEG6
SEG6
SEG5
SEG5
SEG4
SEG4
SEG3
SEG3
SEG2
SEG2
SEG1
SEG1
1E2H
COM3
SEG8
SEG7
SEG6
SEG5
SEG4
SEG3
SEG2
SEG1
1E3H
COM4
SEG8
SEG7
SEG6
SEG5
SEG4
SEG3
SEG2
SEG1
1E4H
COM5
SEG8
SEG7
SEG6
SEG5
SEG4
SEG3
SEG2
SEG1
1E5H
COM6
SEG8
SEG7
SEG6
SEG5
SEG4
SEG3
SEG2
SEG1
1E6H
COM7
SEG8
SEG7
SEG6
SEG5
SEG4
SEG3
SEG2
SEG1
1E7H
COM8
SEG8
SEG7
SEG6
SEG5
SEG4
SEG3
SEG2
SEG1
68
166A
SH79F
SH79F166A
LED Waveform
(1) OP_LEDCOM = 0
1/8 DUTY
1/4 DUTY
V DD
t ol
COM1
V DD
tol
COM1
GND
GND
V DD
COM2
V DD
COM2
GND
GND
V DD
V DD
SEG1
SEG1
GND
GND
V DD
V DD
SEG2
SEG2
GND
V DD
SEG1&
COM1
GND
SELECT
GND
V DD
SEG1&
COM1
SELECT
UNSELECT
UNSELECT
GND
(2) OP_LEDCOM [1] = 1
1/8 DUTY
1/4 DUTY
V DD
t ol
COM1
VDD
tol
COM1
GND
GND
V DD
COM2
V DD
COM2
GND
GND
VDD
V DD
SEG1
SEG1
GND
GND
VDD
V DD
SEG2
GND
V DD
SEG1&
COM1
SELECT
GND
UNSELECT
SEG2
GND
V DD
SEG1&
COM1
SELECT
Note
Noteпјљt OL is overlap time of LED Common , tOL =20Вµs-40Вµs.
69
UNSELECT
GND
166A
SH79F
SH79F166A
3 PWM (Pulse Width Modulation
8.
8.3
Modulation))
3.1 F eature
8.
8.3
пїЅ Complementary output with dead time control
пїЅ Provided interrupt function on period
пїЅ Selectable output polarity
пїЅ Fault Detect function provided to disable PWM output immediately
пїЅ Lock register provided to avoid PWM control register to be unexpected change
The SH79F166A has one 12-bit PWM module. Which can provide the pulse width modulation waveform with the period and the
duty being controlled individually by corresponding register.
PWM timer can be turned to inactive state by the input of FLT pin automatically if EFLT is set.
PWM timer also provides 1 interrupts for PWM0. This makes it possible to change period or duty in every PWM period.
3.2 PWM Module Enable
8.
8.3
Table 8.12 PWM Module Enable Register
CFH
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
PWMEN
-
EFLT
-
-
EPWM01
-
-
EPWM0
R /W
-
R/W
-
-
R/W
-
-
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
0
-
-
0
-
-
0
Bit Number
Bit Mnemonic
Description
6
EFLT
3
EPWM01
PWM01 output enable
0: I/O port
1: PWM output
0
EPWM0
Enable 12-bit PWM0
0: I/O port
1: PWM output
FLT pin configuration:
———
0: general purpose I/O or SS pin (default)
1: PWM Fault Detect input pin
PWM output will be disable at the same time when the PWM Enable register is clear to 0.
The main purpose of the FLT pin is to inactivate the PWM output signals and drive them into an inactive state. The action of the
FLT is performed directly in hardware so that when a fault occurs, it can be managed quickly and the PWMs outputs are put into
an inactive state to save the power devices connected to the PWMs. The FLT pin has no internal pull-high resistor.
If EFLT is set to 0, it means the level on FLT pin has no effect on PWM timers.
Table 8.13 PWM Module Enable Register
B7H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
1
PWMEN
PWMEN1
-
-
-
-
-
-
-
PWM0
R /W
-
-
-
-
-
-
-
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
-
-
-
-
-
-
0
Bit Number
0
Bit Mnemonic
PWM0
Description
Enable 12-bit PWM0
0: PWM output enable
1: PWM output disable, PWM0. PWM01 as I/O , but PWM timer can work normally,
Trigger interrupt
70
166A
SH79F
SH79F166A
3.3 PWM Timer Lock Register
8.
8.3
This register is used to control the change of PWM timer enable register, PWM control register, PWM period register, PWM duty
register and PWM dead time control register. Only when the data in this register is #55h, it is possible to change these register.
Otherwise they cannot be changed.
This register is to enhance the anti-noise ability of SH79F166A.
Table 8.14 PWM Timer Lock Register
E7H
Bit7
PWMLO
PWMLO.7
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7-0
PWMLO[7:0]
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
PWMLO.6 PWMLO.5 PWMLO.4 PWMLO.3 PWMLO.2 PWMLO.1 PWMLO.0
Description
PWM lock register
55h: enable to change PWM related registers
else: disable to change PWM related registers
71
166A
SH79F
SH79F166A
3.4 12-bit PWM Timer
8.
8.3
The SH79F166A has one 12-bit PWM module. The PWM module can provide the pulse width modulation waveform with the
period and the duty being controlled, individually. The PWMC is used to control the PWM module operation with proper clocks.
The PWMP is used to control the period cycle of the PWM module output. PWMD is used to control the duty in the waveform of
the PWM module output.
It is acceptable to change these 3 registers during PWM output Enable. All the change will take affect at the next PWM period.
Table 8.15 12-bit PWM Control Register
D2H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
PWM0C
PWM0IE
PWM0IF
-
FLTS
FLTC
PWM0S
TnCK01
TnCK00
R /W
R/W
R/W
-
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
-
0
0
0
0
0
Bit Number
Bit Mnemonic
7
PWM0IE
PWM0 interrupt enable bit (When EPWM bit in IEN1 is set)
0: Disable PWM0 interrupt
1: Enable PWM0 interrupt
6
PWM0IF
PWM0 interrupt flag
0: Clear by software
1: Set by hardware to indicate that the PWM0 period counter overflow
4
FLTS
FLT status bit
0: PWM is in normal status, cleared by software
1: PWM is in inactive status, set automatically by hardware
3
FLTC
FLT pin configuration
0: Inactivate the PWM output when FLT is low level
1: Inactivate the PWM output when FLT is high level
2
1-0
Description
PWM0S
0 output normal mode of duty cycle
PWM
PWM0
0: high active , PWM0 output high during duty time, output low during remain period
time
1: low active , PWM0 output low during duty time, output high during remain period
time
TnCK0[1
TnCK0[1:: 0]
12-bit PWM clock selector:
00: Oscillator clock/2
01: Oscillator/4
10: Oscillator/8
11: Oscillator/16
Note: When OP_OSC is 0000, 0011 or 1010,PWM clock source is internal RC,
When OP_OSC is 1110, PWM clock source is crystal or ceramic, When OP_OSC
is 0110 or 1101, PWM clock source is crystal or ceramic in XTALX pins.
Note:
(1)Inactivate PWM here means PWM0 and PWM01 outputs keep Low (if PWM0S = 0) or High (if PWM0S = 1).
(2) The PWM outputs will remain in the inactive states as soon as the high/low level of FLT pin is detected.
(3)Clearing FLTS bit when a FAULT input is coming will not success.
72
166A
SH79F
SH79F166A
Table 8.16 PWM Period Control Register (PWM0PL)
D3H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
PWM0PL
PP0.7
PP0.6
PP0.5
PP0.4
PP0.3
PP0.2
PP0.1
PP0.0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7-0
PP0[7
PP0[7:: 0]
Description
12-bit PWM period low 8 nibble registers
Table 8.17 PWM Period Control Register (PWM0PH)
D 4H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
H
PWM0P
PWM0PH
-
-
-
-
PP0.11
PP0.10
PP0.9
PP0.8
R /W
-
-
-
-
R/W
R/W
R/W
R/W
Reset Value
(POR/WDT/LVR
/PIN
POR/WDT/LVR/PIN
/PIN))
-
-
-
-
0
0
0
0
Bit Number
Bit Mnemonic
3-0
PP0[
11
PP0[11
11:: 8]
Description
12-bit PWM period high 4 nibble registers
PWM output period cycle = [PP0.11, PP0.0] X PWM clock.
When [PP0.11, PP0.0] = 000H, PWM0 outputs GND if the PWM0S bit is set to “0” regardless of PWM duty cycle.
When [PP0.11, PP0.0] = 000H, PWM0 outputs high level if the PWM0S bit is set to “1” regardless of PWM duty cycle.
Table 8.18 PWM Duty Control Register (PWM0DL)
D5H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
PWM0DL
PD0.7
PD0.6
PD0.5
PD0.4
PD0.3
PD0.2
PD0.1
PD0.0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7-0
PD0[7
PD0[7:: 0]
Description
12-bit PWM duty low 8 nibble registers
Table 8.19 PWM Duty Control Register (PWM0DH)
D 6H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
PWM0DH
-
-
-
-
PD0.11
PD0.10
PD0.9
PD0.8
R /W
-
-
-
-
R/W
R/W
R/W
R/W
Reset Value
(POR/WDT/LVR
/PIN
POR/WDT/LVR/PIN
/PIN))
-
-
-
-
0
0
0
0
Bit Number
Bit Mnemonic
3-0
PD0[11
PD0[11:: 8]
Description
12-bit PWM duty high 4 nibble registers
PWM output duty cycle = [PD0.11, PD0.0] X PWM clock.
If [PP0.11, PP0.0] ≤ [PD0.11, PD0.0], PWM0 outputs high level when the PWM0S bit is set to “0”.
If [PP0.11, PP0.0] ≤ [PD0.11, PD0.0], PWM0 outputs GND level when the PWM0S bit is set to “1”.
73
166A
SH79F
SH79F166A
te
Programming No
Note
te::
(1) Set PWMLO register to 55H and select the PWM module system clock.
(2) Set the PWM period/duty cycle by writing proper value to the PWM period control register (PWMP) or PWM duty control
register (PWMD). First set the low Byte, then the high Byte.
(3) Select the PWM output mode of the duty cycle by writing the PWM0S bit in the PWM control register (PWMC).
(4) In order to output the desired PWM waveform, enable the PWM module by writing “1” to the EPWM bit in the PWM control
register (PWMC).
(5) If the PWM period cycle or duty cycle is to be changed, the writing flow should be followed as described in step b or step c.
Then the revised data are loaded into the re-load counter and the PWM module starts counting at next period.
(6) Change the data in PWMLO register not equal to 55h in order to enhance the anti-noise ability.
01 02 03 04 05 06 07 08 09 0A 0B0C 0D 0E 0F 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 01 02 03 04 05 06 07 08
PWMn clock tPWM
Write [PPn.11, PPn.0] = 0DH
Write [PDn.11, PDn.0] = 07H
PWMn output
(PWMnS = 0)
n = 0 or 1
Duty cycle
= 06H x tPWM
Duty cycle
= 06H x tPWM
Period cycle = 0FH x tPWM
Duty cycle
= 07H x tPWM
Period cycle = 0DH x tPWM
PWM output Period or Duty cycle changing example
8.
3. 5 PWM01
8.3
Generally, PWM01 have a 180 � phase delay with PWM0 as shown below when there is no dead time inserted. It is
automatically generated by hardware when EPWM01 in PWM timer enable register is set.
PW M0 output
(PWM0S = 0)
PW M01 output
(PWM0S = 0)
Note:
(1) That even if PWM0 are not enabled, PWM01 can also work if enabled.
(2) If EFLT is set, When a valid event occurs on FLT pin, PWM01 and PWM0 are both LOW (PWMS = 0)or both HIGH (PWMS
= 1).
74
166A
SH79F
SH79F166A
3. 6 Dead T ime
8.
8.3
The SH79F166 provides dead time control function on-chip.
When PWM0S = 0, the dead time is generated as below.
P W M int
P W M int
per iod
P W M 0 S =0
d u ty c y c l e
PW M0
P W M 01
d e a d ti m e
d e a d ti m e
d e a d ti m e
Reload
P W M E nable
Reload
When PWM0S = 1, the dead time is generated as below.
p e rio d
P W M in t
P W M in t
P W M0S =1
d u t y cycle
PW M0
PW M01
d e a d t im e
d e a d t im e
P W M E n a b le
d e a d t im e
R e lo a d
R e lo a d
By writing PWM01 dead time control registers, a dead time can be generated between PWM0 and PWM01.
PWM01 have the same period as PWM0.
Note:
(1) Dead time0 must be set before PWM outputs enabled. Otherwise, dead time will not change. So in order to change dead
time, please disable PWM outputs first (while PWMLO is #55h), then change the dead time, enable PWM. Finally, change
the data in PWMLO not equal to #55h in order to make sure the PWM registers would not be changed by noise.
(2) In order to generate dead time, please make sure that (PWM0 Period - PWM0 Duty) > 2* PWM01 dead time control.
Otherwise the output of PWM01 is high level when PWMS = 1 or GND when PWMS = 0.
(3) PWMDT is to used to control Dead Time, the step value is fixed oscillator clock time, but period and duty step value is refer
to TnCK0[1:0]. 2 oscillator clocks at least.
(4) If dead time is needed, any time when PWM is disabled, before enable PWM again, dead time register must be clear to 0 at
first, and then set to proper value.
Table 8.20 PWM0 Dead Time Control Register
D1H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
PWM0DT
DT0.7
DT0.6
DT0.5
DT0.4
DT0.3
DT0.2
DT0.1
DT0.0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7-0
DT0[7
DT0[7:: 0]
Description
12-bit PWM0 dead time control
the dead time period = (DT0.7-DT0.0) X tOSC
75
166A
SH79F
SH79F166A
4 EUART
8.
8.4
4.1 F eature
8.
8.4
пїЅ The SH79F166A has one enhanced EUART which are compatible with the conventional 8051
пїЅ The baud rate can be selected from the divided clock of the system clock, or Timer4/2 overflow rate
пїЅ Enhancements over the standard 8051 the EUART include Framing Error detection and automatic address recognition
пїЅ The EUART can be operated in four modes
4.2 EUART Mode Description
8.
8.4
The EUART can be operated in 4 modes. Users must initialize the SCON before a ny communication can take place. This
involves selection of the Mode and the baud rate. The Timer4/2 should also be initialized if the mode 1 or the mode 3 is used.
In all of the 4 modes, transmission is initiated by any instruction that uses SBUF as a destination register. Reception is initiated
in Mode 0 by the condition RI = 0 and REN = 1. This will generate a clock on the TxD pin and shift in 8 bits on the RxD pin.
Reception is initiated in the other modes by the incoming start bit if RI = 0 and REN = 1. The external transmitter will start the
communication by transmitting the start bit.
EUART Mode Summary
Frame Size Start Bit Stop Bit
9th bit
0
SM
SM0
1
SM
SM1
Mode
Type
Baud Clock
0
0
0
Sych
fSYS /(4 or 12)
8 bits
NO
NO
None
0
1
1
Ansych
Timer 4 or 2 overflow rate/(16 or 32)
10 bits
1
1
None
1
0
2
Ansych
fSYS /(32 or 64)
11 bits
1
1
0, 1
1
1
3
Ansych
Timer 4 or 2 overflow rate/(16 or 32)
11 bits
1
1
0, 1
plex
Mode0
Mode0:: Synchronous Mode
Mode,, Half du
duplex
This mode provides synchronous communication with external devices. In this mode serial data is transmitted and received on
the RxD line. TxD is used to output the shift clock. The TxD clock is provided by the SH79F166A whether the device is
transmitting or receiving. This mode is therefore a half duplex mode of serial communication. In this mode, 8 bits are transmitted
or received per frame. The LSB is transmitted/received first.
The baud rate is programmable to either 1/12 or 1/4 of the system clock. This baud rate is determined in the SM2 bit (SCON.5).
When this bit is set to 0, the serial port runs at 1/12 of the system clock. When set to 1, the serial port runs at 1/4 of the system
clock.
The functional block diagram is shown below. Data enters and exits the serial port on the RxD line. The TxD line is used to
output the SHIFT CLOCK. The SHIFT CLOCK is used to shift data into and out of the SH79F166A.
Transmit Shift Register
Internal
Data Bus
System Clock
PARIN
Write to
SBUF
SOUT
RXD
LOAD
CLOCK
Г· 12
Г·4
T X ST ART
T X SHIF T
T X CLOCK
SM2
0
TI
SERIAL
CONTROLLER
1
Serial Port Interrupt
RI
RX CLOCK
SHIF T
CLOCK
TXD
LOAD SBUF
RI
RX ST ART
REN
RX SHIF T
Read SBUF
CLOCK
PAROUT
SIN
RXD
Receive Shift Register
76
SBUF
SBUF
166A
SH79F
SH79F166A
Any instruction that uses SBUF as a destination register (“write to SBUF” signal) will start the transmission. The next system
clock tells the Tx control block to commence a transmission. The data shift occurs at the falling edge of the SHIFT CLOCK, and
the contents of the transmit shift register is shifted one position to the right. As data bits shift to the right, zeros come in from the
left. After transmission of all 8 bits in the transmit shift register, the Tx control block will deactivates SEND and sets TI (SCON.1)
at the rising edge of the next system clock.
Write to SBUF
RxD
D0
D1
D3
D2
D4
D5
D6
D7
TxD
TI
Send Timing of Mode 0
Reception is initiated by the condition REN (SCON.4) = 1 and RI (SCON.0) = 0. The next system clock activates RECEIVE. The
data latch occurs at the rising edge of the SHIFT CLOCK, and the contents of the receive shift register are shifted one position
to the left. After the receiving of all 8 bits into the receive shift register, the RX control block will deactivates RECEIVE and sets
RI at the rising edge of the next system clock, and the reception will not be enabled till the RI is cleared by software.
RxD
D0
D1
D2
D3
D4
D5
D6
D7
TxD
RI
Receive Timing of Mode 0
Mode1
Mode1:: 8-Bit EUART, Variable Baud Rate
Rate,, Asynchronous Full-Duplex
This mode provides the 10 bits full duplex asynchronous communication. The 10 bits consist of a start bit (logical 0), 8 data bits
(LSB first), and a stop bit (logical 1). When receiving, the eight data bits are stored in SBUF and the stop bit goes into RB8
(SCON.2). The serial receive and transmit baud rate is 1/16 of the Timer4/2 overflow (Refer to Baud Rate Section for details).
The functional block diagram is shown below.
Timer 2
Overflow
Timer 4
Overflow
Transmit Shift Register
STOP
Internal
Data Bus
PARIN
START
Write to SBUF
SOUT
TXD
LOAD
CLOCK
TCLK
0
TX START
1
Г· 16
TX SHIFT
TX CLOCK
TI
RCLK
0
SERIAL
CONTROLLER
1
Г· 16
Serial Port Interrupt
RI
RX CLOCK
LOAD SBUF
SAM PLE
1-TO-0
DETECTOR
RX START
Read SBUF
RX SHIFT
CLOCK
PAROUT
RXD
BIT
DETECTOR
SIN
D8
Receive Shift Register
77
SBUF
RB8
Internal
Data Bus
166A
SH79F
SH79F166A
Transmission begins with a “write to SBUF” signal, and it actually commences at the next system clock following the next
rollover in the divide-by-16 counter (divide baud-rate by 16), thus, the bit times are synchronized to the divide-by-16 counter,
not to the “write to SUBF” signal. The start bit is firstly put out on TxD pin, then are the 8 bits of data. After all 8 bits of data in the
transmit shift register are transmitted, the stop bit is put out on the TxD pin, and the TI flag is set at the same time that the stop
is send.
Write to SBUF
TxD
Start
D0
D1
D2
D3
D4
D5
D6
D7
Stop
Shift CLK
TI
Send Timing of Mode 1
Reception is enabled only if REN is high. The serial port actually starts the receiving of serial data with the detection of a falling
edge on the RxD pin. For this purpose RxD is sampled at the rate of 16 times baud rate. When a falling edge is detected, the
divide-by-16 counter is immediately reset. This helps to align the bit boundaries with the rollovers of the divide-by-16
counter.The 16 states of the counter divide each bit time into 16ths. The bit detector samples the value of RxD at the 7th, 8th and
9th counter states of each bit time. The value accepted is the value that was seen in at least 2 of the 3 samples. This is done for
noise rejection. If the first bit after the falling edge of RxD pin is not 0, which indicates an invalid start bit, and the reception is
immediately aborted. The receive circuits are reset and again waiting for a falling edge in the RxD line. If a valid start bit is
detected, then the rest of the bits are also detected and shifted into the shift register. After shifting in 8 data bits and the stop bit,
the SBUF and RB8 are loaded and RI are set if the following conditions are met:
1. RI must be 0
2. Either SM2 = 0, or the received stop bit = 1
If these conditions are met, then the stop bit goes to RB8, the 8 data bits go into SBUF and RI is set. Otherwise the received
frame may be lost.
At the time, the receiver goes back to looking for another falling edge on the RxD pin. And the user should clear RI by software
for further reception.
RxD
Start
D0
D1
D2
D3
D4
D5
Bit Sample
Shift CLK
RI
Receive Timing of Mode 1
78
D6
D7
Stop
166A
SH79F
SH79F166A
Mode2
Mode2:: 9-Bit EUART, Fixed Baud Rate
Rate,, Asynchronous Full-Duplex
This mode provides the 11 bits full duplex asynchronous communication. The 11 bit consists of one start bit (logical 0), 8 data
bits (LSB first), a programmable 9th data bit, and a stop bit (logical 1). Mode 2 supports multiprocessor communications and
hardware address recognition (Refer to Multiprocessor Communication Section for details). When data is transmitted, the 9th
data bit (TB8 in SCON) can be assigned the value of 0 or 1, for example, the parity bit P in the PSW or used as data/address
flag in multiprocessor communications. When data is received, the 9th data bit goes into RB8 and the stop bit is not saved. The
baud rate is programmable to either 1/32 or 1/64 of the system working frequency, as determined by the SMOD bit in PCON.
The functional block diagram is shown below:
Transmit Shift Register
System Clock
TB8
D8
STOP
Г·
Internal
Data Bus
PARIN
2
SOUT
START
Write to SBUF
TXD
LOAD
CLOCK
SMOD
0
1
TX START
Г· 32
TX SHIFT
TX CLOCK
TI
SERIAL
CONTROLLER
Serial Port Interrupt
RI
Г· 32
RX CLOCK
LOAD SBUF
SAMPLE
1-TO-0
DETECTOR
Read SBUF
RX SHIFT
RX START
CLOCK
PAROUT
BIT
DETECTOR
RXD
SIN
D8
Internal
Data Bus
SBUF
RB8
Receive Shift Register
Transmission begins with a “write to SBUF” signal, the “write to SBUF” signal also loads TB8 into the 9th bit position of the
transmit shift register. Transmission actually commences at the next system clock following the next rollover in the divide-by-16
counter (thus, the bit times are synchronized to the divide-by-16 counter, not to the “write to SUBF” signal). The start bit is firstly
put out on TxD pin, then are the 9 bits of data. After all 9 bits of data in the transmit shift register are transmitted, the stop bit is
put out on the TxD pin, and the TI flag is set at the same time, this will be at the 11th rollover of the divide-by-16 counter after a
write to SBUF.
Write to SBUF
TxD
Start
D0
D1
D2
D3
D4
D5
Shift CLK
TI
Send Timing of Mode 2
79
D6
D7
D8
Stop
166A
SH79F
SH79F166A
Reception is enabled only if REN is high. The serial port actually starts the receiving of serial data, with the detection of a falling
edge on the RxD pin. For this purpose RxD is sampled at the rate of 16 times baud rate. When a falling edge is detected, the
divide-by-16 counter is immediately reset. This helps to align the bit boundaries with the rollovers of the divide-by-16 counter.
The 16 states of the counter divide each bit time into 16ths. The bit detector samples the value of RxD at the 7th , 8th and 9th
counter state of each bit time. The value accepted is the value that was seen in at least 2 of the 3 samples. This is done for
noise rejection. If the first bit detected after the falling edge of RxD pin is not 0, which indicates an invalid start bit, and the
reception is immediately aborted. The receive circuits are reset and again looks for a falling edge in the RxD line. If a valid start
bit is detected, then the rest of the bits are also detected and shifted into the shift register. After shifting in 9 data bits and the
stop b it, the SBUF and RB8 are loaded and RI is set if the following conditions are met:
1. RI must be 0
2. Either SM2 = 0, or the received 9th bit = 1 and the received byte accords with Given Address
If these conditions are met, then the 9th bit goes to RB8, the 8 data bits go into SBUF and RI is set. Otherwise the received
frame may be lost.
At the time, the receiver goes back to looking for another falling edge on the RxD pin. And the user should clear RI by software
for further reception.
RxD
Start
D0
D1
D2
D3
D4
D5
D6
D7
D8
Stop
Bit Sample
Shift CLK
RI
Receive Timing of Mode 2
Mode3
Mode3:: 9-Bit EUART, Variable Baud Rate
Rate,, Asynchronous Full-Duplex
Mode3 uses transmission protocol of the Mode2 and baud rate generation of the Mode1.
Timer 4 Overflow
Transmit Shift Register
Timer 2 Overflow
STOP
TB8
D8
Internal
Data Bus
PARIN
SOUT
TXD
START
Write to SBUF
LOAD
CLOCK
TCLK
0
TX START
1
Г· 16
TX SHIFT
TX CLOCK
TI
RCLK
0
SERIAL
CONTROLLER
1
Serial Port Interrupt
RI
Г·16
RX CLOCK
LOAD SBUF
SAMPLE
1-TO-0
DETECTOR
RX START
Read SBUF
RX SHIFT
CLOCK
PAROUT
RXD
BIT
DETECTOR
SIN
D8
Receive Shift Register
80
SBUF
RB8
Internal
Data Bus
166A
SH79F
SH79F166A
4.3 Baud R ate Generate
8.
8.4
In Mode0, the baud rate is programmable to either 1/12 o r 1/4 of the system frequency. This baud rate is determined by SM2 b it.
When set to 0, the serial port runs at 1/12 of the system clock. When set to 1, the serial port runs at 1/4 of the system clock.
In Mode1 & Mode3, the baud rate can be selected from Timer4/2 overflow rate.
The Mode1 & 3 baud rate equations are shown below, where [RCAP2H, RCAP2L] is the 16-bit reload register for Timer2, [TH4,
TL4] is the 16-bit reload register for Timer4.
BaudRate =
1
fT 2
, Baud Rate using Timer2, the clock source of Timer2 is system clock.
Г—
2 Г— 16 65536 в€’ [RCAP 2 H, RCAP 2 L]
1
fT2
, Baud Rate using Timer2, the clock source of Timer2 is input clock of T2 pin.
Г—
16 65536 в€’ [RCAP 2 H, RCAP 2 L]
1
f /PRESCALER
BaudRate =
Г— T4
пјЊ, Baud Rate using Timer4, the clock source of Timer4 is system clock.
2 Г— 16 65536 в€’ [TH4, TL 4]
1
f /PRESCALER пјЊBaud Rate using Timer4, the clock source of Timer4 is input clock of T4 pin.
BaudRate = Г— T 4
16 65536 в€’ [TH4,TL4]
BaudRate =
In Mode2, the baud rate is programmable to either 1/32 or 1/64 of the system clock. This baud rate is determined by the SMOD bit
(PCON.7). When this bit is set to 0, the serial port runs at 1/64 of the clock. When set to 1, the serial port runs at 1/32 of the clock.
f
BaudRate = 2SMOD Г— ( SYS )
64
4.4 Multi -Processor Communication
8.
8.4
Software Address Recognition
Modes 2 and 3 of the EUART have a special provision for multi-processor communication. In these modes, 9 data bits are
received. The 9th bit goes into RB8. Then a stop bit follows. The EUART can be programmed such that when the stop bit is
received, the EUART interrupt will be activated (i.e. the request flag RI is set) only if RB8 = 1. This feature is enabled by setting
the bit SM2 in SCON.
A way to use this feature in multiprocessor communications is as follows. lf the master processor wants to transmit a block of
data to one of the several slaves, it first sends out an address byte which identifies the target slave. An address byte differs from
a data byte in that the 9th bit is 1 in an address byte and 0 in a data byte.
With SM2 = 1, no other slave will be interrupted by a data byte. An address byte, however, will interrupt all slaves, so that each
slave can examine the received byte and see if it is being addressed. The addressed slave will clear its SM2 bit and prepare to
receive the data bytes that will be coming. After having received a complete message, the slave sets SM2 again. The slaves
that were not addressed leave their SM2 set and go on with their business, ignoring the incoming data bytes.
Note: In Mode0, SM2 is used to select baud rate doubling. In Mode1, SM2 can be used to check the validity of the stop bit. If
SM2 = 1 in Mode1, the receive interrupt will not be activated unless a valid stop bit is received.
Automatic (Hardware) Address R ecognition
In Mode2 & 3, setting the SM2 bit will configure EUART act as following: when a stop bit is received, EUART will generate an
interrupt only if the 9th bit that goes into RB8 is logic 1 (address byte) and the received data byte matches the EUART slave
address. Following the received address interrupt, the slave should clear its SM2 bit to enable interrupts on the reception of the
following data byte(s).
The 9-bit mode requires that the 9th information bit is a 1 to indicate that the received information is an address and not data.
When the master processor wants to transmit a block of data to one of the slaves, it first sends out the address of the targeted
slave (or slaves). All the slave processors should have their SM2 bit set high when waiting for an address byte, which ensures
that they will be interrupted only by the reception of an address byte. The Automatic address recognition feature further ensures
that only the addressed slave will be interrupted. The address comparison is done by hardware not software.
After being interrupted, the addressed slave clears the SM2 bit to receive data bytes. The un-addressed slaves will be
unaffected, as they will be still waiting for their address. Once the entire message is received, the addressed slave should set its
SM2 bit to ignore all transmissions until it receives the next address byte.
The Automatic Address Recognition feature allows a master to selectively communicate with one or more slaves by invoking
the Given Address. All of the slaves may be contacted by using the Broadcast address. Two special Function Registers are
used to define the slave’s address, SADDR, and the address mask, SADEN. The slave address is an 8-bit value specified in the
SADDR register. The SADEN register is actually a mask for the byte value in SADDR. If a bit position in SADEN is 0, then the
corresponding bit position in SADDR is don’t care. Only those bit positions in SADDR whose corresponding bits in SADEN are
1 are used to obtain the Given Address. This gives the user flexibility to address multiple slaves without changing the slave
address in SADDR. Use of the Given Address allows multiple slaves to be recognized while excluding others.
81
166A
SH79F
SH79F166A
Slave 1
Slave 2
SADDR
10100100
10100111
SADEN (0 mask)
11111010
11111001
Given Address
10100x0x
10100xx1
Broadcast Address (OR)
1111111x
11111111
The Given address for slave 1 and 2 differ in the LSB. For slave 1, it is a don’t care, while for slave 2 it is 1. Thus to communicate
only with slave 1, the master must send an address with LSB = 0 (10100000). Similarly the bit 1 is 0 for slave 1 and don’t care
for slave 2. Hence to communicate only with slave 2 the master has to transmit an address with bit 1 = 1 (1010 0011). If the
master wishes to communicate with both slaves simultaneously, then the address must have bit 0 = 1 and bit 1 = 0. The bit 2
position is don’t care for both the slaves. This allows two different addresses to select both slaves (1010 0001 and 1010 0101).
The master can communicate with all the slaves simultaneously with the Broadcast Address. This address is formed from the
logical OR of the SADDR and SADEN. The zeros in the result are defined as don’t cares. In most cases, the Broadcast Address
is FFh, this address will be acknowledged by all slaves.
On reset, the SADDR and SADEN are initialized to 00h. This results in Given Address and Broadcast Address being set as
XXXXXXXX (all bits don’t care). This effectively removes the multiprocessor communications feature, since any selectivity is
disabled. This ensures that the EUART 0 will reply to any address, which it is backwards compatible with the 80C51
microcontrollers that do not support automatic address recognition. So the user may implement multiprocessor by software
address recognition mentioned above.
4.5 Error Detection
8.
8.4
Error detection is available when the SSTAT bit in register PCON is set to logic 1.The SSTAT bit must be logic 1 to access any
of the status bits (FE, RXOV, and TXCOL). The SSTAT bit must be logic 0 to access the Mode Select bits (SM0, SM1, and
SM2).All the 3 bits should be cleared by software after they are set, even when the following frames received without a ny error
will not be cleared automatically.
Transmit Collision
The Transmit Collision bit (TXCOL bit in register SCON) reads �1’ if RI is set 0 and user software writes data to the SBUF
register while a transmission is still in progress. If this occurs, the new data will be ignored and the transmit buffer will not be
written.
Receive Overrun
The Receive Overrun bit (RXOV in register SCON) reads �1’ if a new data byte is latched into the receive buffer before software
has read the previous byte. The previous data is lost when this happen.
Frame Error
The Frame Error bit (FE in register SCON) reads �1’ if an invalid (low) STOP bit is detected.
Break Detection
A break is detected when any 11 consecutive bits are sensed low. Since a break condition also satisfies the requirements for a
framing error, a break condition will also result in reporting a framing error. Once a break condition has been detected, the
EUART will go into an idle state and remain in this idle state until a valid stop bit (rising edge on RxD line) has been received.
82
166A
SH79F
SH79F166A
4. 6 Register
8.
8.4
Table 8.21 EUART Control & Status Register
98H
98H,, Bank0
SCON
R /W
Bit7
SM0
/FE
R/W
Bit6
SM1
/RXOV
R/W
Bit5
SM2
/TXCOL
R/W
Bit4
Bit3
Bit2
Bit1
Bit0
REN
TB8
RB8
TI
RI
R/W
R/W
R/W
R/W
R/W
0
0
0
0
0
0
0
0
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
Bit Number
Bit Mnemonic
7-6
SM[0
SM[0:: 1]
7
FE
6
RXOV
Description
AT = 0
EUART Serial mode control bit
bit,, when SST
SSTA
00: mode 0, Synchronous Mode, fixed baud rate
01: mode 1, 8 bit Asynchronous Mode, variable baud rate
10: mode 2, 9 bit Asynchronous Mode, fixed baud rate
11: mode 3, 9 bit Asynchronous Mode, variable baud rate
EUART Frame Error flag, when FE bit is read
read,, SSTAT bit must be set 1
0: No Frame Error, clear by software
1: Frame error occurs, set by hardware
EUART Receive Over flag, when RXOV bit is read
read,, SSTAT bit must be set 1
0: No Receive Over, clear by software
1: Receive over occurs, set by hardware
SM2
EUART Multi-processor communication enable bit (9th bit � 1’ checker), when
SSTAT = 0
0: In Mode0, baud-rate is 1/12 of system clock
In Mode1, disable stop bit validation check, a ny stop bit will set RI to
generate interrupt
In Mode2 & 3, any byte will set RI to generate interrupt
1: In Mode0, baud-rate is 1/4 of system clock
In Mode1, Enable stop bit validation check, only valid stop bit (1) will set RI to
generate interrupt
In Mode2 & 3, only address byte (9th bit = 1) will set RI to generate interrupt
5
TXCOL
EUART Transmit Collision flag, when TXC OL bit is read
read,, SSTAT bit must be
set 1
0: No Transmit Collision, clear by software
1: Transmit Collision occurs, set by hardware
4
REN
EUART Receiver enable bit
0: Receive Disable
1: Receive Enable
3
TB8
The 9th bit to be transmitted in Mode2 & 3 of EUART, set or clear by software
2
RB8
ed in Mode
1, 2 & 3 of EUART
The 9th bit to be receiv
received
Mode1,
In Mode0, RB8 is not used
In Mode1, if receive interrupt occurs, RB8 is the stop bit that was received
In Modes2 & 3 it is the 9th bit that was received
5
1
0
TI
Transmit interrupt flag of EUART
0: cleared by software
1: Set by hardware at the end of the 8th bit time in Mode0, or at the beginning of
the stop bit in other modes
RI
Receive interrupt flag of EUART
0: cleared by software
1: Set by hardware at the end of the 8th bit time in Mode0, or during the stop bit
time in other modes
83
166A
SH79F
SH79F166A
Table 8.22 EUART Data Buffer Register
99H
99H,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
SBUF
SBUF.7
SBUF.6
SBUF.5
SBUF.4
SBUF.3
SBUF.2
SBUF.1
SBUF.0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
Description
7-0
SBUF[7
SBUF[7:: 0]
This SFR accesses two registers; a transmit shift register and a receive latch register
A write of SBUF will send the byte to the transmit shift register and then initiate a
transmission
A read of SBUF returns the contents of the receive latch
Table 8.23 Power Control Register
87H
87H,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
PCON
SMOD
SSTAT
-
-
GF1
GF0
PD
IDL
R /W
R/W
R/W
-
-
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
-
-
0
0
0
0
Bit Number
Bit Mnemonic
Bit1
Bit0
Description
7
SMOD
Baud rate doubler
If set in Mode1 & 3, the baud-rate of EUART is doubled if using time4 as
baud-rate generator
If set in Mode2, the baud-rate of EUART is doubled
6
SSTAT
SCON[7:5] function select bit
0: SCON[7:5] operates as SM0, SM1, SM2
1: SCON[7:5] operates as FE, RXOV, TXCOL
3-2
GF[1:0]
s for software use
General purpose flag
flags
1
PD
Power-Down mode control bit
0
IDL
Idle mode control bit
Table 8.24 EUART Slave Address & Address Mask Register
9AH-9BH
9AH-9BH,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
SADDR
SADDR.7
SADDR.6
SADDR.5
SADDR.4
SADDR.3
SADDR.2
SADDR.1
SADDR.0
SADEN
SADEN.7
SADEN.6
SADEN.5
SADEN.4
SADEN.3
SADEN.2
SADEN.1
SADEN.0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7-0
SADDR[7:0]
SFR SADDR defines the EUART
EUART’’ s slave address
SADEN[7:0]
SFR SADEN is a bit mask to determine which bits of SADDR are checked
against a received address
0: Corresponding bit in SADDR is a “don’t care”
1: Corresponding bit in SADDR is checked against a received address
7-0
Description
84
166A
SH79F
SH79F166A
Table 8.25 Rxd Pin Schmidt Voltage Control Register
9FH , Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
CON
Rx
RxCON
-
-
-
-
-
-
CON
1
Rx
RxCON
CON1
CON
0
Rx
RxCON
CON0
R /W
-
-
-
-
-
-
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
-
-
-
-
-
0
0
Bit Number
1 -0
Bit Mnemonic
CON
[1
Rx
RxCON
CON[1
[1:: 0]
Description
Rxd pin Schmidt voltage control
00: input low voltage is 0.2 V DD
01: input low voltage is 0.4 V DD
10: input low voltage is 0.5 V DD
11: normal IO
Note
Note:: RxCON is available when EUART is on. Refer to Electrical Characteristics for detail.
85
166A
SH79F
SH79F166A
5 Analog Digital Converter (ADC)
8.
8.5
8.
5.1 Feature
8.5
пїЅ 10-bit Resolution
пїЅ Build in VREF
пїЅ Selectable external or built-in V REF
пїЅ 8 Multiplexed Input Channels
The SH79F166A include a single ended, 10-bit SAR Analog to Digital Converter (ADC) with build in reference voltage
connected to the VDD, users also can select the VREF pin input reference voltage. The 7 ADC channels are shared with 1 ADC
module; each channel can be programmed to connect with the analog input individually. Only one channel can be available at
————
one time. GO/ DONE signal is available to start convert, and indicate end of convert. When conversion is completed, the data in
AD convert data register will be updated and ADCIF bit in ADCON register will be set. If ADC Interrupt is enabled, the ADC
interrupt will generate.
The ADC integrates a digital compare function to compare the value of analog input with the digital value in the AD converter. If
this function is enabled (set EC bit in ADCON register) and ADC module is enabled (set ADON bit in ADCON register). When
the corresponding digital value of analog input is larger than the value in compare value register (ADDH/L), the ADC interrupt
————
will occur, otherwise no interrupt will be generated. The digital comparator can work continuously when GO/ DONE bit is set until
software clear, which behaviors different with the AD converter operation mode.
The ADC module including digital compare module can wok in Idle mode and the ADC interrupt will wake up the Idle mode, but
is disabled in Power-Down mode.
8.
5.2 ADC Diagram
8.5
SCH2 - SCH0
CH7 - CH0
REFC
000
AN0
0
001
AN1
1
010
AN2
011
AN3
V DD
AVREF
Input reference
voltage
100
ADC
Input voltage
101
AN4
AN5
110
AN6
111
AN7
ADC Diagram
86
166A
SH79F
SH79F166A
5.3 ADC Register
8.
8.5
Table 8.26 ADC Control Register
93H
93H,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
ADCON
ADON
ADCIF
EC
REFC
SCH2
SCH1
SCH0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
GO/ DONE
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
—---— -----—
Bit Number
Bit Mnemonic
7
ADON
ADC Enable bit
0: Disable the ADC module
1: Enable the ADC module
6
ADCIF
ADC Interrupt Flag bit
0: No ADC interrupt, cleared by software.
1: Set by hardware to indicate that the AD Convert has been completed, or analog
input is larger than ADDH/ADDL if compare is enabled
5
EC
4
REFC
3-1
0
SCH[2:0]
—-----—
— -----—
------—
GO/ DONE
Description
Compare Function Enable bit
0: Compare function disabled
1: Compare function enabled
Reference Voltage Select bit
0: the reference voltage connected to VDD
1: the reference voltage input from VREF pin
ADC channel Select bits
000: ADC channel AN0
001: ADC channel AN1
010: ADC channel AN2
011: ADC channel AN3
100: ADC channel AN4
101: ADC channel AN5
110: ADC channel AN6
111: ADC channel AN7
ADC status flag bit
0: Automatically cleared by hardware when AD convert is completed. Clearing this
bit during converting time will stop current conversion. If Compare function is
enabled, this bit will not be cleared by hardware until software clear.
1: Set to start AD convert or digital compare.
Notes:
When select the reference voltage input from VREF pin (REFC = 1), the P4.4 is shared as VREF input rather than AN3 input.
87
166A
SH79F
SH79F166A
Table 8.27 ADC定时控制寄�器
94H
94H,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
ADT
TADC2
TADC1
TADC0
-
TS3
TS2
TS1
TS0
R /W
R/W
R/W
R/W
-
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
-
0
0
0
0
Bit Number
Bit Mnemonic
7-5
TADC[2:0]
3-0
TS[3:0]
Description
ADC Clock Period Select bits
000: ADC Clock Period tAD = 2 t SYS
001: ADC Clock Period tAD = 4 t SYS
010: ADC Clock Period tAD = 6 t SYS
011: ADC Clock Period tAD = 8 t SYS
100: ADC Clock Period tAD = 12 tSYS
101: ADC Clock Period tAD = 16 tSYS
110: ADC Clock Period tAD = 24 tSYS
111: ADC Clock Period tAD = 32 tSYS
Sample time select bits
2 tAD ≤ Sample time = (TS [3:0]+1) * tAD ≤ 15 tAD
Note:
(1) Make sure that t AD ≧ 1µs;
(2) The minimum sample time is 2 tAD, even TS[3:0] = 0000;
The maximum sample time is 15 tAD , even TS[3:0] = 1111;
(3) Evaluate the series resistance connected with ADC input pin before set TS[3:0];
(4) Be sure that the series resistance connected with ADC input pin is no more than 10kΩ when 2 tAD sample time is selected;
(5) Total conversion time is: 12 tAD + sample time.
For Example
System Clock
(SYSCLK)
32.768kHz
4MHz
12MHz
TADC[2:0]
000
000
000
111
111
111
000
001
001
001
111
111
111
000
100
100
100
111
111
111
tAD
30.5*2=61Вµs
30.5*2=61Вµs
30.5*2=61Вµs
30.5*32=976Вµs
30.5*32=976Вµs
30.5*32=976Вµs
0.25*2=0.5Вµs
0.25*4=1Вµs
0.25*4=1Вµs
0.25*4=1Вµs
0.25*32=8Вµs
0.25*32=8Вµs
0.25*32=8Вµs
0.083*2=0.166Вµs
0.083*12=1Вµs
0.083*12=1Вµs
0.083*12=1Вµs
0.083*32=2.7Вµs
0.083*32=2.7Вµs
0.083*32=2.7Вµs
TS[3:0]
0000
0111
1111
0000
0111
1111
0000
0111
1111
0000
0111
1111
0000
0111
1111
0000
0111
1111
88
Sample Time
2*61=122Вµs
8*61=488Вµs
15*61=915Вµs
2*976=1952Вµs
8*976=7808Вµs
15*976=14640Вµs
2*1=2Вµs
8*1=8Вµs
15*1=15Вµs
2*8=16Вµs
8*8=64Вµs
15*8=120Вµs
2*1=2Вµs
8*1=8Вµs
15*1=15Вµs
2*2.7=5.4Вµs
8*2.7=21.6Вµs
15*2.7=40.5Вµs
Conversion Time
12*61+122=854Вµs
12*61+488=1220Вµs
12*61+915=1647Вµs
12*976+1952=13664Вµs
12*976+7808=19520Вµs
12*976+14640=26352Вµs
(tAD < 1Вµs, not recommended)
12*1+2=14Вµs
12*1+8=20Вµs
12*1+15=27Вµs
12*8+16=112Вµs
12*8+64=160Вµs
12*8+120=216Вµs
(tAD < 1Вµs, not recommended)
12*1+2=14Вµs
12*1+8=20Вµs
12*1+15=27Вµs
12*2.7+5.4=37.8Вµs
12*2.7+21.6=54Вµs
12*2.7+40.5=72.9Вµs
166A
SH79F
SH79F166A
Table 8.28 ADC Channel Configure Register
95H
95H,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
ADCH
CH7
CH6
CH5
CH4
CH3
CH2
CH1
CH0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
0
77-0
7:0]
CH[
CH[7
Description
Channel Configuration bits
0: P4.0-P4.3пјЊP3.4-P3.7 are I/O port
1: P4.0-P4.3пјЊP3.4-P3.7 are ADC input port
Table 8.29 AD Converter Data Register (Compare Value Register)
96H
96H,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
L
ADD
ADDL
-
-
-
-
-
-
A1
A0
R /W
-
-
-
-
-
-
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
-
-
-
-
-
0
0
97H
97H,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
H
ADD
ADDH
A9
A8
A7
A6
A5
A4
A3
A2
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
1-0
7-0
Bit Mnemonic
A9-A0
Description
ADC Data register
Digital Value of sampled analog voltage, updated when conversion is completed
If ADC Compare function is enabled (EC = 1), this is the value to be compared
with the analog input
The Approach for AD Conversion:
(1) Select the analog input channels and reference voltage.
(2) Enable the ADC module with the selected analog channel.
————
(3) Set GO/ DONE = 1 to start the AD conversion.
————
(4) Wait until GO/ DONE = 0 or ADCIF = 1, if the ADC interrupt is enabled, the ADC interrupt will occur.
(5) Acquire the converted data from ADDH/ADDL.
(6) Repeat step 3-5 if another conversion is required.
The Approach for Digital Compare F unction
unction::
(1) Select the analog input channels and reference voltage.
(2) Set ADDH/ADDL to the compare value.
(3) Set EC = 1 to enable compare function.
(4) Enable the ADC module with the selected analog channel.
————
(5) Set GO/ DONE = 1 to start the compare function.
(6) If the analog input is lager than compare value set in ADDH/ADDL, the ADCIF will be set to 1. if the ADC interrupt is enabled,
the ADC interrupt will occur.
————
(7) The compare function will continue work until the GO/ DONE bit is cleared to 0.
89
166A
SH79F
SH79F166A
6 Buzzer
8.
8.6
8.
6.1 Feature
8.6
пїЅ Output a signal (square wave) used for tones such as a confirmation tone
пїЅ Selectable whether to output one of 8 output frequencies or to disable the output
8.
6
.
2
8.6 Register
Table 8.30 Buzzer Output Control Register
BDH
BDH,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
BUZCON
-
-
-
-
BCA2
BCA1
BCA0
BZEN
R /W
-
-
-
-
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
-
-
-
-
0
0
0
0
Bit Number
Bit Mnemonic
3-1
3:1
BCA[
BCA[3:1
3:1]]
0
BZEN
Description
Buzzer output carrier frequency control bits
000: system clock/8192
001: system clock/4096
010: system clock/2048
011: system clock/1024
100: system clock/512
101:system clock/32
110: system clock/16
111: system clock/8
Enable buzzer output control bit
0: P5.3 is I/O port
1: P5.3 is buzzer output port
90
166A
SH79F
SH79F166A
7 Low Power Detect (LPD)
8.
8.7
7.1 Feature
8.
8.7
пїЅ An internal flag indicates low power is detected
пїЅ LPD detect voltage is selectable
пїЅ LPD de-bounce timer T LVR is about 30-60Вµs
The low power detect (LPD) is used to monitor the supply voltage and generate an internal flag if the voltage decrease below
the specified value. It is used to inform CPU whether the power is shut off or the battery is used out, so the software may do
some protection action before the voltage drop down to the minimal operation voltage.
7. 2 Register
8.
8.7
Table 8.31 Low Power Detection Control Register
B 3H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
CON
LPD
LPDCON
LPDEN
LPDF
LPDMD
LPDIF
LPDS3
LPDS2
LPDS1
LPDS0
R /W
R/W
R
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
Bit Mnemonic
7
LPDEN
6
LPDF
5
LPDMD
4
LPD
LPDIIF
30
3-0
LPDS
0]
LPDS[[3 ::0]
Description
LPD Enable bit
0: Disable lower power detection
1: Enable lower power detection
LPD status Flag bit
0: No LPD happened, clear by hardware,
1: LPD happened, set by hardware
LPD mode select bit
0: When VDD below LPD voltage, LPDF is set
1: When VDD above LPD voltage, LPDF is set
LPD interrupt flag bit
0: No LPD happened, clear by software
1: LPD happened, set by hardware
LPD Voltage Select bit
0000: 2.40V
0001: 2.55V
0010: 2.70V
0011: 2.85V
0100: 3.00V
0101: 3.15V
0110: 3.30V
0111: 3.45V
1000: 3.60V
1001: 3.75V
1010: 3.90V
1011: 4.05V
1100: 4.20V
1101: 4.35V
1110: 4.50V
1111: 4.65V
91
166A
SH79F
SH79F166A
8.8 Low Voltage Reset (LVR)
8.
8.1 Feature
8.8
пїЅ Enabled by the code option and VLVR is 4.3V or 2.1V
пїЅ LVR de-bounce timer T LVR is about 30-60Вµs
пїЅ An internal reset flag indicates low voltage reset generates
The LVR function is used to monitor the supply voltage and generate an internal reset in the device when the supply voltage
below the specified value VLVR. The LVR de-bounce timer T LVR is about 30Вµs.
The LVR circuit has the following functions when the LVR function is enabled: (t means the time of the supply voltage below
V LVR)
Generates a system reset when VDD ≤ V LVR and t ≥ TLVR;
Cancels the system reset when V DD > VLVR or V DD < VLVR, but t < TLVR.
The LVR function is enabled by the code option.
It is typically used in AC line or large battery supplier applications, where heavy loads may be switched on and cause the MCU
supply-voltage temporarily falls below the minimum specified operating voltage. This feature can protect system from working
under bad power supply environment.
92
166A
SH79F
SH79F166A
9 Watchdog Timer (WDT) and R eset State
8.
8.9
8.
9.1 Feature
8.9
пїЅ Auto detect Program Counter(PC) over range, and generate OVL Reset
пїЅ WDT runs even in the Power-Down mode
пїЅ Selectable different WDT overflow frequency
OVL Reset
To enhance the anti-noise ability, SH79F166A built in Program Counter (PC) over range detect circuit, if program counter value
is larger than flash romsize, or detect operation code equal to A5H which is not exist in 8051 instruction set, a OVL reset will be
generate to reset CPU, and set WDOF bit. So, to make use of this feature, you should fill unused flash rom with A5H.
Watchdog Timer
The watchdog timer is a down counter, and its clock source is an independent built-in RC oscillator, so it always runs even in the
Power-Down mode. The watchdog timer will generate a device reset when it overflows. It can be enabled or disabled
permanently by the code option.
The watchdog timer control bits (WDT.2-0) are used to select different overflow frequency. The watchdog timer overflow flag
(WDOF) will be automatically set to “1” by hardware when overflow happens. To prevent overflow happen, by reading or writing
the WDT register RSTSTAT, the watchdog timer should re-count before the overflow happens.
There are also some reset flags in this register as below:
93
166A
SH79F
SH79F166A
9.2 Register
8.
8.9
Table 8.32 Reset Control Register
B1H
B1H,, Bank0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
RSTSTAT
WDOF
-
PORF
LVRF
CLRF
WDT.2
WDT.1
WDT.0
R /W
R/W
-
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value (POR
POR))
0
-
1
0
0
0
0
0
Reset Value (WDT
WDT))
1
-
u
u
u
0
0
0
Reset Value (LVR
LVR))
u
-
u
1
u
0
0
0
Reset Value (PIN
PIN))
u
-
u
u
1
0
0
0
Bit Number
Bit Mnemonic
Description
WDOF
Watch D og Timer Overflow or OVL Reset Flag
Set by hardware when WDT overflow or OVL reset happened, cleared by
software or Power On Reset
0: Watch Dog not overflows and no OVL reset generated
1: Watch Dog overflow or OVL reset occurred
5
PORF
Power On Reset Flag
Set only by Power On Reset, cleared only by software
0: No Power On Reset.
1: Power On Reset occurred.
4
LVRF
Low Voltage Reset Flag
Set only by Low Voltage Reset, cleared by software or Power On Reset
0: No Low Voltage Reset occurs
1: Low Voltage Reset occurred
CLRF
Pin Reset Flag
Set only by pin reset, cleared by software or Power On Reset
0: No Pin Reset occurs
1: Pin Reset occurred
7
3
2-0
WDT[2:0]
WDT Overflow period control bit
000: Overflow period minimal value= 4096 ms
001: Overflow period minimal value= 1024 ms
010: Overflow period minimal value = 256 ms
011: Overflow period minimal value = 128 ms
100: Overflow period minimal value = 64ms
101: Overflow period minimal value = 16ms
110: Overflow period minimal value = 4ms
111: Overflow period minimal value = 1ms
Notes
Notes:: If WDT_opt is enable in application, you must clear WatchDog
periodically, and the interval must be less than the value list above.
94
166A
SH79F
SH79F166A
10 Power Management
8.
8.10
8.
10
.1 Feature
8.10
10.1
пїЅ Two power saving modes: Idle mode and Power-Down mode
пїЅ Two ways to exit Idle and Power-Down mode: interrupt and reset
To reduce power consumption, SH79F166A supplies two power saving modes: Idle mode and Power-Down mode. These two
modes are controlled by PCON & SUSLO register.
10
.2 I dle Mode
8.
8.10
10.2
In this mode, the clock to CPU is frozen, the program execution is halted, and the CPU will stop at a defined state. But the
peripherals continue to be clocked. When entering idle mode, all the CPU status before entering will be preserved. Such as:
PSW, PC, SFR & RAM are all retained.
By two consecutive instructions: setting SUSLO register as 0x55, and immediately followed by setting the IDL bit in PCON
register, will make SH79F166A enter Idle mode. If the consecutive instruction sequence requirement is not met, the CPU will
clear either SUSLO register or IDL bit in the next machine cycle. And the CPU will not enter Idle mode. The setting of IDL bit will
be the last instruction that CPU executed.
There are two ways to exit Idle mode:
(1) An interrupt generated. The clock to the CPU will be restored, and the hardware will clear SUSLO register and IDL bit in
PCON register. Then the program will execute the interrupt service routine first, and then jumps to the instruction
immediately following the instruction that activated Idle mode.
(2) Reset signal (logic low on the RESET pin, WDT RESET if enabled, LVR REST if enabled), this will restore the clock to the
CPU, the SUSLO register and the IDL bit in PCON register will be cleared by hardware, finally the SH79F166A will be reset.
And the program will execute from address 0000H. The RAM will keep unchanged and the SFR value might be changed
according to different function module.
10
.3 Power-Down Mode
8.
8.10
10.3
The Power-Down mode places the SH79F166A in a very low power state. Power-Down mode will stop all the clocks including
CPU and peripherals. If WDT is enabled, WDT block will keep on working. When entering Power-Down mode, all the CPU
status before entering will be preserved. Such as: PSW, PC, SFR & RAM are all retained.
By two consecutive instructions: setting SUSLO register as 0x55, and immediately followed by setting the PD bit in PCON
register, will make SH79F166A enter Power-Down mode. If the consecutive instruction sequence requirement is not met, the
CPU will clear either SUSLO register or PD bit in the next machine cycle. And the CPU will not enter Power-Down mode.
The setting of PD bit will be the last instruction that CPU executed.
Note: If IDL bit and PD bit are set simultaneously, the SH79F166A enters Power-Down mode. The CPU will not go in Idle mode
when exiting from Power-Down mode, and the hardware will clear both IDL & PD bit after exit form Power-Down mode.
There are two ways to exit the Power-Down mode:
(1) An active external Interrupt such as INT0, INT1 & INT4 will make SH79F166A exit Power-Down mode. The oscillator will
start after interrupt happens, after warm-up time, the clocks to the CPU and peripheral will be restored, the SUSLO register
and PD bit in PCON register will be cleared by hardware. Program execution resumes with the interrupt service routine.
After completion of the interrupt service routine, program execution resumes with the instruction immediately following the
instruction that activated Power-Down mode.
(2) Timer3 interrupt will make SH79F166A exit Power-Down mode when 32.768kHz or 128KHz is the clock source. The
oscillator will start after interrupt happens, after warm-up time, the clocks to the CPU and peripheral will be restored, the
SUSLO register and PD bit in PCON register will be cleared by hardware. Program execution resumes with the interrupt
service routine. After completion of the interrupt service routine, program execution resumes with the instruction
immediately following the instruction that activated Power-Down mode.
(3) Reset signal (logic low on the RESET pin, WDT RESET if enabled, LVR REST if enabled). This will restore the clock to the
CPU after warm-up time, the SUSLO register and the PD bit in PCON register will be cleared by hardware, finally the
SH79F166A will be reset. And the program will execute from address 0000H. The RAM will keep unchanged and the SFR
value might be changed according to different function module.
Note: In order to entering Idle/Power-Down, it is necessary to add 3 NOPs after setting IDL/PD bit in PCON.
95
166A
SH79F
SH79F166A
10
.4 Register
8.
8.10
10.4
Table 8.33 Power Control Register
87H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
PCON
SMOD
SSTAT
-
-
GF1
GF0
PD
IDL
R /W
R/W
R/W
-
-
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
-
-
0
0
0
0
Bit Number
Bit Mnemonic
7
SMOD
Baud rate double bit
Description
6
SSTAT
SCON[7:5] function selection bit
3-2
GF[1:0]
s for software use
General purpose flag
flags
1
PD
Power-Down mode control bit
0: Cleared by hardware when an interrupt or reset occurs
1: Set by software to activate the Power-Down mode
0
IDL
Idle mode control bit
0: Cleared by hardware when an interrupt or reset occurs
1: Set by software to activate the Idle mode
Table 8.34 Suspend Mode Control Register
8EH
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
SUSLO
SUSLO.7
SUSLO.6
SUSLO.5
SUSLO.4
SUSLO.3
SUSLO.2
SUSLO.1
SUSLO.0
R /W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
/PIN
(POR/WDT/LVR
POR/WDT/LVR/PIN
/PIN))
0
0
0
0
0
0
0
0
Bit Number
7-0
Bit Mnemonic
O[7: 0]
SUSL
SUSLO
Description
This register is used to control the CPU enter suspend mode (Idle or Power-Down).
Only consecutive instructions like below will make CPU enter suspend mode. Other
wise the either SUSLO, IDL or PD bit will be cleared by hardware in the next
machine cycle.
Example:
IDLE_MODE:
MOV
ORL
NOP
NOP
NOP
SUSLO, #55H
PCON, #01H
POWERDOWN_MODE:
MOV
SUSLO, #55H
ORL
PCON, #02H
NOP
NOP
NOP
96
166A
SH79F
SH79F166A
11 Warm-up Timer
8.
8.11
8.1
1.1 Feature
8.11
пїЅ Built-in power on warm-up counter to eliminate unstable state of power on
пїЅ Built-in oscillator warm-up counter to eliminate unstable state when oscillation startup
SH79F166A has a built-in power warm-up counter; it is designed to eliminate unstable state after power on or to do some
internal initial operation such as read customer option etc.
SH79F166A has also a built-in oscillator warm-up counter, it is designed to eliminate unstable state when oscillator starts
oscillating in the following conditions: Power-on reset, Pin reset, LVR reset, Watchdog Reset and Wake up from Power-down
mode.
After power-on, SH79F166A will start power warm-up procedure first, and then oscillator warm-up procedure.
Power Warm-up T ime
Power On Reset/
Pin Reset/
Low Voltage Reset
Wakeup from Power
WDT R eset
Power--Down
WDT R eset
(Wakeup from Power
Mode
Power--Down
(Not in Power
Power--Down Mode)
Mode
Mode))
(Only for interrupt)
TPWRT**
OSC
Warm up*
TPWRT**
OSC
Warm up*
TPWRT**
OSC
Warm up*
TPWRT**
OSC
Warm up*
11ms
YES
≈1ms
NO
≈1ms
YES
≈800us
YES
OSC Warm-up T ime
Option:
OP_WMT
Oscillator Type
00
01
10
11
Ceramic
Ceramic//Crystal
217 X Tosc
214 X Tosc
211 X Tosc
28 X Tosc
32kHz Crystal
213 X Tosc
Internal RC
27 X Tosc
97
166A
SH79F
SH79F166A
12 Code Option
8.
8.1
OP_SCM
OP_SCM::
0: SCM is invalid in warm up period
1: SCM is valid in warm up period
OP_LEDCOM
OP_LEDCOM::
0: LED common signal is normal (default)
1: LED common signal is inverted
OP_WDTPD
OP_WDTPD::
0: Disable WDT function in Power-Down mode
1: Enable WDT function in Power-Down mode
OP_WDT
OP_WDT::
0: Disable WDT function
1: Enable WDT function
OP_LVREN
OP_LVREN::
0: Disable LVR function
1: Enable LVR function
OP_LVRLE
OP_LVRLE::
0: 4.3V LVR level 1
1: 2.1V LVR level 2
OP_RST
OP_RST::
0: P5.2 used as RST pin
1: P5.2 used as I/O pin
OP_WMT
OP_WMT:: (unavailable for 32kHz crystal and Internal RC)
00: longest warm up time
01: longer warm up time
10: shorter warm up time
11: shortest warm up time
OP_OSC
OP_OSC::
0000: Oscillator1 is internal 12M RC, oscillator2 is disabled
0011: Oscillator1 is internal 128k RC, oscillator2 is internal 12M RC
0110: Oscillator1 is internal 128k RC, oscillator2 is 2M-12M cyrstal/cearmic oscillator
1010: Oscillator1 is 32.768k crystal oscillator, oscillator2 is internal 12M RC
1101: Oscillator1 is 32.768k crystal oscillator, oscillator2 is 2M-12M cyrstal/cearmic oscillator
1110: Oscillator1 is 2M-12M cyrstal/cearmic oscillator, oscillator2 is disabled
Others: Oscillator1 is internal 12M RC, oscillator2 is disabled
OP_OSCDRIVE
OP_OSCDRIVE::
011: 8M-12M crystal
001: 4M crystal
111: 12M ceramic
101: 8M ceramic
110: 4M ceramic
100: 2M ceramic
98
166A
SH79F
SH79F166A
9. Instruction Set
ARITHMETIC OPERATIONS
Opcode
Description
Code
B yte
Cycle
ADD A, Rn
Add register to accumulator
0x28-0x2F
1
1
ADD A, direct
Add direct byte to accumulator
0x25
2
2
ADD A, @Ri
Add indirect RAM to accumulator
0x26-0x27
1
2
ADD A, #data
Add immediate data to accumulator
0x24
2
2
ADDC A, Rn
Add register to accumulator with carry flag
0x38-0x3F
1
1
ADDC A, direct
Add direct byte to A with carry flag
0x35
2
2
ADDC A, @Ri
Add indirect RAM to A with carry flag
0x36-0x37
1
2
ADDC A, #data
Add immediate data to A with carry flag
0x34
2
2
SUBB A, Rn
Subtract register from A with borrow
0x98-0x9F
1
1
SUBB A, direct
Subtract direct byte from A with borrow
0x95
2
2
SUBB A, @Ri
Subtract indirect RAM from A with borrow
0x96-0x97
1
2
SUBB A, #data
Subtract immediate data from A with borrow
0x94
2
2
INC A
Increment accumulator
0x04
1
1
INC Rn
Increment register
0x08-0x0F
1
2
INC direct
Increment direct byte
0x05
2
3
INC @Ri
Increment indirect RAM
0x06-0x07
1
3
DEC A
Decrement accumulator
0x14
1
1
DEC Rn
Decrement register
0x18-0x1F
1
2
DEC direct
Decrement direct byte
0x15
2
3
DEC @Ri
Decrement indirect RAM
0x16-0x17
1
3
Increment data pointer
0xA3
1
Multiply A and B
0xA4
1
Divide A by B
0x84
1
4
11
20
11
20
Decimal adjust accumulator
0xD4
1
1
INC DPTR
MUL AB
DIV AB
DA A
8X8
16 X 8
8/8
16 / 8
99
166A
SH79F
SH79F166A
LOGIC OPERATIONS
Opcode
Description
Code
B yte
Cycle
ANL A, Rn
AND register to accumulator
0x58-0x5F
1
1
ANL A, direct
AND direct byte to accumulator
0x55
2
2
ANL A, @Ri
AND indirect RAM to accumulator
0x56-0x57
1
2
ANL A, #data
AND immediate data to accumulator
0x54
2
2
ANL direct, A
AND accumulator to direct byte
0x52
2
3
ANL direct, #data
AND immediate data to direct byte
0x53
3
3
ORL A, Rn
OR register to accumulator
0x48-0x4F
1
1
ORL A, direct
OR direct byte to accumulator
0x45
2
2
ORL A, @Ri
OR indirect RAM to accumulator
0x46-0x47
1
2
ORL A, #data
OR immediate data to accumulator
0x44
2
2
ORL direct, A
OR accumulator to direct byte
0x42
2
3
ORL direct, #data
OR immediate data to direct byte
0x43
3
3
XRL A, Rn
Exclusive OR register to accumulator
0x68-0x6F
1
1
XRL A, direct
Exclusive OR direct byte to accumulator
0x65
2
2
XRL A, @Ri
Exclusive OR indirect RAM to accumulator
0x66-0x67
1
2
XRL A, #data
Exclusive OR immediate data to accumulator
0x64
2
2
XRL direct, A
Exclusive OR accumulator to direct byte
0x62
2
3
XRL direct, #data
Exclusive OR immediate data to direct byte
0x63
3
3
CLR A
Clear accumulator
0xE4
1
1
CPL A
Complement accumulator
0xF4
1
1
RL A
Rotate accumulator left
0x23
1
1
RLC A
Rotate accumulator left through carry
0x33
1
1
RR A
Rotate accumulator right
0x03
1
1
RRC A
Rotate accumulator right through carry
0x13
1
1
SWAP A
Swap nibbles within the accumulator
0xC4
1
4
100
166A
SH79F
SH79F166A
DATA TRANSFERS
Opcode
Description
Code
B yte
Cycle
MOV A, Rn
Move register to accumulator
0xE8-0xEF
1
1
MOV A, direct
Move direct byte to accumulator
0xE5
2
2
MOV A, @Ri
Move indirect RAM to accumulator
0xE6-0xE7
1
2
MOV A, #data
Move immediate data to accumulator
0x74
2
2
MOV Rn, A
Move accumulator to register
0xF8-0xFF
1
2
MOV Rn, direct
Move direct byte to register
0xA8-0xAF
2
3
MOV Rn, #data
Move immediate data to register
0x78-0x7F
2
2
MOV direct, A
Move accumulator to direct byte
0xF5
2
2
MOV direct, Rn
Move register to direct byte
0x88-0x8F
2
2
MOV direct1, direct2
Move direct byte to direct byte
0x85
3
3
MOV direct, @Ri
Move indirect RAM to direct byte
0x86-0x87
2
3
MOV direct, #data
Move immediate data to direct byte
0x75
3
3
MOV @Ri, A
Move accumulator to indirect RAM
0xF6-0xF7
1
2
MOV @Ri, direct
Move direct byte to indirect RAM
0xA6-0xA7
2
3
MOV @Ri, #data
Move immediate data to indirect RAM
0x76-0x77
2
2
MOV DPTR, #data16
Load data pointer with a 16-bit constant
0x90
3
3
MOVC A, @A+DPTR
Move code byte relative to DPTR to A
0x93
1
7
MOVC A, @A+PC
Move code byte relative to PC to A
0x83
1
8
MOVX A, @Ri
Move external RAM (8-bit address) to A
0xE2-0xE3
1
5
MOVX A, @DPTR
Move external RAM (16-bit address) to A
0xE0
1
6
MOVX @Ri, A
Move A to external RAM (8-bit address)
0xF2-F3
1
4
MOVX @DPTR, A
Move A to external RAM (16-bit address)
0xF0
1
5
PUSH direct
Push direct byte onto stack
0xC0
2
5
POP direct
Pop direct byte from stack
0xD0
2
4
XCH A, Rn
Exchange register with accumulator
0xC8-0xCF
1
3
XCH A, direct
Exchange direct byte with accumulator
0xC5
2
4
XCH A, @Ri
Exchange indirect RAM with accumulator
0xC6-0xC7
1
4
XCHD A, @Ri
Exchange low-order nibble indirect RAM with A
0xD6-0xD7
1
4
101
166A
SH79F
SH79F166A
PROGRAM BRANCHES
Opcode
Description
Code
B yte
Cycle
ACALL addr11
Absolute subroutine call
0x11-0xF1
2
7
LCALL addr16
Long subroutine call
0x12
3
7
RET
Return from subroutine
0x22
1
8
RETI
Return from interrupt
0x32
1
8
AJMP addr11
Absolute jump
0x01-0xE1
2
4
LJMP addr16
Long jump
0x02
3
5
SJMP rel
Short jump (relative address)
0x80
2
4
JMP @A+DPTR
Jump indirect relative to the DPTR
0x73
1
6
Jump if accumulator is zero
0x60
2
Jump if accumulator is not zero
0x70
2
Jump if carry flag is set
0x40
2
Jump if carry flag is not set
0x50
2
Jump if direct bit is set
0x20
3
JZ rel
JNZ rel
JC rel
JNC rel
JB bit, rel
(not taken)
(taken)
(not taken)
(taken)
(not taken)
(taken)
(not taken)
(taken)
(not taken)
(taken)
3
5
3
5
2
4
2
4
4
6
JNB bit, rel
(not taken)
(taken)
Jump if direct bit is not set
0x30
3
4
6
JBC bit, rel
(not taken)
(taken)
Jump if direct bit is set and clear bit
0x10
3
4
6
Compare direct byte to A and jump if not equal
0xB5
3
Compare immediate to A and jump if not equal
0xB4
3
Compare immediate to reg. and jump if not equal
0xB8-0xBF
3
Compare immediate to Ri and jump if not equal
0xB6-0xB7
3
Decrement register and jump if not zero
0xD8-0xDF
2
Decrement direct byte and jump if not zero
0xD5
3
No operation
0
1
CJNE A, direct, rel
(not taken)
(taken)
CJNE A, #data, rel (not taken)
(taken)
CJNE Rn, #data, rel (not taken)
(taken)
CJNE @Ri, #data, rel (not taken)
(taken)
DJNZ Rn, rel
(not taken)
(taken)
DJNZ direct, rel
(not taken)
(taken)
NOP
102
4
6
4
6
4
6
4
6
3
5
4
6
1
166A
SH79F
SH79F166A
BOOLEAN MANIPULATION
Opcode
Description
Code
B yte
Cycle
CLR C
Clear carry flag
0xC3
1
1
CLR bit
Clear direct bit
0xC2
2
3
SETB C
Set carry flag
0xD3
1
1
SETB bit
Set direct bit
0xD2
2
3
CPL C
Complement carry flag
0xB3
1
1
CPL bit
Complement direct bit
0xB2
2
3
ANL C, bit
AND direct bit to carry flag
0x82
2
2
ANL C, /bit
AND complement of direct bit to carry
0xB0
2
2
ORL C, bit
OR direct bit to carry flag
0x72
2
2
ORL C, /bit
OR complement of direct bit to carry
0xA0
2
2
MOV C, bit
Move direct bit to carry flag
0xA2
2
2
MOV bit, C
Move carry flag to direct bit
0x92
2
3
103
166A
SH79F
SH79F166A
10. Electrical Characteristics
Absolute Maximum Ratings*
DC Supply Voltage. . . . . . . . . . . . . . . . . . . .-0.3V to +6.0V
*Comments
Absolute Maximum
Stresses exceed those listed under “Absolute
Ratings
Ratings” may cause permanent damage to this device.
These are stress ratings only. Functional operation of this
device at these or a ny other conditions above those
indicated in the operational sections of this specification is
not implied or intended. Exposure to the absolute maximum
rating conditions for extended periods may affect device
reliability.
Input/Output Voltage. . . . . . . . . . . GND-0.3V to VDD+0.3V
Operating Ambient Temperature. . . . . . . . . -40В°C to +85В°C
Storage Temperature . . . . . . . . . .. . . . . . .-55В°C to +125В°C
FLASH write/erase operating. . . . . . . . . . . . . 0В°C to +85В°C
DC Electrical Characteristics (VDD = 2.0V - 5.5V, GND = 0V, T A = +25В°C, unless otherwise specified)
Parameter
Operating Voltage
Symbol
Min.
Typ.
Typ.в€—
Max.
Unit
VDD
2.0
5.0
5.5
V
IOP
-
5
10
ISB1
-
-
25
3
35
5
mA
ВµA
fOSC = 32.768kHz, OSCX off, VDD = 5.0V
All output pins unload (including all digital input
pins unfloating) CPU on (execute NOP
instruction), LVR off, all other function block off
mA
fOSC = 12MHz, VDD = 5.0V
All output pins unload(including all digital input
pins unfloating), CPU off (IDLE), LVR off, LCD
off, all other function block off
ВµA
fOSC = 32.768kHz, OSCX off ,VDD = 5.0V
All output pins unload (including all digital input
pins unfloating) CPU off (IDLE), LVR off , LCD
off, all other function block off
ВµA
Osc off, V DD = 5.0V
All output pins unload(including all digital input
pins unfloating), CPU off (Power-Down), LVR off,
LCD off, WDT off, all other function block off
Stand by Current
(IDLE)
ISB 2
ISB 3
-
-
15
2
20
10
32.768kHz or 2MHz ≤ f OSC ≤ 12MHz
fOSC = 12MHz, VDD = 5.0V
All output pins unload (including all digital input
pins unfloating) CPU on (execute NOP
instruction), WDT on, all other function block off
Operating Current
IOP2
Condition
Stand by Current
(Power-Down)
ISB4
-
4
15
ВµA
fOSC = 32.768kHz, OSCX off, VDD = 5.0V
All output pins unload(including all digital input
pins unfloating), CPU off (Power-Down), LVR off,
LCD off, WDT off, all other function block off
WDT Current
I WDT
-
1
3
ВµA
All output pins unload, WDT on, VDD = 5.0V
LCD Current
ILCD
-
6
7
ВµA
traditional bias resistance mode, VDD = 5.0V
300k LCD bias resistance, contrast[3:0] = 1111
LPD Current
ILPD
-
-
1
ВµA
VDD = 2.0 - 5.5V
Input Low Voltage 1
V IL1
GND
-
0.3 X VDD
V
I/O Ports
Input High Voltage 1
V IH1
0.7 X V DD
-
V DD
V
I/O Ports
(to be continued)
104
166A
SH79F
SH79F166A
(continue)
Parameter
Symbol
Min.
Typ.
Typ.в€—
Max.
Unit
Condition
——---- --- ——
GND
-
0.2 X VDD
V
RST, T2, T3, T4, INT0/1/2/3/4, T2EX,
RXD (RxCON[1:0] = 00), TXD, FLT,
VDD = 2.4 - 5.5V
GND
-
0.4 X VDD
V
RXD (RxCON[1:0] = 01), VDD = 2.4 - 5.5V
GND
-
0.5 X VDD
V
RXD (RxCON[1:0] = 10), VDD = 2.4 - 5.5V
V IH2
0.8 X V DD
-
V DD
V
Input Leakage Current
IIL
-1
-
1
ВµA
Input pad, V IN = VDD or GND
Output Leakage
Current
IOL
-1
-
1
ВµA
Open-drain output, VDD = 5.0V
VOUT = VDD or GND
Pull-high Resistor
RPH
-
30
-
kΩ
VDD = 5.0V, VIN = GND
Rest pin Pull-high
Resistor
RRPH
-
30
-
kΩ
VDD = 5.0V, VIN = GND
Output High Voltage
VOH
V DD - 0.7
-
-
V
I/O Ports, IOH = -10mA, V DD = 5.0V
Output Low Voltage
V OL1
-
-
GND + 0.6
V
I/O Ports, IOL = 15mA, VDD = 5.0V
LCD Resistor
RON
-
5
-
kΩ
Input Low Voltage 2
V IL2
——---- --- ——
Input High Voltage 2
RST, T2, T3, T4, INT0/1/2/3/4, T2EX, RXD ,
TXD, FLT, V DD = 2.4 - 5.5V
SEG1 - 19, COM1 - 8, VDD = 3.6V - 5.0V
The voltage variation of V1, V2, V3 is less than 0 .2V
Note:
1. “∗” Data in “Typ.” Column is at 5.0V, 25°C, unless otherwise specified.
2. Maximum value of the supply current to VDD is 80mA.
3. Maximum value of the output current from GND is 100mA.
A/D Converter Electrical Characteristics (VDD = 3V, GND = 0V, T A = 25в„ѓ, Unless otherwise specified)
Parameter
Symbol
Min.
Typ.
Max.
Unit
Condition
Supply Voltage
V AD
2.5
3
3.5
V
Resolution
NR
-
10
-
bit
A/D Input Voltage
VAIN
GND
-
V REF
V
A/D Input Resistor*
RAIN
2
-
-
MΩ
Recommended
impedance of analog
voltage source
ZAIN
-
-
10
kΩ
A/D conversion current
IAD
-
1
3
mA
ADC module operating, VDD = 3.0V
A/D Input current
IADIN
-
-
10
ВµA
VDD = 3.0V
Differential linearity error
DLE
-
-
В± 1
LSB
fOSC = 12MHz, VDD = 3.0V
Integral linearity error
ILE
-
-
В± 2
LSB
fOSC = 12MHz, VDD = 3.0V
Full scale error
EF
-
В±1
В±3
LSB
fOSC = 12MHz, VDD = 3.0V
Offset error
EZ
-
В±0.5
В±3
LSB
fOSC = 12MHz, VDD = 3.0V
Total Absolute error
EAD
-
-
В±3
LSB
fOSC = 12MHz, VDD = 3.0V
Total Conversion time
TCON
14
-
-
tAD
GND ≤ V AIN ≤ V REF
VIN = 3.0V
10 bit Resolution, VDD = 3.0V, t AD = 1Вµs
Note: “∗” Here the A/D input Resistor is the DC input-resistance of A/D itself.
105
166A
SH79F
SH79F166A
AC Electrical Characteristics (VDD = 2.0V - 5.5V, GND = 0V, T A = 25В°C, fOSC = 12MHz, unless otherwise specified)
Parameter
Symbol
Min.
Typ.
Max.
Unit
TOSC
-
-
1
s
TOSC
-
1
2
ms
fOSC = 12MHz
RESET pulse width
t RESET
10
-
-
Вµs
Low active
WDT RC Frequency
f WDT
-
2
3
kHz
-
В±1
В±2
%
RC Oscillator
|F - 12MHz|/12MHz (V DD = 2.0 - 5.0V,
TA = -40В°C to +85В°C)
-
-
В±2
%
RC Oscillator
|F - 128kHz|/128kHz (VDD = 2.0 - 5.0V, T A = 25В°C)
Oscillator start time
Frequency Stability
(RC)
| ∆ F|/F
Condition
fOSC= 32.768kHz
Low Voltage Reset Electrical Characteristics (VDD = 2.0V - 5.5V, GND = 0V, TA = +25В°C, unless otherwise specified)
Parameter
Symbol
Min.
Typ.
Max.
Unit
Condition
LVR Voltage1
VLVR1
4.2
4.3
4.4
V
LVR1 enabled
LVR Voltage2
VLVR2
2.0
2.1
2.2
V
LVR1 enabled
Drop-Down Pulse
Width for LVR
TLVR
-
60
-
Вµs
12MHz crystal Electrical Characteristics
Parameter
Symbol
Min.
Typ.
Max.
Unit
Frequency
F12M
-
12
-
MHz
Capacitor
CL
-
12.5
-
pF
Condition
32.768kHz crystal Electrical Characteristics
Parameter
Symbol
Min.
Typ.
Max.
Unit
Frequency
F32k
-
32768
-
Hz
Capacitor
CL
-
12.5
-
pF
106
Condition
166A
SH79F
SH79F166A
11. Application
4 X 12 LCD Display
Power Supply
+12V
C1
C2
R1
D2
D1
3
U2
7805
2
C3
1
+5V
C4
C5
100kohm
+5V
COM1-4
VDD SEG1-12
100uF
100ohm
+5V
LCD
4X12
47uF/16V
0.1uF
VS
GND
OUT
0.1uF
GND
INT0
IR RECEIVER
NC
+12V
12pF
OSCXI
Y1
12pF
SH79F16
SH79F1666A
OSCXO
32.768kHz
P5.0
P5.1
P5.2
15kohm
15kohm
15kohm
15kohm
+5V
to relay
DRIVER
1
16
2
15
14
3
4
13
5
12
6
11
7
10
9
8
0.1uF
10kohm
10kohm
10kohm
10kohm
AN3
AN2
AN1
AN0
P0.1
P0.0
P2.7
P2.6
P2.5
P2.4
DRIVER
1
16
2
15
3
14
4
13
5
12
6
11
7
10
8
9
to relay
+12V
0.1uF
0.1uF
0.1uF
0.1uF
0.1uF
P0.2
P0.3
P0.5
P4.4
+12V
Temperature
sensor
KEY1
P3.4
KEY2
P3.5
KEY3
P3.6
KEY4
P3.7
107
BUZ
1kohm
166A
SH79F
SH79F166A
12. Ordering Information
Part No.
Package
SH79F166AF/044FR
QFP44
SH79F166AP/044PR
LQFP44
108
166A
SH79F
SH79F166A
13. Package Information
QFP 44 Outline Dimensions (BODY SIZE: 10*10)
unit: inch/mm
HD
D
33
11
23
E
1
GD
b 22
c
e
~
~
12
GE
34
HE
44
A2
Symbol
A
A1
A2
Dim ensions in inches
0.106 Max.
0.01 Min.
q
L
L1
A1
D
See Detail F
Seating Plane
y
A
GD
DETAIL F
Dim ensions in mm
2.70 Max.
0.02 Max.
0.079+0.008
-0.004
0.25 Min.
0.50 Max.
2.00+0.2
-0.1
b
0.012 Typ.
0.30 Typ.
C
0.006 В± 0.002
0.15 В± 0.05
D
0.394 В± 0.004
10.00 В± 0.10
E
0.394 В± 0.004
10.00 В± 0.10
e
0.031 Typ.
0.80 Typ.
GD
0.488 NO M.
12.40 NO M.
GE
0.488 NO M.
12.40 NO M.
HD
0.519 В± 0.008
13.20 В± 0.20
HE
0.519 В± 0.008
13.20 В± 0.20
L
0.035+0.002
-0.006
0.88+0.05
-0.15
L1
0.063 Typ.
1.60 Typ.
Y
0.004 Max.
0.10 Max.
Оё
0В° ~ 7В°
0В° ~ 7В°
Notes:
1. Dimensions D and E do not include resin fins.
2. Dimensions G D & GE are for PC Board surface mount pad pitch
design reference only.
109
166A
SH79F
SH79F166A
LQFP 44 Outline Dimensions
unit: inch/mm
HD
D
34
33
11
23
E
1
e
GD
22
c
b
~
~
12
HE
44
A
A2
GD
q
L1
A1
See Detail F
D
L
y
DETAIL F
Seating Plane
Symbol
Dimensions in inches
Dimensions in mm
A
MIN
0.057
MAX
0.065
MIN
1.45
MAX
1.65
A1
0.001
0.001
0.015
0.21
A2
0.051
0.059
1.3
1.5
D
0.388
0.396
9.85
10.15
E
0.388
0.396
9.85
10.15
HD
0.465
0.48
11.8
12.2
HE
0.465
0.48
11.8
12.2
b
0.01
0.014
0.25
e
c
0.031 TYP
0.35
0.8 TYP
0.005 TYP
0.127 TYP
L
0.017
0.028
0.42
0.78
L1
0.037
0В°
0.045
10В°
0.95
0В°
1.15
10В°
Оё
110
166A
SH79F
SH79F166A
14. Product SPEC. Change Notice
Version
Content
Date
2.1
Add LQFP44 package information
Modify the corresponding description of Baudrate including its computational formula
Modify clerical error
Add the description about using High frequency oscillator
Dec. 2013
2.0
Code option update
Modify the baud rate equation
May. 2012
1.0
Original
Mar. 2012
111
166A
SH79F
SH79F166A
Content
1.
FEATURES......................................................................................................................................................................................... 1
2.
GENERAL DESCRIPTION............................................................................................................................................................... 1
3.
BLOCK DIAGRAM............................................................................................................................................................................. 2
4.
PIN CONFIGURATION..................................................................................................................................................................... 3
5.
PIN DESCRIPTION............................................................................................................................................................................6
6.
SFR MAPPING................................................................................................................................................................................... 8
7.
NORMAL FUNCTION......................................................................................................................................................................18
7.1 CPU....................................................................................................................................................................................................... 18
7.1.1 CPU Core SFR............................................................................................................................................................................... 18
7.1.2 Enhanced CPU core SFRs............................................................................................................................................................. 19
7.1.3 Register ...........................................................................................................................................................................................19
7.2 RAM......................................................................................................................................................................................................20
7.2.1 Features..........................................................................................................................................................................................20
7.2.2 Register ...........................................................................................................................................................................................20
7.3 FLASH PROGRAM MEMORY................................................................................................................................................................... 21
7.3.1 Features..........................................................................................................................................................................................21
7.3.2 Flash Operation in ICP Mode........................................................................................................................................................22
7.4 SSP FUNCTION.......................................................................................................................................................................................24
7.4.1 SSP Register................................................................................................................................................................................... 24
7.4.2 Flash Control Flow........................................................................................................................................................................ 26
7.4.3 SSP Programming Notice ...............................................................................................................................................................27
7.5 SYSTEM CLOCK AND OSCILLATOR........................................................................................................................................................ 28
7.5.1 Features..........................................................................................................................................................................................28
7.5.2 Clock Definition............................................................................................................................................................................. 28
7.5.3 Description..................................................................................................................................................................................... 28
7.5.4 Register ...........................................................................................................................................................................................29
7.5.5 Oscillator Type...............................................................................................................................................................................30
7.5.6 Capacitor Selection for Oscillator ................................................................................................................................................. 31
7.6 SYSTEM CLOCK MONITOR (SCM ).........................................................................................................................................................32
7.7 I/O PORT................................................................................................................................................................................................ 33
7.7.1 Features..........................................................................................................................................................................................33
7.7.2 Register ...........................................................................................................................................................................................33
7.7.3 Port Diagram................................................................................................................................................................................. 35
7.7.4 Port Share.......................................................................................................................................................................................35
7.8 TIMER.....................................................................................................................................................................................................39
7.8.1 Features..........................................................................................................................................................................................39
7.8.2 Timer2............................................................................................................................................................................................ 39
7.8.3 Timer3............................................................................................................................................................................................ 45
7.8.4 Timer4............................................................................................................................................................................................ 47
7.8.5 Timer5............................................................................................................................................................................................ 50
7.9 INTERRUPT............................................................................................................................................................................................. 52
7.9.1 Feature........................................................................................................................................................................................... 52
7.9.2 Interrupt Enable Control................................................................................................................................................................52
7.9.3 Interrupt Flag.................................................................................................................................................................................55
7.9.4 Interrupt Vector..............................................................................................................................................................................57
7.9.5 Interrupt Priority............................................................................................................................................................................57
7.9.6 Interrupt Handling......................................................................................................................................................................... 58
7.9.7 Interrupt Response Time................................................................................................................................................................ 58
7.9.8 External Interrupt Inputs................................................................................................................................................................59
7.9.9 Interrupt Summary......................................................................................................................................................................... 59
8.
ENHANCED FUNCTION................................................................................................................................................................ 60
8.1 NORMAL RESISTOR LCD DRIVER......................................................................................................................................................... 60
8.1.1 Registers......................................................................................................................................................................................... 63
8.1.2 Configuration of LCD RAM........................................................................................................................................................... 66
8.2 LED DRIVER..........................................................................................................................................................................................67
8.2.1 Register ...........................................................................................................................................................................................67
8.2.2 Configuration of LED RAM........................................................................................................................................................... 68
8.3 PWM (PULSE WIDTH MODULATION)....................................................................................................................................................70
8.3.1 Feature........................................................................................................................................................................................... 70
8.3.2 PWM Module Enable..................................................................................................................................................................... 70
112
166A
SH79F
SH79F166A
8.3.3 PWM Timer Lock Register............................................................................................................................................................. 71
8.3.4 12-bit PWM Timer..........................................................................................................................................................................72
8.3.5 PWM01...........................................................................................................................................................................................74
8.3.6 Dead Time...................................................................................................................................................................................... 75
8.4 EUART..................................................................................................................................................................................................76
8.4.1 Feature........................................................................................................................................................................................... 76
8.4.2 EUART Mode Description..............................................................................................................................................................76
8.4.3 Baud Rate Generate....................................................................................................................................................................... 81
8.4.4 Multi-Processor Communication................................................................................................................................................... 81
8.4.5 Error Detection.............................................................................................................................................................................. 82
8.4.6 Register ...........................................................................................................................................................................................83
8.5 ANALOG DIGITAL CONVERTER (ADC)................................................................................................................................................. 86
8.5.1 Feature........................................................................................................................................................................................... 86
8.5.2 ADC Diagram................................................................................................................................................................................ 86
8.5.3 ADC Register ..................................................................................................................................................................................87
8.6 BUZZER.................................................................................................................................................................................................. 90
8.6.1 Feature........................................................................................................................................................................................... 90
8.6.2 Register ...........................................................................................................................................................................................90
8.7 LOW POWER DETECT (LPD)................................................................................................................................................................. 91
8.7.1 Feature........................................................................................................................................................................................... 91
8.7.2 Register ...........................................................................................................................................................................................91
8.8 LOW V OLTAGE RESET (LVR)................................................................................................................................................................92
8.8.1 Feature........................................................................................................................................................................................... 92
8.9 WATCHDOG TIMER (WDT) AND RESET S TATE.....................................................................................................................................93
8.9.1 Feature........................................................................................................................................................................................... 93
8.9.2 Register ...........................................................................................................................................................................................94
8.10 POWER MANAGEMENT........................................................................................................................................................................ 95
8.10.1 Feature......................................................................................................................................................................................... 95
8.10.2 Idle Mode......................................................................................................................................................................................95
8.10.3 Power-Down Mode.......................................................................................................................................................................95
8.10.4 Register .........................................................................................................................................................................................96
8.11 WARM-UP TIMER................................................................................................................................................................................. 97
8.11.1 Feature......................................................................................................................................................................................... 97
8.12 CODE OPTION...................................................................................................................................................................................... 98
9.
INSTRUCTION SET........................................................................................................................................................................ 99
10.
ELECTRICAL CHARACTERISTICS....................................................................................................................................... 104
ABSOLUTE MAXIMUM RATINGS*.............................................................................................................................................................. 104
DC E LECTRICAL CHARACTERISTICS (V DD = 2.0V - 5.5V, GND = 0V, TA = +25В°C, UNLESS OTHERWISE SPECIFIED).............................104
A/D CONVERTER E LECTRICAL CHARACTERISTICS (VDD = 3V, GND = 0V, T A = 25в„ѓ, UNLESS OTHERWISE SPECIFIED).......................105
AC E LECTRICAL CHARACTERISTICS (V DD = 2.0V - 5.5V, GND = 0V, TA = 25В°C, F OSC = 12MHZ, UNLESS OTHERWISE SPECIFIED)......106
LOW V OLTAGE RESET ELECTRICAL CHARACTERISTICS (V DD = 2.0V - 5.5V, GND = 0V, T A = +25В°C, UNLESS OTHERWISE SPECIFIED)
...................................................................................................................................................................................................................106
12MHZ CRYSTAL ELECTRICAL CHARACTERISTICS................................................................................................................................... 106
32.768KHZ CRYSTAL ELECTRICAL CHARACTERISTICS............................................................................................................................. 106
11.
APPLICATION............................................................................................................................................................................107
12.
ORDERING INFORMATION....................................................................................................................................................108
13.
PACKAGE INFORMATION ......................................................................................................................................................109
14.
PRODUCT SPEC. CHANGE NOTICE................................................................................................................................... 111
113
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement