23.04.2013 Views

TMPM330 - Keil

TMPM330 - Keil

TMPM330 - Keil

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Under development<br />

8.6 Applications using the Capture Function<br />

<strong>TMPM330</strong> (rev 0.4)8-30<br />

<strong>TMPM330</strong><br />

The capture function can be used to develop many applications, including those described below:<br />

One-shot pulse output triggered by an external pulse<br />

Frequency measurement<br />

Pulse width measurement<br />

Time difference measurement<br />

One-shot pulse output triggered by an external pulse<br />

One-shot pulse output triggered by an external pulse is carried out as follows:<br />

The 16-bit up-counter is made to count up by putting it in a free-running state using the prescaler<br />

output clock. An external pulse is input through the TB5IN0 pin. A trigger is generated at the rising of<br />

the external pulse by using the capture function and the value of the up-counter is taken into the<br />

capture registers (TB5CP0).<br />

The NVIC must be programmed so that an interrupt INTCAP50 is generated at the rising of an<br />

external trigger pulse. This interrupt is used to set the timer registers (TB5RG0) to the sum of the<br />

TB5CP0 value (c) and the delay time (d), (c + d), and set the timer registers (TB5RG1) to the sum of<br />

the TB5RG0 values and the pulse width (p) of one-shot pulse, (c + d + p).<br />

TB5RG1 change must be completed before the next match.<br />

In addition, the timer flip-flop control registers (TB5FFCR) must be set to “11.”<br />

This enables triggering the timer flip-flop (TB5FF0) to reverse when UC5 matches TB5RG0 and<br />

TB5RG1. This trigger is disabled by the INTTB5 interrupt after a one-shot pulse is output.<br />

Symbols (c), (d) and (p) used in the text correspond to symbols c, d and p in Fig. 8-5 One-shot Pulse<br />

Output (With Delay).”<br />

Count clock<br />

(Internal clock)<br />

TB5IN0 pin input<br />

(External trigger pulse)<br />

Match with TB5RG0<br />

Match with TB5RG1<br />

Timer output TB5OUTpin<br />

Put the counter in a free-running state.<br />

c<br />

Enable reverse<br />

Disable reverse when<br />

data is taken into CAP5.<br />

Delay time<br />

(d)<br />

c + d<br />

Enable<br />

reverse<br />

Pulse width<br />

(p)<br />

c + d + p<br />

Taking data into the capture register (CAP5)<br />

INTCAP50 generation<br />

INTTB5 generation<br />

Fig. 8-5 One-shot Pulse Output (With Delay)<br />

INTTB5 generation<br />

16-bit Timer/<br />

Event Counters (TMRBs)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!