1 / 32

Analog-to-Digital Converter

Analog-to-Digital Converter. Chapter 9 MC9S12DP256. Method of Successive Approximation. Implementing Successive Approximation. 9S12DP256 Analog-to-Digital Converter -- File: ATD256.WHP HEX 0082 CONSTANT ATD0CTL2 ATD Control Register 2

evadne
Download Presentation

Analog-to-Digital Converter

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Analog-to-Digital Converter Chapter 9 MC9S12DP256

  2. Method of Successive Approximation

  3. Implementing Successive Approximation

  4. \ 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 ;

  5. : AVG4 ( -- n ) \ Average 4 values in ADR0 - ADR3 0 ADR00H 2- 4 FOR \ sum addr DUP R@ 2* + C@ \ 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# < 8; SCAN=0 MULT=0 WAIT.FOR.CONV AVG4 ADCONV.OFF ;

  6. : GET.4VALUES ( -- val4 val3 val2 val1 ) \ read 4 a/d regs ADR0H 2- 4 FOR \ addr1 DUP R@ 2* + C@ 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

More Related