Panasonic MN101CP49K, MN101C49K, MN101C49G, MN101CF49K, MN101C49H User Manual

Page 1
MICROCOMPUTER MN101C
MN101C49G/49H/49K/F49K/P49K LSI Application Notes Excerption
Pub.No.3144911-031E
Page 2
Request for your special attention and precautions in using the technical information and
semiconductors described in this book
(1) If any of the products or technical information described in this book is to be exported or provided to non-residents, the
laws and regulations of the exporting country, especially, those with regard to security export control, must be observ ed.
(2) The technical information described in this book is intended only to show the main characteristics and application circuit
examples of the products, and no license is granted under any intellectual property right or other right owned by our company or any other company. Therefore, no responsibility is assumed by our company as to the infringement upon any such right owned by any other company which may arise as a result of the use of technical information described in this book.
(3) 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 ins truments and household appliances). Consult our sales staff in advance for information on the following applications: x 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. x Any applications other than the standard applications intended.
(4) 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 de sign, pur chasing, o r use of the p roducts, therefore , ask for the mo st up-to­date Product Standards in advance to make sure that the latest specifications satisfy your requirements.
(5) When designing your equipment, comply with the range of absolute maximum rating and the guaranteed operating condi-
tions (operating power supply voltage and operating environment etc.). Especially, please be careful not to exceed the range of absolute maximum rating on the transient state, such as power-on, power-off and mode-switching. 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 dam­ages, for example, by using the products.
(6) Comply with the instructions for use in order to prevent breakdown and characteristics change due to external factors
(ESD, EOS, thermal stress and mechanical stress) at the time of handling, mounting or at customer's process. When using products for which damp-proof packing is required, satisfy the conditions, such as shelf life and the elapsed time since first opening the packages.
(7) This book may be not reprinted or reproduced whether wholly or partially, without the prior written permission of Mat-
sushita Electric Industrial Co., Ltd.
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.
Page 3

About This Manual

■ Configuration of This Manual
This LSI application note is consists of the following sections.
Chapter 1 Overview
This chapter describes the overview of this application note.
Chapter 2 Startup Program
This chapter describes a startup process necessary for executing a program.
Chapter 3 Register Setup of Each Function
This chapter describes the setting method and setting examples of registers having MN101C49LSI function.
Chapter 4 Sample Program 1
This chapter describes sample programs for using each peripheral device referring to sample circuits.
Chapter 5 Sample Program 2
This chapter provides an explanation of a startup process necessary before executing a sample program in "5.1 Startup", and an explanation of sample programs utilizing basic functions of this LSI in "5.2 Sample Program Using Timer Function" and "5.3 Sample Program Using Serial Function". Each sample program is described following the sections below.
(1) Program operation and display (2) Function used (3) State transition diagram (4) Software
Chapter 6 Appendix 1
This chapter provides a circuit diagram operated in "Chapter 3 Register Setup of Each Function" and "Chapter 4 Sample Program 1" and supplementary explanations.
Chapter 7 Appendix 2
This chapter describes a sample program file organization and directory block diagram of "Chapter 5 Sampler Program 2", and Makefile.
Page 4
■ Related Manuals
Note that the following related documents are available.
"MN101C49G/49H/49K/F49K/P49K LSI User's Manual" "MN101C Series C Compiler User's Manual: Language Description"
<Describes the syntax of the C Compiler.>
"MN101C Series C Compiler User's Manual: Library Reference"
<Describes the standard library of the C Compiler.>
"MN101C/MN101E Series C Compiler User's Manual: Usage Guide"
<Describes the installation, the commands, and options of the C Compiler.>
"MN101C/MN101E Series Cross-assembler User's Manual"
<Describes the assembler syntax and notation.>
"MN101C Series Instruction Manual"
<Describes the instruction set.>
Page 5
Chapter 1 Overview
Chapter 2 Startup Program
Chapter 3
Chapter 4 Sample Program 1
Chapter 5 Sample Program 2
Register Setup of Each Function
1 2 3
4
5
Chapter 6 Appendix 1
Chapter 7 Appendix 2
6 7
Page 6

Table of Contents

Chapter 1 Overview..................................................................................................................................................... 13
1.1 Overview........................................................................................................................................................... 14
1.2 Startup Program.................................................................................................................................................14
1.3 Register Setup of Each Function.......................................................................................................................14
1.4 Sample Program 1.............................................................................................................................................14
1.5 Sample Program 2.............................................................................................................................................14
1.6 Appendix 1 / Appendix 2...................................................................................................................................14
1.7 Development Environment of Sample Program................................................................................................15
1.7.1 Development environment of sample program 1....................................................................................... 15
1.7.2 Development environment of sample program 2....................................................................................... 16
Chapter 2 Startup Program........................................................................................................................................... 17
2.1 Overview........................................................................................................................................................... 18
2.2 Startup Processing............................................................................................................................................. 18
2.2.1. Memory area (Section) ......................................................................................................................... 18
2.2.2 Declaration for section............................................................................................................................... 19
2.2.3 Setting stack area....................................................................................................................................... 19
2.2.4 Clear area to be used to 0 ...........................................................................................................................19
2.2.5 Initializing static variables with initial values............................................................................................19
Chapter 3
Register Setup of Each Function
3.1 Description of C and Assembly Languages....................................................................................................... 22
3.2 Operation mode/Initializing Peripherals............................................................................................................ 24
3.2.1 Memory control register.............................................................................................................................24
3.2.2 Expansion address control register.............................................................................................................25
3.2.3 Oscillation frequency register....................................................................................................................26
3.2.4 CPU mode control register.........................................................................................................................27
3.3 Memory, Initializing Peripheral.........................................................................................................................30
3.3.1 Address bank register.................................................................................................................................30
3.3.2 ROM correction register............................................................................................................................ 31
3.4 Operation State Transition, Initializing Peripherals........................................................................................... 34
........................................................................................................................21
3.4.1 Oscillation stabilization wait control register.............................................................................................34
3.5 Interrupt, Initializing Peripherals.......................................................................................................................36
3.5.1 Interrupt control register............................................................................................... ............................. 36
3.5.2 Noise filter control register........................................................................................................................ 42
3.5.3 Both edges interrupt control register.......................................................................................................... 43
3.5.4 Key interrupt control register..................................................................................................................... 44
Page 7
3.6 How to Interrupt................................................................................................................................................ 45
3.6.1 Interrupt vector table..................................................................................................................................45
3.6.2 Interrupt processing programs....................................................................................................................47
3.6.3 Checking interrupt .....................................................................................................................................47
3.7 Input/Output, Initializing Peripherals................................................................................................................ 48
3.7.1 Port 0..........................................................................................................................................................49
3.7.2 Port 1..........................................................................................................................................................50
3.7.3 Port 2..........................................................................................................................................................51
3.7.4 Port 3..........................................................................................................................................................51
3.7.5 Port 4..........................................................................................................................................................52
3.7.6 Port 5..........................................................................................................................................................53
3.7.7 Port 6..........................................................................................................................................................54
3.7.8 Port 7..........................................................................................................................................................55
3.7.9 Port 8..........................................................................................................................................................56
3.7.10 Port A....................................................................................................................................................... 56
3.7.11 Port C.......................................................................................................................................................57
3.7.12 Port D....................................................................................................................................................... 58
3.8 Prescaler, Initializing Peripherals......................................................................................................................59
3.8.1 Prescaler control register............................................................................................................................59
3.8.2 Timer prescaler selection register .............................................................................................................. 59
3.8.3 Serial interface transfer clock selection register.........................................................................................60
3.9 8-bit Timer, Initializing Peripherals...................................................................................................................62
3.9.1 Types of setting for 8-bit timer .................................................................................................................. 64
3.9.2 Setting for cascade connection...................................................................................................................70
3.9.3 Setting remote control carrier output operation..........................................................................................72
3.10 16-bit Timer, Initializing Peripherals...............................................................................................................75
3.10.1 Types of setting for 16-bit timer..............................................................................................................76
3.11 Initializing Free Run Time Base Timer, Initializing Peripherals.....................................................................82
3.11.1 Time base timer .......................................................................................................................................82
3.11.2 Free run timer...........................................................................................................................................83
3.12 Watchdog Timer, Initializing Peripherals........................................................................................................ 84
3.13 Buzzer, Initializing Peripherals.......................................................................................................................86
3.14 Serial Communication, Initializing Peripherals............................................................................................... 88
3.14.1
Setting asynchronous (UART) communication (Half duplex, Full duplex)
3.14.2 Setting synchronous (SYSNC) communication..................................................................................... 101
3.14.3 Handling on communication errors........................................................................................................ 105
...............................................98
Page 8
3.14.4 Setting communication speed for UART...............................................................................................106
3.14.5 Notes and applications related to communication channel.....................................................................106
3.15 Data Transfer Function, Initializing Peripherals............................................................................................108
3.15.1 Setting in individual modes....................................................................................................................110
3.16 A/D Conversion, Initializing Peripherals.......................................................................................................113
3.17 D/A Conversion, Initializing Peripherals.......................................................................................................116
3.18 Access Cycle Timing Variable Function, Initializing Peripherals................................................................. 118
Chapter 4 Sample Program 1.....................................................................................................................................119
4.1 Overview of Sample Circuit ................................................................................................. ........................... 120
4.2 Sample Program Features................................................................................................................................ 129
4.2.1 Sample program features.........................................................................................................................129
4.2.2 Basic operation of sample program..........................................................................................................129
4.2.3 Structure of sample program.................................................................................................................... 131
4.2.4 Descriptions of individual functions........................................................................................................ 131
4.3 Switching States between Operation Mode and Sleep Mode...........................................................................147
4.3.1 Processing during initialization................................................................................................................147
4.3.2 Operation mode switching processing.....................................................................................................147
4.4
Set Values and Descriptions Related to Individual Processes in Sample Program
4.4.1 Initializing................................................................................................................................................ 149
4.4.2 Interrupt processing (external interrupt, timer, serial and other).............................................................. 151
4.4.3 Timer processing......................................................................................................................................152
4.4.4 Serial communication processing ............................................................................................................ 154
4.4.5 A/D converter processing.........................................................................................................................156
4.4.6 Processing for data transfer...................................................................................................................... 156
4.4.7 Processing for input/output ports............................................................................................................. 157
Chapter 5 Sample Program 2.....................................................................................................................................159
5.1 Startup.............................................................................................................................................................160
5.1.1 Overview..................................................................................................................................................160
5.1.2 Startup processing.................................................................................................................................... 160
5.1.3 Startup program.......................................................................................................................................160
....................................................................149
5.2 Sample Program Using Timer Function.......................................................................................................... 163
5.2.1 Timer program......................................................................................................................................... 163
5.2.2 Stopwatch program.................................................................................................................................. 165
5.2.3 Time matching program........................................................................................................................... 179
5.2.4 Roulette program .....................................................................................................................................191
5.2.5 Slot program ............................................................................................................................................ 205
Page 9
5.3 Sample Program Using Serial Function...........................................................................................................219
5.3.1 Serial program..........................................................................................................................................219
5.3.2 Serial program 1.......................................................................................................................................222
5.3.3 Serial program 2.......................................................................................................................................235
Chapter 6 Appendix 1................................................................................................................................................251
6.1 Description on Functions Not Used in This Sample........................................................................................ 252
6.2 Initializing Based on Applications...................................................................................................................254
6.3 Trouble Shooting ............................................................................................................................................. 255
6.4 Notes on Designing Circuit.............................................................................................................................258
6.4.1 Selecting high speed clock crystal oscillator............................................................................................ 258
6.4.2 Selecting low speed clock crystal oscillator............................................................................................. 258
6.4.3 Analog input pins..................................................................................................................................... 258
6.4.4 Analog output .......................................................................................................................................... 258
6.5 Notes on Designing Program........................................................................................................................... 259
6.6 How to Use C Language Compiler..................................................................................................................259
6.7 Using MAKE...................................................................................................................................................261
6.8 CD Directory Tree........................................................................................................................................... 262
6.9 Circuit Diagram............................................................................................................................................... 264
6.10 Connection Diagram...................................................................................................................................... 266
Chapter 7 Appendix 2................................................................................................................................................269
7.1 Program File Composition...............................................................................................................................270
7.2 Makefile .......................................................................................................................................................... 271
7.2.1 Makefile format.......................................................................................................................................271
7.2.2 Makefile list............................................................................................................................................. 272
7.3 Directory Block Diagram................................................................................................................................275
Page 10
Chapter 3 Register Setup of Each Function

3.9 8-bit Timer, Initializing Peripherals

There are five 8-bit timers comprising timer 0 to 4. The timer comprises a binary counter, a compare register and a mode register. You can combine two 8-bit timers, timer 0 and 1 or 2 and 3, to use as a 16-bit timer.
Binary counter
This counter counts a clock selected by the prescaler or the mode register.
Compare register
This register determines the time base of a timer by specifying clock number counted by the binary counter.
Mode register
This register enables/disables the timer operation, and selects the clock source. The setting content of the mode register depends on the timer.
Timer 0:
BIT7: Unused BIT6: Unused BIT5: "0" Normal operation
"1" P22(IRQ2), pulse width measurement
BIT4: "0" Normal operation
"1" PWM operation
BIT3: "0" Stop count
"1" Count operation BIT2, 1, 0: Clock source selection 000: High speed crystal clock oscillation frequency 001: Timer 0, prescaler output signal 010: Low speed crystal clock oscillation frequency 011: Synchronous low speed crystal clock oscillation frequency 110: Timer 0, pin input external signal 111: Synchronous timer 0, pin input external signal
62
Timer 1:
BIT7: Not used BIT6: Not used BIT5: Not used BIT4: "0" Normal operation
"1" Cascade connection
Page 11
Chapter 3 Register Setup of Each Function
BIT3: "0" Stop count
"1" Count operation
BIT2, 1, 0: Clock source selection
000:
High speed crystal clock oscillation frequency
001: Timer 1, prescaler output signal 010: Low speed crystal clock oscillation frequency 011: Synchronous low speed crystal clock oscillation frequency 110: Timer 1, pin input external signal 111: Synchronous timer 1, pin input external signal
Timer 2:
BIT7: Unused BIT6: Unused BIT5: "0" Normal operation
"1" P23(IRQ3), pulse width measurement BIT4: "0" Normal operation
"1" PWM operation BIT3: "0" Stop count
"1" Count operation BIT2, 1, 0: Clock source selection
000: High speed crystal clock oscillation frequency 001: Timer 2, prescaler output signal 010: Low speed crystal clock oscillation frequency 011: Synchronous low speed crystal clock oscillation frequency 110: Timer 2, pin input external signal 111: Synchronous timer 2, pin input external signal
Timer 3:
BIT7: Unused BIT6: Unused BIT5: Unused BIT4: "0" Normal operation
"1" Cascade connection BIT3: "0" Stop count
"1" Count operation BIT2, 1, 0: Clock source selection
000: High speed crystal clock oscillation frequency
63
Page 12
Chapter 3 Register Setup of Each Function
001: Timer 3, prescaler output signal 010: Low speed crystal clock oscillation frequency 011: Synchronous low speed crystal clock oscillation frequency 110: Timer 3, pin input external signal 111: Synchronous timer 3, pin input external signal
Timer 4:
BIT7: Unused BIT6: Unused BIT5: "0" Normal operation
"0" P24(IRQ4), pulse width measurement BIT4: "0" Normal operation
"1" PWM operation BIT3: "0" Stop count
"1" Count operation BIT2, 1, 0: Clock source selection
000: High speed crystal clock oscillation frequency 001: Timer 4, prescaler output signal 010: Low speed crystal clock oscillation frequency 011: Synchronous low speed crystal clock oscillation frequency 110: Timer 4, pin input external signal 111: Synchronous timer 4, pin input external signal
The synchronization synchronizes with the timing of the system clock. See the "LSI User’s Manual".

3.9.1 Types of setting for 8-bit timer

Interval timer
You can apply interval timer setting to all 8-bit timers ranging from the timer 0 to 4. Your source clock selection and compare register setting determines the generation cycle of the timer interrupt. The timer generates the interrupt on the next count after it matches the set value on the compare register, then clears the count. You write a count which is equivalent to a period setting minus 1 to the compare register.
64
The following is the example for setting the interval timer with 10 milli seconds.
To set to the interval timer with 10 milli seconds, convert the time base to the frequency first. Formula: 1 / 10 milli seconds = 100 Hz
Setting by using
high speed oscillation clock:
The prescaler can set the high speed oscillation clock to 4, 16, 32 or 64 divisions.
Page 13
Chapter 3 Register Setup of Each Function
20 MHz / 64 = 312500 312500 / 100 = 3125 This setting is not available with the 8-bit timer.
Setting by using
The following section describes a sample program.
/* Control data declaration */ #define TM0MOD 0x00 #define TM0PWM 0x00 #define TM0EN 0x08 #define TM0CK 0x01
/* Determine time for interval timer */ #define TM0PSC 0x00 #define TIME
/* Register address declaration */ #define TM0BC_adr 0x3F50 #define TM0BC #define TM0OC_adr 0x3F52 #define TM0OC #define TM0MD_adr 0x3F54 #define TM0MD #define CK0MD_adr 0x3F56 #define CK0MD
/* Setting program */
CK0MD = TM0PSC; TM0OC = TIME; TM0MD = TM0MOD | TM0PWM | TM0EN | TM0CK;
This sample is stored in the CD.
low speed oscillation clock:
32.768 kHz/ 4 = 8192 8192 / 100 = 81.92 = approx. 82 If you set the formula 82 1 = 81, the interval timer with 10 milli seconds will be set.
/* 0b00000000 Normal timer operation */ /* 0b00000000 Timer operation */ /* 0b00001000 Count operation */ /* 0b00000001 Prescaler output */
/* 4 division setting */
81 /* Timer count value */
(*(volatile unsigned char *)TM0BC_adr)
(*(volatile unsigned char *)TM0OC_adr)
(*(volatile unsigned char *)TM0MD_adr)
(*(volatile unsigned char *)CK0MD_adr)
/* Set prescaler */ /* Set timer value */
Stored directory: Sample\chapter3,4\Initial\ASM\TIMER\INTERVAL8\ Stored directory: Sample\chapter3,4\Initial\C\TIMER\INTERVAL8\
Event count
The event count uses a binary counter to count an external signal supplied from the timer pin. You can set a measurement count value to the compare register for generating an interrupt as for the interval timer.
The following section describes a sample program.
/* Control data declaration */ #define TM0CAS 0x00 /* 0b00000000 Normal timer operation */ #define TM0EN 0x08 /* 0b00001000 Count operation */ #define TM0CK 0x06 /* 0b00000110 External input signal */
/* Set value to interrupt, interrupt on 5th signal */ #define COUNT 0x04
/* Register address declaration */ #define TM0BC_adr 0x3F50
65
Page 14
Chapter 3 Register Setup of Each Function
#define TM0BC (*(volatile unsigned char *)TM0BC_adr) #define TM0OC_adr 0x3F52 #define TM0OC (*(volatile unsigned char *)TM0OC_adr) #define TM0MD_adr 0x3F54 #define TM0MD (*(volatile unsigned char *)TM0MD_adr) #define CK0MD_adr 0x3F56 #define CK0MD (*(volatile unsigned char *)CK0MD_adr)
/* Setting program*/ /* Operation is based on external signal, and prescaler is not set */ TM0OC = COUNT; /* Set timer value */ TM0MD = TM0CAS | TM0EN | TM0CK;
This sample is stored in the CD. Stored directory: Sample\chapter3,4\Initial\ASM\TIMER\EVENT8\ Stored directory: Sample\chapter3,4\Initial\C\TIMER\EVENT8\
Timer pulse output setting
The timer pulse output can provide a pulse signal at an arbitrary frequency. The period of the timer pulse output is twice as long as the period set on the compare register. To provide timer pulse, set the output mode register (special register) of the port 1 to the timer output, and set the input/output setting register to output. See "3.7.2 Port 1".) The timer setting for timer pulse output setting is identical to that for the inte rval timer.
PWM operation
The PWM output generates the PWM basic component and provides it from the timer output pin when the binary counter and the compare register of a timer match or on the overflow timing of the binary counter. Since the PWM output uses the overflow of the binary counter, you can use only the frequency component generated by the overflow of the timer. The resolution of the PWM output is fixed to the one 255th due to the 8-bit counter. The PWM output provides "1" until it counts up to the count set on the compare register after count start (00), and then provides "0" until it overflows after the match to the compare register. Since the frequency components use the timer overflow, they are determined by the prescaler setting. This sample uses the low speed oscillation clock (assuming its oscillation is at 32.768 kHz) to set the 1/4 duty output for the 128 Hz frequency.
66
Page 15
TMxIO (x is the timer
number)
Chapter 3 Register Setup of Each Function
Compare register value
8-bit timer overflow cycle
128 Hz
Figure 3 8-bit timer PWM operation timing chart
The following section describes a sample program.
/* Control data declaration */ #define TM4MOD 0x00
#define TM4PWM 0x10 #define TM4EN 0x08 #define TM4CK 0x02 /* 32.768 kHz / 256 = 128 Hz */
/* Determine width for High period of PWM output */ #define TIME
/* Register address declaration */ #define TM4BC_adr 0x3F60 #define TM4BC #define TM4OC_adr 0x3F62 #define TM4OC #define TM4MD_adr 0x3F64 #define TM4MD #define CK4MD_adr 0x3F66 #define CK4MD
/* Setting program */
TM4OC = TIME; TM4MD = TM4MOD | TM4PWM | TM4EN | TM4CK;
This sample is stored in the CD.
64 /* 1/4 duty (64/256)*/
/* 0b00000000 Pulse width measurement control (normal timer
operation)*/ /* 0b00010000 PWM operation */ /* 0b00001000 Count operation */ /* 0b00000010 Use low speed oscillation clock*/
(*(volatile unsigned char *)TM4BC_adr)
(*(volatile unsigned char *)TM4OC_adr)
(*(volatile unsigned char *)TM4MD_adr)
(*(volatile unsigned char *)CK4MD_adr)
/* Set pulse width */
Stored directory: Sample\chapter3,4\Initial\ASM\TIMER\PWM\ Stored directory: Sample\chapter3,4\Initial\C\TIMER\PWM\
Synchronous output operation
The synchronous output operation provides the output from the port D at the count up timing of the timer. You can use the timer 1 and 2 for the synchronous output. You use the port D to set the synchronous output operation. See "3.7.12 Port D".) You can use the timer setting both in the interval timer mode and event count mode. You can also set
67
Page 16
Chapter 3 Register Setup of Each Function
the interval output for the interval timer.
Serial interface transfer clock generation
You can use the ouput signal from a timer to generate a serial transfer clock. You can use the interval timer and timer output setting to set the timer.
The following timers are available for the serial interface communication.
Timer 2 Timer 3 Timer 4 Serial 0 Available Not available Available Serial 1 Not available Not available Available Serial 2 Not available Available Not available Serial 3 Not available Available Not available
When you use the timer as transfer clock for the serial interface communication, the transfer speed will be the half of the setting value. Declare the setting value in advance because it varies depending on the communication transfer speed. This sample uses the case when the communication transfer speed is 19200 bps. See the setting value list of the serial interface transfer speed in the LSI User's Manual for the setting value.
The following section describes a sample program.
/* Control data declaration */ #define TM2MOD 0x00 */ #define TM2PWM 0x00 #define TM2EN 0x08 /* Control data declaration */ /* 1200 baud */ #define S12 #define C12 #define CK12 /* 2400 baud */ #define S24 #define C24 #define CK24 /* 4800 baud */ #define S48 #define C48 #define CK48 /* 9600 baud */
#define S96 #define C96 #define CK96 /* 19200 baud */ #define S192 #define C192 #define CK192 0x00 /* Link set values above */ /* For 19200 baud */ #define TM2CK CK192 #define TM2PSC S192 #define TIME
0x01 0x64 0x01
0x00 0x129 0x01
0x00 0x64 0x01
0x00 0x129 0x00
0x00 0x64
C192
/* 0b00000000 Pulse width measurement control (normal timer operation)
/* 0b00000000 Timer operation */ /* 0b00001000 Count operation */
/* 16 divisions */
/* Prescaler input */
/* 4 divisions */
/* Prescaler input */
/* 4 divisions */
/* Prescaler input */
/* 4 divisions */
/* Clock direct input */
/* 4 divisions */
/* Clock direct input */
/* */ /* Clock source */ /* Timer count value */
68
Page 17
/* Register address declaration */ #define TM2BC_adr 0x3F58 #define TM2BC #define TM2OC_adr 0x3F5A #define TM2OC #define TM2MD_adr 0x3F5C #define TM2MD #define CK2MD_adr 0x3F5E #define CK2MD
/* Setting program */
CK2MD = TM2PSC; TM2OC = TIME; TM2MD = TM2MOD | TM2PWM | TM2EN | TM2CK;
This sample is stored in the CD. Stored directory: Sample\chapter3,4\Initial\ASM\TIMER\Sclock\ Stored directory: Sample\chapter3,4\Initial\C\TIMER\Sclock\
(*(volatile unsigned char *)TM2BC_adr)
(*(volatile unsigned char *)TM2OC_adr)
(*(volatile unsigned char *)TM2MD_adr)
(*(volatile unsigned char *)CK2MD_adr)
Simple pulse width measurement
The simple pulse width measurement uses timer count to measure the pulse width when the interrupt input
Chapter 3 Register Setup of Each Function
/* Set prescaler */ /* Set timer value */
signal stays "Low". 3 timers, timers 0, 2, and 4, are available for the simple pulse width measurement.
The following section describes a sample program.
/* Control data declaration */ #define TM0MOD 0x20 #define TM0PWM 0x00 #define TM0EN 0x08
/* Determine time for interval timer */ #define TIME
/* Register address declaration */ #define TM0BC_adr 0x3F50 #define TM0BC #define TM0OC_adr 0x3F52 #define TM0OC #define TM0MD_adr 0x3F54 #define TM0MD #define CK0MD_adr 0x3F56 #define CK0MD
/* Setting program */ TM0OC = TIME; TM0MD = TM0MOD | TM0PWM | TM0EN | TM0CK;
This sample is stored in the CD. Stored directory: Sample\chapter3,4\Initial\ASM\TIMER\PLUSE8\
0xFF
/* 0b00100000 Pulse width measurement */ /* 0b00000000 Timer operation */ /* 0b00001000 Count operation */
/* Timer count value, maximum value */
(*(volatile unsigned char *)TM0BC_adr)
(*(volatile unsigned char *)TM0OC_adr)
(*(volatile unsigned char *)TM0MD_adr)
(*(volatile unsigned char *)CK0MD_adr)
/* Set timer value (counter clear) */
Stored directory: Sample\chapter3,4\Initial\C\TIMER\PLUSE8\
69
Page 18
Inquiries
If you have questions regarding technical information on this manual, please visit the following URL.
User Support Team Semiconductor Company Matsushita Electric Industrial Co., Ltd.
URL: http://panasonic.co.jp/semicon/e-micom/inquiry
For inquiries regarding Microcomputer,
Microcomputer Web site
We offer you technical information regarding microcomputers at http://panasonic.co.jp/semicon/e-micom.
Microcomputer Manual Download Site
http://panasonic.co.jp/semicon/e-micom/manual
We upload LSI User's Manuals and Tool Manuals in PDF format at URL above.
For inquiries on microcomputer technical information
http://panasonic.co.jp/semicon/e-micom/inquiry
We inform you of an e-mail address for inquires per LSI model at URL above. Please send your inquires according to your microcomputer model.
MN101C49G/49H/49K/F49K/P49K
LSI Application Notes Excerption
June, 2005 3rd Edition 1st Printing
Issued by Matsushita Electric Industrial Co., Ltd
2005 Matsushita Electric Industrial Co., Ltd. All Rights Reserved
Page 19

SALES OFFICES

NORTH AMERICA
U.S.A. Sales Office: Panasonic Industrial Company [PIC] New Jersey Office:
2 Panasonic Way Secaucus, New Jersey 07094, U.S.A.
Chicago Office:
1707 N. Randall Road Elgin, Illinois 60123-7847, U.S.A.
San Jose Office:
2033 Gateway Place, Suite 200, San Jose, California 95110, U.S.A
Atlanta Office:
1225 Northbrook Parkway Suite 1-151 Suwanee, Georgia 30024, U.S.A.
San Diego Office:
9444 Balboa Avenue, Suite 185, San Diego, California 92123, U.S.A. Tel:1-858-503-2910 Fax:1-858-715-5545
Panasonic Canada Inc. [PCI]
5770 Ambler Drive 27 Mississauga, Ontario L4W 2T3, Canada
Tel:1-201-348-5257 Fax:1-201-392-4652
Tel:1-847-468-5720 Fax:1-847-468-5725
Tel:1-408-487-9510 Fax:1-408-436-8037
Tel:1-770-338-6953 Fax:1-770-338-6849
Canada Sales Office:
Tel:1-905-238-2243 Fax:1-905-238-2414
LATIN AMERICA
Mexico Sales Office: Panasonic de Mexico, S.A. de C.V. [PANAMEX]
Amores 1120 Col. Del Valle Delegacion Benito Juarez C.P. 03100 Mexico, D.F. Mexico
Guadalajara Office:
Sucursal Guadarajara Av. Lazaro Cardenas 2305 Local G-102 Plaza Comercial Abastos; Col. Las Torres Guadalajara, Jal. 44920, Mexico
Brazil Sales Office: Panasonic do Brasil Ltda. [PANABRAS]
Caixa Postal 1641, Sao Jose dos Campos, Estado de Sao Paulo, Brasil
Tel:52-5-488-1000 Fax:52-5-488-1073
Tel:52-3-671-1205 Fax:52-3-671-1256
Tel:55-12-3935-9000 Fax:55-12-3931-3789
EUROPE
Europe Sales Office: Panasonic Industrial Europe GmbH [PIE] Germany Sales Office:
Hans-Pinsel-Strasse 2 85540 Haar, Germany
Tel:49-89-46159-119 Fax:49-89-46159-195
ASIA
Singapore Sales Office:
Panasonic Semiconductor Sales Asia [PSCSA]
300 Beach Road, #16-01, the Concourse, Singapore 199555, the Republic of Singapore
Malaysia Sales Office:
Panasonic Industrial Company (M) Sdn. Bhd. [PICM]
Head Office:
15th Floor, Menara IGB, Mid Valley City, Lingkaran Syed Putra, 59200 Kuala Lumpur, Malaysia
Penang Office:
Suite 20-07,20th Floor, MWE Plaza, No.8, Lebuh Farquhar,10200 Penang, Malaysia
Johore Sales Office:
Menara Pelangi, Suite8.3A, Level8, No.2, Jalan Kuning, Taman Pelangi, 80400 Johor Bahru, Johor, Malaysia
Thailand Sales Office:
Panasonic Industrial (Thailand) Ltd. [PICT]
252-133 Muang Thai-Phatra Complex Building, 31st Floor Rachadaphisek Road, Huaykwang, Bangkok 10320, Thailand
Philippines Sales Office:
Panasonic Industrial Sales Philippines [PISP]
102 Laguna Boulevard,Bo.Don Jose Laguna Technopark, Santa. Rosa, Laguna 4026, the Philippines
China Sales Office:
Panasonic Semiconductor Sales (China) [PSCSCH]
Panasonic Industrial (China) Co., Ltd.
Semiconductor Group
Floor 12, China Insurance Building, 166 East Road Lujiazui, Pudong New District, Shanghai 200120, China
Panasonic Industrial (Tianjin) Co., Ltd.
Semiconductor Group
Room No.1001, Tianjin International Building, 75 Nanjing Road, Tianjin 300050, China
Panasonic SH Industrial Sales (Shenzhen) Co., Ltd.
Semiconductor Group (Shum Yip Centre Office)
25F, Shum Yip Centre, #5045, East Shennan Road, Shenzhen 518010, China
Panasonic Shun Hing Industrial Sales (Hong Kong) Co., Ltd.
Semiconductor Group
11th Floor, Great Eagle Centre, 23 Harbour Road, Wanchai, Hong Kong
Taiwan Sales Office:
Panasonic Industrial Sales (Taiwan) Co.,Ltd. [PIST]
Head Office:
6F, 550, Sec. 4, Chung Hsiao E. RD. Taipei 110, Taiwan
Kaohsiung Office:
6th Floor, Hsin Kong Bldg. No.251, Chi Hsien 1st Road, Kaohsiung 800, Taiwan
Korea Sales Office:
Panasonic Industrial Korea Co., Ltd. [PIKL]
Kukje Center Bldg. 11th Floor, 191 Hangangro 2ga, Youngsan-ku, Seoul 140-702, Korea
Tel:65-6390-3688 Fax:65-6390-3689
Tel:60-3-2297-6888 Fax:60-6-2284-6898
Tel: 60-4-201-5113 Fax:60-4-261-9989
Tel:60-7-331-3822 Fax:60-7-355-3996
Tel:66-2-693-3400 to 3421 Fax:66-2-693-3422 to 3427
Tel:63-2-520-8615 Fax:63-2-520-8629
Tel:86-21-6841-9642 Fax:86-21-6841-9631
Tel:86-22-2313-9771 Fax:86-22-2313-9770
Tel:86-755-8211-0888 Fax:86-755-8211-0970
Tel:852-2529-7322 Fax:852-2865-4455
Tel:886-2-2757-1900 Fax:886-2-2757-1906
Tel:886-7-346-3815 Fax:886-7-236-8362
Tel:82-2-795-9600 Fax:82-2-795-1542
Semiconductor Company, Matsushita Electric Industrial Co., Ltd.
Nagaokakyo, Kyoto 617-8520, Japan
Tel:075-951-8151
070305 Printed in Japan
http://panasonic.co.jp/semicon/e-index.html
Loading...