117/317
5 - Peripherals
Set the TAOC2HR-TAOC2LR register pair to the number of ticks corresponding to the
duration of the whole cycle (this number depends on the clock frequency), minus 4.
Set the OLVL2 bit in the TACR1 register to the state required for the output pin for the
duration of the pulse, and OLVL1 in TACR1 to the complement of this state to terminate the
pulse.
Set the PWM bit in TACR2 to enable the Pulse-Width Modulation mode.
Set the PWM bit in TACR2 to enable the output pin.
The OCF1 and OCF2 bits are never set in this mode. However, the leading edge of the pulse,
corresponding to the start of cycle, can generate an interrupt if desired. Actually, the Compare
2 event, as mentioned before, mimics a Capture 1 event. This sets the ICF1 bit in the TASR
register. This can trigger an interrupt if the ICIE mask bit is set. It must then be reset by soft-
ware as explained for Input Capture.
The physical Capture 1 input, ICAP1_A, is inhibited for this reason, but the other input pin,
ICAP2_A remains active. This allows input captures to be performed while the timer is used in
Pulse-Width Modulation mode. An example of this is given in the first application in Chapter 9.
In this application, the timer generates periodic pulses while its frequency is controlled using a
Phase-Locked Loop scheme to synchronize it with an external reference frequency.
The application described in Chapter 9 uses the timer in PWM mode with interrupt generation.
The capture feature is also used at the same time to synchronize pulse generation with an ex-
ternal signal, using a Phase-Locked Loop. Another timer is used to produce an interrupt after
a delay each time the timer is reinitialized for the program's needs.
5.6 ANALOG TO DIGITAL CONVERTER
5.6.1 Description
As a measuring device, the converter is specified by parameters that give the degree of accu-
racy of the conversion. These are:
Input range: positive. Negative voltages are not converted.
Type of conversion: ratiometric.
Resolution: 8 bits, that is, 256 discrete values.
Linearity: the conversion is guaranteed monotonic. This means that when the input voltage
increases, the converted value either remains the same or increases, never decreases. The
same applies when the voltage decreases.
Accuracy: to within 1 LSB worst case, all causes of error included; typical 0.3 LSB. This
means that for any voltage at the input, the conversion result does not differ from the
expected result by more than 1/255 of the supply voltage in the worst case, or 0.12%
typically.
Содержание ST7 Series
Страница 1: ...ST7 8 BIT MCU FAMILY USER GUIDE JANUARY 1999 1 ...
Страница 238: ...238 317 8 C Language and the C Compiler 08 Burn bmp Then use the EPROMer programmer software as described in Chapter 7 ...
Страница 289: ...289 317 10 Second Application a Sailing Computer 10 befor Bs Rw Vw VMG AlphaR AlphaV Before the wind ...