Setup Example - Panasonic MN103S User Manual

Panaxseries
Hide thumbs Also See for MN103S:
Table of Contents

Advertisement

9.6.2

Setup Example

Up/Down Counting Setup Example
The binary counter counts up when the external input signal(TM8AIO) is "H" and counts down when it is "L" at
timing of the timer 8 count clock. The count clock is IOCLK, and the oscillator frequency is set to 10 MHz, 6
multiplication and IOCLK=MCLK/2. A setup procedure with a description of each step is shown below.
Setup Procedure
(1) Stop the counter
TM8MD(0x0000A200)
bp6: TMLDE=0
bp7: TMCNE=0
(2) Select the count clock source
TM8MD(0x0000A200)
bp2-0: TMCK2-0=000
(3) Select the timer up/down
TM8MD(0x0000A200)
bp9-8: TMUD1-0=10
(4) Set the timer counter clear enabled
TM8MD(0x0000A200)
bp11: TMCLE=1
(5) Set the input pin (pin function)
P3MD(0x0000A033)
bp6: P36M=1
(6) Set the input pin (I/O function)
P3DIR(0x0000A023)
bp0: P36D=0
(7) Initialize the timer 8
TM8MD(0x0000A200)
bp6: TMLDE=1
(8) Start the timer operation
TM8MD(0x0000A200)
bp7: TMCNE=1
The binary counter counts up when the TM8AIO pin is set to "H", and counts down when the TM8AIO pin is set
to "L". The binary counts up or down according to the condition of the pin.
(1) Set the TMLDE flag and the TMCNE flag of the timer 8
mode register (TM8MD) to the timer 8 counting.
(2) Select the count clock source (IOCLK) by the TMCK2-0
flag of the TM8MD register.
(3) Set the TMUD1-0 flag of the TM8MD register to "10";
and, select up counting when the TMnAIN pin is at "H"
level and down counting when the TMnAIN pin is input
at "L" level input.
(4) Set the TMCLE flag of the TM8MD register to "1" to
enable the clear operation of the TM8BC register. The
TM8BC counter is cleared.
(5) Set the P36M flag of the port 3 output mode register
(P3MD) to "1" to set the port to pin function.
(6) Set the P36D flag of the port 3 I/O control register
(P3DIR) to "0" to set the port to the input pin.
(7) Set the TMLDE flag of the TM8MD register to "1" to
initialize the timer 8. The value of the binary counter
(TM8BC) is initialized to 0x0000. Reset the TMLDE flag
to "0" after setting.
(8) Set the TMCNE flag of the TM8MD register to "1" to
operate the timer 8.
Description
Up/Down Counting
Chapter 9
16-bit Timer
IX - 51

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mn103sa7dMn103sa7g

Table of Contents