Panasonic MN103S65G User Manual

MICROCOMPUTER MN103S
MN103S65G LSI Application Note Excerption
Pub.No.3326501-010E
PanaXSeries is a trademark of Matsushita Electric Industrial Co., Ltd. The other corporation names, logotype and product names written in this book are trademarks or registered trademarks of their corresponding corporations.
Request for your special attention and precautions in using the technical information
(1) An export permit needs to be obtained from the competent authorities of the Japanese Government if any of
the products or technologies described in this book and controlled under the "Foreign Exchange and Foreign Trade Law" is to be exported or taken out of Japan.
(2) The technical information described in this book is limited to showing representative characteristics and
applied circuits examples of the products. It neither warrants non-infringement of intellectual property right or any other rights owned by our company or a third party, nor grants any license.
(3) W e are not liable for the infringement of rights owned by a third party arising out of the use of the product or
technologies as described in this book.
(4) The products described in this book are intended to be used for standard applications or general electronic
equipment (such as office equipment, communications equipment, measuring instrument s and household appliances). Consult our sales staff in advance for information on the following applications:
• Special applications (such as for airplanes, aerospace, automobiles, traffic control equipment, combustion equipment, life support systems and safety devices) in which exceptional quality and reliability are required, or if the failure or malfunction of the products may directly jeopardize life or harm the human body.
• Any applications other than the standard applications intended.
(5) The products and product specifications described in this book are subject to change without notice for
modification and/or improvement. At the final stage of your design, purchasing, or use of the prod ucts, therefore, ask for the most up-to-date Product Standards in advance to make sure that the latest specifications satisfy your requirements.
(6) When designing your equipment, comply with the guaranteed values, in particular those of maximum rating,
the range of operating power supply volta ge, and heat radiation characteristics. Otherwise, we will not be liable for any defect which may arise later in your equipment. Even when the products are used within the guaranteed values, take into the consideration of incidence of break down and failure mode, possible to occur to semiconductor products. Measures on the systems such as redundant design, arresting the spread of fire or preventing glitch are recommended in order to prevent physical injury, fire, social damages, for example, by using the products.
(7) When using products for which damp-proof packing is required, observe the conditions (including shelf life
and amount of time let standing of unsealed items) agreed upon when specification sheets are individually exchanged.
(8) This book may be not reprinted or reproduced whether wholly or partially, without the prior written
permission of Matsushita Electric Industrial Co., Ltd.
If you have any inquiries or questions about this book or our semiconductors, please contact one of our sales offices listed at the back of this book.
Table of Contents
About This Manual
Composition of this book This LSI application note explains in order of the sample program which used the program collection which uses the
circumference circuit of MN103S65G loading, and 3-phase PWM.
Composition as a manual
This book is roughly divided and consists of a title, the text, a sample program, an inclusion directory, cautions
information, and reference information.
Next, the layout and definition of each portion are shown.
1.Inside title
2.Small title
It is the minimum block of this book.
3.Text
4.Sample program
5.Inclusion directory The inclusion directory is shown although the sample program is recorded on CD-ROM.
The example of this page is a
thing for explanation. It differs from an actual page.
2-7 Port0
A port 0 is general-purpose 8-bit input/output port, and can set up input and output per bit.
a port 0 -- input and output -- also in which setup, addition of a pull-up resistor is possible
Moreover, it can be used as a terminal of the serial communication 0 and the serial communication 1 as a special
function.
The bit 0-2 is made to serve a double purpose as an input-and-output terminal of the serial communication 0.
The bit 3-5 is made to serve a double purpose as an input-and-output terminal of the serial communication 2.
A bit 6-7 can be used as an input-and-output terminal as it is.
When using serial communication, a serial output signal terminal is set as an "output."
It is [ following ] a sample program.
/* Declaration of control data When using the serial communication 0,
the serial communication 0 carries out a UART setup and a clock for monitors,
and it is an output setup. Other bits are input-set up. */
#define p0port 0x05 /* 0b00000101 Serial output Other inputs */
#define p0pulup 0x00 /* 0b00000000 A pull-up is not carried out for all.*/
/* Declaration of control data When using serial ports 0 and 2,
the serial communication 0 carries out a UART setup and a clock for monitors,
and it is an output setup.
The serial communication 2 is synchronous system and a slave setup.
Other bits are input-set up. */
#define p0port 0x0D /* 0b00001101 Bit0(CH0S),2(CH0CK),3(CH2S) */
#define p0pulup 0x00 /* 0b00000000 A pull-up is not carried out for all.*/
/* Declaration of the register address*/
#define P0OUT_adr 0x3F10
#define P0OUT (*(volatile unsigned char *)P0OUT_adr)
#define P0IN_adr 0x3F20
#define P0IN (*(volatile unsigned char *)P0IN_adr)
#define P0DIR_adr 0x3F30
#define P0DIR (*(volatile unsigned char *)P0DIR_adr)
#define P0PLU_adr 0x3F40
#define P0PLU (*(volatile unsigned char *)P0PLU_adr)
/* Setting program*/
P0DIR = p0port;
P0PLU = p0pulup;
This sample is recorded on CD-ROM.
Inclusion directory:SAMPLE\INITIAL\ASM\IOPORT\PORT0\
Inclusion directory:SAMPLE\INITIAL\C\IOPORT\PORT0\
Panasonic
2-7 Input and output, a peripheral initial
IV
Table of Contents
Chapter1 Power supply injection
(power-onboot)Initialization of
the memory at the time
Chapter2 Each peripheral initial by C
Chapter3 The sample program in a
sample circuit
1
2
3
Chapter4 Appendix
4
VII
Table of Contents
Chapter1 Initialization of the memory at the time of a power supply injection
(power-on boot)
Chapter2 Each peripheral initial by C
2-1 About description of C and an assembler............................................................................................................2-2
2-2 Interruption, a peripheral initial............................................................................................................................2-4
2-2-1 Interruption control register......................................................................................................................2-4
2-2-2 Interruption level (multiplex interruption)...............................................................................................2-6
2-3 The Interruption Processing Method................................................................................................................. 2-7
2-3-1 Interrupt vector table
2-3-2 Interruption group handler routine..................................................................................................... 2-7
2-3-3 Interruption processing program........................................................................................................ 2-7
2-3-4 The check of interruption................................................................................................................... 2-7
2-4 A 8-bit 16-bit timer, a peripheral initial ...............................................................................................................2-30
2-4-1 The various registers of a 8-bit timer.......................................................................................................2-30
2-4-2 The various registers of a 16-bit timer.....................................................................................................2-40
2-5 Serial communication, a peripheral initial...........................................................................................................2-51
2-5-1 The various registers of serial communication (channels 0 and 1)........................................................2-51
2-5-2 The various registers of serial communication (channel 2)....................................................................2-53
2-6 PWM for motor control........................................................................................................................................2-63
2-7 The initial of I/O Port ........................................................................................................................................ 2-70
2-7-1 Port0 ..........................................................................................................................................................2-71
2-7-2 Port1 ..........................................................................................................................................................2-71
2-7-3 Port2 ..........................................................................................................................................................2-72
2-7-4 Port3 ..........................................................................................................................................................2-73
2-7-5 Port4 ..........................................................................................................................................................2-74
2-7-6 Port5 ..........................................................................................................................................................2-75
2-7-7 Port6 ..........................................................................................................................................................2-76
2-7-8 Port7 ..........................................................................................................................................................2-77
2-7-9 Port8 ..........................................................................................................................................................2-78
2-7-10 Port9 ........................................................................................................................................................2-79
2-8 Noise filter function ................................................................................................................................................2-87
2-9 A/D conversion, a peripheral initial....................................................................................................................... 2-91
2-9-1 The various registers of A/D conversion.................................................................................................2-91
.......................................................................................................................... 2-7
VIII
Table of Contents
Chapter 3 The sample program in a sample circuit
3-1 The outline of a sample circuit............................................................................................................................. 3-2
3-2 Composition of a sample program...................................................................................................................... 3-2
3-2-1 Sample program specification ................................................................................................................. 3-2
3-2-2 Composition of a sample program.......................................................................................................... 3-2
3-3 The set point about each processing in a sample program, and its explanation ...............................................3-3
3-3-1 Interruption processing (others [ - / external interruption and timer serial ])........................................ 3-3
3-3-2 Timer processing ...................................................................................................................................... 3-4
3-3-3 Processing about input/output port.......................................................................................................... 3-4
Chapter4 Appendix
4-1 Flash microcomputer............................................................................................................................................4-2
4-2 Purpose-oriented initialization............................................................................................................................. 4-3
4-3 Such at the time ....................................................................................................................................................4-4
4-4 About use of MAKE............................................................................................................................................ 4-6
4-5 The notes on circuitry........................................................................................................................................... 4-7
4-5-1 About supply voltage ............................................................................................................................... 4-7
4-5-2 About an analog input terminal............................................................................................................... 4-7
4-6 The notes on program creation............................................................................................................................ 4-7
4-6-1 Memory space.......................................................................................................................................... 4-7
4-7 The usage of C compiler...................................................................................................................................... 4-8
4-8 Class figure ........................................................................................................................................................... 4-10
4-9 Reference circuit diagram.................................................................................................................................... 4-11
IX
Loading...
+ 12 hidden pages