Title: Analog-to-Digital Converter
1Analog-to-Digital Converter
2Method of Successive Approximation
3Implementing Successive Approximation
4(No Transcript)
5(No Transcript)
6(No Transcript)
7(No Transcript)
8(No Transcript)
9(No Transcript)
10(No Transcript)
11(No Transcript)
12(No Transcript)
13(No Transcript)
14(No Transcript)
15(No Transcript)
16(No Transcript)
17(No Transcript)
18(No Transcript)
19(No Transcript)
20(No Transcript)
21(No Transcript)
22(No Transcript)
23(No Transcript)
24(No Transcript)
25(No Transcript)
26(No Transcript)
27(No Transcript)
28(No Transcript)
29(No Transcript)
30\ 9S12DP256 Analog-to-Digital Converter --
File ATD256.WHP HEX Â 0082 CONSTANT
ATD0CTL2 \ ATD Control Register 2 0084
CONSTANT ATD0CTL4 \ ATD Control
Register 4 0085 CONSTANT ATD0CTL5
\ ATD Control Register 5 0086 CONSTANT
ATD0STAT \ ATD Status Register 0090
CONSTANT ADR00H \ A/D Result
Register 0 ADCONV.ON ( -- ) 85
ATD0CTL4 C! \ 8-bit resol, /8 clock C0
ATD0CTL2 C! \ Set ADPU and AFFC Â
ADCONV.OFF ( -- ) 0 ATDCTL2 C! \
Clear ADPU Â WAIT.FOR.CONV ( -- ) BEGIN
7 ATD0STAT ?HI UNTIL
31Â AVG4 ( -- n ) \ Average 4
values in ADR0 - ADR3 0 ADR00H 2- 4 FOR
\ sum addr DUP R_at_ 2 C_at_ \
sum addr val ROT SWAP \ sum addr
NEXT DROP 4 / Â ADCONV ( ch --
val ) \ Avg 4 readings from channel ch
ADCONV.ON 8 MOD 80 OR ATDCTL5 C! \ ch lt 8
SCAN0 MULT0 WAIT.FOR.CONV AVG4 ADCONV.OFF
Â
32Â GET.4VALUES ( -- val4 val3 val2 val1 ) \
read 4 a/d regs ADR0H 2- 4 FOR
\ addr1 DUP R_at_ 2 C_at_ SWAP
\ valn addr1 NEXT DROP Â ADCONV03
( -- val3 val2 val1 val0 ) \ Convert 1st 4
channels ADCONV.ON 10 ATDCTL5 C!
WAIT.FOR.CONV GET.4VALUES Â ADCONV47
( -- val3 val2 val1 val0 ) \ Convert 2nd 4
channels ADCONV.ON 14 ATDCTL5 C!
WAIT.FOR.CONV GET.4VALUES Â DECIMAL Â