DOC PREVIEW
NMT EE 308 - Analog or Digital Converters

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

EE 308 Spring 2010Analog/Digital Converters• A 10-bit A/D converter is used to convert an input voltage. The reference voltages areVRL= 0V and VRH= 5V.– What is the quantization level of the A/D converter?∆V =VRH− VRL2b− 1= 4.88 mV• What is the dynamic range of the A/D converter?DRdB= 6.02b = 60.2 dB• If the value read from the A/D converter is 0x15a, what is the input voltage?Vin= VRL+VRH− VRL2b− 1ADvalue = 0 V + 4.88 mV × 346 = 1.6894 V• The MC9S12 has two 10-bit A/D converter (ATD0 and ATD1).– Each A/D converter has an 8-channel analog mulitplexer in front of it, so eachchannel can convert 8 analog inputs (but not at exactly the same time).• ATD0 us es the eight bits of Port AD0, called PAD00 through PAD07– Ports AD0 and AD1 of ATD0 are used by DBug-12 at startup to determine whetherto execute DBug-12, or to run code from EEPROM of the bootloader.• ATD1 us es the eight bits of Port AD1, called PAD08 through PAD151EE 308 Spring 2010The MC9S12 Analog/Digital Converter• We will discuss only ATD0. ATD1 is identical.• ATD0 is an eight-channel 10-bit A/D converter.– The A/D converter can also be used in 8-bit mode.• There are eight inputs to the A/D converter.• The inputs are fed through a multiplexer to the single A/D converter.• There are inputs on the MC9S12 for the reference voltages VRLand VRH– In normal operation VRL= 0 V and VRH= 5 V.– You must have VSS≤ VRL< VRH≤ VDD.– The accuracy of the A/D converter is guaranteed only for VRH− VRL=5 V.• When using the A/D converter, you can choose between performing single or contin-uous conversion on a single channel or multiple channels.• The AD conversion results are stored in the registers ATD0DR0 through ATD0DR7– You c an choose whether to have the results left-justified or right-justified.• To program the MC9S12 A/D converter you need to set up the A/D control registersATD0CTL2, ATD0CTL3, ATD0CTL4 and ATD0CTL5• The registers ATD0CTL0 and ATD0CTL1 are used for factory test, and not used in normaloperation.• When the AD converter is not used, Port AD0 can be used for general purpose input– Register ATD0DIEN is used to set up Port AD0 pins for use as a general purposeinputs.– The values on the pins are read from PORTAD0.2EE 308 Spring 2010A/DA/DCC CB CAMULT = 0MULT = 1PAD00PAD01PAD02PAD03PAD04PAD05PAD06PAD07PAD00PAD01PAD02PAD03PAD04PAD05PAD06PAD07ATD0R0ATD0R1ATD0R2ATD0R3ATD0R4ATD0R5ATD0R6ATD0R7ATD0R0ATD0R1ATDR02ATDR03ATDR04ATDR05ATDR06ATDR07Single or continuous conversionOnly one channel, determined by CC CB CASeveral Channels.Starting channel determined by CC CB CA1 to 8 conversions, number determined by S1C, S2C, S4C, S8C1 to 8 conversions, number dertemined by S1C, S2C, S4C, S8CMC9S12 A/D Converter Setup3EE 308 Spring 2010To Use A/D Converter:ADPU= 1 (Power up A/D)CCF7 CCF6 CCF5 CCF4 CCF3 CCF2 CCF1CCF0MULTSCAN 0 CC CB CA0CC2 CC1 CC0SCFSMP1 SMP0PRS1PRS0PRS4 PRS3 PRS2S8CFRZ1FRZ0AFFC ASWAI 0ADPU ASCIEASCIFETRIGLE ETRIGLP0S4C S2C S1C FIFOSRES8DJMDSGNATD0STAT0ATD0CTL5ATD0CTL4ATD0CTL3ATD0CTL2ATD0STAT1ETORF FIFOR 0SCAN = 0 => Single conversion sequenceSCAN = 1 => Convert continuouslyS8C, S4C, S2C, S1C: Number of conversions per sequency: 0001 −− 0111 (1 to 7) 0000 or 1xxx (8)SRES8 = 0 => 10 Bit ModeSRES8 = 1 => 8 Bit ModeDJM = 0 => Left justified data in the result registersDJM = 1 +> Right justified data in the result registersDSGN = 0 => Unsigned data in the result registersDSGN = 1 => Signed data representation in the result registers (only for left justified)Other values of ATDCTL4 will not work, or will result in slower operation of A/DATDCTL4ATDCTL4= 0x85 => 2 MHz AD clock, 12 cycles per conversion, 8 bit mode= 0x05 => 2 MHz AD clock, 14 cycles per conversion, 10 bit modeSCF Flag is set after a sequence of conversions is completeThe SCF Flag is cleared when ATD0CTL5 is written, or by writing a 1 to the SCF bitAfter writing to ATD0CTL5, SCF flag cleared and conversions start0x00820x00830x00840x00850x00860x008B4EE 308 Spring 2010USING THE MC9S12 A/D CONVERTER1. Power up A/D Converter (ADPU = 1 in ATD0CTL2)2. Select number of conversions per sequence (S8C S4C S2C S1C in ATD0CTL3)S8C S4C S2C S1C = 0001 to 0111 for 1 to 7 conversionsS8C S4C S2C S1C = 0000 or 1xxx for 8 conversions3. Set up ATD0CTL4• For 8-bit mode write 0x85 to ATD0CTL4• For 10-bit mode write 0x05 to ATD0CTL4• Other values of ATD0CTL4 either will not work or will result in slower A/D conver-sion rates4. Select DJM in ATD0CTL5(a) DJM = 0 => Left justified data in the result registers(b) DJM = 1 => Right justified data in the result registers5. Select DSGN in ATD0CTL5(a) DSGN = 0 => Unsigned data representation in the result register(b) DSGN = 1 => Signed data representation in the result registerThe Available Result Data Formats are shown in the following table:SRES8 DJM DSGN Result Data Format1 0 0 8-bit/left justified/unsigned - Bits 15-81 0 1 8-bit/left justified/signed - Bits 15-81 1 X 8-bit/right justified/unsigned - Bits 7-00 0 0 10-bit/left justified/unsigned - Bits 15-60 0 1 10-bit/left justified/signed - Bits 15-60 1 X 10-bit/right justified/unsigned - Bits 9-05EE 308 Spring 20106. Select MULT in ATD0CTL5:• MULT = 0: Convert one channel eight the specified number of times– Choose channel to convert with CC, CB, CA of ATD0CTL5.• MULT = 1: Convert across several channels. CC, CB, CA of ATD0CTL5 is the firstchannel to be converted7. Select SCAN in ATD0CTL5:• SCAN = 0: Convert one sequence, then stop• SCAN = 1: Convert continuously8. After writing to ATD0CTL5, the A/D converter starts, and the SCF bit is cleared. Aftera sequence of conversions is completed, the SCF flag in ATD0STAT0 is set.• You c an read the results in ATD0DRx [0-7]H.9. If SCAN = 0, you need to write to ATD0CTL5 to start a new sequence. If SCAN = 1, theconversions continue automatically, and you can read new values in ADR[0-7]H.10. To get an interrupt after the sequence of conversions are completed, set ASCIE bit ofATD0CTL2. After the sequence of conversions, the ASCIF bit in ATD0CTL2 will be set,and an interrupt will be generated.11. With 24 MHz bus clock and ATD0CTL4 = 0x05, it takes 7 µs to make one conversion,56 µs to make eight conversions.12. On MC9S12 EVBU, AD0 channels 0 and 1 are used to determine start-up program (D-Bug12, EEPROM or bootloader). Do not use AD0 channels 0 or 1 unless


View Full Document

NMT EE 308 - Analog or Digital Converters

Documents in this Course
Load more
Download Analog or Digital Converters
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Analog or Digital Converters and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Analog or Digital Converters 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?