![]() |
|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
motorola reserves the right to make changes without further notice to any products herein. motorola makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does motorola assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. "typical" parameters can and do vary in different applications. all operating parameters, including "typicals" must be validated for each customer application by customer's technical experts. motorola does not convey any license under its patent rights nor the rights of others. motorola products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the motorola product could create a situation where personal injury or death may occur. should buyer purchase or use motorola products for any such unintended or unauthorized application, buyer shall indemnify and hold motorola and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that motorola was negligent regarding the design or manufacture of the part. motorola and the motorola logo are registered trademarks of motorola, inc. motorola, inc. is an equal opportunity/affirmative action employer. ?motorola, inc. 1995, 1996 qadc queued analog-to-digital converter reference manual f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . .
f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc preface motorola reference manual iii preface this manual describes the capabilities, operation, and functions of the queued analog- to-digital converter (qadc). the following conventions are used throughout the man- ual. logic level one is the voltage that corresponds to boolean true (1) state. logic level zero is the voltage that corresponds to boolean false (0) state. to set a bit or bits means to establish logic level one on the bit or bits. to clear a bit or bits means to establish logic level zero on the bit or bits. a signal that is asserted is in its active logic state. an active low signal changes from logic level one to logic level zero when asserted, and an active high signal changes from logic level zero to logic level one. a signal that is negated is in its inactive logic state. an active low signal changes from logic level zero to logic level one when negated, and an active high signal changes from logic level one to logic level zero. lsb means least significant bit or bits. msb means most significant bit or bits. refer- ences to low and high bytes are spelled out. a specific bit or signal within a range is referred to by mnemonic and number. for example, addr15 is bit 15 of the address bus. a range of bits or signals is referred to by mnemonic and the numbers that define the range. for example, data[7:0] form the low byte of the data bus. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc table of contents motorola reference manual v paragraph title page section 1 overview 1.1 block diagram ........................................................................................... 1-1 1.2 qadc features ......................................................................................... 1-2 1.3 memory map ............................................................................................. 1-2 section 2 signal descriptions 2.1 port a pin functions .................................................................................. 2-2 2.1.1 port a analog input pins ................................................................... 2-2 2.1.2 port a digital input/output pins ......................................................... 2-2 2.2 port b pin functions .................................................................................. 2-2 2.2.1 port b analog input pins ................................................................... 2-2 2.2.2 port b digital input pins .................................................................... 2-2 2.3 external trigger input pins ........................................................................ 2-3 2.4 multiplexed address output pins .............................................................. 2-3 2.5 multiplexed analog input pins ................................................................... 2-3 2.6 voltage reference pins ............................................................................. 2-4 2.7 dedicated analog supply pins .................................................................. 2-4 2.8 external digital supply pin ........................................................................ 2-4 2.9 internal digital supply pins ....................................................................... 2-4 section 3 configuration and control 3.1 qadc bus interface unit .......................................................................... 3-1 3.2 qadc bus accessing ............................................................................... 3-1 3.3 module configuration ................................................................................ 3-3 3.3.1 low power stop mode ...................................................................... 3-3 3.3.2 freeze mode ..................................................................................... 3-4 3.3.3 supervisor/unrestricted address space ........................................... 3-4 3.3.4 interrupt arbitration priority ............................................................... 3-5 3.3.5 qadc module configuration register .............................................. 3-5 3.4 qadc test register .................................................................................. 3-6 3.5 general-purpose i/o port operation ......................................................... 3-6 3.5.1 port data register ............................................................................. 3-6 3.5.2 port data direction register .............................................................. 3-7 section 4 external multiplexing 4.1 external multiplexing operation ................................................................ 4-1 4.2 module version options ............................................................................ 4-3 table of contents f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola table of contents qadc vi reference manual (continued) paragraph title page table of contents section 5 pin connection considerations 5.1 analog reference pins .............................................................................. 5-1 5.2 analog power pins .................................................................................... 5-1 5.3 analog supply filtering and grounding ..................................................... 5-3 5.4 accommodating positive/negative stress conditions ............................... 5-5 5.5 analog input considerations ..................................................................... 5-6 5.6 analog input pins ...................................................................................... 5-8 5.6.1 settling time for the external circuit ................................................. 5-9 5.6.2 error resulting from leakage ......................................................... 5-10 section 6 analog subsystem 6.1 analog-to-digital converter operation ...................................................... 6-1 6.1.1 conversion cycle times ................................................................... 6-2 6.1.1.1 amplifier bypass mode conversion timing .............................. 6-2 6.2 front-end analog multiplexer .................................................................... 6-3 6.3 digital to analog converter array .............................................................. 6-3 6.4 comparator ............................................................................................... 6-4 6.5 successive approximation register .......................................................... 6-4 section 7 digital control 7.1 queue priority ........................................................................................... 7-1 7.2 boundary conditions ................................................................................. 7-3 7.3 scan modes .............................................................................................. 7-4 7.3.1 disabled mode and reserved mode ................................................. 7-4 7.3.2 single-scan modes ........................................................................... 7-4 7.3.2.1 software initiated single-scan mode ........................................ 7-5 7.3.2.2 external trigger single-scan mode .......................................... 7-6 7.3.2.3 interval timer single-scan mode .............................................. 7-6 7.3.3 continuous-scan modes ................................................................... 7-7 7.3.3.1 software initiated continuous-scan mode ................................ 7-8 7.3.3.2 external trigger continuous-scan mode .................................. 7-9 7.3.3.3 periodic timer continuous-scan mode .................................... 7-9 7.4 qadc clock (qclk) generation .............................................................. 7-9 7.5 periodic/interval timer ............................................................................ 7-13 7.6 control and status registers .................................................................. 7-14 7.6.1 control register 0 ........................................................................... 7-14 7.6.2 control register 1 ........................................................................... 7-16 7.6.3 control register 2 ........................................................................... 7-17 7.6.4 status register ................................................................................ 7-20 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc table of contents motorola reference manual vii (continued) paragraph title page table of contents 7.7 conversion command word table ......................................................... 7-26 7.8 result word table ................................................................................... 7-32 section 8 interrupts 8.1 interrupt operation .................................................................................... 8-1 8.2 polled and interrupt-driven operation ....................................................... 8-1 8.3 interrupt sources ....................................................................................... 8-2 8.4 qadc interrupt register ........................................................................... 8-2 8.5 interrupt priority ......................................................................................... 8-3 8.6 interrupt arbitration .................................................................................... 8-4 8.7 interrupt vectors ........................................................................................ 8-4 8.8 initializing the qadc for interrupt driven operation ................................. 8-5 8.9 interrupt processing summary .................................................................. 8-6 section 9 queue priority examples 9.1 queue priority schemes ........................................................................... 9-1 appendix a electrical characteristics appendix b register summary b.1 address map ............................................................................................ b-1 b.2 qadc registers ....................................................................................... b-1 b.2.1 qadc module configuration register ............................................. b-1 b.2.2 qadc test register ......................................................................... b-2 b.2.3 qadc interrupt register .................................................................. b-2 b.2.4 port a/b data register ..................................................................... b-3 b.2.5 port data direction register ............................................................. b-3 b.2.6 qadc control registers .................................................................. b-4 b.2.7 qadc status register ..................................................................... b-7 b.2.8 conversion command word table .................................................. b-8 b.2.9 result registers ............................................................................. b-11 appendix c conversion accuracy definitions c.1 transfer curve ......................................................................................... c-1 c.2 offset error ............................................................................................... c-2 c.3 quantizing error ....................................................................................... c-2 c.4 monotonicity ............................................................................................. c-2 c.5 gain error (slope error) ........................................................................... c-2 c.6 integral non-linearity ............................................................................... c-3 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola table of contents qadc viii reference manual (continued) paragraph title page table of contents c.7 differential non-linearity (related to monotonicity) ................................. c-4 index f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc list of illustrations motorola reference manual ix figure title page 1-1 qadc block diagram ..................................................................................... 1-1 2-1 qadc input and output signals .................................................................... 2-1 3-1 bus cycle accesses ....................................................................................... 3-2 4-1 example of external multiplexing ................................................................... 4-2 5-1 analog input circuitry ..................................................................................... 5-2 5-2 errors resulting from clipping ....................................................................... 5-3 5-3 star-ground at the point of power supply origin ........................................... 5-4 5-4 input pin subjected to negative stress .......................................................... 5-5 5-5 voltage limiting diodes in a negative stress circuit ..................................... 5-6 5-6 external multiplexing of analog signal sources ............................................ 5-7 5-7 electrical model of an a/d input pin ............................................................... 5-8 6-1 qadc module block diagram ........................................................................ 6-1 6-2 conversion timing ......................................................................................... 6-2 6-3 bypass mode conversion timing ................................................................... 6-3 7-1 qadc queue operation with pause ............................................................. 7-2 7-2 qadc clock subsystem functions .............................................................. 7-10 7-3 qadc clock programmability examples ..................................................... 7-12 7-4 queue status transition ............................................................................... 7-25 7-5 qadc conversion queue operation ........................................................... 7-27 8-1 qadc interrupt flow diagram ....................................................................... 8-1 8-2 qadc interrupt vector format ....................................................................... 8-5 9-1 ccw priority situation 1 ................................................................................. 9-2 9-2 ccw priority situation 2 ................................................................................. 9-3 9-3 ccw priority situation 3 ................................................................................. 9-3 9-4 ccw priority situation 4 ................................................................................. 9-4 9-5 ccw priority situation 5 ................................................................................. 9-4 9-6 ccw priority situation 6 ................................................................................. 9-5 9-7 ccw priority situation 7 ................................................................................. 9-5 9-8 ccw priority situation 8 ................................................................................. 9-6 9-9 ccw priority situation 9 ................................................................................. 9-6 9-10 ccw priority situation 10 ............................................................................... 9-7 9-11 ccw priority situation 11 ............................................................................... 9-7 9-12 ccw freeze situation 12 ............................................................................... 9-8 9-13 ccw freeze situation 13 ............................................................................... 9-8 9-14 ccw freeze situation 14 ............................................................................... 9-8 9-15 ccw freeze situation 15 ............................................................................... 9-9 9-16 ccw freeze situation 16 ............................................................................... 9-9 9-17 ccw freeze situation 17 ............................................................................... 9-9 9-18 ccw freeze situation 18 ............................................................................... 9-9 9-19 ccw freeze situation 19 ............................................................................. 9-10 c-1 transfer curve of an ideal 10-bit a/d converter ...........................................c-1 list of illustrations f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola list of illustrations qadc x reference manual (continued) figure title page list of illustrations c-2 transfer curve of a non-monotonic 10-bit a/d converter .............................c-2 c-3 transfer curve of a 10-bit a/d converter with gain error .............................c-3 c-4 transfer curve of a 10-bit a/d converter with integral > one lsb ..............c-4 c-5 transfer curve of a 10-bit a/d converter with differential linearity .............c-5 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc list of tables motorola reference manual xi table title page 1-1 qadc address map .............................................................................................. 1-3 2-1 multiplexed analog input channels ....................................................................... 2-3 4-1 analog input channels .......................................................................................... 4-3 5-1 external circuit settling time (10-bit conversions).............................................. 5-9 5-2 error resulting from input leakage (ioff) ........................................................ 5-10 7-1 qadc clock programmability ............................................................................. 7-12 7-2 prescaler clock high times ................................................................................ 7-15 7-3 prescaler clock low times ................................................................................. 7-16 7-4 queue 1 operating modes .................................................................................. 7-17 7-5 queue 2 operating modes .................................................................................. 7-18 7-6 queue status....................................................................................................... 7-24 7-7 input sample times............................................................................................. 7-30 7-8 nonmultiplexed channel assignments and pin designations ............................. 7-31 7-9 multiplexed channel assignments and pin designations.................................... 7-32 8-1 qadc status flags and interrupt sources............................................................ 8-2 9-1 trigger events ....................................................................................................... 9-1 9-2 status bits.............................................................................................................. 9-2 a-1 qadc maximum ratings ...................................................................................... a-1 a-2 qadc dc electrical characteristics (operating) .................................................. a-2 a-3 qadc ac electrical characteristics (operating) .................................................. a-3 a-4 qadc conversion characteristics (operating)..................................................... a-4 b-1 qadc address map.............................................................................................. b-1 b-2 prescaler clock high times .................................................................................. b-4 b-3 prescaler clock low times................................................................................... b-5 b-4 queue 1 operating modes .................................................................................... b-5 b-5 queue 2 operating modes .................................................................................... b-6 b-6 queue status ........................................................................................................ b-8 b-7 input sample times .............................................................................................. b-9 b-8 nonmultiplexed channel assignments and pin designations............................. b-10 b-9 multiplexed channel assignments and pin designations ................................... b-10 list of tables f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola list of tables qadc xii reference manual f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc overview motorola reference manual 1-1 section 1 overview the queued analog-to-digital converter (qadc) is a 10-bit, unipolar, successive ap- proximation converter. a maximum of 16 analog input channels can be supported us- ing internal multiplexing. a maximum of 44 input channels can be supported in the expanded, externally multiplexed mode. the actual number of channels depends upon the number of pins available to the qadc module. 1.1 block diagram figure 1-1 displays the major components of the qadc module. the qadc consists of an analog front-end and a digital control subsystem, which includes an intermodule bus (imb) interface block. figure 1-1 qadc block diagram the analog section includes input pins, an analog multiplexer, and two sample and hold analog circuits. the analog conversion is performed by the digital-to-analog con- verter (dac) resistor-capacitor array and a high-gain comparator. the digital control section contains control logic to sequence the conversion process, channel select logic, and a successive approximation register (sar). also included are the periodic/interval timer, control and status registers, the conversion command word (ccw) table ram, and the result word table ram. qadc block queue of 10-bit conversion command words (ccw), 40 words intermodule bus interface digital control 10-bit result table, 40 words 10-bit to 16-bit result alignment 10-bit analog to digital converter analog input multiplexer and digital pin functions external triggers external mux address up to 16 analog input pins reference inputs analog power inputs f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola overview qadc 1-2 reference manual the bus interface unit (biu) allows the qadc to operate with the applications software through the imb environment. 1.2 qadc features ?sample and hold ?up to 16 analog input channels using internal multiplexing ?directly supports up to four external multiplexers (for example, the mc14051) ?up to 44 total input channels with internal and external multiplexing ?programmable input sample time for various source impedances ?two conversion command queues of variable length ?sub-queues possible using pause mechanism ?queue complete and pause software interrupts available on both queues ?automated queue modes initiated by: ?external trigger ?periodic/interval timer, within qadc module ?software command ?single-scan or continuous-scan of queues ?40 result registers ?output data readable in three formats: ?right-justified unsigned ?left-justified signed ?left-justified unsigned ?unused analog channels can be used as digital ports 1.3 memory map the qadc occupies 512 bytes, or 256 words, of address space. nine words are con- trol, port, and status registers, 40 words are the ccw table, and 40 words are the re- sult word table which occupy 120 address locations because the result data is readable in three data alignment formats. the remaining words are reserved for ex- pansion. table 1-1 displays the qadc memory map. each register address in table 1-1 consists of a 15-bit base address plus a 9-bit offset. the offset represents the nine low order bits of register address. ?####?represents the 15-bit base address plus the high order bit of the offset. (for example, both ljur and rjur registers are represented by $####b0?####fe, even though they repre- sent different addresses since each register has a different most significant bit in their offset). for the precise locations of these registers, refer to the appropriate microcon- troller unit (mcu) manual. the column labeled ?ccess?specifies which address space is designated supervisor data space or unrestricted data space. remember that the msb is determined by the mm bit. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc overview motorola reference manual 1-3 access to supervisor-only data space is permitted only when the software is operating in supervisor access mode. assignable data space can be either restricted to supervi- sor-only access or unrestricted to both supervisor and user data space addresses. the supv bit in the module configuration register designates the assignable space as supervisor or unrestricted. attempts to read a supervisor-only data space when not in the supervisor access mode causes a value of $0000 to be returned. attempts to read assignable data space in the unrestricted access mode when the space is programmed as supervisor space causes a value of $ffff to be returned. attempts to write supervisor-only or supervi- sor-assigned data space when in the unrestricted access mode has no effect. the cpu32 indicates the supervisor and user space access with the function code sig- nal fc2 on the imb bus. cpu16 does not support supervisor/user space selection, and is always in the supervisor access mode. in such cases, the supv bit has no meaning or effect. the first block of the address map contains the nine words used for control, status, port, and test information. the control registers permit the software to initialize the qadc for the desired configuration and queue operating mode. also included are the status bits that the software may read to identify an interrupt source and to determine notes: 1. s = supervisor only 2. s/u = unrestricted or supervisor depending on the state of the supv bit in the qadcmcr. table 1-1 qadc address map access address offset 15 8 7 0 s 1 $####00 $000 module configuration register (qadcmcr) s $####02 $002 test register (qadctest) s $####04 $004 interrupt register (qadcint) s/u 2 $####06 $006 port a data (portqa) port b data (portqb) s/u $####08 $008 port data direction register (ddrqa) s/u $####0a $00a control register 0 (qacr0) s/u $####0c $00c control register 1 (qacr1) s/u $####0e $00e control register 2 (qacr2) s/u $####10 $010 status register (qasr) $####12 $####2e $012 $02e reserved s/u $####30? $####7e $030? $07e conversion command word (ccw) table $####80? $####ae $080 $0ae reserved s/u $####b0? $####fe $0b0 $0fe result word table right justified, unsigned result register (rjurr) $####00? $####2e $100 $12e reserved s/u $####30? $####7e $130 $17e result word table left justified, signed result register (ljsrr) $####80? $####ae $180 $1ae reserved s/u $####b0? $####fe $1b0 $1fe result word table left justified, unsigned result register (ljurr) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola overview qadc 1-4 reference manual other information about the operation of the qadc. refer to appendix b register summary for more information. the qadc has three global registers for configuring module operation: the module configuration register (qadcmcr), the interrupt register (qadcint), and a test reg- ister (qadctest). the global registers are always defined to be in supervisor-only data space. when the cpu supports the supervisor/user address data space desig- nations, software can establish the global registers to be in supervisor data space and the remaining registers and tables to be in user space. all qadc analog channel/port pins that are not used for analog input channels can be used as digital port pins. port values are read/written by accessing the port a and b data registers (portqa and portqb). the digital port pins are specified as inputs or outputs by programming the port data direction register (ddrqa). only port a uses open drain pull-down output drivers. the remaining four registers in the control register block control the operation of the queuing mechanism, and provide a means of monitoring the operation of the qadc. control register 0 (qacr0) contains hardware configuration information. control reg- ister 1 (qacr1) is associated with queue 1, and control register 2 (qacr2) is asso- ciated with queue 2. the status register (qasr) provides visibility on the status of each queue and the particular conversion that is in progress. following the register block in the address map is the ccw table. there are 40 words to hold the desired analog conversion sequences. each ccw is a 16-bit word, with ten implemented bits in four fields. refer to appendix b register summary for more information. the final block of address space belongs to the result word table, which appears in three places in the memory map. each result word table location holds one 10-bit con- version value. the software selects one of three data formats, which map the 10-bit result onto the 16-bit data bus by reading the address which produces the desired alignment. the first address block presents the result data in right justified format, the second block is presented in left justified signed format, and the third is presented in left justified unsigned format. refer to appendix b register summary for more information. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc signal descriptions motorola reference manual 2-1 section 2 signal descriptions the qadc uses a maximum of 21 external pins. there are 16 channel/port pins that can support up to 44 channels when external multiplexing is used (including internal channels). all of the channel pins can also be used as general-purpose digital port pins. in addition, there are also two analog reference pins, two analog submodule pow- er pins, and one v sse pin for the open drain output drivers on port a. the qadc allows external trigger inputs and the multiplexer outputs to be combined onto some of the channel pins. all of the channel pins are used for at least two func- tions, depending on the modes in use. the following paragraphs describe qadc pin functions. figure 2-1 displays the qadc module pins. figure 2-1 qadc input and output signals qadc pinout an52/ma0/pqa0 an53/ma1/pqa1 an54/ma2/pqa2 an55/etrig1/pqa3 an56/etrig2/pqa4 an57/pqa5 an58/pqa6 an59/pqa7 an0/anw/pqb0 an1/anx/pqb1 an2/any/pqb2 an3/anz/pqb3 an48/pqb4 an49/pqb5 an50/pqb6 an51/pqb7 digital results and control analog converter analog multiplexer port a analog inputs, ext trigger inputs, ext mux address outputs, digital i/o * port b analog inputs, ext mux inputs, digital inputs v sse v ddi v ssi qadc v dda v ssa v rl v rh output driver power analog references analog power internal digital power (shared w/ other modules) port a * port b * port a pins incorporate open drain pull down drivers. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola signal descriptions qadc 2-2 reference manual 2.1 port a pin functions the eight port a pins can be used as analog inputs, or as a bidirectional 8-bit digital input/output port. refer to the following paragraphs for more information. 2.1.1 port a analog input pins when used as analog inputs, the eight port a pins are referred to as an[59:52]. due to the digital output drivers associated with port a, the analog characteristics of port a are different from those of port b. refer to appendix b register summary for more information on analog signal characteristics. all of the analog signal input pins may be used for at least one other purpose. 2.1.2 port a digital input/output pins port a pins are referred to as pqa[7:0] when used as a bidirectional 8-bit digital input/ output port. these eight pins may be used for general-purpose digital input signals or digital open drain pull-down output signals. port a pins are connected to a digital input synchronizer during reads and may be used as general purpose digital inputs when the applied voltages meet high voltage input (v ih ) and low voltage input (v il ) requirements. refer to appendix a electrical characteristics for more information on voltage requirements. each port a pin is configured as an input or output by programming the upper half of the port data direction register (ddrqa). the digital input signal states are read by the software in the upper half of the port data register when the port data direction register specifies that the pins are inputs. the digital data in the port data register is driven onto the port a pins when the corresponding bit in the port data direction register specifies output. refer to appendix b register summary for more information. since the outputs are open drain drivers (so as to minimize the effects to the analog function of the pins), active external pull-up provisions must be made when the output is used to drive another integrated circuit. 2.2 port b pin functions the eight port b pins can be used as analog inputs, or as an 8-bit digital input only port. refer to the following paragraphs for more information. 2.2.1 port b analog input pins when used as analog inputs, the eight port b pins are referred to as an[51:48]/ an[3:0]. since port b functions as analog and digital input only, the analog character- istics are different from those of port a. refer to appendix a electrical char- acteristics for more information on analog signal characteristics. all of the analog signal input pins may be used for at least one other purpose. 2.2.2 port b digital input pins port b pins are referred to as pqb[7:0] when used as an 8-bit digital input only port. in addition to functioning as analog input pins, the port b pins are also connected to f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc signal descriptions motorola reference manual 2-3 the input of a synchronizer during reads and may be used as general-purpose digital inputs when the applied voltages meet v ih and v il requirements. refer to appendix a electrical characteristics for more information on voltage requirements. since port b pins are input only, a data direction register is not necessary. the digital input signal states are read by the software in the lower half of the port data register. refer to appendix b register summary for more information. 2.3 external trigger input pins the qadc uses two external trigger pins (etrig[2:1]). the external trigger inputs are included in two multifunction port a pins (pqa[4:3]), which are normally used as ana- log channel input pins. each of the two input external trigger pins is associated with one of the scan queues, queue 1 and queue 2. when a queue is in an external trigger mode, the corresponding external trigger pin is configured as a digital input and the software programmed input/output direction for the external trigger pins in the data di- rection register (ddrqa) is ignored. refer to paragraph 7.7 in section 7 digital control for more information. 2.4 multiplexed address output pins in the non-multiplexed mode, the 16 channel pins are connected to an internal multi- plexer which routes the analog signals into the internal a/d converter. in the externally multiplexed mode, the qadc allows automatic channel selection through up to four external 8-to-1 selector chips. the qadc provides a 3-bit multi- plexed address output to the external multiplex chips to allow selection of one of eight inputs. the multiplexed address output signals (ma[2:0]) can be used as multiplex ad- dress output bits, or as general i/o. ma[2:0] are used as the address inputs for up to four 8-channel multiplexer chips (for example, the mc14051 and the mc74hc4051). since the ma[2:0] pins are digital out- puts in the multiplexed mode, the software programmed input/output direction for the multiplex address pins in the data direction register is ignored. refer to paragraph 7.7 in section 7 digital control for more information on the use of multiplexed address output pins in the external multiplexed mode. 2.5 multiplexed analog input pins in the external multiplexed mode, four of the port b pins are redefined to each repre- sent eight input channels. refer to table 2-1 . refer to paragraph 7.7 in section 7 digital control for more information. table 2-1 multiplexed analog input channels multiplexed analog input channels anw even numbered channels from 0 to 14 anx odd numbered channels from 1 to 15 any even channels from 16 to 30 anz odd channels from 17 to 31 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola signal descriptions qadc 2-4 reference manual 2.6 voltage reference pins v rh and v rl are the dedicated input pins for the high and low reference voltages. sep- arating the reference inputs from the power supply pins allows for additional external filtering, which increases reference voltage precision and stability, and subsequently contributes to a higher degree of conversion accuracy. refer to appendix a elec- trical characteristics for more information. 2.7 dedicated analog supply pins v dda and v ssa pins supply power to the analog subsystems of the qadc module. dedicated power is required to isolate the sensitive analog circuitry from the normal levels of noise present on the digital power supply. refer to appendix a electri- cal characteristics for more information. 2.8 external digital supply pin each port a pin includes a digital open drain output driver, as well as an analog input signal path and a digital input synchronizer. the v sse pin provides the ground level for the drivers on the port a pins. since the qadc output pins have open drain type drivers, a dedicated v dde pin is not needed. refer to appendix a electrical characteristics for more information. 2.9 internal digital supply pins v ddi and v ssi pins provide the power for the digital portions of the qadc, and for all other digital modules on the microcontroller chip. since these pins are common to all modules, they are not counted as qadc pins. refer to appendix a electrical characteristics for more information. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc configuration and control motorola reference manual 3-1 section 3 configuration and control the qadc module communicates with other microcontroller modules via the inter- module bus (imb). the qadc bus interface unit (biu) coordinates imb activity with internal qadc bus activity. this section describes the operation of the biu, imb read/ write accesses to qadc memory locations, module configuration, and general-pur- pose i/o operation. 3.1 qadc bus interface unit the biu is designed to act as a slave device on the imb. the biu has the following functions: to respond with the appropriate bus cycle termination, and to supply imb in- terface timing to all internal module signals. biu components consist of imb buffers, address match and module select logic, inter- rupt and arbitration logic, the biu state machine, clock prescaler logic, data bus routing logic, and the interface to the internal module data bus. the qadc responds to all imb operations and signals, allowing byte, word, and long word addressable read and write operations in any addressable space. note normal accesses to the qadc require two clocks. however, if the cpu tries to access locations that are also accessible by the qadc while the qadc is accessing them, the qadc produces wait states. from one to four cpu wait states may be inserted by the qadc in the process of reading and writing. 3.2 qadc bus accessing the qadc permits software access to 8-bit, 16-bit words, and 32-bit long words, at even and odd addresses, however, coherency (ensuring that all samples are taken consecutively in one scan) is not provided for accesses that require more than one bus cycle. for example, if a read of two consecutive word locations in a result area are made, the qadc could change one word in the result area between the bus cycles. there is no holding register for the second word. refer to paragraph 7.6.3 in section 7 digital control for more information on coherency. all read and write accesses that require more than one 16-bit access to complete occur as two or more indepen- dent bus cycles. these accesses include misaligned and long word accesses. note cpu32 does not support word access or long word access to an odd address. both of these are considered misaligned accesses. the cpu16 supports misaligned and long word accesses. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola configuration and control qadc 3-2 reference manual figure 3-1 shows the three bus cycles which are implemented by the qadc. the fol- lowing paragraphs describe how the three types of accesses are used, including mis- aligned and long word accesses. figure 3-1 bus cycle accesses byte accesses to an even address read or write bits 15 through 8 of a qadc location, as shown in the top illustration of figure 3-1 . in the case of write cycles, bits 7 through 0 of the addressed qadc register are not disturbed. in the case of read cycles, the qadc provides zeros to the imb for bits 7 through 0. byte accesses to an odd address read or write bits 7 through 0 of a qadc location, as shown in the center illustration of figure 3-1 . in the case of write cycles, bits 15 through 8 of the addressed qadc location are not disturbed. in the case of read cy- cles, the qadc provides zeros to the imb for bits 15 through 8. word accesses to an even address read or write bits 15 through 0 of a qadc location, as shown in the lower illustration of figure 3-1 . a full 16 bits of data is written to and read from the qadc location with each access. qadc bus cyc acc 00 intermodule bus 8-bit access of an even address (isiz = 01, a0 = 0) data[15:8] data[7:0] data[15:8] data[7:0] qadc location wr wr intermodule bus 8-bit access of an odd address (isiz = 01, a0 = 1; or isiz = 10, a0 = 1) data[15:8] data[7:0] data[15:8] data[7:0] qadc location wr wr intermodule bus 16-bit aligned access (isiz = 10, a0 = 0) data[15:8] data[7:0] data[15:8] data[7:0] qadc location wr wr 00 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc configuration and control motorola reference manual 3-3 word accesses to an odd address require two bus cycles; half of two different 16-bit qadc locations are accessed. the first bus cycle is treated by the qadc as an 8-bit read or write of an odd address. the second cycle is an 8-bit read or write of an even address. the qadc address space is organized into 16-bit even address locations, so a 16-bit read or write of an odd address obtains or provides the lower half of one qadc location, and the upper half of the following qadc location. long word (32-bit) accesses to an even address require two bus cycles to complete the access, and two full qadc locations are accessed. the first bus cycle reads or writes the addressed 16-bit qadc location and the second cycle reads or writes the following 16-bit location. long word accesses to an odd address require three bus cycles. portions of three dif- ferent qadc locations are accessed. the first bus cycle is treated by the qadc as an 8-bit access of an odd address, the second cycle is a 16-bit aligned access, and the third cycle is an 8-bit access of an even address. the qadc address space is orga- nized into 16-bit even address locations, so a 32-bit read or write of an odd address provides the lower half of one qadc location, the full 16-bit content of the following qadc location, and the upper half of the third qadc location. 3.3 module configuration the module configuration register (qadcmcr) contains parameters which allow the qadc to interface with other mcu modules. the register defines freeze and stop mode operation, supervisor-only access protection, and the qadc software interrupt arbitration priority number. the implemented fields can be read and written. unimple- mented locations read zero and writes have no effect. they are typically written once when the software initializes the qadc, and not changed afterwards. 3.3.1 low power stop mode when the stop bit in the qadcmcr is set, the clock signal to the a/d converter is disabled, effectively turning off the analog circuitry. this results in a static, low power consumption, idle condition. the stop mode aborts any conversion sequence in progress. because the bias currents to the analog circuits are turned off in stop mode, the qadc requires some recovery time (t sr in appendix a electrical char- acteristics ) to stabilize the analog circuits after the stop enable bit is cleared. in the stop mode, the biu state machine and logic do not shut down, and the qadc- mcr, the interrupt register (qadcint), and the test register (qadctest) are fully accessible and are not reset. the data direction register (ddrqa), port data register (portqa/portqb), and control register 0 (qacr0) are not reset and are read-only accessible. the ram is not reset and is not accessible. control register 1 (qacr1), control register 2 (qacr2), and the status register (qasr) are reset and are read-only accessible. in addition, the qadc clock (qclk) and the periodic/interval timer are held in reset during stop mode. if the stop bit is clear, stop mode is disabled. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola configuration and control qadc 3-4 reference manual 3.3.2 freeze mode freeze mode occurs when the background debug mode is enabled in the device inte- gration module and a breakpoint is encountered. this is indicated by the assertion of the internal freeze line on the imb. the frz bit in the qadcmcr determines whether or not the qadc responds to an imb internal freeze signal assertion. freeze is very useful when debugging an application. when the frz bit is set, the qadc finishes any current conversion then freezes. de- pending on when the frz bit is asserted, there are three possible queue ?reeze?sce- narios: ?when a queue is not executing, the qadc freezes immediately. ?when a queue is executing, the qadc completes the current conversion and then freezes. ?if during the execution of the current conversion, the queue operating mode for the active queue is changed, or a queue 2 abort occurs, the qadc freezes im- mediately. when the qadc enters the freeze mode while a queue is active, the current ccw lo- cation of the queue pointer is saved. during freeze, the analog clock is held in reset and is not clocked. although qclk is unaffected, the periodic/interval timer is held in reset. external trigger events that oc- cur during the freeze mode are not recorded. the biu remains active to allow imb ac- cess to all qadc registers and ram. although the qadc saves a pointer to the next ccw in the current queue, the software can force the qadc to execute a different ccw by writing new queue operating modes for normal operation. the qadc looks at the queue operating modes, the current queue pointer, and any pending trigger events to decide which ccw to execute. if the frz bit is clear, the internal freeze signal is ignored. 3.3.3 supervisor/unrestricted address space the qadc memory map is divided into two segments: supervisor-only data space and assignable data space. access to supervisor-only data space is permitted only when the software is operating in supervisor access mode. assignable data space can be either restricted to supervisor-only access or unrestricted to both supervisor and user data space accesses. the supv bit in the qadcmcr designates the assignable space as supervisor or unrestricted. attempts to read a supervisor-only data space when not in the supervisor access mode causes a value of $0000 to be returned. attempts to read assignable data space in the unrestricted access mode when the space is programmed as supervisor space causes a value of $ffff to be returned. attempts to write supervisor-only or supervi- sor-assigned data space when in the unrestricted access mode has no effect. the cpu indicates the supervisor and user space access with the function code bits (fc[2:0]) on the imb bus. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc configuration and control motorola reference manual 3-5 note some cpus do not support supervisor/user space selection, and are always in the supervisor access mode. in such cases, the supv bit has no meaning or effect. the supervisor-only data space segment contains the qadc global registers, which include the qadcmcr, the qadctest, and the qadcint. the supervisor/unre- stricted space designation for the ccw table, the result word table, and the remaining qadc registers are programmable. 3.3.4 interrupt arbitration priority each module that can generate interrupts, including the qadc, has an iarb (interrupt arbitration number) field in the qadcmcr. each iarb field must have a different val- ue. during an interrupt acknowledge cycle, iarb permits arbitration among simulta- neous interrupts of the same priority level. the reset value of iarb in the qadcmcr is $f. this prevents qadc interrupts from being discarded. initialization software must set the iarb field to a lower value in the range $f (highest priority) to $1 (lowest priority) if lower priority interrupts are to be ar- bitrated. refer to section 8 interrupts for more information. 3.3.5 qadc module configuration register the qadcmcr contains fields and bits that control freeze and stop modes and deter- mines the privilege level required to access most registers. it also contains the iarb field. stop ?stop enable 0 = disable stop mode. 1 = enable stop mode. frz ?freeze enable 0 = ignores the imb internal freeze signal. 1 = finish any current conversion, then freeze supv ?supervisor/unrestricted data space 0 = only the module configuration register, test register, and interrupt register are designated as supervisor-only data space. access to all other locations is un- restricted. 1 = all qadc registers and tables are designated as supervisor-only data space. qadcmcr module configuration register $####00 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 stop frz not used supv not used iarb reset: 0 0 1 0 0 0 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola configuration and control qadc 3-6 reference manual iarb[3:0] ?interrupt arbitration number iarb determines qadc interrupt arbitration priority. an iarb field can be assigned a value from %0001 (lowest priority) to %1111 (highest value). refer to section 8 in- terrupts for more information. 3.4 qadc test register qadctest ? qadc test register $####02 qadctest is used only during factory testing of the mcu. 3.5 general-purpose i/o port operation each of the port pins, when used as a general-purpose input, is conditioned by a syn- chronizer with an enable feature. the synchronizer is not enabled until the qadc de- codes an imb bus cycle which addresses the port data register to minimize the high- current effect of mid-level signals on the inputs used for analog signals. digital input signals must meet the input low voltage (v il ) or input high voltage (v ih ) specifications in appendix a electrical characteristics . if an analog input pin does not meet the digital input pin specifications when a digital port read operation occurs, an indeterminate state is read. during a port data register read, the actual value of the pin is reported when its corre- sponding bit in the data direction register defines the pin to be an input (port a only). when the data direction bit specifies the pin to be an output, the content of the port data register is read. by reading the latch which drives the output pin, software instruc- tions that read data, modify it, and write the result, like bit manipulation instructions, work correctly. when a reduced number of digital port pins are implemented on a par- ticular microcontroller version, the unused bit positions are read as a zero and write operations do not have any effect. there are two special cases to consider for the digital i/o port operation. when the mux (externally multiplexed) bit is set in qacr0, the data direction register settings are ignored for the bits corresponding to pqa[2:0], the three multiplexed address (ma[2:0]) output pins. the ma[2:0] pins are forced to be digital outputs, regardless of the data direction setting, and the multiplexed address outputs are driven. the data returned during a port data register read is the value of the multiplexed address latches which drive ma[2:0], regardless of the data direction setting. similarly, when an external trigger queue operating mode is selected, the data direc- tion setting for the corresponding pins, pqa3 or pqa4, is ignored. the port pins are forced to be digital inputs for etrig1 and/or etrig2. the data driven during a port data register read is the actual value of the pin, regardless of the data direction setting. 3.5.1 port data register qadc ports a and b are accessed through two 8-bit port data registers (portqa and portqb). f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc configuration and control motorola reference manual 3-7 port a pins are referred to as pqa[7:0] when used as a bidirectional 8-bit input/output port that may be used for general-purpose digital input signals or digital open drain pull-down output signals. port a can also be used for analog inputs (an[59:52], exter- nal trigger inputs (etrig[2:1]), and external multiplexer address outputs (ma[2:0]). port b pins are referred to as pqb[7:0] when used as an input-only 8-bit digital port that may be used for general-purpose digital input signals. data for pqb[7:0] is ac- cessed in the lower half of the qpdr. port b can also be used for nonmultiplexed (an[51:48]/an[3:0]) and multiplexed (anz, any, anx, anw) analog inputs. portqa and portqb are unaffected by reset. 3.5.2 port data direction register the port data direction register (ddrqa) is associated with the port a digital i/o pins. the bidirectional pins have somewhat higher leakage and capacitance specifications. refer to appendix a electrical characteristics for more information. any bit in this register set to one configures the corresponding pin as an output. any bit in this register cleared to zero configures the corresponding pin as an input. the software is responsible for ensuring that ddr bits are not set to one on pins used for analog inputs. when the ddr bit is set to one and the pin is selected for analog conversion, the voltage sampled is that of the output digital driver as influenced by the load. note caution should be exercised when mixing digital and analog inputs. this should be isolated as much as possible. rise and fall times should be as large as possible to minimize ac coupling effects. since port b is input-only, a data direction register is not needed. therefore, the lower byte of the port data direction register is not implemented. read operations on the re- served bits return zeros, and writes have no effect. portqa ?port a data register $####06 portqb ?port b data register $####07 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 pqa7 pqa6 pqa5 pqa4 pqa3 pqa2 pqa1 pqa0 pqb7 pqb6 pqb5 pqb4 pqb3 pqb2 pqb1 pqb0 reset: u u u u u u u uuuuuuuuu analog channel: an59 an58 an57 an56 an55 an54 an53 an52 an51 an50 an49 an48 an3 an2 an1 an0 external trigger inputs: etrig2 etrig1 multiplexed address outputs: ma2 ma1 ma0 multiplexed analog inputs: anz any anx anw f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola configuration and control qadc 3-8 reference manual ddrqa ? port data direction register $####08 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ddqa7 ddqa6 ddqa5 ddqa4 ddqa3 ddqa2 ddqa1 ddqa0 reserved reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc external multiplexing motorola reference manual 4-1 section 4 external multiplexing external multiplexer chips concentrate a number of analog signals onto a few inputs to the analog converter. this is helpful in applications that need to convert more analog signals than the a/d converter can normally provide. external multiplexing also puts the multiplex chip closer to the signal source. this minimizes the number of analog sig- nals that need to be shielded due to the close proximity to noisy high speed digital sig- nals at the microcontroller chip. for example, four 8-input multiplexer chips can be put at the connector where the an- alog signals first arrive on the computer board. as a result, only four analog signals need to be shielded from noise as they approach the microcontroller chip, rather than having to protect 32 analog signals. however, external multiplexer chips may intro- duce additional noise and errors if not properly utilized. therefore, it is necessary to maintain low ?n?resistance (the impedance of an analog switch when active within a multiplex chip) and insert a low pass filter (r/c) on the input side of the multiplex chip. 4.1 external multiplexing operation the qadc can use from one to four external multiplexer chips to expand the number of analog signals that may be converted. up to 32 analog channels can be converted through external multiplexer selection. the externally multiplexed channels are auto- matically selected from the channel field of the conversion command word (ccw) ta- ble, the same as internally multiplexed channels. refer to paragraph 7.7 in section 7 digital control for additional information on channel number assignments. all of the automatic queue features are available for externally and internally multi- plexed channels. the software selects the external multiplexed mode by setting the mux bit in control register 0 (qacr0). figure 4-1 shows the maximum configuration of four external multiplexer chips con- nected to the qadc. the external multiplexer chips select one of eight analog inputs and connect it to one analog output, which becomes an input to the qadc. the qadc provides three multiplexed address signals ?ma0, ma1, and ma2, to select one of eight inputs. these inputs are connected to all four external multiplexer chips. the an- alog output of the four multiplex chips are each connected to four separate qadc in- puts ?an w , an x , an y , and an z . f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola external multiplexing qadc 4-2 reference manual figure 4-1 example of external multiplexing when the external multiplexed mode is selected, the qadc automatically creates the ma open drain output signals from the channel number in each ccw. the qadc also converts the proper input channel (an w , an x , an y , and an z ) by interpreting the ccw channel number. as a result, up to 32 externally multiplexed channels appear to the conversion queues as directly connected signals. the software simply puts the chan- nel number of externally multiplexed channels into ccws. refer to table 7-9 in sec- tion 7 digital control which shows the channel numbers for the externally multiplexed channels that are assigned the range of channel 0 to channel 31. figure 4-1 shows that the three ma signals may also be analog input pins. when ex- ternal multiplexing is selected, none of the ma pins can be used for analog or digital inputs. they become multiplexed address outputs. qadc ext mux conn an52/ma0/pqa0 * an53/ma1/pqa1 * an54/ma2/pqa2 * an55/etrig1/pqa3 * an56/etrig2/pqa4 * an57/pqa5 * an58/pqa6 * an59/pqa7 * an0/anw/pqb0 an1/anx/pqb1 an2/any/pqb2 an3/anz/pqb3 an48/pqb4 an49/pqb5 an50/pqb6 an51/pqb7 digital results and control analog converter analog multiplexer v sse qadc v dda v ssa v rl v rh mux an0 an2 an4 an6 an8 an10 an11 an12 mux an1 an3 an5 an7 an9 an11 an13 an15 mux an16 an18 an20 an22 an24 an26 an28 an30 mux an17 an19 an21 an23 an25 an27 an29 an31 analog power analog references external triggers port b port a * * port a pins incorporate open drain pull down drivers. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc external multiplexing motorola reference manual 4-3 4.2 module version options the number of available analog channels varies, depending on whether or not exter- nal multiplexing is used. a maximum of 16 analog channels are supported by the in- ternal multiplexing circuitry of the converter. table 4-1 shows the total number of analog input channels supported with zero to four external multiplexer chips. the qadc uses 21 pins which allow a maximum of 41 analog channels to be converted. notes: 1. the above assumes that the external trigger inputs are shared with two analog input pins. 2. when external multiplexing is used, three input channels become multiplexed address out- puts, and for each external multiplexer chip, one input channel becomes a multiplexed ana- log input. table 4-1 analog input channels number of analog input channels available directly connected + external multiplexed = total channels 1 , 2 no external mux chips one external mux chip two external mux chips three external mux chips four external mux chips 16 12 + 8 = 20 11 + 16 = 27 10 + 24 = 34 9 + 32 = 41 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola external multiplexing qadc 4-4 reference manual f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc pin connection considerations motorola reference manual 5-1 section 5 pin connection considerations the qadc requires accurate, noise-free input signals for proper operation. this sec- tion discusses the design of external circuitry to maximize qadc performance. 5.1 analog reference pins no a/d converter can be more accurate than its analog reference. any noise in the reference can result in at least that much error in a conversion. the reference for the qadc, supplied by pins v rh and v rl , should be low-pass filtered from its source to obtain a noise-free, clean signal. in many cases, simple capacitive bypassing may suf- fice. in extreme cases, inductors or ferrite beads may be necessary if noise or rf en- ergy is present. series resistance is not advisable since there is an effective dc current requirement from the reference voltage by the internal resistor string in the rc dac array. external resistance may introduce error in this architecture under certain conditions. any series devices in the filter network should contain a minimum amount of dc resistance. for accurate conversion results, the analog reference voltages must be within the lim- its defined by v dda and v ssa , as explained in the following subsection. 5.2 analog power pins the analog supply pins (v dda and v ssa ) define the limits of the analog reference volt- ages (v rh and v rl ) and of the analog multiplexer inputs. figure 5-1 is a diagram of the analog input circuitry. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola pin connection considerations qadc 5-2 reference manual figure 5-1 analog input circuitry since the sample amplifier is powered by v dda and v ssa , it can accurately transfer input signal levels up to but not exceeding v dda and down to but not below v ssa . if the input signal is outside of this range, the output from the sample amplifier is clipped. in addition, v rh and v rl must be within the range defined by v dda and v ssa . as long as v rh is less than or equal to v dda and v rl is greater than or equal to v ssa and the sample amplifier has accurately transferred the input signal, resolution is ratiometric within the limits defined by v rl and v rh . if v rh is greater than v dda , the sample am- plifier can never transfer a full-scale value. if v rl is less than v ssa , the sample ampli- fier can never transfer a zero value. figure 5-2 shows the results of reference voltages outside the range defined by v dda and v ssa . at the top of the input signal range, v dda is 10 mv lower than v rh . this results in a maximum obtainable 10-bit conversion value of 3fe. at the bottom of the signal range, v ssa is 15 mv higher than v rl , resulting in a minimum obtainable 10-bit conversion value of three. sample amp 8 channels total * rc dac array comparator ref 1 v ssa v rl ref 2 v dda v rh qadc 8ch sample amp * two sample amps exist on the qadc with 8 channels on each sample amp. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc pin connection considerations motorola reference manual 5-3 figure 5-2 errors resulting from clipping 5.3 analog supply filtering and grounding two important factors influencing performance in analog integrated circuits are supply filtering and grounding. generally, digital circuits use bypass capacitors on every v dd / v ss pin pair. this applies to analog subsystems or submodules also. equally important as bypassing is the distribution of power and ground. analog supplies should be isolated from digital supplies as much as possible. this ne- cessity stems from the higher performance requirements often associated with analog circuits. therefore, deriving an analog supply from a local digital supply is not recom- mended. however, if for economic reasons digital and analog power are derived from a common regulator, filtering of the analog power is recommended in addition to the bypassing of the supplies already mentioned. for example, an rc low pass filter could be used to isolate the digital and analog supplies when generated by a common reg- ulator. if multiple high precision analog circuits are locally employed (i.e. two a/d con- verters), the analog supplies should be isolated from each other as sharing supplies introduces the potential for interference between analog circuits. grounding is the most important factor influencing analog circuit performance in mixed signal systems (or in standalone analog systems). close attention must be paid not to introduce additional sources of noise into the analog circuitry. common sources of noise include ground loops, inductive coupling, and combining digital and analog grounds together inappropriately. qadc clipping 0 .020 5.100 5.110 input in volts (v rh = 5.120 v, v rl = 0 v) 1 2 3 4 5 6 7 8 3fa 3fb 3fc 3fd 3fe 3ff .010 .030 5.120 5.130 10-bit result f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola pin connection considerations qadc 5-4 reference manual the problem of how and when to combine digital and analog grounds arises from the large transients which the digital ground must handle. if the digital ground is not able to handle the large transients, the current from the large transients can return to ground through the analog ground. it is the excess current overflowing into the analog ground which causes performance degradation by developing a differential voltage between the true analog ground and the microcontroller? ground pin. the end result is that the ground observed by the analog circuit is no longer true ground and often ends in skewed results. two similar approaches designed to improve or eliminate the problems associated with grounding excess transient currents involve star-point ground systems. one ap- proach is to star-point the different grounds at the power supply origin, thus keeping the ground isolated. refer to figure 5-3 . figure 5-3 star-ground at the point of power supply origin another approach is to star-point the different grounds near the analog ground pin on the microcontroller by using small traces for connecting the non-analog grounds to the analog ground. the small traces are meant only to accommodate dc differences, not ac transients. note this star-point scheme still requires adequate grounding for digital and analog subsystems in addition to the star-point ground. qadc vrh vrl vssa vdda vdd vss analog power supply +5v +5v agnd digital power supply +5v pgnd pcb qadc power schem f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc pin connection considerations motorola reference manual 5-5 other suggestions for pcb layout in which the qadc is employed include: ?analog ground must be low impedance to all analog ground points in the circuit. ?bypass capacitors should be as close to the power pins as possible. ?the analog ground should be isolated from the digital ground. this can be done by cutting a separate ground plane for the analog ground. ?non-minimum traces should be utilized for connecting bypass capacitors and fil- ters to their corresponding ground/power points. ?minimum distance for trace runs when possible. 5.4 accommodating positive/negative stress conditions positive or negative stress refers to conditions which exceed nominally defined oper- ating limits. examples include applying a voltage exceeding the normal limit on an in- put (for example, voltages outside of the suggested supply/reference ranges) or causing currents into or out of the pin which exceed normal limits. qadc specific con- siderations are voltages greater than v dda , v rh or less than v ssa applied to an analog input which cause excessive currents into or out of the input. refer to appendix a electrical characteristics for more information on exact magnitudes. both stress conditions can potentially disrupt conversion results on neighboring inputs. parasitic devices, associated with cmos processes, can cause an immediate disrup- tive influence on neighboring pins. common examples of parasitic devices are diodes to substrate and bipolar devices with the base terminal tied to substrate (v ssi /v ssa ground). under stress conditions, current introduced on an adjacent pin can cause er- rors on adjacent channels by developing a voltage drop across the adjacent external channel source impedances. figure 5-4 shows an active parasitic bipolar when an input pin is subjected to negative stress conditions. positive stress conditions do not activate a similar parasitic device. figure 5-4 input pin subjected to negative stress the current out of the pin (i out ) under negative stress is determined by the following equation: qadc par stress conn r stress r adjacent adjacent negative 10k vdd pin under parasitic i out i in + stress stress voltage device pins f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola pin connection considerations qadc 5-6 reference manual where: v stress = adjustable voltage source v be = parasitic bipolar base/emitter voltage (refer to v negclamp in ap- pendix a electrical characteristics ) r stress = source impedance (10k resistor in figure 5-4 on stressed channel) the current into (i in ) the neighboring pin is determined by the 1/k n (gain) of the para- sitic bipolar transistor (1/k n 1). one way to minimize the impact of stress conditions on the qadc is to apply voltage limiting circuits such as diodes to supply and ground. however, leakage from such cir- cuits and the potential influence on the sampled voltage to be converted must be con- sidered. refer to figure 5-5 . figure 5-5 voltage limiting diodes in a negative stress circuit another method for minimizing the impact of stress conditions on the qadc is to stra- tegically allocate qadc inputs so that the lower accuracy inputs are adjacent to the inputs most likely to see stress conditions. finally, suitable source impedances should be selected to meet design goals and min- imize the effect of stress conditions. 5.5 analog input considerations the source impedance of the analog signal to be measured and any intermediate fil- tering should be considered whether external multiplexing is used or not. figure 5-6 shows the connection of eight typical analog signal sources to one qadc analog input pin through a separate multiplexer chip. also, an example of an analog signal source connected directly to a qadc analog input channel is displayed. i out v stress v be r stress ------------------------------------------- - = qadc neg stress conn vdd r kr to device external voltage vss f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc pin connection considerations motorola reference manual 5-7 figure 5-6 external multiplexing of analog signal sources ~ ~ ~ ~ ~ ~ ~ ~ c in c sample c in c sample c in = c in + c sample r muxout r source 2 analog signal source filtering and interconnect typical mux chip interconnect qadc qadc ext mux ex ~ c filter c source r filter 2 c muxin 0.1 m f 1 c muxout (mc54hc4051, mc74hc4051, mc54hc4052, mc74hc4052, mc54hc4053, etc.) r source 2 c filter c source r filter 2 c muxin 0.1 m f 1 r source 2 c filter c source r filter 2 c muxin 0.1 m f 1 r source 2 c filter c source r filter 2 c muxin 0.1 m f 1 r source 2 c filter c source r filter 2 c muxin 0.1 m f 1 r source 2 c filter c source r filter 2 c muxin 0.1 m f 1 r source 2 c filter c source r filter 2 c muxin 0.1 m f 1 r source 2 c filter c source r filter 2 c muxin 0.1 m f 1 c filter r filter 2 0.1 m f 1 1. typical value 2. r filter typically 10k w ?0k w . notes: r source 2 c source f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola pin connection considerations qadc 5-8 reference manual 5.6 analog input pins analog inputs should have low ac impedance at the pins. low ac impedance can be realized by placing a capacitor with good high frequency characteristics at the input pin of the part. ideally, that capacitor should be as large as possible (within the practi- cal range of capacitors that still have good high frequency characteristics). this capac- itor has two effects: ?it helps attenuate any noise that may exist on the input. ?it sources charge during the sample period when the analog signal source is a high-impedance source. series resistance can be used with the capacitor on an input pin to implement a simple rc filter. the maximum level of filtering at the input pins is application dependent and is based on the bandpass characteristics required to accurately track the dynamic characteristics of an input. simple rc filtering at the pin may be limited by the source impedance of the transducer or circuit supplying the analog signal to be measured. (re- fer to 5.6.2 error resulting from leakage ). in some cases, the size of the capacitor at the pin may be very small. figure 5-7 is a simplified model of an input channel. refer to this model in the follow- ing discussion of the interaction between the external circuitry and the circuitry inside the qadc. figure 5-7 electrical model of an a/d input pin in figure 5-7 , r f and c f comprise the external filter circuit. c s is the internal sample capacitor. each channel has its own capacitor. c s is never precharged; it retains the value of the last sample. v i is an internal voltage source used to precharge the dac qadc sample amp model s1 s2 amp r f s4 s3 c dac v i c s c f v src internal circuit model external circuit = source voltage = internal capacitance (for a bypassed channel, this is the c dac capacitance) v src r f c f c s c dac v i = filter impedance (source impedance included) = filter capacitor = dac capacitor array = internal voltage source for precharge (v dda /2) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc pin connection considerations motorola reference manual 5-9 capacitor array (c dac ) before each sample. the value of this supply is v dda /2, or 2.5 volts for 5-volt operation. the following paragraphs provide a simplified description of the interaction between the qadc and the user's external circuitry. this circuitry is assumed to be a simple rc low-pass filter passing a signal from a source to the qadc input pin. the following simplifying assumptions are made: ?the source impedance is included with the series resistor of the rc filter. ?the external capacitor is perfect (no leakage, no significant dielectric absorption characteristics, etc.) ?all parasitic capacitance associated with the input pin is included in the value of the external capacitor. ?inductance is ignored. ?the "on" resistance of the internal switches is zero ohms and the "off" resistance is infinite. 5.6.1 settling time for the external circuit the values for r f and c f in the user's external circuitry determine the length of time required to charge c f to the source voltage level (v src ). at time t = 0, s1 in figure 5- 7 closes. s2 is open, disconnecting the internal circuitry from the external circuitry. as- sume that the initial voltage across c f is zero. as c f charges, the voltage across it is determined by the following equation, where t is the total charge time: when t = 0, the voltage across c f = 0. as t approaches infinity, v cf will equal v src . (this assumes no internal leakage.) with 10-bit resolution, 1/2 of a count is equal to 1/2048 full-scale value. assuming worst case (v src = full scale), table 5-1 shows the required time for c f to charge to within 1/2 of a count of the actual source voltage dur- ing 10-bit conversions. table 5-1 is based on the rc network in figure 5-7 . note the following times are completely independent of the a/d converter architecture (assuming the qadc is not affecting the charging). table 5-1 external circuit settling time (10-bit conversions) filter capacitor (cf) source resistance (r f ) 100 w 1 k w 10 k w 100 k w 1 m f 760 m s 7.6 ms 76 ms 760 ms .1 m f 76 m s 760 m s 7.6 ms 76 ms .01 m f 7.6 m s 76 m s 760 m s 7.6 ms .001 m f 760 ns 7.6 m s 76 m s 760 m s 100 pf 76 ns 760 ns 7.6 m s 76 m s v cf v src 1e t r f c f () = f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola pin connection considerations qadc 5-10 reference manual the external circuit described in table 5-1 is a low-pass filter. a user interested in measuring an ac component of the external signal must take the characteristics of this filter into account. 5.6.2 error resulting from leakage a series resistor limits the current to a pin, therefore input leakage acting through a large source impedance can degrade a/d accuracy. the maximum input leakage cur- rent is specified in appendix a electrical characteristics . input leakage is greatest at high operating temperatures and as a general rule decreases by one half for each 10 c decrease in temperature. assuming v rh ?v rl = 5.12 v, 1 count (assuming 10-bit resolution) corresponds to 5 mv of input voltage. a typical input leakage of 50 na acting through 100 k w of external series resistance results in an error of less than 1 count (5.0 mv). if the source imped- ance is 1 m w and a typical leakage of 50 na is present, an error of 10 counts (50 mv) is introduced. in addition to internal junction leakage, external leakage (e.g., if external clamping di- odes are used) and charge sharing effects with internal capacitors also contribute to the total leakage current. table 5-2 illustrates the effect of different levels of total leak- age on accuracy for different values of source impedance. the error is listed in terms of 10-bit counts. caution leakage from the part of 10 na is obtainable only within a limited tem- perature range. table 5-2 error resulting from input leakage (ioff) source impedance leakage value (10-bit conversions) 10 na 50 na 100 na 1000 na 1 k w 0.2 counts 10 k w 0.1 counts 0.2 counts 2 counts 100 k w 0.2 counts 1 count 2 counts 20 counts f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc analog subsystem motorola reference manual 6-1 section 6 analog subsystem this section describes the qadc analog subsystem, which includes the front-end an- alog multiplexer, digital to analog converter (dac) array, the comparator, and the suc- cessive approximation register (sar). 6.1 analog-to-digital converter operation the analog subsystem consists of the path from the input pins through the input mul- tiplexing circuitry, into the dac array, and through the analog comparator. the output of the comparator feeds into the sar and is considered the boundary between the an- alog and digital subsystems of the qadc. figure 6-1 shows a block diagram of the qadc analog submodule. figure 6-1 qadc module block diagram clock pqa7 pqa0 pqb7 pqb0 chan. mux vdda vssa sample/ mux 4: 1 10-bit compar- charge successive port pqa port pqb result bus periodic sample imb address addr data clock external alignment decode input i/o control registers and control logic timer timer 16: 2 triggers ator rc-dac vrh vrl address decode result table ccw table 10-bit, 10-bit, pump and bias 40-word ram 40-word ram dac hold sample/ hold prescaler inter- module bus inter- face approximation register dummy qadc detail block f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola analog subsystem qadc 6-2 reference manual 6.1.1 conversion cycle times total conversion time is made up of initial sample time, transfer time, final sample time, and resolution time. initial sample time refers to the time during which the selected in- put channel is connected to the sample capacitor at the input of the sample buffer am- plifier. during the transfer period, the sample capacitor is disconnected from the multiplexer, and the stored voltage is buffered and transferred to the rc dac array. during the final sampling period, the sample capacitor and amplifier are bypassed, and the multiplexer input charges the rc dac array directly. during the resolution pe- riod, the voltage in the rc dac array is converted to a digital value and stored in the sar. initial sample time is fixed at two qclks and the transfer time at four qclks. final sample time can be 2, 4, 8, or 16 adc clock cycles, depending on the value of the ist field in the ccw. resolution time is ten cycles. transfer and resolution require a minimum of 18 qclk clocks (8.6 m s with a 2.1-mhz qclk). if the maximum final sample time period of 16 qclks is selected, the total conversion time is 15.2 m s (with a 2.1-mhz qclk). figure 6-2 illustrates the timing for conversions. this diagram assumes a final sam- pling period of two qclks. figure 6-2 conversion timing 6.1.1.1 amplifier bypass mode conversion timing if the amplifier bypass mode is enabled for a conversion by setting the amplifier bypass (byp) field in the ccw, the timing changes to that shown in figure 6-3 . refer to para- graph 7.7 in section 7 digital control for more information on the byp field. the initial sample time and the transfer time are eliminated reducing the potential con- version time by six qclks. however, due to internal rc effects, a minimum final sam- initial sample time transfer time final sample time resolution time sample and transfer time successive approximation resolution sequence 2 cycles 4 cycles n cycles: 10 cycles qclk (2, 4, 8, 16) qadc conversion tim f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc analog subsystem motorola reference manual 6-3 ple time of four qclks must be allowed. this results in a savings of four qclks. when using the bypass mode, the external circuit should be of low source impedance (typically less than 10 k w ). also, the loading effects of the external circuitry by the qadc need to be considered, since the benefits of the sample amplifier are not present. figure 6-3 bypass mode conversion timing 6.2 front-end analog multiplexer the internal multiplexer selects one of the 16 analog input pins or one of three special internal reference channels for conversion. the following are the three special chan- nels: ?v rh ?reference voltage high ?v rl ?reference voltage low ?v dda /2 ?mid-analog supply voltage the selected input is connected to one side of the dac capacitor array. the other side of the dac array is connected to the comparator input. the multiplexer also includes positive and negative stress protection circuitry, which prevents other channels from affecting the current conversion when voltage levels are applied to the other channels. refer to appendix a electrical characteristics for specific voltage level limits. 6.3 digital to analog converter array the digital to analog converter (dac) array consists of binary-weighted capacitors and a resistor-divider chain. the array serves two purposes: ?the array holds the sampled input voltage during conversion. ?the resistor-capacitor array provides the mechanism for the successive approx- imation a/d conversion. ?resolution begins with the most significant bit (msb) and works down to the least significant bit (lsb). the switching sequence is controlled by the digital logic. sample time resolution time sample time successive approximation resolution sequence n cycles: 10 cycles qclk (2, 4, 8, 16) qadc byp conversion tim f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola analog subsystem qadc 6-4 reference manual 6.4 comparator the comparator is used during the approximation process to sense whether the digi- tally selected arrangement of the dac array produces a voltage level higher or lower than the sampled input. the comparator output feeds into the sar which accumulates the a/d conversion result sequentially, starting with the msb. 6.5 successive approximation register the input of the successive approximation register (sar) is connected to the compar- ator output. the sar sequentially receives the conversion value one bit at a time, starting with the msb. after accumulating the 10 bits of the conversion result, the sar data is transferred to the appropriate result location, where it may be read from the imb by user software. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-1 section 7 digital control the digital control subsystem includes the control logic to sequence the conversion activity, channel select logic, the clock and periodic/interval timer, control and status registers, the conversion command word table ram, and the result word table ram. the central element for control of the qadc conversions is the 40-entry conversion command word (ccw) table. each ccw specifies the conversion of one input chan- nel. depending on the application, one or two queues can be established in the ccw table. a queue is a scan sequence of one or more input channels. by using a pause mechanism, subqueues can be created in the two queues. each queue can be oper- ated using several different scan modes. the scan modes for queue 1 and queue 2 are programmed in qacr1 and qacr2 (control registers 1 and 2). once a queue has been started by a trigger event (any of the ways to cause the qadc to begin executing the ccws in a queue or subqueue), the qadc performs a sequence of conversions and places the results in the result word table. 7.1 queue priority queue 1 has priority over queue 2 execution. the following cases show the conditions under which queue 1 asserts its priority: ?when a queue is not active, a trigger event for queue 1 or queue 2 causes the corresponding queue execution to begin. ?when queue 1 is active and a trigger event occurs for queue 2, queue 2 cannot begin execution until queue 1 reaches completion or the paused state. the status register records the trigger event by reporting the queue 2 status as trigger pend- ing. additional trigger events for queue 2, which occur before execution can be- gin, are recorded as trigger overruns. ?when queue 2 is active and a trigger event occurs for queue 1, the current queue 2 conversion is aborted. the status register reports the queue 2 status as sus- pended. any trigger events occurring for queue 2 while queue 2 is suspended are recorded as trigger overruns. once queue 1 reaches the completion or the paused state, queue 2 begins executing again. the programming of the resume bit in qacr2 determines which ccw is executed in queue 2. refer to 7.6.3 con- trol register 2 for more information. ?when simultaneous trigger events occur for queue 1 and queue 2, queue 1 be- gins execution and the queue 2 status is changed to trigger pending. ?subqueues that are paused. the pause feature can be used to divide queue 1 and/or queue 2 into multiple sub- queues. a subqueue is defined by setting the pause bit in the last ccw of the sub- queue. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-2 reference manual figure 7-1 shows the ccw format and an example of using pause to create sub- queues. queue 1 is shown with four ccws in each subqueue and queue 2 has two ccws in each subqueue. figure 7-1 qadc queue operation with pause the queue operating mode selected for queue 1 determines what type of trigger event causes the execution of each of the subqueues within queue 1. similarly, the queue operating mode for queue 2 determines the type of trigger event required to execute each of the subqueues within queue 2. for example, when the external trigger rising edge continuous-scan mode is selected for queue 1, and there are six subqueues within queue 1, a separate rising edge is re- quired on the external trigger pin after every pause to begin the execution of each sub- queue (refer to figure 7-1 ). refer to 7.3 scan modes for more information on different scan modes. the choice of single-scan or continuous-scan applies to the full queue, and is not ap- plied to each subqueue. once a subqueue is initiated, each ccw is executed sequen- tially until the last ccw in the subqueue is executed and the pause state is entered. qadc cqp 00 begin queue 1 bq2 39 end of queue 1 begin queue 2 end of queue 2 00 39 channel select, sample, hold, and a/d conversion conversion command word (ccw) table result word table 0 p 0 0 1 0 0 0 1 0 0 0 0 1 0 1 0 1 0 p 1 p 0 pause pause pause pause pause pause f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-3 execution can only continue with the next ccw, which is the beginning of the next subqueue. a subqueue cannot be executed a second time before the overall queue execution has been completed. refer to 7.6.3 control register 2 for more informa- tion. trigger events which occur during the execution of a subqueue are ignored, except that the trigger overrun flag is set. when a continuous-scan mode is selected, a trigger event occurring after the completion of the last subqueue (after the queue completion flag is set), causes the execution to continue with the first subqueue, starting with the first ccw in the queue. when the qadc encounters a ccw with the pause bit set, the queue enters the paused state after completing the conversion specified in the ccw with the pause bit. the pause flag is set and a pause software interrupt may optionally be issued. the sta- tus of the queue is shown to be paused, indicating completion of a subqueue. the qadc then waits for another trigger event to again begin execution of the next sub- queue. 7.2 boundary conditions the following are queue operation boundary conditions: ?the first ccw in a queue contains channel 63, the end-of-queue (eoq) code. the queue becomes active and the first ccw is read. the end-of-queue is rec- ognized, the completion flag is set, and the queue becomes idle. a conversion is not performed. ?bq2 (beginning of queue 2) is set beyond the end of the ccw table (40?3) and a trigger event occurs on queue 2. refer to 7.6.3 control register 2 for informa- tion on bq2. the end-of-queue condition is recognized immediately, the comple- tion flag is set, and the queue becomes idle. a conversion is not performed. ?bq2 is set to ccw0 and a trigger event occurs on queue 1. after reading ccw0, the end-of-queue condition is recognized, the completion flag is set, and the queue becomes idle. a conversion is not performed. note multiple end-of-queue conditions may be recognized simultaneously, although there is no change in the qadc behavior. for example, if bq2 is set to ccw0, ccw0 contains the eoq code, and a trigger event occurs on queue 1, the qadc reads ccw0 and detects both end-of-queue conditions. the completion flag is set and queue 1 be- comes idle. boundary conditions also exist for combinations of pause and end-of-queue. one case is when a pause bit is in one ccw and an end-of-queue condition is in the next ccw. the conversion specified by the ccw with the pause bit set completes normally. the pause flag is set. however, since the end-of-queue condition is recognized, the com- pletion flag is also set and the queue status becomes idle, not paused. examples of this situation include: f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-4 reference manual ?the pause bit is set in ccw5 and the channel 63 (eoq) code is in ccw6. ?the pause is in ccw39. ?during queue 1 operation, the pause bit is set in ccw20 and bq2 points to ccw21. another pause and end-of-queue boundary condition occurs when the pause and an end-of-queue condition occur in the same ccw. both the pause and end-of-queue conditions are recognized simultaneously. the end-of-queue condition has prece- dence so a conversion is not performed for the ccw and the pause flag is not set. the qadc sets the completion flag and the queue status becomes idle. examples of this situation are: ?the pause bit is set in ccw10 and eoq is programmed into ccw10. ?during queue 1 operation, the pause bit set in ccw32, which is also bq2. 7.3 scan modes the qadc queuing mechanism allows the application to utilize different requirements for automatically scanning input channels. in single-scan mode, a single pass through a sequence of conversions defined by a queue is performed. in continuous-scan mode, multiple passes through a sequence of conversions defined by a queue is executed. the following paragraphs describe single-scan and continu- ous-scan operations. 7.3.1 disabled mode and reserved mode when the disabled mode or a reserved mode is selected, the queue is not active. trig- ger events cannot initiate queue execution. when both queue 1 and queue 2 are dis- abled, wait states are not encountered for imb accesses of the ram. when both queues are disabled, it is safe to change the prescaler values. 7.3.2 single-scan modes when the application software wants to execute a single pass through a sequence of conversions defined by a queue, a single-scan queue operating mode is selected. by programming the mq1 field in qacr1, the following modes can be selected for queue 1: ?software initiated single-scan mode ?external trigger rising edge single-scan mode ?external trigger falling edge single-scan mode in addition to the above modes, queue 2 can also be programmed for the interval timer single-scan mode, using the periodic/interval timer. the queue operating mode for queue 2 is selected by the mq2 field in qacr2. in all single-scan queue operating modes, the software must also enable the queue to begin execution by writing the single-scan enable bit to a one in the queue? control register. the single-scan enable bits, sse1 and sse2, are provided for queue 1 and queue 2 respectively. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-5 until the single-scan enable bit is set, any trigger events for that queue are ignored. the single-scan enable bit may be set to a one during the write cycle, which selects the single-scan queue operating mode. the single-scan enable bit can be written as a one or a zero, but is always read as a zero. the completion flag, completion interrupt, or queue status are used to determine when the queue has completed. after the single-scan enable bit is set, a trigger event causes the qadc to begin exe- cution with the first ccw in the queue. the single-scan enable bit remains set until the queue is completed. after the queue reaches completion, the qadc resets the single- scan enable bit to zero. if the single-scan enable bit is written to a one or a zero by the software before the queue scan is complete, the queue is not affected. however, if the software changes the queue operating mode, the new queue operating mode and the value of the single-scan enable bit are recognized immediately. the current conver- sion is aborted and the new queue operating mode takes effect. in the software initiated single-scan mode, the writing of a one to the single-scan en- able bit causes the qadc to internally generate a trigger event and the queue execu- tion begins immediately. in the other single-scan queue operating modes, once the single-scan enable bit is written, the selected trigger event must occur before the queue can start. a trigger overrun is recorded if a trigger event occurs during queue execution in the external trigger single-scan mode and the interval timer single-scan mode. when a pause bit is encountered during the queue scan in a single-scan mode, anoth- er trigger event is required for queue execution to continue. software involvement is not needed to enable queue execution to continue from the paused state. the single- scan enable bit allows the entire queue to be scanned once. in the software initiated single-scan mode, the trigger event is generated internally as soon as the conversion is complete for the ccw with the pause bit set. the pause is two qclks. in the external trigger single-scan mode, the queue remains paused until another trigger edge is received on the external trigger pin. in the interval timer single-scan mode, the next expiration of the timer is the trigger event for the queue. after the queue execution is complete, the queue status is shown as idle. the software can restart the queue by setting the single-scan enable bit to a one. queue execution begins with the first ccw in the queue. 7.3.2.1 software initiated single-scan mode software can initiate the execution of a scan sequence for queue 1 or 2 by selecting the software initiated single-scan mode, and writing the single-scan enable bit in qacr1 or qacr2. a trigger event is generated internally and the qadc immediately begins execution of the first ccw in the queue. if a pause is encountered, queue ex- ecution ceases momentarily while another trigger event is generated internally, and then execution continues. the qadc automatically performs the conversions in the queue until an end-of-queue condition is encountered. the queue remains idle until the software again sets the sin- gle-scan enable bit. while the time to internally generate and act on a trigger event is f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-6 reference manual very short, software can momentarily read the status conditions, indicating that the queue is paused. the trigger overrun flag is never set while in the software initiated single-scan mode. the software initiated single-scan mode is useful in the following applications: ?allows software complete control of the queue execution. ?allows the software to easily alternate between several queue sequences. 7.3.2.2 external trigger single-scan mode the external trigger single-scan mode is a variation of the external trigger continuous- scan mode, and is also available with both queue 1 and queue 2. the software pro- grams the polarity of the external trigger edge that is to be detected, either a rising or a falling edge. the software must enable the scan to occur by setting the single-scan enable bit for the queue. the first external trigger edge causes the queue to be executed one time. each ccw is read and the indicated conversions are performed until an end-of-queue condition is encountered. after the queue is completed, the qadc clears the single-scan enable bit. software may set the single-scan enable bit again to allow another scan of the queue to be initiated by the next external trigger edge. the external trigger single-scan mode is useful when the input trigger rate can exceed the queue execution rate. analog samples can be taken in sync with an external event, even though the software is not interested in data taken from every edge. the software can start the external trigger single-scan mode and get one set of data, and at a later time, start the queue again for the next set of samples. the external trigger single-scan mode is also useful when the software needs to change the polarity of the external trigger so that both the rising and falling edges cause queue execution. 7.3.2.3 interval timer single-scan mode queue 2 can also use the periodic/interval timer in a single-scan queue operating mode. the timer interval can range from 128 to 128k qclk cycles in binary multiples. when the interval timer single-scan mode is selected and the software sets the single- scan enable bit in qacr2, the timer begins counting. when the time interval expires, an internal trigger event is created to start the queue. the timer is reloaded and begins counting again. meanwhile, the qadc begins execution with the first ccw in queue 2. the qadc automatically performs the conversions in the queue until a pause or an end-of-queue condition is encountered. when a pause occurs, queue execution stops until the timer interval expires again, and queue execution continues. when the queue execution reaches an end of queue situation, the timer is held in reset and the single- scan enable bit is cleared. software may set the single-scan enable bit again, allowing another scan of the queue to be initiated by the interval timer. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-7 the interval timer generates a trigger event whenever the time interval elapses. the trigger event may cause the queue execution to continue following a pause, or may be considered a trigger overrun. once the queue execution is completed, the single-scan enable bit must be set again to enable the timer to count again. the interval timer single-scan mode can be used in applications which need coherent results, for example: ?when it is necessary that all samples are guaranteed to be taken during the same scan of the analog pins. ?when the interrupt rate in the periodic timer continuous-scan mode would be too high. ?in sensitive battery applications, where the single-scan mode uses less power than the software initiated continuous-scan mode. 7.3.3 continuous-scan modes when the application software wants to execute multiple passes through a sequence of conversions defined by a queue, a continuous-scan queue operating mode is se- lected. by programming the mq1 field in qacr1, the following software initiated modes can be selected for queue 1: ?software initiated continuous-scan mode ?external trigger rising edge continuous-scan mode ?external trigger falling edge continuous-scan mode in addition to the above modes, queue 2 can also be programmed for the periodic tim- er continuous-scan mode, where a scan is initiated at a selectable time interval using the on-chip periodic/interval timer. the queue operating mode for queue 2 is selected by the mq2 field in qacr2. when a queue is programmed for a continuous-scan mode, the single-scan enable bit in the queue control register does not have any meaning or effect. as soon as the queue operating mode is programmed, the selected trigger event can initiate queue execution. in the case of the software initiated continuous-scan mode, the trigger event is gener- ated internally and queue execution begins immediately. in the other single-scan queue operating modes, the selected trigger event must occur before the queue can start. a trigger overrun is recorded if a trigger event occurs during queue execution in the external trigger continuous-scan mode and the periodic timer continuous-scan mode. when a pause bit is encountered during the scan, another trigger event is re- quired for queue execution to continue. software involvement is not needed to enable queue execution to continue from the paused state. in the software initiated continuous-scan mode, the trigger event is generated internal- ly as soon as the conversion is complete for the ccw with the pause bit set. the pause is two qclks. in the external trigger continuous-scan mode, the queue remains paused until another trigger edge is received on the external trigger pin. in the periodic timer continuous-scan mode, the next expiration of the timer is the trigger event for the queue. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-8 reference manual after the queue execution is complete, the queue status is shown as idle. since the continuous-scan queue operating modes allow the entire queue to be scanned multi- ple times, software involvement is not needed to enable queue execution to continue from the idle state. the next trigger event causes queue execution to begin again, starting with the first ccw in the queue. note it may not be possible to guarantee coherent samples since the rela- tionship between any conversion in time and any other conversion may be variable (due to programmable trigger events, queue priori- ties, and so on). 7.3.3.1 software initiated continuous-scan mode when the software initiated continuous-scan mode is programmed, the trigger event is generated automatically by the qadc. queue execution begins immediately. if a pause is encountered, queue execution ceases for two qclks, while another trigger event is generated internally, and then execution continues. when the end-of-queue is reached, another internal trigger event is generated, and queue execution begins again from the beginning of the queue. while the time to internally generate and act on a trigger event is very short, software can momentarily read the status conditions, indicating that the queue is paused or idle. the trigger overrun flag is never set while in the software initiated continuous-scan mode. the software initiated continuous-scan mode keeps the result registers updated more frequently than any of the other queue operating modes. the software can always read the result table to get the latest converted value for each channel. the channels scanned are kept up to date by the qadc without software involvement. software can read a result value at any time. note it may not be possible to guarantee coherent samples since the rela- tionship between any conversion in time and any other conversion may be variable (due to programmable trigger events, queue priori- ties, and so on). the software initiated continuous-scan mode may be chosen for either queue, but is normally used only with queue 2. when the software initiated continuous-scan mode is chosen for queue 1, that queue operates continuously and queue 2, being lower in priority, never gets executed. the short interval of time between a queue 1 pause and the internally generated trigger event, or between a queue 1 completion and the sub- sequent trigger event is not sufficient to allow queue 2 execution to begin. the software initiated continuous-scan mode is a useful choice with queue 2 for con- verting channels that do not need to be synchronized to anything, or for the slow-to- change analog channels. interrupts are normally not used with the software initiated continuous-scan mode. rather, the software reads the latest conversion result from f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-9 the result table at any time. once initiated, software action is not needed to sustain conversions of channel. 7.3.3.2 external trigger continuous-scan mode the qadc provides external trigger pins for both queues. when the external trigger software initiated continuous-scan mode is selected, a transition on the associated ex- ternal trigger pin initiates queue execution. the polarity of the external trigger signal is programmable, so that the software can choose to begin queue execution on the rising or falling edge. each ccw is read and the indicated conversions are performed until an end-of-queue condition is encountered. when the next external trigger edge is de- tected, the queue execution begins again automatically. software initialization is not needed between trigger events. some applications need to synchronize the sampling of analog channels to external events. there are cases when it is not possible to use software initiation of the queue scan sequence, since interrupt response times vary. 7.3.3.3 periodic timer continuous-scan mode the qadc includes a dedicated periodic/interval timer for initiating a scan sequence for queue 2 only. software selects a programmable timer interval ranging from 128 to 128k times the qclk period in binary multiples. the qclk period is prescaled down from the intermodule bus (imb) mcu clock. when the periodic timer continuous-scan mode is selected, the timer begins counting. after the programmed interval elapses, the timer generated trigger event starts the queue. the timer is then reloaded and begins counting again. meanwhile, the qadc automatically performs the conversions in the queue until an end-of-queue condition or a pause is encountered. when a pause occurs, the qadc waits for the periodic in- terval to expire again, then continues with the queue. after end-of-queue has been de- tected, the next trigger event causes queue execution to begin again with the first ccw in queue 2. the periodic timer generates a trigger event whenever the time interval elapses. the trigger event may cause the queue execution to continue following a pause or queue completion, or may be considered a trigger overrun. as with all continuous-scan queue operating modes, software action is not needed between trigger events. software enables the completion interrupt when using the periodic timer continuous- scan mode. when the interrupt occurs, the software knows that the periodically col- lected analog results have just been taken. the software can use the periodic interrupt to obtain non-analog inputs as well, such as contact closures, as part of a periodic look at all inputs. 7.4 qadc clock (qclk) generation figure 7-2 is a block diagram of the clock subsystem. the qclk provides the timing for the a/d converter state machine which controls the timing of the conversion. the qclk is also the input to a 17-stage binary divider which implements the periodic/in- f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-10 reference manual terval timer. to retain the specified analog conversion accuracy, the qclk frequency (f qclk ) must be within the tolerance specified in appendix a electrical char- acteristics . before using the qadc, the software must initialize the prescaler with values that put the qclk within the specified range. though most software applications initialize the prescaler once and do not change it, write operations to the prescaler fields are per- mitted. caution a change in the prescaler value while a conversion is in progress is likely to corrupt the result from any conversion in progress. there- fore, any prescaler write operation should be done only when both queues are in the disabled modes. figure 7-2 qadc clock subsystem functions qadc clock block prescaler rate selection (from control register 0): binary counter periodic/interval timer select 2 15 2 14 2 13 2 12 2 11 2 10 2 9 2 8 2 7 2 16 2 17 one's complement compare clock generate 5-bit down counter zero detect reset qclk load psh set qclk qclk qadc clock ( ? 2 to ? 40 ) low time cycles (psl) add half cycle to high (psa) high time cycles (psh) input sample time (from ccw) queue 2 mode rate selection (from control register 2): sar control sar[9:0] periodic/interval trigger event 53 3 3 1 5 4 system clock (fsys) a/d converter state machine f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-11 to accommodate wide variations of the main mcu clock frequency (imb system clock ?f sys ), qclk is generated by a programmable prescaler which divides the mcu sys- tem clock to a frequency within the specified qclk tolerance range. to allow the a/d conversion time to be maximized across the spectrum of system clock frequencies, the qadc prescaler permits the frequency of qclk to be software selectable. it also allows the duty cycle of the qclk waveform to be programmable. the software establishes the basic high phase of the qclk waveform with the psh (prescaler clock high time) field in qacr0, and selects the basic low phase of qclk with the psl (prescaler clock low time) field. the duty cycle of the qclk can be further modified with the psa (prescaler add a clock tic) bit in qacr0. the combination of the psh and psl parameters establishes the frequency of the qclk. figure 7-2 shows that the prescaler is essentially a variable pulse width signal gener- ator. a 5-bit down counter, clocked at the system clock rate, is used to create both the high phase and the low phase of the qclk signal. at the beginning of the high phase, the 5-bit counter is loaded with the 5-bit psh value. when the zero detector finds that the high phase is finished, the qclk is reset. a 3-bit comparator looks for a one? com- plement match with the 3-bit psl value, which is the end of the low phase of the qclk. the psa bit allows the qclk high-to-low transition to be delayed by a half cycle of the input clock. the following sequence summarizes the process of determining what values are to be put into the prescaler fields in qacr0: 1. choose the system clock frequency (f sys ). 2. choose first-try values for psh, psl, and psa, then skip to step 4. 3. choose different values for psh, psl, and psa. 4. if high qclk time is less than t psh (qadc clock duty cycle ?minimum high phase time), return to step 3. refer to appendix a electrical charac- teristics for more information on t psh . note high qclk time (in ns) = 1000 (psh + 1 + 0.5 psa) ? f sys (in mhz) 5. if low qclk time is less than t psl (qadc clock duty cycle ?minimum low phase time), return to step 3. refer to appendix a electrical charac- teristics for more information on t psl . note low qclk time (in ns) = 1000 (psl + 1 ?0.5 psa) ? f sys (in mhz) 6. calculate the qclk frequency (f qclk ). note f qclk (in mhz) = 1000 ? (high qclk time + low qclk time) 7. choose the number of input sample cycles for a typical input channel. 8. if the calculated conversion times are not sufficient, return to step 3. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-12 reference manual 9. code the selected psh, psl, and psa values into the prescaler fields of qacr0. figure 7-3 and table 7-1 show examples of qclk programmability. the examples include conversion times based on the following assumptions: ?system clock (f sys ) = 20.97 mhz. ?input sample time is as fast as possible (ist = 0, 2 qclk cycles). figure 7-3 and table 7-1 also show the conversion time calculated for a single con- version in a queue. for other mcu system clock frequencies and other input sample times, the same calculations can be made. figure 7-3 qadc clock programmability examples the mcu system clock frequency is the basis of the qadc timing. the qadc requires that the system clock frequency be at least twice the qclk frequency. refer to ap- pendix a electrical characteristics for information on the minimum and maximum allowable qclk frequencies. the qclk frequency is established by the combination of the psh and psl parame- ters in qacr0. the 5-bit psh field selects the number of system clock cycles in the high phase of the qclk wave. the 3-bit psl field selects the number of system clock cycles in the low phase of the qclk wave. example 1 in figure 7-3 shows that when psh = 3, the qclk remains high for four cycles of the system clock. it also shows that when psl = 3, the qclk remains low for four system clock cycles. in example 1, the equation for qclk high cycles is the psh value plus one, and the equation for the qclk low cycles is the psl value plus one. table 7-1 qadc clock programmability control register 0 information f sys = 20.97 input sample time (ist) = %00 example number psh psa psl qclk (mhz) conversion time ( m s) 17071.0 18.0 27171.0 18.0 qclk examples f sys ex1 ex2 system clock qadc qclk ex 16 cycles f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-13 refer to appendix a electrical characteristics for information on mini- mum qclk high time (t psh ) and the minimum qclk low time (t psl ). in order to be able to tune the qclk as close as possible to the fastest conversion time for any given system clock frequency, the qadc permits one more programma- ble control of the qclk high and low time. the psa parameter in qacr0 allows the qclk high phase to be stretched for a half cycle of the system clock, and correspond- ingly, the qclk low phase is shortened by a half cycle of the system clock. example 2 in figure 7-3 is the same as example 1, except that the psa bit is set. the qclk high phase has 4.5 system clock cycles; the qclk low phase has 3.5 system clock cycles. the following are equations for calculating the qclk high and low phases: ?high qclk time = 1000 (psh + 1 + 0.5 psa) ? f sys (in ns) ?low qclk time = 1000 (psl + 1 ?0.5 psa) ? f sys (in ns) ?f qclk = 1000 ? (high qclk time + low qclk time) (in mhz) where: ?psh = 0 to 31, the prescaler qclk high cycles in qacr0 ?psl = 0 to 7, the prescaler qclk low cycles in qacr0 ?psa = 0 to 1, the prescaler qclk add half cycle in qacr0 ?f sys = system clock frequency in mhz ?f qclk = qclk frequency in mhz 7.5 periodic/interval timer the on-chip periodic/interval timer is enabled to generate trigger events at a program- mable interval, initiating execution of queue 2. the periodic/interval timer stays reset under the following conditions: ?queue 2 is programmed to any queue operating mode which does not use the periodic/interval timer ?interval timer single-scan mode is selected, but the single-scan enable bit is set to zero ?imb system reset or the master reset is asserted ?stop mode is selected ?freeze mode is selected two other conditions which cause a pulsed reset of the timer are: ?roll over of the timer counter ?a queue operating mode change from one periodic/interval timer mode to another periodic/interval timer mode during the stop mode, the periodic/interval timer is held in reset. since stop mode causes qacr2 to be initialized to zero, a valid periodic or interval timer mode must be written to qacr2 after stop mode is exited to release the timer from reset. when the imb internal freeze line is asserted and a periodic or interval timer mode f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-14 reference manual is selected, the timer counter is reset after the current conversion completes. when the periodic or interval timer mode has been enabled (the timer is counting), but a trig- ger event has not been issued, the freeze mode takes effect immediately, and the tim- er is held in reset. when the internal freeze line is negated, the timer counter starts counting from the beginning. refer to paragraph 3.3.2 in section 3 configura- tion and control for more information. 7.6 control and status registers the following paragraphs describe the control and status registers. the qadc has three control registers and one status register. 7.6.1 control register 0 control register 0 establishes the qclk with prescaler parameter fields and defines whether external multiplexing is enabled. all of the implemented control register fields can be read or written, reserved locations read zero and writes have no effect. they are typically written once when the software initializes the qadc, and not changed af- terwards. mux ?externally multiplexed mode the mux bit allows the software to select the externally multiplexed mode, which af- fects the interpretation of the channel numbers and forces the ma0, ma1 and ma2 pins to be outputs. 0 = internally multiplexed, 16 possible channels. 1 = externally multiplexed, 44 possible channels. psh[8:4] ?prescaler clock high time the psh field selects the qclk high time in the prescaler. refer to appendix a electrical characteristics for information on qadc operating clock fre- quency (f qclk ) values. to keep the qclk within the specified range, the psh field se- lects the high time of the qclk, which can range from 1 to 32 system clock cycles. the minimum high time for the qclk is specified as t psh . table 7-2 displays the bits in psh field which enable a range of qclk high times. qacr0 ? control register 0 $####0a 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 mux reserved psh psa psl reset: 0 0 0 0 1 1 0 0 1 1 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-15 psa ?prescaler add a clock tic psa adds a system clock tic to the qclk high time in the prescaler. the psh and psl fields establish f qclk . the psa field does not change the frequency of the clock, how- ever, it does change the duty cycle by one tic, or one half of the mcu system clock period. the psa bit modifies the qclk duty cycle by adding one system clock tic to the high time and subtracting one system clock tic from the low time. 0 = qclk high and low times are not modified. 1 = add one system clock half cycle to the high time of the qclk and subtract one system clock half cycle from the low time. table 7-2 prescaler clock high times psh[8:4] qclk high time 00000 1 system clock cycle 00001 2 system clock cycles 00010 3 system clock cycles 00011 4 system clock cycles 00100 5 system clock cycles 00101 6 system clock cycles 00110 7 system clock cycles 00111 8 system clock cycles 01000 9 system clock cycles 01001 10 system clock cycles 01010 11 system clock cycles 01011 12 system clock cycles 01100 13 system clock cycles 01101 14 system clock cycles 01110 15 system clock cycles 01111 16 system clock cycles 10000 17 system clock cycles 10001 18 system clock cycles 10010 19 system clock cycles 10011 20 system clock cycles 10100 21 system clock cycles 10101 22 system clock cycles 10110 23 system clock cycles 10111 24 system clock cycles 11000 25 system clock cycles 11001 26 system clock cycles 11010 27 system clock cycles 11011 28 system clock cycles 11100 29 system clock cycles 11101 30 system clock cycles 11110 31 system clock cycles 11111 32 system clock cycles f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-16 reference manual psl[2:0] ?prescaler clock low time the psl field selects the qclk low time in the prescaler. refer to appendix a electrical characteristics for information on f qclk values. to keep the qclk within the specified range, the psl field selects the low time of the qclk, which can range from one to eight system clock cycles. the minimum low time for the clock is specified as t psl . table 7-2 displays the bits in psl field which enable a range of qclk low times. 7.6.2 control register 1 control register 1 is the mode control register for the operation of queue 1. the appli- cations software defines the queue operating mode for the queue, and may enable a completion and/or pause interrupt. all of the control register fields are read/write data. however, the sse1 bit always reads as zero unless the test mode is enabled. most of the bits are typically written once when the software initializes the qadc, and not changed afterwards. cie1 ?queue 1 completion interrupt enable cie1 enables an interrupt upon completion of queue 1. the interrupt request is initiat- ed when the conversion is complete for the ccw in queue 1. 0 = disable the queue completion interrupt associated with queue 1. 1 = enable an interrupt after the conversion of the sample requested by the last ccw in queue 1. pie1 ?queue 1 pause interrupt enable pie1 enables an interrupt when queue 1 enters the pause state. the interrupt request is initiated when conversion is complete for a ccw that has the pause bit set. 0 = disable the pause interrupt associated with queue 1. 1 = enable an interrupt after the conversion of the sample requested by a ccw in queue 1 which has the pause bit set. table 7-3 prescaler clock low times psl[2:0] qclk low time 000 1 system clock cycle 001 2 system clock cycles 010 3 system clock cycles 011 4 system clock cycles 100 5 system clock cycles 101 6 system clock cycles 110 7 system clock cycles 111 8 system clock cycles qacr1 ? control register 1 $####0c 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 cie1 pie1 sse1 not used mq1 not used reset: 0 0 0 0 0 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-17 sse1 ?queue 1 single-scan enable bit sse1 enables a single-scan of queue 1 to start after a trigger event occurs. the sse1 bit may be set to a one during the same write cycle when the mq1 bits are set for one of the single-scan queue operating modes. the single-scan enable bit can be written as a one or a zero, but is always read as a zero, unless a test mode is selected. the sse1 bit enables a trigger event to initiate queue execution for any single-scan oper- ation on queue 1. the qadc clears the sse1 bit when the single-scan is complete. 0 = trigger events are not accepted for single-scan modes. 1 = accept a trigger event to start queue 1 in a single-scan mode. mq1[10:8] ?queue 1 operating mode the mq1 field selects the queue operating mode for queue 1. table 7-4 shows the bits in the mq1 field which enable different queue 1 operating modes. 7.6.3 control register 2 control register 2 is the mode control register for the operation of queue 2. software specifies the queue operating mode of queue 2, and may enable a completion and/or a pause interrupt. all control register fields are read/write data, except the sse2 bit, which is readable only when the test mode is enabled. most of the bits are typically written once when the software initializes the qadc, and not changed afterwards. cie2 ?queue 2 completion software interrupt enable cie2 enables an interrupt upon completion of queue 2. the interrupt request is initiat- ed when the conversion is complete for the ccw in queue 2. 0 = disable the queue completion interrupt associated with queue 2. 1 = enable an interrupt after the conversion of the sample requested by the last ccw in queue 2. table 7-4 queue 1 operating modes mq1[10:8] operating modes 000 disabled mode, conversions do not occur 001 software triggered single-scan mode (started with sse1) 010 external trigger rising edge single-scan mode (on etrig1 pin) 011 external trigger falling edge single-scan mode (on etrig1 pin) 100 reserved mode, conversions do not occur 101 continuous-scan software triggered mode 110 external trigger rising edge continuous-scan mode (on etrig1 pin) 111 external trigger falling edge continuous-scan mode (on etrig1 pin) qacr2 ? control register 2 $####0e 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 cie2 pie2 sse2 mq2 res not used bq2 reset: 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-18 reference manual pie2 ?queue 2 pause software interrupt enable pie2 enables an interrupt when queue 2 enters the pause state. the interrupt request is initiated when conversion is complete for a ccw that has the pause bit set. 0 = disable the pause interrupt associated with queue 2. 1 = enable an interrupt after the conversion of the sample requested by a ccw in queue 2 which has the pause bit set. sse2 ?queue 2 single-scan enable bit sse2 enables a single-scan of queue 2 to start after a trigger event occurs. the sse2 bit may be set to a one during the same write cycle when the mq2 bits are set for one of the single-scan queue operating modes. the single-scan enable bit can be written as a one or a zero, but is always read as a zero, unless a test mode is selected. the sse2 bit enables a trigger event to initiate queue execution for any single-scan oper- ation on queue 2. the qadc clears the sse2 bit when the single-scan is complete. 0 = trigger events are not accepted for single-scan modes. 1 = accept a trigger event to start queue 2 in a single-scan mode. mq2[12:8] ?queue 2 operating mode the mq2 field selects the queue operating mode for queue 2. table 7-5 shows the bits in the mq2 field which enable different queue 2 operating modes. table 7-5 queue 2 operating modes mq2[12:8] operating modes 00000 disabled mode, conversions do not occur 00001 software triggered single-scan mode (started with sse2) 00010 external trigger rising edge single-scan mode (on etrig2 pin) 00011 external trigger falling edge single-scan mode (on etrig2 pin) 00100 interval timer single-scan mode: time = qclk period x 2 7 00101 interval timer single-scan mode: time = qclk period x 2 8 00110 interval timer single-scan mode: time = qclk period x 2 9 00111 interval timer single-scan mode: time = qclk period x 2 10 01000 interval timer single-scan mode: time = qclk period x 2 11 01001 interval timer single-scan mode: time = qclk period x 2 12 01010 interval timer single-scan mode: time = qclk period x 2 13 01011 interval timer single-scan mode: time = qclk period x 2 14 01100 interval timer single-scan mode: time = qclk period x 2 15 01101 interval timer single-scan mode: time = qclk period x 2 16 01110 interval timer single-scan mode: time = qclk period x 2 17 01111 reserved mode 10000 reserved mode 10001 continuous-scan software triggered mode 10010 external trigger rising edge continuous-scan mode (on etrig2 pin) 10011 external trigger falling edge continuous-scan mode (on etrig2 pin) 10100 periodic timer continuous-scan mode: time = qclk period x 2 7 10101 periodic timer continuous-scan mode: time = qclk period x 2 8 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-19 res ?queue 2 resume res selects the queue 2 resumption point after suspension due to queue 1. if res is changed during the execution of queue 2, the change is not recognized until an end- of-queue condition is reached, or the queue operating mode of queue 2 is changed. the primary reason for selecting re-execution of the entire queue or subqueue is to guarantee that all samples are taken consecutively in one scan (coherency). when subqueues are not used, queue 2 execution restarts after suspension with the first ccw in queue 2. when a pause has previously occurred in queue 2 execution, queue execution restarts after suspension with the first ccw in the current subqueue. a subqueue is considered to be a stand-alone sequence of conversions. once a pause flag has been set to report subqueue completion, that subqueue is not repeated until all ccws in queue 2 are executed. an example of using the resume bit is when the frequency of queue 1 trigger events prohibit queue 2 completion. if the rate of queue 1 execution is too high, it is best for queue 2 execution to continue with the ccw that was being converted when queue 2 was suspended. this allows queue 2 to eventually complete execution. 0 = after suspension, begin execution with the first ccw in queue 2 or the current subqueue. 1 = after suspension, begin execution with the aborted ccw in queue 2. bq2[5:0] ?beginning of queue 2 the bq2 field indicates the ccw location where queue 2 begins. to allow the length of queue 1 and queue 2 to vary, a programmable pointer identifies the ccw table lo- cation where queue 2 begins. the bq2 field also serves as an end-of-queue condition for queue 1. software defines the beginning of queue 2 by programming the bq2 field in qacr2. bq2 is usually programmed before or at the same time as the queue operating mode for queue 2 is selected. if bq2 is 40 or greater, queue 2 does not have any entries, and the entire ccw table is dedicated to queue 1. if bq2 is 0, the entire ccw table is 10110 periodic timer continuous-scan mode: time = qclk period x 2 9 10111 periodic timer continuous-scan mode: time = qclk period x 2 10 11000 periodic timer continuous-scan mode: time = qclk period x 2 11 11001 periodic timer continuous-scan mode: time = qclk period x 2 12 11010 periodic timer continuous-scan mode: time = qclk period x 2 13 11011 periodic timer continuous-scan mode: time = qclk period x 2 14 11100 periodic timer continuous-scan mode: time = qclk period x 2 15 11101 periodic timer continuous-scan mode: time = qclk period x 2 16 11110 periodic timer continuous-scan mode: time = qclk period x 2 17 11111 reserved mode table 7-5 queue 2 operating modes (continued) mq2[12:8] operating modes f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-20 reference manual dedicated to queue 2. as a special case, when a queue operating mode for queue 1 is selected and a trigger event occurs for queue 1 with bq2 set to 0, queue 1 execution is terminated after ccw0 is read. conversions do not occur. the bq2 pointer may be changed dynamically, to alternate between queue 2 scan se- quences. a change in bq2 while queue 2 is active does not take effect until an end- of-queue condition is recognized, or until the queue operating mode of queue 2 is changed. for example, two scan sequences could be defined as follows: the first se- quence starts at ccw10, with a pause after ccw11 and an eoq programmed in ccw15; the second sequence starts at ccw16, with a pause after ccw17 and an eoq programmed in ccw39. with bq2 set to ccw10 and the continuous-scan mode selected, queue execution begins. when the pause is encountered in ccw11, a software interrupt routine can redefine bq2 to be ccw16. therefore, after the end-of-queue is recognized in ccw15, an internal retrigger event is generated and execution restarts at ccw16. when the pause software interrupt occurs again, software can change bq2 back to ccw10. after the end-of-queue is recognized in ccw39, an internal retrigger event is created and execution now restarts at ccw10. if bq2 is changed while queue 1 is active, the effect of bq2 as an end-of-queue indi- cation for queue 1 is immediate. note if bq2 was assigned to the ccw that queue 1 is currently working on, then that conversion is completed before bq2 takes effect. each time a ccw is read for queue 1, the ccw location is compared with the current value of the bq2 pointer to detect a possible end-of-queue condition. for example, if bq2 is changed to ccw3 while queue 1 is converting ccw2, queue 1 is terminated after the conversion is completed. however, if bq2 is changed to ccw1 while queue 1 is converting ccw2, the qadc would not recognize a bq2 end-of-queue condition until queue 1 execution reached ccw1 again, presumably on the next pass through the queue. 7.6.4 status register the status register contains information about the state of each queue and the current a/d conversion. except for the four flag bits (cf1, pf1, cf2, and pf2) and the two trigger overrun bits (tor1 and tor2), all of the status register fields contain read-only data. the four flag bits and the two trigger overrun bits are cleared by writing a zero to the bit after the bit was previously read as a one. qasr ? status register $####10 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 cf1 pf1 cf2 pf2 tor1 tor2 qs cwp reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-21 cf1 ?queue 1 completion flag cf1 indicates that a queue 1 scan has been completed. the scan completion flag is set by the qadc when the input channel sample requested by the last ccw in queue 1 is converted, and the result is stored in the result table. the end of queue 1 is identified when execution is complete on the ccw in the loca- tion prior to that pointed to by bq2, when the current ccw contains an end-of-queue code instead of a valid channel number, or when the currently completed ccw is in the last location of the ccw ram. when cf1 is set and interrupts are enabled for that queue completion flag, the qadc asserts an interrupt request at the level specified by irl1 in the interrupt register (qadcint). the software reads the completion flag during an interrupt service routine to identify the interrupt request. the interrupt request is cleared when the software writes a zero to the completion flag bit, when the bit was previously read as a one. once set, only software or reset can clear cf1. cf1 is maintained by the qadc regardless of whether the corresponding interrupt is enabled. the software polls for cf1 bit to see if it is set. this allows the software to recognize that the qadc is finished with a queue 1 scan. the software acknowledges that it has detected the completion flag being set by writing a zero to the completion flag after the bit was read as a one. refer to section 8 interrupts for more information. 0 = queue 1 scan is not complete. 1 = queue 1 scan is complete. pf1 ?queue 1 pause flag pf1 indicates that a queue 1 scan has reached a pause. pf1 is set by the qadc when the current queue 1 ccw has the pause bit set, the selected input channel has been converted, and the result has been stored in the result table. once pf1 is set, the queue enters the paused state and waits for a trigger event to allow queue execution to continue. however, if the ccw with the pause bit set is the last ccw in a queue, the queue execution is complete. the queue status becomes idle, not paused, and both the pause and completion flags are set. when pf1 is set and interrupts are enabled for the corresponding queue, the qadc asserts an interrupt request at the level specified by irl1 in the interrupt register. the software may read pf1 during an interrupt service routine to identify the interrupt re- quest. the interrupt request is cleared when the software writes a zero to pf1, when the bit was previously read as a one. once set, only software or reset can clear pf1. pf1 is maintained by the qadc regardless of whether the corresponding interrupts are enabled. the software may poll pf1 to find out when the qadc has reached a pause in scanning a queue. the software acknowledges that it has detected a pause flag being set by writing a zero to pf1 after the bit was last read as a one. 0 = queue 1 has not reached a pause. 1 = queue 1 has reached a pause. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-22 reference manual cf2 ?queue 2 completion flag cf2 indicates that a queue 2 scan has been completed. cf2 is set by the qadc when the input channel sample requested by the last ccw in queue 2 is converted, and the result is stored in the result table. the end of queue 2 is identified when the current ccw contains an end-of-queue code instead of a valid channel number, or when the currently completed ccw is in the last location of the ccw ram. when cf2 is set and interrupts are enabled for that queue completion flag, the qadc asserts an interrupt request at the level specified by irl2 in the interrupt register (qadcint). the software reads cf2 during an interrupt service routine to identify the interrupt request. the interrupt request is cleared when the software writes a zero to the cf2 bit, when the bit was previously read as a one. once set, only software or re- set can clear cf2. cf2 is maintained by the qadc regardless of whether the corresponding interrupts are enabled. the software polls for cf2 to see if it is set. this allows the software to recognize that the qadc is finished with a queue 2 scan. the software acknowledges that it has detected the completion flag being set by writing a zero to the completion flag after the bit was read as a one. refer to section 8 interrupts for more information. 0 = queue 2 scan is not complete. 1 = queue 2 scan is complete. pf2 ?queue 2 pause flag pf2 indicates that a queue 2 scan has reached a pause. pf2 is set by the qadc when the current queue 2 ccw has the pause bit set, the selected input channel has been converted, and the result has been stored in the result table. once pf2 is set, the queue enters the paused state and waits for a trigger event to allow queue execution to continue. however, if the ccw with the pause bit set is the last ccw in a queue, the queue execution is complete. the queue status becomes idle, not paused, and both the pause and completion flags are set. when pf2 is set and interrupts are enabled for the corresponding queue, the qadc asserts an interrupt request at the level specified by irl2 in the interrupt register. the software reads pf2 during an interrupt service routine to identify the interrupt request. the interrupt request is cleared when the software writes a zero to pf2, when the bit was previously read as a one. once set, only software or reset can clear pf2. pf2 is maintained by the qadc regardless of whether the corresponding interrupts are enabled. the software may poll pf2 to find out when the qadc has reached a pause in scanning a queue. the software acknowledges that it has detected a pause flag being set by writing a zero to pf2 after the bit was last read as a one. 0 = queue 2 has not reached a pause. 1 = queue 2 has reached a pause. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-23 tor1 ?queue 1 trigger overrun tor1 indicates that an unexpected trigger event has occurred for queue 1. tor1 can be set only while queue 1 is in the active state. a trigger event generated by a transition on the external trigger pin or by the periodic/ interval timer may be recorded as a trigger overrun. tor1 can only occur when using an external trigger mode. tor1 cannot occur when the software initiated single-scan mode and the software initiated continuous-scan mode are selected. tor1 occurs when a trigger event is received while a queue is executing and before the scan has completed or paused. tor1 can also occur when a trigger event has oc- curred on a queue, but execution has not yet begun. tor1 has no effect on the queue execution. after a trigger event has occurred for queue 1, and before the scan has completed or paused, additional queue 1 trigger events are not retained. such trigger events are considered unexpected, and the qadc sets the tor1 error status bit. an unexpected trigger event may be a system overrun situation, indicating a system loading mis- match. the software acknowledges that it has detected a trigger overrun being set by writing a zero to the trigger overrun, after the bit was read as a one. once set, only software or reset can clear tor1. 0 = no unexpected queue 1 trigger events have occurred. 1 = at least one unexpected queue 1 trigger event has occurred. tor2 ?queue 2 trigger overrun tor2 indicates that an unexpected trigger event has occurred for queue 2. tor2 can be set when queue 2 is in the active, suspended, and trigger pending states. the tor2 trigger overrun can only occur when using an external trigger mode or a periodic/interval timer mode. trigger overruns cannot occur when the software initiat- ed single-scan mode and the software initiated continuous-scan mode are selected. tor2 occurs when a trigger event is received while a queue is executing and before the scan has completed or paused. tor2 also occurs when a trigger event has oc- curred on a queue, but execution has not yet begun. tor2 has no effect on the queue execution. a trigger event that causes a trigger overrun is not retained since it is con- sidered unexpected. after a trigger event has occurred for queue 2, and before the scan has completed or paused, additional queue 2 trigger events are not retained, and are considered unex- pected. also, when a queue 2 trigger event is pending, but queue 1 is active, additional queue 2 trigger events are considered unexpected. in both cases, the qadc sets the tor2 error status bit. an unexpected trigger event may be a system overrun situation, indicating a system loading mismatch. the software acknowledges that it has detected a trigger overrun being set by writing a zero to the trigger overrun, after the bit was read as a one. once set, only software or reset can clear tor2. 0 = no unexpected queue 2 trigger events have occurred. 1 = at least one unexpected queue 2 trigger event has occurred. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-24 reference manual qs[9:6] ?queue status the 4-bit read-only qs field indicates the current condition of queue 1 and queue 2. the following are the five queue status conditions: ?idle ?active ?paused ?suspended ?trigger pending the two most significant bits are associated primarily with queue 1, and the remaining two bits are associated with queue 2. since the priority scheme between the two queues causes the status to be interlinked, the status bits are considered as one 4-bit field. table 7-6 shows the bits in the qs field and how they affect the status of queue 1 and queue 2. refer to section 9 queue priority examples , which shows the 4-bit queue status field transitions in typical situations. one or both queues may be in the idle state. when a queue is idle, ccws are not be- ing executed for that queue, the queue is not in the pause state, and there is not a trig- ger pending. the idle state occurs when a queue is disabled, when a queue is in a reserved mode, or when a queue is in a valid queue operating mode awaiting a trigger event to initiate queue execution. a queue is in the active state when a valid queue operating mode is selected, when the selected trigger event has occurred, or when the qadc is performing a conversion specified by a ccw from that queue. table 7-6 queue status qs[9:6] queue 1/queue 2 states 0000 queue 1 idle, queue 2 idle 0001 queue 1 idle, queue 2 paused 0010 queue 1 idle, queue 2 active 0011 queue 1 idle, queue 2 trigger pending 0100 queue 1 paused, queue 2 idle 0101 queue 1 paused, queue 2 paused 0110 queue 1 paused, queue 2 active 0111 queue 1 paused, queue 2 trigger pending 1000 queue 1 active, queue 2 idle 1001 queue 1 active, queue 2 paused 1010 queue 1 active, queue 2 suspended 1011 queue 1 active, queue 2 trigger pending 1100 reserved 1101 reserved 1110 reserved 1111 reserved f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-25 only one queue can be active at a time. either or both queues can be in the paused state. a queue is paused when the previous ccw executed from that queue had the pause bit set. the qadc does not execute any ccws from the paused queue until a trigger event occurs. consequently, the qadc can service queue 2 while queue 1 is paused. only queue 2 can be in the suspended state. when a trigger event occurs on queue 1 while queue 2 is executing, the current queue 2 conversion is aborted. the queue 2 status is reported as suspended. queue 2 transitions back to the active state when queue 1 becomes idle or paused. a trigger pending state is required since both queues cannot be active at the same time. the status of queue 2 is changed to trigger pending when a trigger event occurs for queue 2 while queue 1 is active. in the opposite case, when a trigger event occurs for queue 1 while queue 2 is active, queue 2 is aborted and the status is reported as queue 1 active, queue 2 suspended. so due to the priority scheme, only queue 2 can be in the trigger pending state. there are two transition cases which cause the queue 2 status to be trigger pending before queue 2 is shown to be in the active state. when queue 1 is active and there is a trigger pending on queue 2, after queue 1 completes or pauses, queue 2 continues to be in the trigger pending state for a few clock cycles. the following are fleeting sta- tus conditions: ?queue 1 idle with queue 2 trigger pending. ?queue 1 paused with queue 2 trigger pending. figure 7-4 displays the status conditions of the queue status field as the qadc goes through the transition from queue 1 active to queue 2 active. figure 7-4 queue status transition the queue status field is affected by the stop mode. since all of the analog logic and control registers are reset, the queue status field is reset to queue 1 idle, queue 2 idle. during the freeze mode, the queue status field is not modified. the queue status field queue 1 queue 2 trigger pending trigger pending active idle active active idle (paused) idle (paused) qadc queue status f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-26 reference manual retains the status it held prior to freezing. as a result, the queue status can show queue 1 active, queue 2 idle, even though neither queue is being executed during freeze. cwp ?command word pointer the cwp allows the software to know which ccw is executing at present, or was last completed. the command word pointer is a software read-only field, and write opera- tions have no effect. the cwp allows software to monitor the progress of the qadc scan sequence. the cwp field is a ccw word pointer with a valid range of 0 to 39. when a queue enters the paused state, the cwp points to the ccw with the pause bit set. while in pause, the cwp value is maintained until a trigger event occurs on the same queue or the other queue. usually, the cwp is updated a few clock cycles be- fore the queue status field shows that the queue has become active. for example, software may read a cwp pointing to a ccw in queue 2, and the status field shows queue 1 paused, queue 2 trigger pending. when the qadc finishes the scan of the queue, the cwp points to the ccw where the end-of-queue condition was detected. therefore, when the end-of-queue condition is a ccw with the eoq code (channel 63), the cwp points to the ccw containing the eoq. when the last ccw in a queue is in the last ccw table location (ccw39), and it does not contain the eoq code, the end-of-queue is detected when the following ccw is read, so the cwp points to word 40. finally, when queue 1 operation is terminated after a ccw is read that is defined as bq2, the cwp points to the same ccw as bq2. since the cwp is six bits, the value could range from 0 to 63. however, since there are 40 locations in the ccw table, the normal range of cwp is 0 to 39. the cwp shows 40 when queue execution terminates with the physical end of the ccw table. the cwp would also show a value between 40 and 63 if bq2 were set in that range and queue 2 execution were initiated. during the stop mode, the cwp is reset to zero, since the control registers and the analog logic are reset. when the freeze mode is entered, the cwp is unchanged; it points to the last executed ccw. 7.7 conversion command word table the ccw table is a ram, 40 words long and 10 bits wide, which can be programmed by the software to request conversions of one or more analog input channels. the en- tries in the ccw table are 10-bit conversion command words. the ccw table is writ- ten by software and is not modified by the qadc. each ccw requests the conversion of an analog channel to a digital result. the ccw specifies the analog channel num- ber, the input sample time, and whether the queue is to pause after the current ccw. the ten implemented bits of the ccw word are read/write data, but they may be writ- ten once when the software initializes the qadc, and not changed afterwards. unim- plemented bits are read as zeros, and write operations have no effect. each location in the ccw table corresponds to a location in the result word table. when a conversion f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-27 is completed for a ccw entry, the 10-bit result is written in the corresponding result word entry. the qadc provides 40 ccw table entries. if more results are needed, software uses one or more result table locations for multiple channels. the beginning of queue 1 is the first location in the ccw table. the first location of queue 2 is specified by the beginning of queue 2 pointer (bq2) in qacr2. to dedicate the entire ccw table to queue 1, queue 2 is programmed to be in the disabled mode, and the beginning of bq2 is programmed to any value greater than 39. to dedicate the entire ccw table to queue 2, queue 1 is programmed to be in the disabled mode, and bq2 is specified as the first location in the ccw table. figure 7-5 illustrates the operation of the queue structure. figure 7-5 qadc conversion queue operation qadc cq 00 begin queue 1 bq2 39 end of queue 1 begin queue 2 end of queue 2 p ist chan 97 8 6 4321 50 p = pause until next trigger ist = input sample time chan = channel number and end-of-queue code 10-bit conversion command word format 00 39 result 7 864321 5 90 8 10 11 12 13 14 15 result 97 8 4321 50 8 10 11 12 13 14 6 15 s result 97 8 4321 50 8 10 11 12 13 14 6 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 right justified, unsigned result left justified, unsigned result left justified, signed result 10-bit result, readable in three 16-bit formats s = sign bit channel select, sample, hold, and a/d conversion conversion command word (ccw) table result word table byp byp = bypass f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-28 reference manual to prepare the qadc for a scan sequence, the software writes to the ccw table to specify the desired channel conversions. the software also establishes the criteria for initiating the queue execution by programming the queue operating mode. the queue operating mode determines what type of trigger event causes queue execution to be- gin. ?rigger event?is used to refer to any of the ways to cause the qadc to begin executing the ccws in a queue or subqueue. an ?xternal trigger?is only one of the possible ?rigger events? a scan sequence may be initiated by the following: ?a software command ?expiration of the periodic/interval timer ?external trigger signal the software also specifies whether the qadc is to perform a single pass through the queue or is to scan continuously. when a single-scan mode is selected, the software selects the queue operating mode and sets the single-scan enable bit. when a contin- uous-scan mode is selected, the queue remains active in the selected queue operat- ing mode after the qadc completes each queue scan sequence. during queue execution, the qadc reads each ccw from the active queue and exe- cutes conversions in four stages: ?initial sample ?transfer ?final sample ?resolution during initial sample, the selected input channel is connected to the sample capacitor at the input of the sample buffer amplifier. during the transfer period, the sample capacitor is disconnected from the multiplexer, and the stored voltage is buffered and transferred to the rc dac array. during the final sample period, the sample capacitor and amplifier are bypassed, and the multiplexer input charges the rc dac array directly. each ccw specifies a final input sample time of 2, 4, 8, or 16 qclk cycles. when an analog-to-digital conversion is complete, the result is written to the corresponding location in the result word table. the qadc continues to sequentially execute each ccw in the queue until the end of the queue is detected or a pause bit is found in a ccw. when the pause bit is set in the current ccw, the qadc stops execution of the queue until a new trigger event occurs. the pause status flag bit is set, which may cause an interrupt to notify the software that the queue has reached the pause state. after the trigger event occurs, the paused state ends and the qadc continues to execute each ccw in the queue until another pause is encountered or the end of the queue is de- tected. the following indicate the end-of-queue condition: ?the ccw channel field is programmed with 63 ($3f) to specify the end of the queue. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-29 ?the end of queue 1 is implied by the beginning of queue 2, which is specified in the bq2 field in qacr2. ?the physical end of the queue ram space defines the end of either queue. when any of the end-of-queue conditions is recognized, a queue completion flag is set, and if enabled, an interrupt is issued to the software. the following situations pre- maturely terminate queue execution: ?since queue 1 is higher in priority than queue 2, when a trigger event occurs on queue 1 during queue 2 execution, the execution of queue 2 is suspended by aborting the execution of the ccw in progress, and the queue 1 execution be- gins. when queue 1 execution is completed, queue 2 conversions restart with the first ccw entry in queue 2 or the first ccw of the queue 2 subqueue being exe- cuted when queue 2 was suspended. alternately, conversions can restart with the aborted queue 2 ccw entry. the resume (res) field in qacr2 allows the soft- ware to select where queue 2 begins after suspension. by choosing to re-execute all of the suspended queue 2 queue and subqueue ccws, all of the samples are guaranteed to have been taken during the same scan pass. however, a high trig- ger event rate for queue 1 can prohibit the completion of queue 2. if this occurs, the software may choose to begin execution of queue 2 with the aborted ccw entry. ?software can change the queue operating mode to disabled mode. any current conversion taking place for that queue is aborted. putting a queue into the dis- abled mode does not power down the converter. ?software can change the queue operating mode to another valid mode. any cur- rent conversion taking place for that queue is aborted. the queue restarts at the beginning of the queue, once an appropriate trigger event occurs. ?for low power operation, software can set the stop mode bit to prepare the mod- ule for a loss of clocks. the qadc aborts any conversion in progress when the stop mode is entered. ?when the freeze enable bit is set by software and the imb internal freeze line is asserted, the qadc freezes at the end of the current conversion. when internal freeze is negated, the qadc resumes queue execution beginning with the next ccw entry. refer to paragraph 3.3.2 in section 3 configuration and control for more information. p ?pause the pause bit allows software to create sub-queues within queue 1 and queue 2. the qadc performs the conversion specified by the ccw with the pause bit set, and then the queue enters the pause state. another trigger event causes execution to continue from the pause to the next ccw. 0 = do not enter the pause state after execution of the current ccw. 1 = enter the pause state after execution of the current ccw. ccw ? conversion command word table $####30?####7e 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 not used p byp ist chan reset: u u u u u u u u u u f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-30 reference manual byp ?sample amplifier bypass setting the byp field in the ccw enables the amplifier bypass mode for a conversion, and subsequently changes the timing. the initial sample time and the transfer time are eliminated, reducing the potential conversion time by six qclks. however, due to in- ternal rc effects, a minimum final sample time of four qclks must be allowed. this results in a shortened conversion time of four qclks. when using this mode, the ex- ternal circuit should be of low source impedance. loading effects of the external cir- cuitry need to be considered, since the benefits of the sample amplifier are not present. 0 = amplifier bypass mode disabled. 1 = amplifier bypass mode enabled. ist[7:6] ?input sample time the ist field allows software to specify the length of the sample window. provision is made to vary the input sample time, through software control, to offer flexibility in the source impedance of the circuitry providing the qadc analog channel inputs. longer sample times permit more accurate a/d conversions of signals with higher source im- pedances. table 7-7 shows the four selectable input sample times. the programmable sample time can also be used to increase the time interval be- tween conversions to adjust the queue execution time or the sampling rate. in addition to the four sample times listed in table 7-7 , the sample amplifier may be bypassed entirely. this results in a shorter conversion time (by four qclks) may also reduce the effects of the sample amplifier on the system performance. the sample amplifier can be bypassed on each conversion by setting the byp bit field in the ccw. this mode is mainly intended for factory testing, but may also be used in applications with some considerations. the bypass option shortens the conversion time by six qclks. however, due to inter- nal rc effects, a minimum final sample time of four qclks must be used. this results in a conversion time savings of four qclks. the slightly shorter sample time may be of use in some applications, depending on system constraints, but may be offset by the loss of the sample amplifier benefits. this means that external circuit loading from the qadc may increase due to the direct connection of the internal rc dac array dur- ing the sample phase. typically, the bypass mode may only be used if external source impedance is kept low. refer to appendix a electrical characteristics for information on the maximum allowable input source impedance. table 7-7 input sample times ist[7:6] input sample times 00 input sample time = qclk period x 2 01 input sample time = qclk period x 4 10 input sample time = qclk period x 8 11 input sample time = qclk period x 16 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-31 chan[5:0] ?channel number the chan field selects the input channel number. the software programs the channel field of the ccw with the channel number corresponding to the analog input pin to be sampled and converted. the analog input pin channel number assignments and the pin definitions vary depending on whether the multiplexed or non-multiplexed mode is used by the application. as far as the queue scanning operations are concerned, there is no distinction between an internally or externally multiplexed analog input. refer to section 4 external multiplexing for more information on external multiplex- ing. table 7-8 shows the channel number assignments for the nonmultiplexed mode. ta- ble 7-9 shows the channel number assignments for the multiplexed mode. table 7-8 nonmultiplexed channel assignments and pin designations nonmultiplexed input pins channel number in ccw chan field port pin name analog pin name other functions pin type binary decimal pqb0 pqb1 pqb2 pqb3 an0 an1 an2 an3 input input input input 000000 000001 000010 000011 0 1 2 3 pqb4 pqb5 an48 an49 invalid reserved input input 0xxxxx 10xxxx 110000 110001 4 to 31 32 to 47 48 49 pqb6 pqb7 pqa0 pqa1 an50 an51 an52 an53 input input input/output input/output 110010 110011 110100 110101 50 51 52 53 pqa2 pqa3 pqa4 pqa5 an54 an55 an56 an57 etrig1 etrig2 input/output input/output input/output input/output 110110 110111 111000 111001 54 55 56 57 pqa6 pqa7 v rl v rh an58 an59 low ref high ref input/output input/output input input 111010 111011 111100 111101 58 59 60 61 v dda /2 end of queue code 111110 111111 62 63 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-32 reference manual if the ccw channel field specifies a reserved channel number (channels 32 to 47) or an invalid channel number (channels 4 to 31 in the non-multiplexed mode), the low ref- erence level (v rl ) is converted. the channel field is programmed for channel 63 to in- dicate the end of the queue. channels 60 to 63 are special internal channels. when one of the special channels is selected, the sampling amplifier is not used. the value of v rl , v rh , or v dda /2 is placed directly onto the converter. also for the internal spe- cial channels, programming any input sample time other than two has no benefit ex- cept to lengthen the overall conversion time. 7.8 result word table the result word table is a ram, 40 words long and 10 bits wide. an entry is written by the qadc after completing an analog conversion specified by the corresponding ccw table entry. software can read or write the result word table, but in normal operation, the software reads the result word table to obtain analog conversions from the qadc. unimplemented bits are read as zeros, and write operations do not have any effect. while there is only one result word table, the data can be accessed in three different data formats: ?right justified in the 16-bit word, with zeros in the higher order unused bits. ?left justified, with the most significant bit inverted to form a sign bit, and zeros in the unused lower order bits. ?left justified, with zeros in the lower order unused bits. table 7-9 multiplexed channel assignments and pin designations multiplexed input pins channel number in ccw chan field port pin name analog pin name other functions pin type binary decimal pqb0 pqb1 pqb2 pqb3 anw anx any anz input input input input 00xxx0 00xxx1 01xxx0 01xxx1 0 to 14 even 1 to 15 odd 16 to 30 even 17 to 31 odd pqb4 pqb5 pqb6 an48 an49 an50 reserved input input input 10xxxx 110000 110001 110010 32 to 47 48 49 50 pqb7 pqa0 pqa1 pqa2 an51 ma0 ma1 ma2 input input/output input/output input/output 110011 110100 110101 110110 51 52 53 54 pqa3 pqa4 pqa5 pqa6 an55 an56 an57 an58 etrig1 etrig2 input/output input/output input/output input/output 110111 111000 111001 111010 55 56 57 58 pqa7 v rl v rh an59 low ref high ref v dda /2 input/output input input 111011 111100 111101 111110 59 60 61 62 end of queue code 111111 63 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc digital control motorola reference manual 7-33 the left justified, signed format corresponds to a half-scale, offset binary, two? com- plement data format. the data is routed onto the imb according to the selected format. the address used to access the table determines the data alignment format. all write operations to the result word table are right justified. the three result data formats are produced by routing the ram bits onto the data bus. the software chooses among the three formats by reading the result at the memory address which produces the desired data alignment. the result word table is read/write accessible by software. during normal operation, applications software only needs to read the result table. write operations to the table may occur during test or debug breakpoint operation. when locations in the ccw table are not used by an application, software could use the corresponding locations in the result word table as scratch pad ram, remembering that only 10 bits are implemented. the result alignment is only implemented for software read operations. since write op- erations are not the normal use for the result registers, only one write data format is supported, which is right justified data. note some write operations, like bit manipulation, may not operate as ex- pected because the hardware cannot access a true 16-bit value. notes: 1. s = sign bit. rjurr ? right justified, unsigned result format $####b0?####fe 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 not used result ljsrr ? left justified, signed result format $####30?####7e 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 s 1 result not used ljurr ? left justified, unsigned result register $####b0?####fe 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 result not used f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola digital control qadc 7-34 reference manual f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc interrupts motorola reference manual 8-1 section 8 interrupts interrupt recognition and servicing involve interaction between the integration module, the cpu, and the module requesting interrupt service. this section provides an over- view of the qadc interrupt process. polled operation, an alternative to using inter- rupts, is discussed along with the different aspects of interrupt operation. an interrupt is a special form of exception processing. interrupt requests can be gen- erated on-chip, or can come from external sources. however, the cpu services all in- terrupt requests as though originated by an on-chip module ?to the cpu, an external interrupt request appears to come from the integration module. there are schemes to prioritize all interrupt requests and to arbitrate between simultaneous requests of the same priority. 8.1 interrupt operation figure 8-1 displays the qadc interrupt flow. figure 8-1 qadc interrupt flow diagram 8.2 polled and interrupt-driven operation qadc inputs can be monitored by polling or by using interrupts. when interrupts are not needed, software can disable the pause and completion interrupts, and monitor the completion flag and the pause flag for each queue in the status register (qasr). in other words, flag bits can be polled to determine when new results are available. table 8-1 displays the status flag and interrupt enable bits which correspond to queue 1 and queue 2 activity. qadc interrupt block pie1 pf1 cie1 cf1 conversion pause enable conversion pause flag conversion complete interrupt enable conversion complete flag queue 1 (irl1) pie2 pf2 cie2 cf2 conversion pause enable conversion pause flag conversion complete interrupt enable conversion complete flag queue 2 (irl2) interrupt arbitration (iarb) irq[7:0] interrupt acknowledge (iack) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola interrupts qadc 8-2 reference manual if interrupts are enabled for an event, the qadc requests interrupt service when the event occurs. using interrupts does not require continuously polling the status flags to see if an event has taken place. however, status flags must be cleared after an inter- rupt is serviced, in order to disable the interrupt request. in both polled and interrupt-driven operating modes, status flags must be re-enabled after an event occurs. flags are re-enabled by clearing appropriate qasr bits in a par- ticular sequence. the register must first be read, then zeros must be written to the flags that are to be cleared. if a new event occurs between the time that the register is read and the time that it is written, the associated flag is not cleared. 8.3 interrupt sources the qadc includes four sources of interrupt service requests, each of which is sepa- rately enabled. each time the result is written for the last conversion command word (ccw) in a queue, the completion flag for the corresponding queue is set, and when enabled, an interrupt request is generated. in the same way, each time the result is written for a ccw with the pause bit set, the queue pause flag is set, and when en- abled, an interrupt request is generated. refer to table 8-1 . the pause and complete interrupts for queue 1 and queue 2 have separate interrupt vector numbers, so that each source can be separately serviced. 8.4 qadc interrupt register qadcint specifies the priority level of qadc interrupt requests and the vector pro- vided during an interrupt acknowledge cycle. the interrupt level for queue 1 and queue 2 may be different. the interrupt register is read/write accessible in supervisor data space only. the implemented interrupt register fields can be read and written, re- served locations read zero and writes have no effect. they are typically written once when the software initializes the qadc, and not changed afterwards. table 8-1 qadc status flags and interrupt sources queue queue activity status flag interrupt enable bit queue 1 result written to last ccw in queue 1 cf1 cf1 result written for a ccw with pause bit set in queue 1 pf1 pf1 queue 2 result written to last ccw in queue 2 cf2 cf2 result written for a ccw with pause bit set in queue 2 pf2 pf2 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc interrupts motorola reference manual 8-3 irl1[14:12] ?queue 1 interrupt level the irl1 field establishes the queue 1 interrupt request level. the 000 state disables queue 1 interrupts by blocking interrupt requests. when queue 1 interrupts are to be used, the irl1 field must be initialized to a non-zero value. level 001 is the lowest pri- ority software interrupt request and level 111 is the highest priority request. irl2[10:8] ?queue 2 interrupt level the irl2 field establishes the queue 2 interrupt request level. the 000 state disables queue 2 interrupts by blocking interrupt requests. when queue 2 interrupts are to be used, the irl2 field must be initialized to a non-zero value. level 001 is the lowest pri- ority interrupt request and level 111 is the highest priority request. ivb[7:0] ?interrupt vector base initialization software inputs the upper six ivb bits in the interrupt register. during in- terrupt arbitration, the vector provided to the cpu by the qadc is made up of the up- per six ivb bits, plus two low-order bits provided to the qadc to identify one of four qadc interrupt requests. the interrupt vector number is independent of the interrupt level and the interrupt arbitration number. a $0f vector number corresponds to the un- initialized interrupt vector. after reset, the lower byte of the interrupt register reads as $0f. once the ivb field is written, the two least significant bits always read as zeros. 8.5 interrupt priority the cpu16 and the cpu32 use an interrupt priority scheme based on that of the 68000 family. this scheme utilizes a three-bit interrupt priority mask that is located in the cpu16 condition code register and in the cpu32 status register. the interrupt pri- ority mask can have eight possible values, from %000 to %111. there are seven levels of interrupt priority, one to seven, each corresponding to a par- ticular interrupt request signal. the cpu compares the priority of each interrupt ser- vice request to the mask value. interrupt request levels greater than the mask value are accepted; interrupt request levels less than or equal to the mask value are ignored, except for the nonmaskable level seven interrupt request, which is serviced even if the cpu interrupt mask value is seven. the values contained in the irl1 and irl2 fields in the interrupt register (qadcint) determine the priority of qadc interrupt service requests. a value of %000 in either field disables the interrupts associated with that field. notes: 1. reserved 2. bits 1 and 0 supplied by the qadc. qadcint qadc interrupt register $####04 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 irl1 irl2 ivb ivb[1:0] 2 reset: 0 0 0 0 0 0 0 0 0 0 1 1 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola interrupts qadc 8-4 reference manual irl1 determines the priority of both queue 1 interrupt sources. irl2 determines the priority of both queue 2 interrupt sources. as a result, queue 1 and queue 2 can have different priorities in the overall interrupt hierarchy of the mcu. the qadc also has an internal interrupt request prioritization. queue 1 interrupt requests are higher in priority than queue 2 requests, and completion flag requests are higher in priority than pause requests. 8.6 interrupt arbitration after queue 1 or queue 2 issues an interrupt service request, the cpu performs an in- terrupt acknowledge cycle. during the interrupt acknowledge cycle, the cpu identifies the interrupt request level being acknowledged by placing it on the address bus. the qadc compares the acknowledged interrupt level with irl1 and irl2 values, and re- sponds if the values match. the same interrupt priority level can be assigned to more than one module. for exam- ple, the qadc and the queued serial module (qsm) can both be assigned priority five. if the qadc and the qsm request interrupt service simultaneously, then the interrupt arbitration (iarb) fields in the respective module configuration registers are used to determine which module is serviced first. the iarb field is essentially a second-level priority in case of a tie. each module that can request interrupt service has an iarb field. arbitration is performed by means of serial contention of iarb field bit values. arbitration always takes place, even when a single source requests service. iarb fields contain four bits. an iarb value of $1111 has the highest arbitration prior- ity, and %0001 has the lowest. if a module with an iarb field value of %0000 requests interrupt service, the cpu processes a spurious interrupt exception because the mod- ule requesting the interrupt service cannot confirm that it made the request. initializa- tion software must assign each iarb field a unique non-zero value in order to implement the arbitration scheme. if two or more modules are assigned the same non- zero iarb field value, operation is undefined when interrupts of the same priority level are recognized. 8.7 interrupt vectors when the qadc is the only module with an interrupt request pending at the level being acknowledged, or when the qadc iarb value is higher than that of other modules with requests pending at the acknowledged level, the qadc responds to the interrupt acknowledge cycle with an 8-bit interrupt vector number. the cpu uses the vector number to calculate a displacement into the exception vector table, then uses the vec- tor at that location to jump to an interrupt service routine. the interrupt vector base (ivb) field establishes the six high-order bits of the 8-bit in- terrupt vector number, and the qadc provides two low-order bits which correspond to one of the four internal qadc interrupt sources. figure 8-2 shows the format of the interrupt vector, and lists the binary coding of the two low-order bits for the four qadc interrupt sources. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc interrupts motorola reference manual 8-5 figure 8-2 qadc interrupt vector format after reset, and before the ivb field is initialized by the software, the ivb field has a default value of $0f, which corresponds to the uninitialized interrupt exception vector. 8.8 initializing the qadc for interrupt driven operation the following steps are required to ensure proper operation of qadc interrupt pro- cesses. 1. set the three-bit interrupt priority mask. this mask is located in the cpu32 sta- tus register or the cpu16 condition code register. 2. assign the qadc a unique non-zero iarb value. the iarb field is located in the qadcmcr. the lowest priority iarb value is %0001, and the highest pri- ority iarb value is %1111. 3. set the interrupt request levels for queue 1 and queue 2 in the irl1 and irl2 bit fields, located in the qadcint. they should be higher than the interrupt mask value in order for the interrupt requests to be recognized. level 001 is the lowest priority interrupt request, and level 111 is the highest priority request. 4. establish the six high-order bits of the eight-bit ivb field in the qadcint. the qadc provides the two low-order vector bits to identify one of four qadc inter- rupt requests. 5. load each interrupt service routine. the ivb number for each qadc interrupt request corresponds to a specific vector in the exception vector table. refer to the cpu16 reference manual (cpu16rm/ad) or the cpu32 reference man- ual (cpu32rm/ad) for information on locating an entry in the exception vector table given a vector number. each vector in the exception vector table points to the beginning address of an exception handler routine. 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 ivb0 ivb1 ivb3 ivb4 ivb5 ivb6 ivb2 ivb7 1 1 0 1 1 0 0 0 ?queue 1 completion software interrupt ?queue 1 pause software interrupt ?queue 2 completion software interrupt ?queue 2 pause software interrupt vector bits provided by qadc interrupt register provided by software to cpu during software interrupt arbitration qadc swi vect ivb0 ivb1 ivb3 ivb4 ivb5 ivb6 ivb2 ivb7 (from qadc module) software interrupt vector provided f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola interrupts qadc 8-6 reference manual 8.9 interrupt processing summary a summary of the entire interrupt processing sequence follows. 1. a result is written for the last ccw in a queue and the completion flag for the corresponding queue is set, and when enabled, an interrupt request is gener- ated. similarly, each time a result is written for a ccw with the pause bit set, the queue pause flag is set, and when enabled, an interrupt request is generat- ed. 2. qadc asserts the internal interrupt request line corresponding to the level pro- grammed in the irl1 and irl2 field in the qadcint. 3. an interrupt acknowledge cycle is performed on the imb, during which time the cpu identifies the highest interrupt level requesting service. the cpu com- pares the level of each interrupt request it receives with the mask value. inter- rupt request levels greater than the mask are accepted; interrupt request levels less than or equal to the mask are ignored. 4. if multiple modules simultaneously assert the same interrupt request level, the values in the iarb field in the respective module configuration registers deter- mine which module is serviced first. 5. when the qadc is the only module with an interrupt pending at the level being acknowledged, or when the qadc iarb value is higher than the modules with requests pending at the given interrupt level, the qadc responds to the inter- rupt acknowledge cycle by providing an 8-bit vector number which the cpu uses to call an interrupt service routine. 6. the cpu calculates displacement into the exception vector table using the vec- tor number supplied by the qadc, then jumps to the service routine pointed to by the vector. 7. the subroutine services the interrupt. as part of interrupt servicing, it must clear the pause or completion flag by writing a zero to the flag bit after reading the flag. f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc queue priority examples motorola reference manual 9-1 section 9 queue priority examples the following section describes the qadc priority scheme when trigger events on two queues overlap or conflict. 9.1 queue priority schemes since there are two conversion command queues and only one a/d converter, there is a priority scheme to determine which conversion is to occur. each queue has a va- riety of trigger events that are intended to initiate conversions, and they can occur asynchronously in relation to each other and other conversions in progress. for exam- ple, a queue can be idle awaiting a trigger event, a trigger event can have occurred, but the first conversion has not started, a conversion can be in progress, a pause con- dition can exist awaiting another trigger event to continue the queue, and so on. the following paragraphs and figures outline the prioritizing criteria used to determine which conversion occurs in each overlap situation. note each situation in figure 9-1 through figure 9-19 are labeled s1 through s19. in each diagram, time is shown increasing from left to right. the execution of queue 1 and queue 2 (q1 and q2) is shown as a string of rectangles representing the execution time of each ccw in the queue. in most of the situations, there are four ccws (la- beled c1 to c4) in both queue 1 and queue 2. in some of the situa- tions, ccw c2 is presumed to have the pause bit set, to show the similarities of pause and end-of-queue as terminations of queue ex- ecution. trigger events are described in table 9-1 . when a trigger event causes a ccw execution in progress to be aborted, the aborted conversion is shown as a ragged end of a shortened ccw rectangle. the situation diagrams also show when key status bits are set. table 9-2 describes the status bits. table 9-1 trigger events trigger events t1 events that trigger queue 1 execution (external trigger, software initiated single-scan enable bit, or completion of the previous continuous loop) t2 events that trigger queue 2 execution (external trigger, software initiated single-scan enable bit, timer period/inter- val expired, or completion of the previous continuous loop) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola queue priority examples qadc 9-2 reference manual below the queue execution flows are three sets of blocks that show the status infor- mation that is made available to the software. the first two rows of status blocks show the condition of each queue as: ?idle ?active ?pause ?suspended ?trigger pending the third row of status blocks shows the 4-bit qs status register field that encodes the condition of the two queues. two transition status cases, qs = 0011 and qs = 0111, are not shown because they exist only very briefly between stable status conditions. the first three examples in figure 9-1 , figure 9-2 , and figure 9-3 (s1, s2, and s3) show what happens when a new trigger event is recognized before the queue has completed servicing the previous trigger event on the same queue. in situation s1 ( figure 9-1 ), one trigger event is being recognized on each queue while that queue is still working on the previously recognized trigger event. the trigger over- run error status bit is set, and otherwise, the premature trigger event is ignored. a trig- ger event which occurs before the servicing of the previous trigger event is through, does not disturb the queue execution in progress. figure 9-1 ccw priority situation 1 table 9-2 status bits bit function cf flag set when the end of the queue is reached pf flag set when a queue completes execution up through a pause bit trigger overrun error (tor) set when a new trigger event occurs before the queue is finished serving the previous trigger event q1 q2 qs idle idle active idle 0000 1000 0000 0010 0000 tor1 t1 t1 q1: c1 c2 c3 c4 cf1 c1 c2 c3 c4 tor2 t2 t2 q2: cf2 idle qadc s1 active f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc queue priority examples motorola reference manual 9-3 in situation s2 ( figure 9-2 ), more than one trigger event is recognized before servicing of a previous trigger event is complete, the trigger overrun bit is again set, but other- wise, the additional trigger events are ignored. after the queue is complete, the first newly detected trigger event causes queue execution to begin again. when the trigger event rate is high, a new trigger event can be seen very soon after completion of the previous queue, leaving software little time to retrieve the previous results. also, when trigger events are occurring at a high rate for queue 1, the lower priority queue 2 chan- nels may not get serviced at all. figure 9-2 ccw priority situation 2 figure 9-3 shows that when the pause feature is in use, the trigger overrun error sta- tus bit is set the same way, and that queue execution continues unchanged. figure 9-3 ccw priority situation 3 qadc s2 active idle q1 q2 qs idle active idle active idle 1000 1000 0000 0010 0000 c1 c2 c3 c4 tor2 t2 t2 q2: cf2 idle c1 c2 c3 c4 t1 cf1 c1 c2 c3 c4 tor1 t1 t1 q1: cf1 tor1 t1 tor1 t1 tor2 t2 qadc s3 pause q1 q2 qs idle active idle active idle 1000 0110 0001 0010 active 0000 idle c1 c2 t1 t1 q1: tor1 pf1 c1 c2 0000 q2: 0100 tor2 pf2 t2 t2 0101 c3 c4 t1 t1 tor1 cf1 active pause 1001 c3 c4 cf2 t2 t2 tor2 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola queue priority examples qadc 9-4 reference manual the next two situations consider trigger events that occur for the lower priority queue 2, while queue 1 is actively being serviced. figure 9-4 shows that a queue 2 trigger event that is recognized while queue 1 is ac- tive, is saved, and as soon as queue 1 is finished, queue 2 servicing begins. figure 9-4 ccw priority situation 4 situation s5 ( figure 9-5 ) shows that when multiple queue 2 trigger events are detect- ed while queue 1 is busy, the trigger overrun error bit is set, but queue 1 execution is not disturbed. situation s5 also shows that the effect of queue 2 trigger events during queue 1 execution is the same when the pause feature is in use in either queue. figure 9-5 ccw priority situation 5 qadc s4 q1 q2 qs idle idle active idle 0000 1000 0010 active 0000 c1 c2 c3 c4 t1 q1: cf1 q2: c1 c2 c3 c4 t2 cf2 idle 1011 triggered qadc s5 q1 q2 qs idle idle idle 0000 1000 0010 active 0000 c1 c2 t1 q1: c1 c2 pf2 c3 c4 c3 c4 cf2 idle 1011 trig q2: t2 t2 pf1 pause active pause tor1 t2 t2 cf1 tor1 t1 active trig 0110 active active 0101 1001 1011 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc queue priority examples motorola reference manual 9-5 the remaining situations, s6 through s11, show the impact of a queue 1 trigger event occurring during queue 2 execution. queue 1 is higher in priority, the conversion taking place in queue 2 is aborted, so that there is not a variable latency time in responding to queue 1 trigger events. in situation 6 ( figure 9-6 ), the conversion initiated by the second ccw in queue 2 is aborted just before the conversion is complete, so that queue 1 execution can begin. queue 2 is considered suspended. after queue 1 is finished, queue 2 starts over with the first ccw, when the res (resume) control bit is set to 0. situation s7 ( figure 9- 7 ) shows that when pause operation is not in use with queue 2, queue 2 suspension works the same way. figure 9-6 ccw priority situation 6 figure 9-7 ccw priority situation 7 qadc s6 idle q1 q2 qs idle idle 0000 1000 active c1 c2 t1 q1: c1 c3 c4 idle q2: pf1 pause active cf1 t1 active suspend 0100 active active 0110 1010 c1 c2 c3 c4 cf2 t2 0010 0000 qadc s7 t1 t1 pause q1 q2 qs idle active idle idle 0010 0110 1010 0010 active 0000 idle q1: pf1 c1 c2 0000 1010 0101 active pause 0110 c1 q2: t2 pf2 c1 c2 c3 c4 cf1 c3 c4 cf2 t2 c3 suspend active act suspend active f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola queue priority examples qadc 9-6 reference manual situations s8 and s9 ( figure 9-8 and figure 9-9 ) repeat the same two situations with the resume bit set to a one. when the res bit is set, following suspension, queue 2 resumes execution with the aborted ccw, not the first ccw in the queue. figure 9-8 ccw priority situation 8 figure 9-9 ccw priority situation 9 situations s10 and s11 ( figure 9-10 and figure 9-11 ) show that when an additional trigger event is detected for queue 2 while the queue is suspended, the trigger overrun error bit is set, the same as if queue 2 were being executed when a new trigger event occurs. trigger overrun on queue 2 thus permits the software to know that queue 1 is taking up so much qadc time that queue 2 trigger events are being lost. qadc s8 idle q1 q2 qs idle idle 0000 1000 0010 active c1 c2 t1 q1: c1 c3 c4 idle q2: pf1 pause active cf1 t1 active suspend 0100 active active 0110 1010 c2 c3 c4 cf2 t2 0000 qadc s9 t1 pause q1 q2 qs idle active idle act idle 0010 0110 1010 0010 active 0000 idle q1: pf1 c1 c2 0000 1010 0101 active pause 0110 c1 q2: t2 c2 pf2 t1 c3 c4 cf1 c4 cf2 suspend act active suspend t2 c3 c1 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc queue priority examples motorola reference manual 9-7 figure 9-10 ccw priority situation 10 figure 9-11 ccw priority situation 11 the above situations cover normal overlap conditions that arise with asynchronous trigger events on the two queues. an additional conflict to consider is that the freeze condition can arise while the qadc is actively executing ccws. the conventional use for the freeze mode is for software/hardware debugging. when the cpu background debug mode is enabled and a breakpoint occurs, the freeze signal is issued, which can cause peripheral modules to stop operation. when freeze is detected, the qadc com- pletes the conversion in progress, unlike queue 1 suspending queue 2. after the freeze condition is removed, the qadc continues queue execution with the next ccw in se- quence. qadc s10 t1 t1 pause q1 q2 qs idle active idle active idle 0010 0110 1010 0010 active 0000 idle q1: pf1 c1 c2 0000 1010 0101 active pause 0110 q2: t2 pf2 c1 c2 c3 c4 cf1 c3 c4 cf2 t2 c3 suspend active c1 act suspend t2 tor2 t2 tor2 qadc s11 t1 t1 c3 c4 cf1 pause q1 q2 qs idle active idle act idle 0010 0110 1010 0010 active 0000 idle q1: pf1 c1 c2 0000 1010 0101 active pause 0110 q2: t2 suspend act c1 active suspend t2 tor2 t2 tor2 c2 pf2 c4 cf2 t2 c3 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola queue priority examples qadc 9-8 reference manual when freeze occurs between the conversion of two simultaneous samples, the sec- ond value is not a valid result. when the software is correlating successive samples from one scan in any other way, the freeze condition can disrupt measurements. for example, when the software is averaging multiple samples of one channel to produce a more accurate conversion result, if freeze were to occur before the consecutive con- versions are complete, the average value would span the breakpoint interval. trigger events that occur during freeze are not recorded. when a trigger event is pend- ing for queue 2 before freeze begins, that trigger event is remembered when the freeze is passed. similarly, when freeze occurs while queue 2 is suspended, after freeze, queue 2 resumes execution as soon as queue 1 is finished. situations 12 through 19 ( figure 9-12 to figure 9-19 ) show examples of all of the freeze situations. figure 9-12 ccw freeze situation 12 figure 9-13 ccw freeze situation 13 figure 9-14 ccw freeze situation 14 qadc s12 c3 c4 cf1 c1 c2 t1 q1: freeze qadc s13 c1 c2 t2 q2: cf2 c3 c4 freeze qadc s14 c1 c2 t1 q1: cf1 c3 c4 freeze t1 t1 t2 t2 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc queue priority examples motorola reference manual 9-9 figure 9-15 ccw freeze situation 15 figure 9-16 ccw freeze situation 16 figure 9-17 ccw freeze situation 17 figure 9-18 ccw freeze situation 18 qadc s15 c1 c2 t2 q2: cf2 c3 c4 freeze t2 t2 t1 t1 qadc s16 c1 c2 t1 q1: cf1 c3 c4 freeze t1 t1 pf1 qadc s17 c1 c2 t2 q2: cf2 c3 c4 freeze t2 t2 pf2 qadc s18 c1 c2 t1 q1: cf1 c3 c4 freeze t2 c1 c2 q2: c3 cf2 c4 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola queue priority examples qadc 9-10 reference manual figure 9-19 ccw freeze situation 19 qadc s19 c1 c2 t1 q1: cf1 c4 freeze cf2 c4 c1 c2 t2 q2: c3 c3 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc electrical characteristics motorola reference manual a-1 appendix a electrical characteristics notes: 1. below disruptive current conditions, the channel being stressed has conversion values of $3ff for analog in- puts greater than v rh and $000 for values less than v rl . this assumes that v rh v dda and v rl 3 v ssa due to the presence of the sample amplifier. other channels are not affected by non-disruptive conditions. 2. input signals with large slew rates or high frequency noise components cannot be converted accurately. these signals also affect the conversion accuracy of other channels. 3. exceeding limit may cause conversion error on stressed channels and on unstressed channels. transitions within the limit do not affect device reliability or cause permanent damage. 4. input must be current limited to the value specified. to determine the value of the required current-limiting re- sistor, calculate resistance values using positive and negative clamp values, then use the larger of the calcu- lated values. 5. this parameter is periodically sampled rather 100% tested. 6. condition applies to one pin at a time. 7. determination of actual maximum disruptive input current, which can affect operation, is related to external sys- tem component values. 8. current coupling is the ratio of the current induced from overvoltage (positive or negative, through an external series coupling resistor), divided by the current induced on adjacent pins. a voltage drop may occur across the external source impedances of the adjacent pins, impacting conversions on these adjacent pins. table a-1 qadc maximum ratings num parameter symbol min max unit 1 analog supply, with reference to v ssa v dda ?0.3 6.5 v 2 internal digital supply, with reference to v ssi v ddi ?0.3 6.5 v 3 reference supply, with reference to v rl v rh ?0.3 6.5 v 4v ss differential voltage v ssi ?v ssa ?0.1 0.1 v 5v dd differential voltage v ddi ?v dda ?6.5 6.5 v 6v ref differential voltage v rh ?v rl ?6.5 6.5 v 7v rh to v dda differential voltage v rh ?v dda ?6.5 6.5 v 8v rl to v ssa differential voltage v rl ?v ssa ?6.5 6.5 v 9 disruptive input current 1, 2, 3, 4, 5, 6, 7 v negclamp = ?0.3 v v posclamp = 8 v i na ?500 500 m a 10 positive overvoltage current coupling ratio 1, 5, 6, 8 pqa pqb k p 2000 2000 11 negative overvoltage current coupling ratio 1, 5, 6, 8 pqa pqb k n 125 500 12 maximum input current 3, 4, 6 v negclamp = ?0.3 v v posclamp = 8 v i ma ?25 25 ma f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola electrical characteristics qadc a-2 reference manual notes: 1. refers to operation over full temperature and frequency range. 2. to obtain full-scale, full-range results, v ssa v rl v indc v rh v dda . 3. accuracy tested and guaranteed at v rh ?v rl = 5.0v 10%. 4. parameter applies to the following pins: port a: pqa[7:0]/an[59:58]/etrig[2:1] port b: pqb[7:0]/an[3:0]/an[51:48]/an[z:w] 5. open drain only. 6. current measured at maximum system clock frequency with qadc active. 7. maximum leakage occurs at maximum operating temperature. current decreases by approximately one-half for each 10 c decrease from maximum temperature. 8. this parameter is periodically sampled rather than 100% tested. table a-2 qadc dc electrical characteristics (operating) (v ssi and v ssa = 0vdc, f qclk = 2.1 mhz, t a within operating temperature range) num parameter symbol min max unit 1 analog supply 1 v dda 4.5 5.5 v 2 internal digital supply 1 v ddi 4.5 5.5 v 3v ss differential voltage v ssi v ssa ?1.0 1.0 mv 4v dd differential voltage v ddi ?v dda ?1.0 1.0 v 5 reference voltage low 2 v rl v ssa ? 6 reference voltage high 2 v rh ? dda v 7v ref differential voltage 3 v rh ?v rl 4.5 5.5 v 8 mid-analog supply voltage v dda /2 2.25 2.75 v 9 input voltage v indc v ssa v dda v 10 input high voltage, pqa and pqb v ih 0.7 (v dda )v dda + 0.3 v 11 input low voltage, pqa and pqb v il v ssa ?0.3 0.2 (v dda )v 12 input hysteresis 4 v hys 0.5 v 13 output low voltage, pqa 5 i ol = 5.3 ma i ol = 10.0 m a v ol 0.4 0.2 v 14 analog supply current normal operation 6 low-power stop i dda 15.0 10.0 ma m a 15 reference supply current i ref 150 m a 16 load capacitance, pqa c l ?0pf 17 input current, channel off 7 pqa pqb i off 250 150 na 18 total input capacitance 8 pqa not sampling pqa sampling pqb not sampling pqb sampling c in 15 20 10 15 pf f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc electrical characteristics motorola reference manual a-3 notes: 1. conversion characteristics vary with f qclk rate. reduced conversion accuracy occurs at max f qclk rate. 2. duty cycle must be as close as possible to 75% to achieve optimum performance. 3. minimum applies to 1.0 mhz operation. 4. assumes that short input sample time has been selected (ist = 0). 5. assumes that f sys = 20.97 mhz. 6. assumes f qclk = 0.999 mhz, with clock prescaler values of: qacr0: psh = %01111, psa = %1, psl = 100) ccw: byp = %0 7. assumes f qclk = 2.097 mhz, with clock prescaler values of: qacr0: psh = %00110, psa = %1, psl = 010) ccw: byp = %0 table a-3 qadc ac electrical characteristics (operating) (v ddi and v dda = 5.0 vdc 5%, v ssi and v ssa = 0vdc, t a within operating temperature range.) num parameter symbol min max unit 1 qadc clock (qclk) frequency 1 f qclk 0.5 2.1 mhz 2 qadc clock duty cycle 2, 3 high phase time (t psl t psh )t psh 500 ns 3 conversion cycles 4 cc 18 32 qclk cycles 4 conversion time 2,4,5 f qclk = 0.999 mhz 6 min = ccw/ist = %00 max = ccw/ist = %11 f qclk = 2.097 mhz 1, 7 min = ccw/ist = %00 max = ccw/ist = %11 t conv 18.0 8.58 32 15.24 m s 5 stop mode recovery time t sr ?0 m s f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola electrical characteristics qadc a-4 reference manual notes: 1. at v rh ?v rl = 5.12 v, one count = 5 mv. 2. this parameter is periodically sampled rather than 100% tested. 3. absolute error includes 1/2 count (2.5 mv) of inherent quantization error and circuit (differential, integral, and offset) error. specification assumes that adequate low-pass filtering is present on analog input pins ?capacitive filter with 0.01 m f to 0.1 m f capacitor between analog input and analog ground, typical source isolation imped- ance of 20 k w . 4. assumes f sys = 20.97 mhz. 5. assumes clock prescaler values of: qacr0: psh = %01111, psa = %1, psl = 100) ccw: byp = %0 6. assumes clock prescaler values of: qacr0: psh = %00110, psa = %1, psl = 010) ccw: byp = %0 7. maximum source impedance is application-dependent. error resulting from pin leakage depends on junction leakage into the pin and on leakage due to charge-sharing with internal capacitance. error from junction leakage is a function of external source impedance and input leakage current. in the following expression, expected error in result value due to junction leakage is expressed in voltage (v errj ): v errj = r s x i off where i off is a function of operating temperature. (see table a-2 , note 7). charge-sharing leakage is a function of input source impedance, conversion rate, change in voltage between successive conversions, and the size of the decoupling capacitor used. error levels are best determined empir- ically. in general, continuous conversion of the same channel may not be compatible with high source imped- ance. table a-4 qadc conversion characteristics (operating) (v ddi and v dda = 5.0 vdc 5%, v ssi and v ssa = 0 vdc, t a within operating temperature range, 0.5 mhz f qclk 2.1 mhz, 2 clock input sample time) num parameter symbol min typ max unit 1 resolution 1 1 count 5 mv 2 differential nonlinearity 2 dnl 0.5 counts 3 integral nonlinearity inl 2.0 counts 4 absolute error 2, 3, 4 f qclk = 0.999 mhz 5 pqa pqb f qclk = 2.097 mhz 6 pqa pqb ae 2.5 2.5 4.0 4.0 counts 5 source impedance at input 7 r s ?0 k w f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc register summary motorola reference manual b-1 appendix b register summary b.1 address map b.2 qadc registers the following section provides a summary of qadc registers and their content. b.2.1 qadc module configuration register stop ?stop enable 0 = disable stop mode 1 = enable stop mode notes: 1. s = supervisor only 2. u = unrestricted or supervisor depending on the state of the supv bit in the qadcmcr. table b-1 qadc address map access address offset 15 8 7 0 s 1 $####00 $000 module configuration register (qadcmcr) s $####02 $002 test register (qadctest) s $####04 $004 interrupt register (qadcint) s/u 2 $####06 $006 port a data (portqa) port b data (portqb) s/u $####08 $008 port data direction register (ddrqa) s/u $####0a $00a control register 0 (qacr0) s/u $####0c $00c control register 1 (qacr1) s/u $####0e $00e control register 2 (qacr2) s/u $####10 $010 status register (qasr) $####12? $####2e $012? $02e reserved s/u $####30? $####7e $030? $07e conversion command word (ccw) table $####80? $####ae $080? $0ae reserved s/u $####b0? $####fe $0b0? $0fe result word table right justified, unsigned result register (rjurr) $####00? $####2e $100? $12e reserved s/u $####30? $####7e $130? $17e result word table left justified, signed result register (ljsrr) $####80? $####ae $180? $1ae reserved s/u $####b0? $####fe $1b0? $1fe result word table left justified, unsigned result register (ljurr) qadcmcr module configuration register $####00 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 stop frz not used supv not used iarb reset: 0 0 1 0 0 0 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola register summary qadc b-2 reference manual frz ?freeze enable 0 = ignores the imb ifreeze signal 1 = finish any current conversion, then freeze supv ?supervisor/unrestricted data space 0 = only the module configuration register, test register, and interrupt register are designated as supervisor-only data space. access to all other locations is un- restricted. 1 = all qadc registers and tables are designated as supervisor-only data space. iarb[3:0] ?software interrupt arbitration number iarb determines qadc interrupt arbitration priority. the reset value is $f (highest pri- ority), to prevent qadc interrupts from being discarded during initialization. b.2.2 qadc test register qadctest ? qadc test register $####02 qadctest is used only during factory testing of the mcu. b.2.3 qadc interrupt register irl1[14:12] ?queue 1 interrupt level the irl1 field establishes the queue 1 interrupt request level. the 000 state disables queue 1 interrupts by blocking interrupt requests. when queue 1 interrupts are to be used, the irl1 field must be initialized to a non-zero value. level 001 is the lowest pri- ority software interrupt request and level 111 is the highest priority request. irl2[10:8] ?queue 2 interrupt level the irl2 field establishes the queue 2 interrupt request level. the 000 state disables queue 2 interrupts by blocking interrupt requests. when queue 2 interrupts are to be used, the irl2 field must be initialized to a non-zero value. level 001 is the lowest pri- ority interrupt request and level 111 is the highest priority request. ivb[7:0] ?interrupt vector base initialization software inputs the upper six ivb bits in the interrupt register. during in- terrupt arbitration, the vector provided to the cpu by the qadc is made up of the up- per six ivb bits, plus two low-order bits provided to the qadc to identify one of four qadc interrupt requests. the interrupt vector number is independent of the interrupt level and the interrupt arbitration number. a $0f vector number corresponds to the un- initialized interrupt vector. after reset, the lower byte of the interrupt register reads as $0f. once the ivb field is written, the two least significant bits always read as zeros. notes: 1. reserved 2. bits 1 and 0 supplied by the qadc. qadcint qadc interrupt register $####04 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 irl1 1 irl2 ivb ivb[1:0] 2 reset: 0 0 0 0 0 0 0 0 0 0 1 1 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc register summary motorola reference manual b-3 b.2.4 port a/b data register qadc ports a and b are accessed through two 8-bit port data registers (portqa and portqb). port a pins are referred to as pqa[7:0] when used as a bidirectional 8-bit input/output port that may be used for general-purpose digital input signals or digital open drain out- put signals. port a can also be used for analog inputs (an[59:52]), external trigger in- puts (etrig[2:1]), and external multiplexer address outputs (ma[2:0]). port b pins are referred to as pqb[7:0] when used as an input only 8-bit digital port that may be used for general-purpose digital input signals. port b can also be used for nonmultiplexed (an[51:48])/an[3:0]) and multiplexed (anz, any, anx, anw) analog inputs. read operations on the reserved bits return zeros, and writes have no effect. b.2.5 port data direction register the port data direction register (ddrqa) is associated with the port a digital i/o pins. the bidirectional pins have somewhat higher leakage and capacitance specifications. refer to appendix a electrical characteristics for more information. any bit in this register set to one configures the corresponding pin as an output. any bit in this register cleared to zero configures the corresponding pin as an input. the software is responsible for ensuring that ddr bits are not set to one on pins used for analog inputs. when the ddr bit is set to one and the pin is selected for analog conversion, the voltage sampled is that of the output digital driver as influenced by the load. note caution should be exercised when mixing digital and analog inputs. this should be isolated as much as possible. rise and fall times should be as large as possible. portqa ?port a data register $####06 portqb ?port b data register $####07 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 pqa7 pqa6 pqa5 pqa4 pqa3 pqa2 pqa1 pqa0 pqb7 pqb6 pqb5 pqb4 pqb3 pqb2 pqb1 pqb0 reset: u u u u u u u uuuuuuuuu analog channel: an59 an58 an57 an56 an55 an54 an53 an52 an51 an50 an49 an48 an3 an2 an1 an0 external trigger inputs: etrig2 etrig1 multiplexed address outputs: ma2 ma1 ma0 multiplexed analog inputs: anz any anx anw ddrqa ? port data direction register $####08 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ddqa7 ddqa6 ddqa5 ddqa4 ddqa3 ddqa2 ddqa1 ddqa0 reserved reset: 0 0 0 0 0 0 0 0 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola register summary qadc b-4 reference manual since port b is input-only, a data direction register is not needed. therefore, the lower byte of the port data direction register is not implemented. read operations on the re- served bits return zeros, and writes have no effect. b.2.6 qadc control registers mux ?externally multiplexed mode the mux bit allows the software to select the externally multiplexed mode, which af- fects the interpretation of the channel numbers and forces the ma0, ma1 and ma2 pins to be outputs. 0 = internally multiplexed, 16 possible channels. 1 = externally multiplexed, 44 possible channels. psh[8:4] ?prescaler clock high time the psh field selects the qadc clock (qclk) high time in the prescaler. table b-2 displays the bits in psh field which enable a range of qclk high times. psa ?prescaler add a clock tic 0 = qclk high and low times are not modified. 1 = add one system clock half cycle to the high time of the qclk and subtract one system clock half cycle from the low time. psl[2:0] ?prescaler clock low time the psl field selects the qadc clock (qclk) low time in the prescaler. table b-2 displays the bits in psl field which enable a range of qclk low times. qacr0 ? control register 0 $####0a 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 mux reserved psh psa psl reset: 0 0 0 0 1 1 0 0 1 1 table b-2 prescaler clock high times psh[8:4] qclk high time psh[8:4] qclk high time 00000 1 system clock cycle 10000 17 system clock cycles 00001 2 system clock cycles 10001 18 system clock cycles 00010 3 system clock cycles 10010 19 system clock cycles 00011 4 system clock cycles 10011 20 system clock cycles 00100 5 system clock cycles 10100 21 system clock cycles 00101 6 system clock cycles 10101 22 system clock cycles 00110 7 system clock cycles 10110 23 system clock cycles 00111 8 system clock cycles 10111 24 system clock cycles 01000 9 system clock cycles 11000 25 system clock cycles 01001 10 system clock cycles 11001 26 system clock cycles 01010 11 system clock cycles 11010 27 system clock cycles 01011 12 system clock cycles 11011 28 system clock cycles 01100 13 system clock cycles 11100 29 system clock cycles 01101 14 system clock cycles 11101 30 system clock cycles 01110 15 system clock cycles 11110 31 system clock cycles 01111 16 system clock cycles 11111 32 system clock cycles f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc register summary motorola reference manual b-5 cie1 ?queue 1 completion interrupt enable 0 = disable the queue completion interrupt associated with queue 1. 1 = enable an interrupt after the conversion of the sample requested by the last ccw in queue 1. pie1 ?queue 1 pause interrupt enable 0 = disable the pause interrupt associated with queue 1. 1 = enable an interrupt after the conversion of the sample requested by a ccw in queue 1 which has the pause bit set. sse1 ?queue 1 single-scan enable bit 0 = trigger events are not accepted for single-scan modes. 1 = accept a trigger event to start queue 1 in a single-scan mode. mq1[10:8] ?queue 1 operating mode the mq1 field selects the queue operating mode for queue 1. table b-4 shows the bits in the mq1 field which enable different queue 1 operating modes. table b-3 prescaler clock low times psl[2:0] qclk low time 000 1 system clock cycle 001 2 system clock cycles 010 3 system clock cycles 011 4 system clock cycles 100 5 system clock cycles 101 6 system clock cycles 110 7 system clock cycles 111 8 system clock cycles qacr1 ? control register 1 $####0c 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 cie1 pie1 sse1 not used mq1 not used reset: 0 0 0 0 0 0 table b-4 queue 1 operating modes mq1[10:8] operating modes 000 disabled mode, conversions do not occur 001 software triggered single-scan mode (started with sse1) 010 external trigger rising edge single-scan mode (on etrig1 pin) 011 external trigger falling edge single-scan mode (on etrig1 pin) 100 reserved mode, conversions do not occur 101 continuous-scan software triggered mode 110 external trigger rising edge continuous-scan mode (on etrig1 pin) 111 external trigger falling edge continuous-scan mode (on etrig1 pin) f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola register summary qadc b-6 reference manual cie2 ?queue 2 completion software interrupt enable 0 = disable the queue completion interrupt associated with queue 2. 1 = enable an interrupt after the conversion of the sample requested by the last ccw in queue 2. pie2 ?queue 2 pause software interrupt enable 0 = disable the pause interrupt associated with queue 2. 1 = enable an interrupt after the conversion of the sample requested by a ccw in queue 2 which has the pause bit set. sse2 ?queue 2 single-scan enable bit 0 = trigger events are not accepted for single-scan modes. 1 = accept a trigger event to start queue 2 in a single-scan mode. mq2[12:8] ?queue 2 operating mode the mq2 field selects the queue operating mode for queue 2. table b-5 shows the bits in the mq2 field which enable different queue 2 operating modes. qacr2 ? control register 2 $####0e 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 cie2 pie2 sse2 mq2 res not used bq2 reset: 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 table b-5 queue 2 operating modes mq2[12:8] operating modes 00000 disabled mode, conversions do not occur 00001 software triggered single-scan mode (started with sse2) 00010 external trigger rising edge single-scan mode (on etrig2 pin) 00011 external trigger falling edge single-scan mode (on etrig2 pin) 00100 interval timer single-scan mode: time = qclk period x 2 7 00101 interval timer single-scan mode: time = qclk period x 2 8 00110 interval timer single-scan mode: time = qclk period x 2 9 00111 interval timer single-scan mode: time = qclk period x 2 10 01000 interval timer single-scan mode: time = qclk period x 2 11 01001 interval timer single-scan mode: time = qclk period x 2 12 01010 interval timer single-scan mode: time = qclk period x 2 13 01011 interval timer single-scan mode: time = qclk period x 2 14 01100 interval timer single-scan mode: time = qclk period x 2 15 01101 interval timer single-scan mode: time = qclk period x 2 16 01110 interval timer single-scan mode: time = qclk period x 2 17 01111 reserved mode 10000 reserved mode 10001 continuous-scan software triggered mode 10010 external trigger rising edge continuous-scan mode (on etrig2 pin) 10011 external trigger falling edge continuous-scan mode (on etrig2 pin) 10100 periodic timer continuous-scan mode: time = qclk period x 2 7 10101 periodic timer continuous-scan mode: time = qclk period x 2 8 10110 periodic timer continuous-scan mode: time = qclk period x 2 9 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc register summary motorola reference manual b-7 res ?queue 2 resume 0 = after suspension, begin execution with the first ccw in queue 2 or the current subqueue. 1 = after suspension, begin execution with the aborted ccw in queue 2. bq2[5:0] ?beginning of queue 2 the bq2 field indicates the ccw location where queue 2 begins. to allow the length of queue 1 and queue 2 to vary, a programmable pointer identifies the ccw table lo- cation where queue 2 begins. the bq2 field also serves as an end-of-queue condition for queue 1. b.2.7 qadc status register cf1 ?queue 1 completion flag 0 = queue 1 scan is not complete. 1 = queue 1 scan is complete. pf1 ?queue 1 pause flag 0 = queue 1 has not reached a pause. 1 = queue 1 has reached a pause. cf2 ?queue 2 completion flag 0 = queue 2 scan is not complete. 1 = queue 2 scan is complete. pf2 ?queue 2 pause flag 0 = queue 2 has not reached a pause. 1 = queue 2 has reached a pause. tor1 ?queue 1 trigger overrun 0 = no unexpected queue 1 trigger events have occurred. 1 = at least one unexpected queue 1 trigger event has occurred. 10111 periodic timer continuous-scan mode: time = qclk period x 2 10 11000 periodic timer continuous-scan mode: time = qclk period x 2 11 11001 periodic timer continuous-scan mode: time = qclk period x 2 12 11010 periodic timer continuous-scan mode: time = qclk period x 2 13 11011 periodic timer continuous-scan mode: time = qclk period x 2 14 11100 periodic timer continuous-scan mode: time = qclk period x 2 15 11101 periodic timer continuous-scan mode: time = qclk period x 2 16 11110 periodic timer continuous-scan mode: time = qclk period x 2 17 11111 reserved mode qasr ? status register $####10 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 cf1 pf1 cf2 pf2 tor1 tor2 qs cwp reset: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 table b-5 queue 2 operating modes (continued) mq2[12:8] operating modes f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola register summary qadc b-8 reference manual tor2 ?queue 2 trigger overrun 0 = no unexpected queue 2 trigger events have occurred. 1 = at least one unexpected queue 2 trigger event has occurred. qs[9:6] ?queue status table b-6 shows the bits in the qs field and how they affect the status of queue 1 and queue 2. cwp ?command word pointer the cwp allows the software to know which ccw is executing at present, or was last completed. the command word pointer is a software read-only field, and write opera- tions have no effect. b.2.8 conversion command word table p ?pause 0 = do not enter the pause state after execution of the current ccw. 1 = enter the pause state after execution of the current ccw. byp ?sample amplifier bypass 0 = amplifier bypass mode disabled. 1 = amplifier bypass mode enabled. table b-6 queue status qs[9:6] queue 1/queue 2 states 0000 queue 1 idle, queue 2 idle 0001 queue 1 idle, queue 2 paused 0010 queue 1 idle, queue 2 active 0011 queue 1 idle, queue 2 trigger pending 0100 queue 1 paused, queue 2 idle 0101 queue 1 paused, queue 2 paused 0110 queue 1 paused, queue 2 active 0111 queue 1 paused, queue 2 trigger pending 1000 queue 1 active, queue 2 idle 1001 queue 1 active, queue 2 paused 1010 queue 1 active, queue 2 suspended 1011 queue 1 active, queue 2 trigger pending 1100 reserved 1101 reserved 1110 reserved 1111 reserved ccw ? conversion command word table $####30?####7e 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 not used p byp ist chan reset: u u u u u u u u u u f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc register summary motorola reference manual b-9 ist[7:6] ?input sample time the ist field allows software to specify the length of the sample window. table b-7 shows the bits in the ist field which enable different input sample times. chan[5:0] ?channel number the chan field selects the input channel number. table b-8 shows the channel num- ber assignments for the nonmultiplexed mode. table b-9 shows the channel number assignments for the multiplexed mode. table b-7 input sample times ist[7:6] input sample times 00 input sample time = qclk period x 2 01 input sample time = qclk period x 4 10 input sample time = qclk period x 8 11 input sample time = qclk period x 16 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola register summary qadc b-10 reference manual table b-8 nonmultiplexed channel assignments and pin designations nonmultiplexed input pins channel number in ccw chan field port pin name analog pin name other functions pin type binary decimal pqb0 pqb1 pqb2 pqb3 an0 an1 an2 an3 input input input input 000000 000001 000010 000011 0 1 2 3 pqb4 pqb5 an48 an49 invalid reserved input input 0xxxxx 10xxxx 110000 110001 4 to 31 32 to 47 48 49 pqb6 pqb7 pqa0 pqa1 an50 an51 an52 an53 input input input/output input/output 110010 110011 110100 110101 50 51 52 53 pqa2 pqa3 pqa4 pqa5 an54 an55 an56 an57 etrig1 etrig2 input/output input/output input/output input/output 110110 110111 111000 111001 54 55 56 57 pqa6 pqa7 v rl v rh an58 an59 low ref high ref input/output input/output input input 111010 111011 111100 111101 58 59 60 61 v dda /2 end of queue code 111110 111111 62 63 table b-9 multiplexed channel assignments and pin designations multiplexed input pins channel number in ccw chan field port pin name analog pin name other functions pin type binary decimal pqb0 pqb1 pqb2 pqb3 anw anx any anz input input input input 00xxx0 00xxx1 01xxx0 01xxx1 0 to 14 even 1 to 15 odd 16 to 30 even 17 to 31 odd pqb4 pqb5 pqb6 an48 an49 an50 reserved input input input 10xxxx 110000 110001 110010 32 to 47 48 49 50 pqb7 pqa0 pqa1 pqa2 an51 ma0 ma1 ma2 input input/output input/output input/output 110011 110100 110101 110110 51 52 53 54 pqa3 pqa4 pqa5 pqa6 an55 an56 an57 an58 etrig1 etrig2 input/output input/output input/output input/output 110111 111000 111001 111010 55 56 57 58 pqa7 v rl v rh an59 low ref high ref v dda /2 input/output input input 111011 111100 111101 111110 59 60 61 62 end of queue code 111111 63 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc register summary motorola reference manual b-11 b.2.9 result registers the conversion result is unsigned, right justified data. bits [9:0] are used for the 10-bit resolution; bits [15:10] return zero when read. the conversion result is signed, left justified data. bits [15:6] are used for the 10-bit resolution, with the most significant bit inverted to form a sign bit; bits [5:0] return zero when read. the conversion result is unsigned, left justified data. bits [15:6] are used for the 10-bit resolution; bits [5:0] return zero when read. notes: 1. s = sign bit. rjurr ? right justified, unsigned result register $####b0?####fe 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 not used result ljsrr ? left justified, signed result register $####30?####7e 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 s 1 result not used ljurr ? left justified, unsigned result register $####b0?####fe 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 result not used f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola register summary qadc b-12 reference manual f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc conversion accuracy definitions motorola reference manual c-1 appendix c conversion accuracy definitions this section explains the terminology used to specify the analog characteristics of the qadc. c.1 transfer curve figure c-1 is a plot of the conversion result versus the absolute input voltage. the ide- al curve can be thought of as a staircase of uniform step size with perfect positioning of the endpoints (without gain or offset errors). figure c-1 transfer curve of an ideal 10-bit a/d converter the ideal transfer curve has the midpoint code of $000 at the origin, so that the tran- sition of the conversion result from $000 to $001 occurs for an input of one half lsb. since the input range spans the 1024 codes from $000 to $3ff, the full scale result of $3ff is centered at one least significant (lsb) below the full scale input for an ideal converter. for example, a 10-bit converter with a reference voltage of 5.12 v (a binary multiple) has an lsb of exactly 5 mv; there are 1024 values from $000 to $3ff. for an ideal converter, the first transition (from $000 to $001) occurs at 2.5 mv, and the last tran- sition (from $3fe to $3ff) occurs at 5.1125 v, or one and one half lsbs before full scale. qadc 10-bit ideal 0 input voltage (lsbs) 1-bit accuracy conversion result $000 $001 $002 $003 $004 $005 $3fb $3fc $3fd $3fe $3ff offset quantization error offset 1 2 3 4 5 fs? fs? fs? fs? fs? fs f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola conversion accuracy definitions qadc c-2 reference manual c.2 offset error the offset error is the dc shift of the entire transfer curve of an ideal converter. c.3 quantizing error the error in the actual code transition due to finite resolution is called the quantizing error. the quantizing error is one half lsb. c.4 monotonicity in a monotonic converter, the conversion result only increases as input voltage is in- creased. missing or out-of-sequence codes are not allowed, within a single transfer curve. however, measuring the transfer curve repeatedly might have some variation due to noise. figure c-2 shows the two ways that an a/d converter can be non-mono- tonic. figure c-2 transfer curve of a non-monotonic 10-bit a/d converter c.5 gain error (slope error) figure c-3 shows that the gain error is an error in the input to output transfer ratio. gain error causes an error in the slope of the transfer curve; the average input step size that causes a code transition is not equal to the desired lsb. in ratiometric con- verters, like the qadc, the gain is a function of the external reference used. qadc 10-bit nonmono codes out of sequence 0 1-bit accuracy $000 $001 $002 $003 $004 $005 $3fb $3fc $3fd $3fe $3ff 1 2 3 4 5 fs? fs? fs? fs? fs? fs missing code input voltage (lsbs) conversion result f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc conversion accuracy definitions motorola reference manual c-3 figure c-3 transfer curve of a 10-bit a/d converter with gain error c.6 integral non-linearity figure c-4 displays integral nonlinearity, which is defined as the worst case error from any code transition point on the offset- and gain-corrected actual transfer curve to an ideal curve of infinite resolution. integral non-linearity is the sum of the quantizing and differential non-linearity errors. an a/d converter can be monotonic, yet not have inte- gral linearity equal to its resolution. qadc 10-bit gain err 0 1-bit accuracy $000 $001 $002 $003 $004 $005 $3fb $3fc $3fd $3fe $3ff 1 2 3 4 5 fs? fs? fs? fs? fs? fs gain error f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola conversion accuracy definitions qadc c-4 reference manual figure c-4 transfer curve of a 10-bit a/d converter with integral > one lsb c.7 differential non-linearity (related to monotonicity) figure c-5 displays differential nonlinearity, which is defined as the input step size be- tween any two adjacent code transitions. to guarantee monotonicity, the input voltage step size must range between zero and two lsbs, not including the endpoints (0 motorola conversion accuracy definitions qadc c-6 reference manual f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc index motorola reference manual i-1 ? accesses byte 3-2 clock requirements 3-1 long word 3-1, 3-3 misaligned 3-1 word 3-2 address space 3-4 an 2-2, 2-3 analog front-end multiplexer 6-3 input considerations 5-6 multiplexed 2-3 pins 5-8 port a 2-2 port b 2-2 power pins 5-1 reference pins 5-1 section contents 1-1 submodule block diagram 6-1 supply filtering and grounding 5-3 pins 2-4 to digital converter operation 6-1 ? beginning of queue 2 (bq2) 7-19, b-7 binary divider 7-10 -weighted capacitors 6-3 biu 1-2, 3-1 boundary conditions 7-3 bq2 7-3, 7-19, b-7 bus interface unit (biu) 1-2 components 3-1 byp 6-2, 7-30, b-8 bypass mode 6-2 ? ccw 1-1, 7-26, b-8 c f 5-9 cf1 7-21, b-7 cf2 7-22, b-7 chan 7-31, b-9 channel assignments (multiplexed) 7-32, b-10 assignments (nonmultiplexed) 7-31, b-10 invalid 7-32 number (chan) 7-31, b-9 reserved 7-32 charge sharing 5-10 cie1 7-16, b-5 cie2 7-17, b-6 clock block diagram 7-10 frequency 7-11 generation 7-9 requirements 3-1 coherency 3-1, 7-8, 7-19 command word pointer (cwp) 7-26, b-8 comparator 6-4 control registers 0 (qacr0) 1-4, 7-14, b-4 1 (qacr1) 1-4, 7-16, b-5 2 (qacr2) 1-4, 7-17, b-6 conversion command word table (ccw) 1-1, 7-1, 7-26, b-8 cycle times 6-2 stages 7-28 cpu 16 8-3 condition code register 8-5 reference 8-5 32 8-3 reference 8-5 status register 8-5 misaligned accesses 3-1 supervisor/user access 1-3 wait states 3-1 cwp 7-26, b-8 ? dac 1-1 ddrqa 3-7, b-3 differential non-linearity c-4 digital control section contents 1-1, 7-1?-33 input port (pqb) 2-2 input/output port (pqa) 2-2 to analog converter (dac) 1-1, 6-3 disabled mode 7-4 index f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola index qadc i-2 reference manual ? end-of-queue condition 7-28 eoq 7-3 error gain/slope c-2 offset c-2 quantizing c-2 resulting from leakage 5-10 etrig 2-3 exception vector table 8-5 external digital supply pin 2-4 leakage 5-10 multiplexing 4-1?? trigger continuous-scan mode 7-9 trigger pins 2-3 trigger single-scan mode 7-6 externally multiplexed mode (mux) 7-14, b-4 ? fc 3-4 final sample time 6-2 f qclk 7-10, 7-14 freeze enable (frz) 3-5, b-2 mode 3-4 freeze (internal signal) 3-4, 7-29, b-2 frz 3-4, 3-5, b-2 f sys 7-12 function code 3-4 ? gain error c-2 global registers 1-4 ? i/o port operation 3-6 iarb 3-5, 3-6, 8-4, b-2 imb 1-1, 7-9 initial sample time 6-2 input sample time (ist) 7-12, 7-30, b-9 integral non-linearity c-3 intermodule bus (imb) 1-1, 3-1 internal digital supply pins 2-4 interrupt arbitration 8-4 arbitration number (iarb) 3-5, b-2 arbitration priority 3-5, b-2 initializing 8-5 polled vs interrupt operation 8-1 priority 8-3 priority mask 8-3 processing summary 8-6 recognition and servicing 8-1?-6 register (qadcint) 1-4, 8-2, b-2 sources 8-2 vector base (ivb) 8-3, b-2 vectors 8-4 interval timer single-scan mode 7-6 invalid channel number 7-32 irl1 8-3, b-2 irl2 8-3, b-2 ist 7-12, 7-30, b-9 ivb 8-3, 8-4, b-2 ? least significant bit (lsb) 6-3 left justified signed result word table (ljsrr) 7-33, b-11 unsigned result word table (ljurr) 7-33, b-11 ljsrr 7-33, b-11 ljurr 7-33, b-11 lsb 6-3 ? ma 3-6 memory map b-1 mid-analog supply voltage 6-3 modes disabled 7-4 freeze 3-4 reserved 7-4 scan. see scan modes stop 3-3 module configuration register (qadcmcr) 1-4, 3-3, b-1 monotonic converter. see monotonicity monotonicity c-2 most significant bit (msb) 6-3 mq1 7-17, b-5 mq2 7-18, b-6 msb 6-3 multiple end-of-queue 7-3 multiplexed analog inputs 2-3 mux 3-6, 7-14, b-4 ? negative stress 5-5 non-linearity differential c-4 integral c-3 ? offset error c-2 open drain drivers 2-2 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . qadc index motorola reference manual i-3 ? p 7-29, b-8 pause (p) 7-1, 7-29, b-8 periodic/interval timer 7-13 continuous-scan mode 7-9 pf1 7-21, b-7 pf2 7-22, b-7 pie1 7-16, b-5 pie2 7-18, b-6 port a data register (portqa) 3-6, b-3 b data register (portqb) 3-6, b-3 data direction register (ddrqa) 3-7, b-3 portqa 3-6, b-3 portqb 3-6, b-3 positive stress 5-5 pqa 2-2, 3-7 pqb 2-2, 3-7 prescaler 7-11 add a clock tic (psa) 7-11, 7-15, b-4 clock high time (psh) 7-11, 7-14, b-4 clock low time (psl) 7-11, 7-16, b-4 qacr0 field values 7-11 psa 7-11, 7-13, 7-15, b-4 psh 7-11, 7-14, b-4 psl 7-11, 7-16, b-4 ? qacr0 1-4, 7-14, b-4 qacr1 1-4, 7-16, b-5 qacr2 1-4, 7-17, b-6 qadc block diagram 1-1 clock (qclk) 6-2 conversion characteristics (operating) a-4 electrical characteristics (operating) ac a-3 dc a-2 features 1-2 maximum ratings a-1 memory map 1-2, b-1 pin functions diagram 2-1 qadcint 1-4, 8-2, b-2 qadcmcr 1-4, 3-3, 3-5, b-1 qadctest 1-4, 3-6, b-2 qasr 1-4, 7-20, b-7 qclk 6-2, 7-9 frequency 7-10 high time 7-13 low time 7-13 qs 7-24, b-8 quantizing error c-2 queue 7-1 1 completion flag (cf1) 7-21, b-7 1 completion interrupt enable (cie1) 7-16, b-5 1 interrupt level (irl1) 8-3, b-2 1 operating mode (mq1) 7-17, b-5 1 pause flag (pf1) 7-21, b-7 1 pause interrupt enable (pie1) 7-16, b-5 1 single-scan enable bit (sse1) 7-17, b-5 1 trigger overrun (tor1) 7-23, b-7 2 completion flag (cf2) 7-22, b-7 2 completion software interrupt enable (cie2) 7-17, b-6 2 interrupt level (irl2) 8-3, b-2 2 operating mode (mq2) 7-18, b-6 2 pause flag (pf2) 7-22, b-7 2 pause software interrupt enable (pie2) 7-18, b-6 2 resume (res) 7-19, b-7 2 single-scan enable bit (sse2) 7-18, b-6 2 trigger overrun (tor2) 7-23, b-8 priority 7-1 priority schemes 9-1 status (qs) 7-24, b-8 ? registers control 0 (qacr0) 7-14, b-4 control 1 (qacr1) 7-16, b-5 control 2 (qacr2) 7-17, b-6 interrupt (qadcint) 8-2 module configuration (qadcmcr) 3-5, b-1 port a data register (portqa) 3-6 port b data register (portqb) 3-6 port data direction (ddrqa) 3-7 status (qasr) 7-20, b-7 test (qadctest) 3-6, b-2 res 7-19, 7-29, b-7 reserved channel number 7-32 mode 7-4 resistor-divider chain 6-3 resolution time 6-2 result word table 1-1, 7-1, 7-32 r f 5-9 right justified, unsigned result word table (rjurr) 7-33, b-11 rjurr 7-33, b-11 ? sample amplifier bypass (byp) 7-30, b-8 sar 1-1, 6-4 scan modes continuous-scan modes external trigger 7-9 periodic timer continuous-scan mode 7-9 software initiated 7-8 single-scan modes external trigger 7-6 interval timer 7-6 software initiated 7-5 signal descriptions 2-1 slope error c-2 software initiated f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . motorola index qadc i-4 reference manual continuous-scan mode 7-8 single-scan mode 7-5 spurious interrupt 8-4 sse1 7-17, b-5 sse2 7-18, b-6 star-point ground system 5-4 state machine 7-10 status register (qasr) 1-4, 7-20, b-7 stop 3-3, 3-5, b-1 stop enable (stop) 3-5, b-1 mode 3-3 stress conditions 5-5 subqueue 7-1 successive approximation register (sar) 1-1, 6-4 supervisor /unrestricted data space (supv) 3-5, b-2 privilege level 1-3 supv 1-3, 3-4, 3-5, b-2 system clock 7-12 ? t1 9-1 t2 9-1 test register (qadctest) 1-4, 3-6, b-2 tor 9-2 tor1 7-23, b-7 tor2 7-23, b-8 t psh 7-13, 7-14 t psl 7-13 transfer curve c-1 time 6-2 trigger event 7-28, 9-1 overrun error (tor) 9-2 t sr 3-3 ? v cf 5-9 v dda 2-4, 5-1 v dda/2 6-3 v ddi 2-4 v ih 2-2, 3-6 v il 2-2, 3-6 voltage inputs 2-2 reference pins 2-4 v rh 2-4, 5-1, 5-10, 6-3, 7-32 v rl 2-4, 5-1, 5-10, 6-3, 7-32 v src 5-9 v ssa 2-4, 5-1 v sse 2-4 v ssi 2-4 f r e e s c a l e s e m i c o n d u c t o r , i freescale semiconductor, inc. f o r m o r e i n f o r m a t i o n o n t h i s p r o d u c t , g o t o : w w w . f r e e s c a l e . c o m n c . . . |
Price & Availability of QADCRM
![]() |
|
|
All Rights Reserved © IC-ON-LINE 2003 - 2022 |
[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy] |
Mirror Sites : [www.datasheet.hk]
[www.maxim4u.com] [www.ic-on-line.cn]
[www.ic-on-line.com] [www.ic-on-line.net]
[www.alldatasheet.com.cn]
[www.gdcy.com]
[www.gdcy.net] |