Chapter 916-bit TimerUp/Down Counting IX - 519.6.2 Setup Example■ Up/Down Counting Setup ExampleThe binary counter counts up when the external input signal(TM8AIO) is “H” and counts down when it is “L” attiming of the timer 8 count clock. The count clock is IOCLK, and the oscillator frequency is set to 10 MHz, 6multiplication and IOCLK=MCLK/2. A setup procedure with a description of each step is shown below.The binary counter counts up when the TM8AIO pin is set to “H”, and counts down when the TM8AIO pin is setto “L”. The binary counts up or down according to the condition of the pin.Setup Procedure Description(1) Stop the counterTM8MD(0x0000A200)bp6: TMLDE=0bp7: TMCNE=0(1) Set the TMLDE flag and the TMCNE flag of the timer 8mode register (TM8MD) to the timer 8 counting.(2) Select the count clock sourceTM8MD(0x0000A200)bp2-0: TMCK2-0=000(2) Select the count clock source (IOCLK) by the TMCK2-0flag of the TM8MD register.(3) Select the timer up/downTM8MD(0x0000A200)bp9-8: TMUD1-0=10(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 inputat “L” level input.(4) Set the timer counter clear enabledTM8MD(0x0000A200)bp11: TMCLE=1(4) Set the TMCLE flag of the TM8MD register to “1” toenable the clear operation of the TM8BC register. TheTM8BC counter is cleared.(5) Set the input pin (pin function)P3MD(0x0000A033)bp6: P36M=1(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 input pin (I/O function)P3DIR(0x0000A023)bp0: P36D=0(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) Initialize the timer 8TM8MD(0x0000A200)bp6: TMLDE=1(7) Set the TMLDE flag of the TM8MD register to “1” toinitialize the timer 8. The value of the binary counter(TM8BC) is initialized to 0x0000. Reset the TMLDE flagto “0” after setting.(8) Start the timer operationTM8MD(0x0000A200)bp7: TMCNE=1(8) Set the TMCNE flag of the TM8MD register to “1” tooperate the timer 8.