![](http://datasheet.mmic.net.cn/370000/-PD78083_datasheet_16681058/-PD78083_367.png)
341
CHAPTER 10 APPLICATIONS OF A/D CONVERTER
<Hardware used>
D/A converter
8-bit timer/event counter 1
<Initial setting>
OSMS = #00000001B ; Oscillation mode select register: does not use divider circuit
PM13 = #
×××××××
1B ; Sets port 13 in input mode
TCL1 = #
××××
1001B ; Interval of 8-bit timer/event counter: 668
μ
s
TMC1 = #000000
×
0B
CR10 = #174
DACS0 = #80H
; Sets D/A converter
DAM = #00000001B
SET1 DAM.4
; Sets D/A converter in real-time output mode
SET1 TCE1
; Enables operation of 8-bit timer/event counter 1 and enables interrupt
CLR1 TMIF1
CLR1 TMMK1
Caution To prevent output of a value on resetting and starting, once set the normal mode and write
the initial value to the D/A conversion value setting register 0 (DACS0), and then output
the initial value. After that, set the real-time output mode, and enable the operation of
8-bit timer/event counter 1 and interrupt.
If D/A conversion is started in the real-time output mode after reset and start with the initial
value set to the DACS0 register, 0 V (data D0 in Figure 10-2. Analog Output and Output
Data Storage Timing) is output.
<Starting>
When starting output, enable the operation of the D/A converter (by setting bit 4 (DAM4) of the D/A converter
mode register(DAM)), the operation of 8-bit timer/event counter 1 (by setting bit 0 (TCE) of the 8-bit timer
mode control register (TMC1)), and interrupts (by clearing TMIF1 and TMMK1).