152
CHAPTER 5 APPLICATIONS OF 16-BIT TIMER/EVENT COUNTER
5.4 One-Shot Pulse Output
The 16-bit timer/event counter has a function which outputs a one-shot pulse in synchronization with a software
trigger and external trigger (INTP0/TI00/P00 pin input).
When using the one-shot pulse output function, the 16-bit timer mode control register (TMC0), capture/compare
control register 0 (CRC0), and 16-bit timer output control register (TOC0) must be set.
In this section, an example for setting the one-shot pulse by using the software trigger is introduced.
The OSPT flag (bit 6 of the TOC0 register) is set at arbitrary timing (such as key input).
After the software trigger has occurred, TM0 is cleared and started. When the value of TM0 coincides with the
value set in advance to CR01, the TO0/P30 pin output is inverted (and becomes active). When the value of TM0
later coincides with the value set in advance to CR00, the TO0/P30 pin output is inverted again (and becomes inactive).
The TM0 counter is cleared and counting up is started again after the value of TM0 has coincided with the value of
CR00. The output of the TO0/P30 pin, however, is not inverted even if coincidence occurs next time. TM0 is cleared
and started and the output of the TO0/P30 pin is inverted only when the software trigger is set. The active level of
the TO0/P30 pin is determined by selecting the initial value of the TO0/P30 pin output of the TOC0 register.
Note that, when using the one-shot pulse output function with the software trigger, the OSPT flag must not be set
to 1 while the one-shot pulse is output. To output the one-shot pulse again, do so after INTTM00, which is an interrupt
request that occurs when TM0 coincides with CR00, has occurred.
In the example presented in this section, the software trigger is designed by using key input, and “H” active output
is produced 10 ms after for 1 ms.