Chapter 88-bit TimerTimer Output Function VIII - 378.5.2 Setup Example■ Timer Output Setup ExampleThe TM1IO pin outputs 100 KHz pulse by using timer 1. In order to output 100 KHz, select IOCLK for a countclock source, and set 1/2 cycle (200 KHz) to the timer 1 base register.An example setup procedure, with a description of each step is shown below.Figure:8.5.2 Output Waveform of TM1IO pinTM1BC starts to count down from 0x95. When an underflow occurs, the signal of theTM1IO output pin isinverted; and, TM1BC starts to count down from 0x95 again.Setup Procedure Description(1) Check the counter stoppedTM1MD (0x0000A181)bp6: TM1LDE=0bp7: TM1CNE=0(1) Set the TM1LDE flag and the TM1CNE flag of the timer1 mode register (TM1MD) to “0” to stop timer 1counting.(2) Set the TM1IO pin to output and modeP3MD (0x0000A033)bp1: P31M=1P3DIR (0x0000A023)bp1: P31D=1(2) Set the P3MD flag of the port 3 mode register (P31M) to“1” for TM1IO pin setting.Set the P31D flag of the port 3 I/O control register(P3DIR) to “1” for output pin setting.(3) Set 1/2 cycle for timer outputTM1BR(0x0000A189)=0x95(3) Set 1/2 cycle of the timer output to the timer 1 baseregister (TM1BR). The setting value is 149 (0x95) dueto 200KHz. Setting value = (10MHZ × 2/6) / 200KHz -1(4) Select the count clock sourceTM1MD(0x0000A181)bp2-0: TM1CK2-0=000(4) Select IOCLK to the count clock source by the TM1CK2-0 flag of the TM1MD register.(5) Initialize timer 1TM1MD(0x0000A181)bp6: TM1LDE=1(5) Set the TM1LDE flag of the TM1MD register to “1” toinitialize timer 1. The value of the TM1BR register isloaded to the TM1BC counter; and, output of TM1IOchanges “L”. Reset the TM1LDE flag to “0”.(6) Start the timer operationTM1MD (0x0000A181)bp7: TM1CNE=1(6) Set the TM1CNE flag of the TM1MD register to “1” tooperate timer 1.100KHzTMOIO output