ZUD-CC-07-0235-E
January, 2008
1st Product Solution Group, Multipurpose Microcomputer Systems Division,
Microcomputer Operations Unit
NEC Electronics Corporation
© NEC Electronics Corporation 2008
78K0R/Kx3 Microcontroller
Sample Program
Operation Manual
(Master Transmission/Reception
(Serial Interface IIC0), C Source)
This software is for reference only and NEC Electronics does not guarantee its operation.
Thoroughly evaluate this software on your set prior to use.
Sample Program (Master Transmission/Reception (Serial Interface IIC0), C Source) Operation Manual (78K0R/Kx3 Microcontroller)
2
ZUD-CC-07-0235-E
The information in this document is current as of January, 2008. The information is subject to
change without notice. For actual design-in, refer to the latest publications of NEC Electronics data
sheets or data books, etc., for the most up-to-date specifications of NEC Electronics products. Not
all products and/or types are available in every country. Please check with an NEC Electronics sales
representative for availability and additional information.
No part of this document may be copied or reproduced in any form or by any means without the prior
written consent of NEC Electronics. NEC Electronics assumes no responsibility for any errors that may
appear in this document.
NEC Electronics does not assume any liability for infringement of patents, copyrights or other intellectual
property rights of third parties by or arising from the use of NEC Electronics products listed in this document
or any other liability arising from the use of such products. No license, express, implied or otherwise, is
granted under any patents, copyrights or other intellectual property rights of NEC Electronics or others.
Descriptions of circuits, software and other related information in this document are provided for illustrative
purposes in semiconductor product operation and application examples. The incorporation of these
circuits, software and information in the design of a customer's equipment shall be done under the full
responsibility of the customer. NEC Electronics assumes no responsibility for any losses incurred by
customers or third parties arising from the use of these circuits, software and information.
While NEC Electronics endeavors to enhance the quality, reliability and safety of NEC Electronics products,
customers agree and acknowledge that the possibility of defects thereof cannot be eliminated entirely. To
minimize risks of damage to property or injury (including death) to persons arising from defects in NEC
Electronics products, customers must incorporate sufficient safety measures in their design, such as
redundancy, fire-containment and anti-failure features.
NEC Electronics products are classified into the following three quality grades: "Standard", "Special" and
"Specific".
The "Specific" quality grade applies only to NEC Electronics products developed based on a customer-
designated "quality assurance program" for a specific application. The recommended applications of an NEC
Electronics product depend on its quality grade, as indicated below. Customers must check the quality grade of
each NEC Electronics product before using it in a particular application.
The quality grade of NEC Electronics products is "Standard" unless otherwise expressly specified in NEC
Electronics data sheets or data books, etc. If customers wish to use NEC Electronics products in applications
not intended by NEC Electronics, they must contact an NEC Electronics sales representative in advance to
determine NEC Electronics' willingness to support a given application.
(Note)
•
•
•
•
•
•
M8E 02. 11-1
(1)
(2)
"NEC Electronics" as used in this statement means NEC Electronics Corporation and also includes its
majority-owned subsidiaries.
"NEC Electronics products" means any product developed or manufactured by or for NEC Electronics (as
defined above).
Computers, office equipment, communications equipment, test and measurement equipment, audio
and visual equipment, home electronic appliances, machine tools, personal electronic equipment
and industrial robots.
Transportation equipment (automobiles, trains, ships, etc.), traffic control systems, anti-disaster
systems, anti-crime systems, safety equipment and medical equipment (not specifically designed
for life support).
Aircraft, aerospace equipment, submersible repeaters, nuclear reactor control systems, life
support systems and medical equipment for life support, etc.
"Standard":
"Special":
"Specific":
Sample Program (Master Transmission/Reception (Serial Interface IIC0), C Source) Operation Manual (78K0R/Kx3 Microcontroller)
3
ZUD-CC-07-0235-E
CONTENTS
1.
OVERVIEW........................................................................................................................................................................4
2. RESOURCES USED .........................................................................................................................................................5
3. SOFTWARE CONFIGURATION........................................................................................................................................6
4. FUNCTION EXPLANATIONS............................................................................................................................................7
5. FLOWCHARTS..................................................................................................................................................................9
Sample Program (Master Transmission/Reception (Serial Interface IIC0), C Source) Operation Manual (78K0R/Kx3 Microcontroller)
4
ZUD-CC-07-0235-E
1. OVERVIEW
This manual explains the sample program functions of a master operation by a single-master system with serial interface
IIC0 for the 78K0R/Kx3.
In this sample program, a master operation by a single-master system is performed with serial interface IIC0.
The communication conditions are as follows.
• f
CLK = 20 MHz
• Transmission format
• Number of transmit data: 1
• Number of receive data: 2
• Transmit data: A9H
• Receive data: Any
• Slave address: A0H
• INTIIC0 (Interrupt of end of IIC0 communication servicing) is used.
• The following communication format is assumed.
ST + ADR/W + DT + ST + ADR/R + DT + DT + SP
ST: Start condition
SP: Stop condition
ADR/W: Slave address + W
ADR/R: Slave address + R
DT: Data
When this sample program is actually used, the transmission format must conform to the specifications of the product that
is communicating.