« Close

Datasheets and User Guides

App Notes

Software & Driver - Timer Stop Input (Mode 9)

This mode should only be assigned to Timer1.  On every rising edge seen by the external pin, this mode increments a 16-bit register.  When that register matches the specified timer value (stop count value), Timer0 is stopped.  The range for the stop count value is 1-65535.  Generally, the signal applied to Timer1 is from Timer0, which is configured in some output timer mode.  One place where this might be useful is for stepper motors, allowing control over a certain number of steps.

Note that the timer is counting from the external pin like other input timer modes, so you must connect something to the stop timer input pin.  For example, if you are using Timer1 to stop Timer0 which is outputting pulses, you must connect a jumper from Timer0 to Timer1.

Once this timer reaches the specified stop count value, and stops the adjacent timer, the timers must be reconfigured to restart the output.

When Timer0 is stopped, it is still enabled but just not outputting anything.  Thus rather than returning to whatever previous digital I/O state was on that terminal, it goes to the state "digital-input" (which has a 100 kΩ pull-up to 3.3 volts).  That means the best results are generally obtained if the terminal used by Timer0 was initially configured as digital input (factory default), rather than output-high or output-low.  This will result in negative going pulses, so if you need positive going pulses consider using a simple inverter IC such as the CD74ACT540E from TI.

The MSW of the read from this timer mode returns the number of edges counted, but does not increment past the stop count value.  The LSW of the read returns edges waiting for.


This description seems to be conflicted because is says that Timer0 should be configured as output but also says that for "best results" Timer0 should be configured as input.

The terminal that Timer0 appears on should have been configured as a digital input before the timer was put on it.  I added some text above.