Chapter 916-bit TimerIX - 46 Event Count9.5.2 Setup Example■ Event Count Setup ExampleIf the rising edge of the TM8BIO input pin is detected 5 times with the timer 8, an interrupt is generated. Anexample setup procedure, with a description of each step is shown below.Setup Procedure Description(1) Stop the counterTM8MD(0x0000A200)bp6: TMLDE=0bp7: TMCNE=0(1) Set the TMLDE flag and TMCNE flag of the timer 8mode register (TM8MD) to “0” to stop the timer 8counting.(2) Disable the interruptG7ICR(0x0000891C)bp8: G7IE1=0(2) Set the G7IE1 flag of the G7ICR register to “0” to disablethe interrupt.(3) Set the interrupt generation cycleTM8CA(0x0000A208)=0x0004(3) Set the interrupt generation cycle to the timer 8compare/capture register (TM8CA). The setting valueis 4(0x0004) due to 5 times.(4) Select the count clock sourceTM8MD(0x0000A200)bp2-0: TMCK2-0=111(4) Select the count clock source(TM8BIO pin) by theTMCK2-0 flag of the TM8MD register.(5) Select the timer up/downTM8MD(0x0000A200)bp9-8: TMUD1-0=00(5) Select the timer up count by the TMUD1-0 flag of theTM8MD register.(6) Set the timer counter clear enabledTM8MD(0x0000A200)bp11: TMCLE=1(6) Set the TMCLE flag of the TM8MD register to “1” toenable the clear operation of the TM8BC counter.When the TM8CA register and the TM8BC countermatch, the TM8BC counter is cleared.(7) Select the timer compare/capture Aoperation modeTM8MDA(0x0000A204)bp7-6: TMAM1-0=00(7) Set the function of the timer 8 compare/capture registerto the compare register (double buffer ) by the TMAM1-0 flag of the timer 8 compare/capture A mode register(TM8MDA).(8) Select the timer B pin polarityTM8MDB(0x0000A205)bp5: TMBEG=0(8) Set the edge (rising edge or falling edge) at single edgeof the input pin of the count clock source to “0” by theTMBEG flag of the timer 8 compare/capture B moderegister(TM8MDB); then, set the rising edge.(9) Initialize the timer 8TM8MD(0x0000A200)bp6: TMLDE=1(9) Set the TMLDE flag of the TM8MD register to “1” toinitialize the binary counter. Reset the TMLDE flag to“0” after setting.(10) Set the interrupt levelG7ICR(0x0000891C)bp14-12: G7LV2-0=100(10) Set the interrupt level by the G7LV2-0 flag of the G7ICRregister. If the interrupt request flag has been setalready , clear the request flag.