Developer Home Contents Search Contact Us Support Intel(r)



8XC196KR: Using the A/D Scan Mode


ABSTRACT:

This techbit describes one implementation of the A/D scan mode using the PTS on the 8XC196KR. The PTS cycles are initiated by the A/D Done interrupt. The example shown, uses the A/D Done interrupt to trigger consecutive PTS cycles.

1.0 Introduction

      1. More uniform latency time from setting AD_DONE to start of conversion.

      2. Less code when performing multiple conversions.

      3. Higher priority than an interrupt.

2.0 A/D Scan Mode Description

      1. The controller fetches the interrupt vector for the interrupt serviced by the PTS.

      2. The program branches to the interrupt service routine.

      3. The interrupt service routine should service the PTS. This may include leaving the PTS disabled.

2.1 PTSCB

2.2 A/D Command/Data Table

3.0 A/D Scan Mode Operation

      1. Store PTS_PTR1 in TEMP1 (TEMP1=n)

      2. Fetch the word pointed to by TEMP1 (an A/D command) and store in TEMP2

      3. Increment TEMP1 by two (TEMP1=n+2)

      4. Fetch the word pointed to by PTS_PTR2 (AD_RESULT) and store at the address in TEMP1 (n+2)

      5. Increment TEMP1 by two (TEMP1=n+4)

      6. Load TEMP2 (holding the A/D command) into the SFR, AD_COMMAND

      7. If the update bit in PTS_CONTROL equals 1, load PTS_PTR1 with TEMP1 (PTS_PTR1=n+4) (will fetch next command)

      8. If the update bit equals 0, leave PTS_PTR1 unchanged (PTS_PTR1=n) (will fetch same command)

      9. decrement PTSCOUNT

      1. Reinitialize PTSCOUNT

      2. Load PTS_PTR1

      3. Set PTSSEL

3.1 Flow Chart

4.0 Implementation

      1. Setting up the PTS Control Block
      2. Setting up the Command/Data table
      3. Starting the first A/D conversion
      4. Responding to the PTS interrupt
      5. Ending the A/D Scan mode

4.1 Setting up the PTSCB

4.2 Setting up the Command/Data Table

4.3 Starting the first A/D Conversion

4.4 Responding to the PTS Interrupt

      1. initialize PTSCOUNT
      2. Set PTSSEL.5
      3. Load PTSPTR1
      4. Starting the next (first) A/D conversion

4.5 Ending the A/D Scan mode

5.0 Example


$debug errorprint xref



;***************************************************

;** This program is the first example program **

;** for the A/D Scan mode tech bit. **

;** REV 1.0 6/4/91 **

;***************************************************



$NOLIST



$INCLUDE (KR.INC)



$LIST



 PUBLIC START



AD_PTSCOUNT 	equ 10H 		;do 16 a/d conversions

AD_PTSCONTROL 	equ 11001011B

AD_PTSPTR1 		equ AD_RESULT

AD_PTSPTR2 		equ 6000H 	;must equal address of 

command_start

AD_COMMAND0 	equ 00011000B 		;norm conv, 8-bit, start now,ch0

AD_COMMAND1 	equ 00000000B 		;no conv

AD_TIME_LOAD 	equ 0A6H 		;value to load into AD_TIME register



 rseg at 50H

ad_pts: dsb 6 		;must be quad word aligned



 rseg

temp0: dsw 1

temp1: dsw 1

pntr0: dsw 1

pntr1: dsw 1



 cseg at 200AH

 dcw ad_done_isr



 cseg at 204AH

 dcw ad_pts



 cseg



START: 		;Initialize for A/D Scan Mode



AD_TABLE_LOAD:

 Ld temp0,#ad_ptscount 		;number of commands to load

 Ld pntr0,#ad_command_data

 Ld pntr1,#command_start



AD_TABLE_LOOP:

 Ld temp1,[pntr0]+ 	 	;loop until command/data table

 St temp1,[pntr1]+ 		;filled

 Inc pntr1

 Inc pntr1 		;increment twice to skip blank

 Djnz temp0,ad_table_loop



PTSCB_LOAD:

 Ld pntr0,#ad_pts_table

 Ld pntr1,#ad_pts

 Ld temp0,#6 		;number of bytes in PTSCB



PTSCB_LOOP:

 Ldb temp1,[pntr0]+ 		;loop until PTSCB filled

 Stb temp1,[pntr1]+

 Djnz temp0,ptscb_loop



 Ldb temp0,#ad_time_load

 Stb temp0,ad_time 		;load AD_TIME register

 Stb zero_reg,ad_test 		;clear AD_TEST register



 Ldb temp0,int_mask

 orb temp0,#00100000B

 Stb temp0,int_mask 		;enable AD_DONE interrupt



 





Ld temp0,ptssel

 Or temp0,#0000000000100000B

 Stb temp0,ptssel 		;enable A/D PTS servicing



 Ei 		;enable interrupts

 Epts 		;enable PTS



 Br main_start



AD_DONE_ISR:

 Br $ 		;loop forever when pts count=0

 nop

 nop



MAIN_START:

 Ldb temp0,#ad_command0

 Stb temp0,ad_command 		;start first A/D conversion on Ch0



MAIN_LOOP:

 Br $ 		;loop until interrupt or

 		;pts cycle occurs

 nop

 nop



AD_COMMAND_DATA:

 cseg

 dcw AD_Command0

 dcw AD_Command0

 dcw AD_Command0

 dcw AD_Command0

 dcw AD_Command0

 dcw AD_Command0

 dcw AD_Command0

 dcw AD_Command0

 dcw AD_Command0

 dcw AD_Command0

 dcw AD_Command0

 dcw AD_Command0

 dcw AD_Command0

 dcw AD_Command0

 dcw AD_Command0

 dcw AD_Command1



AD_PTS_TABLE:

 dcb 10H

 dcb 11001011B

 dcw command_start

 dcw ad_result



 dseg at 6000H



COMMAND_START:

 dsw 32 			;save storage space for 16 commands/results

 end



* Legal Information © 1999 Intel Corporation