; File: ADC_40uS.A51 Date: 05/04/93 ; ; /* (c) Copyright BLUE EARTH RESEARCH, MANKATO, MN 1993. */ ; /* All rights reserved. */ $ DEBUG ERRORPRINT XREF $ TITLE (A/D CONVERTOR 40 uS LOOP) $ DATE (05-04-93) $ PW(92) PL(60) ; ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸ ; ³ Written By: Thomas Bachmann ³ ; ³ Blue Earth Research, Mankato, MN 56001 ³ ; ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ; ; ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ; ; This program sets up a loop to read the A/D Convertor and ; store the results in external data memory starting at the ; address defined by the symbol "STORE" and continuing until ; data is read and stored in the memory location defined by ; the symbol "UP_TO". Note that the number of samples taken ; MUST be a multiple of 256. ; ; There is a 40 æS loop time per data point. This is ; accomplished by invoking the succeeding conversion ; immediately before the previous results have been read. ; ; ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ; The selected channel byte is determined by internal memory ; location 1FH. The data collection process can be invoked ; by the following BASIC statement: ; 10 CHX=9 : DBY(1FH)=CHX : CALL 7F00H ; Results are stored in memory locations 5000H - 5xFFH. ; Note: The number of data points taken is specified by the ; program constant "SampleCount". This variable is ; multiplied by 256 to determine the number of data ; points that are stored in external data memory. $ EJECT ; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ; ³ INITIALIZE PARAMETERS AND DECLARE CONSTANTS ³ ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ SampleCount EQU 8 STORE EQU 5000H ; STORE CONVERSION RESULTS UP_TO EQU STORE+(256*SampleCount) ; ADC Points to the Analog to Digital Converter ADC EQU 0FF00H Channel DATA 1FH ; Hold Analog Channel Byte ; ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸ ; ³ BEGINNING OF MAIN PROGRAM LOOP ³ ; ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ; CSEG AT 7F00H Initialize: PUSH ACC PUSH PSW PUSH DPH PUSH DPL ORL PSW,#000$11$000B ; Select Bank 3 ; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ; ³ INVOKE FIRST CONVERSION ³ ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ MOV A,Channel ; CONFIGURATION BYTE MOV DPTR,#ADC ; POINT TO ADC MOVX @DPTR,A ; INVOKE CONVERSION ; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ; ³ LOAD INITIAL STORAGE ADDRESS IN HOLD REGISTERS ³ ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ MOV R2,#HIGH STORE MOV R0,#LOW STORE $ EJECT ; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ; ³ DATA STORAGE LOOP ³ ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ; Program timing (in microseconds) LOOP2: NOP ; (1) LOOP2a: MOV A,#12 ; WAIT FOR A WHILE ; (1) DJNZ ACC,$ ; (2*ACC) MOV A,Channel ; SELECT INPUT CHANNEL ; (1) MOVX @DPTR,A ; INVOKE CONVERSION ; (2) MOVX A,@DPTR ; GET PREVIOUS RESULT ; (2) ; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ; ³ STORE RESULT OF A/D CONVERSION ³ ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ MOV P2,R2 ; (2) MOVX @R0,A ; STORE RESULTS ; (2) INC R0 ; INCREMENT POINTER ; (1) CJNE R0,#0,NO_CY ; CHECK FOR OVERFLOW ; (2) INC R2 ; (1) ; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ; ³ CHECK TO SEE IF ALL DATA GATHERED ³ ; ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ CJNE R2,#HIGH(UP_TO),LOOP2a ; (2) NO_CY: CJNE R2,#HIGH(UP_TO),LOOP2 ; (2) DONE: POP DPL POP DPH POP PSW POP ACC RET ; BACK TO BASIC END ; Following is the HEX file derived from the assembled source ; file. This can be used for directly loading the program via ; MONITOR-51 and almost any terminal program. :107F0000C0E0C0D0C083C08243D018E51F90FF00FE :107F1000F07A50780000740CD5E0FDE51FF0E08A9F :107F2000A0F208B800040ABA58ECBA58E8D082D0D7 :067F300083D0D0D0E02256 :00000001FF