EM78P330/331NxJ/xS
8-Bit Microprocessor
with OTP ROM
Product
Specification
D
OC
. V
ERSION
1.1
ELAN MICROELECTRONICS CORP.
March 2007
Trademark Acknowledgments:
IBM is a registered trademark and PS/2 is a trademark of IBM.
Windows is a trademark of Microsoft Corporation.
ELAN and ELAN logo
are trademarks of ELAN Microelectronics Corporation.
Copyright
©
2007 by ELAN Microelectronics Corporation
All Rights Reserved
Printed in Taiwan
The contents of this specification are subject to change without further notice. ELAN Microelectronics assumes no
responsibility concerning the accuracy, adequacy, or completeness of this specification. ELAN Microelectronics
makes no commitment to update, or to keep current the information and material contained in this specification.
Such information and material may change to conform to each confirmed order.
In no event shall ELAN Microelectronics be made responsible for any claims attributed to errors, omissions, or
other inaccuracies in the information or material contained in this specification. ELAN Microelectronics shall not
be liable for direct, indirect, special incidental, or consequential damages arising from the use of such information
or material.
The software (if any) described in this specification is furnished under a license or nondisclosure agreement, and
may be used or copied only in accordance with the terms of such agreement.
ELAN Microelectronics products are not intended for use in life support appliances, devices, or systems. Use of
ELAN Microelectronics product in such applications is not supported and is prohibited.
NO PART OF THIS SPECIFICATION MAY BE REPRODUCED OR TRANSMITTED IN ANY FORM OR BY
ANY MEANS WITHOUT THE EXPRESSED WRITTEN PERMISSION OF ELAN MICROELECTRONICS.
ELAN MICROELECTRONICS CORPORATION
Headquarters:
No. 12, Innovation Road 1
Hsinchu Science Park
Hsinchu, Taiwan 30077
Tel: +886 3 563-9977
Fax: +886 3 563-9966
http://www.emc.com.tw
Hong Kong:
Elan (HK) Microelectronics
Corporation, Ltd.
Flat A, 19F., World Tech Centre
95 How Ming Street, Kwun Tong
Kowloon , HONG KONG
Tel: +852 2723-3376
Fax: +852 2723-7780
elanhk@emc.com.hk
Shenzhen:
Elan Microelectronics
Shenzhen, Ltd.
SSMEC Bldg., 3F, Gaoxin S. Ave.
Shenzhen Hi-Tech Industrial Park
Shenzhen, Guandong, CHINA
Tel: +86 755 2601-0565
Fax: +86 755 2601-0500
USA:
Elan Information
Technology Group (USA)
1821 Saratoga Ave., Suite 250
Saratoga, CA 95070
USA
Tel: +1 408 366-8225
Fax: +1 408 366-8220
Shanghai:
Elan Microelectronics
Shanghai, Ltd.
23/Bldg. #115 Lane 572, Bibo Road
Zhangjiang Hi-Tech Park
Shanghai, CHINA
Tel: +86 21 5080-3866
Fax: +86 21 5080-4600
Contents
Contents
1
2
3
4
5
General Description .................................................................................................. 1
Features ..................................................................................................................... 1
Pin Assignment ......................................................................................................... 2
Functional Block Diagram........................................................................................ 3
Pin Description.......................................................................................................... 4
5.1
6
EM78P330N ....................................................................................................... 4
5.2 EM78P331N ....................................................................................................... 5
Function Description ................................................................................................ 6
6.1
Operational Registers......................................................................................... 6
6.1.1
6.1.2
6.1.3
6.1.4
6.1.5
6.1.6
6.1.7
6.1.8
6.1.9
6.1.10
6.1.11
6.1.12
6.1.13
6.1.14
6.1.15
6.1.16
6.1.17
6.1.18
6.1.19
6.1.20
6.1.21
6.1.22
6.1.23
6.1.24
6.1.25
6.1.26
6.1.27
6.1.28
6.1.29
6.1.30
R0 (Indirect Address Register) ...........................................................................6
R1 (Time Clock/Counter).....................................................................................6
R2 (Program Counter) and Stack........................................................................6
6.1.3.1 Data Memory Configuration .................................................................8
R3 (Status Register) ............................................................................................9
R4 (RAM Select Register)...................................................................................9
R5 ~ R8 (Port 5 ~ Port 8) ..................................................................................10
R9 (TMR4: Timer 4 Register) ............................................................................10
RA (SPIRB: SPI Read Buffer) ...........................................................................10
RB (SPIWB: SPI Write Buffer)...........................................................................10
RC (SPIS: SPI Status Register) ........................................................................10
RD (SPIC: SPI Control Register) ......................................................................11
RE (WUCR: Wake-up Control Register) ...........................................................12
RF (Interrupt Status Register) ...........................................................................13
R10 ~ R3F .........................................................................................................14
Bank 1 R5 (PWM Control Register #1) .............................................................14
Bank 1 R6 (PWM Control Register 2) ...............................................................15
Bank1 R7 (PWM Timer/Counter Control Register) ...........................................16
Bank1 R8 (PRD1H: Most Significant Byte of PWM1 Time Period).........................16
Bank1 R9 (PRD2H: Most Significant Byte of PWM2 Time Period).........................16
Bank1 RA (PRD3H: Most Significant Byte of PWM3 Time Period).........................16
Bank1 RB (PRDL: Least Significant Bits of PWM Period Cycle) ......................17
Bank 1 RC (DT1H: Most Significant Byte of PWM1 Duty Cycle)......................17
Bank 1 RD (DT2H: Most Significant Byte of PWM2 Duty Cycle)......................17
Bank1 RE (DT3H: Most Significant Byte of PWM3 Duty Cycle) .......................17
Bank1 RF (DTL: Least Significant Bits of PWM Duty Cycle) ............................17
Bank 2 R6 (BOCON: Buzzer Output Control Register).....................................18
Bank 2 R7 (System Control Register) ...............................................................19
Bank 2 R8 (AISR: ADC Input Select Register)..................................................20
Bank 2 R9 (ADCON: ADC Control Register) ....................................................21
Bank 2 RA (ADOC: ADC Offset Calibration Register).......................................22
Product Specification (V1.1) 03.13.2007
•iii
Contents
6.1.31
6.1.32
6.1.33
6.1.34
6.1.35
6.1.36
6.1.37
6.1.38
6.1.39
6.1.40
6.1.41
6.1.42
6.1.43
6.1.44
6.1.45
6.1.46
Bank 2 RB (ADDATA: Converted Value of ADC) ..............................................23
Bank 2 RC (ADDATA1H: Converted Value of ADC)..........................................23
Bank 2 RD (ADDATA1L: Converted Value of ADC) ..........................................23
Bank 2 RE (LVDC: LVD Control Register ) .......................................................24
Bank 2 RF (TMR3H: Most Significant Bits of PWM3 Timer) .............................24
Bank3 R5 (Pull-low Control Register 1) ............................................................24
Bank 3 R6 (Pull-Low Control Register 2) ..........................................................25
Bank3 R7 (Pull-Low Control Register 3) ...........................................................25
Bank3 R8 (Pull-low Control Register 4) ............................................................26
Bank3 R9 (Pull-High Control Register 1) ..........................................................26
Bank 3 RA (Pull-High Control Register 2) .........................................................26
Bank 3 RB (Pull-high Control Register 3)..........................................................27
Bank 3 RC (Pull-high Control Register 4) .........................................................27
Bank 3 RD (TMR1H: Most Significant Bits of PWM1 Timer).............................28
Bank 3 RE (TMR2H: Most Significant Bits of PWM2 Timer).............................28
Bank 3 RF (TMRL: Least Significant Bits of PWM Timer).................................28
A (Accumulator).................................................................................................28
CONT (Control Register)...................................................................................28
IOC5 ~ IOC8 (I/O Port Control Register) ..........................................................29
IOC9 (T4CON: Timer 4 Control Register) .........................................................29
IOCA (TCMPCON: Comparator Control Register)............................................30
IOCE (WDT Control Register) ...........................................................................30
IOCF (Interrupt Mask Register).........................................................................32
6.2
Special Purpose Registers ............................................................................... 28
6.2.1
6.2.2
6.2.3
6.2.4
6.2.5
6.2.6
6.2.7
6.3
6.4
6.5
TCC/WDT and Prescaler.................................................................................. 33
I/O Ports ........................................................................................................... 34
6.4.1
6.5.1
6.5.2
6.5.3
6.5.4
6.5.5
6.5.6
Usage of Port 6 Input Change Wake-up/Interrupt Function..............................37
Overview and Features .....................................................................................37
SPI Function Description..................................................................................39
SPI Signal and Pin Description .........................................................................41
Programming the Related Registers .................................................................42
SPI Mode Timing ...............................................................................................45
SPI Software Application ...................................................................................46
Overview ...........................................................................................................48
Function Description..........................................................................................48
Programming the Related Registers .................................................................49
Reset and Wake-up Operation..........................................................................50
6.7.1.1 Wake-up and Interrupt Mode Operation Summary ............................53
6.7.1.2 Register Initial Values after Reset ......................................................55
6.7.1.3 Controller Reset Block Diagram.........................................................62
The T and P Status under Status Register ........................................................63
Product Specification (V1.1) 03.13.2007
Serial Peripheral Interface Mode...................................................................... 37
6.6
Timer 4 ............................................................................................................. 48
6.6.1
6.6.2
6.6.3
6.7
Reset and Wake-up.......................................................................................... 50
6.7.1
6.7.2
iv•
Contents
6.8
6.9
Interrupt ............................................................................................................ 63
Analog-to-Digital Converter (ADC) ................................................................... 65
6.9.1
ADC Control Register (AISR/Bank 2 R8, ADCON/ Bank 2 R9,
ADOC/ Bank 2 RA) ............................................................................................65
6.9.1.1 Bank 2 R8 (AISR: ADC Input Select Register)...................................65
6.9.1.2 Bank 2 R9 (ADCON: ADC Control Register) .....................................66
6.9.1.3 Bank 2 RA (ADOC: ADC Offset Calibration Register)........................68
ADC Data Register (ADDATA/Bank 2 RB, ADDATA1H/Bank 2 RC,
ADDATA1L/Bank 2 RD) .....................................................................................68
ADC Sampling Time ..........................................................................................68
AD Conversion Time .........................................................................................68
ADC Operation during Sleep Mode...................................................................69
Programming Process/Considerations..............................................................69
6.9.6.1 Programming Process........................................................................69
6.9.6.2 Sample Demo Programs ....................................................................70
Overview ...........................................................................................................72
Increment Timer Counter ..................................................................................73
PWM Time Period .............................................................................................73
PWM Duty Cycle ...............................................................................................74
Comparator X ....................................................................................................74
PWM Programming Process/Steps...................................................................74
6.9.2
6.9.3
6.9.4
6.9.5
6.9.6
6.10 Dual Sets of PWM (Pulse Width Modulation) ................................................... 72
6.10.1
6.10.2
6.10.3
6.10.4
6.10.5
6.10.6
6.11 Timer ................................................................................................................ 74
6.11.1 Overview ...........................................................................................................74
6.11.2 Function Description..........................................................................................75
6.11.3 Programming the Related Registers .................................................................76
6.11.3.1 Related Control Registers of TMR1, TMR2, and TMR3.....................76
6.11.4 Timer Programming Process/Steps...................................................................76
6.12 Comparator ...................................................................................................... 76
6.12.1
6.12.2
6.12.3
6.12.4
6.12.5
6.13.1
6.13.2
6.13.3
6.13.4
External Reference Signal ................................................................................77
Comparator Outputs..........................................................................................77
Using Comparator as an Operation Amplifier....................................................78
Comparator Interrupt .........................................................................................78
Wake-up from Sleep Mode................................................................................78
Oscillator Modes................................................................................................78
Crystal Oscillator/Ceramic Resonators (Crystal)...............................................79
External RC Oscillator Mode.............................................................................80
Internal RC Oscillator Mode ..............................................................................81
6.13 Oscillator .......................................................................................................... 78
6.14 Power-on Considerations ................................................................................. 82
6.14.1 External Power-on Reset Circuit .......................................................................82
6.14.2 Residual Voltage Protection ..............................................................................83
6.15 LVD (Low Voltage Detector) ............................................................................. 84
Product Specification (V1.1) 03.13.2007
•v