************************************************* * * * Program: 8 channel A/D Input * * * * Name : ada4evb.asm * * * * Date : 29 May 2001 * * * * By : Steven J. Dombrowski * * * * * * This program scans all 8 A/D channels on * * the M68HC12A4EVB and continuously updates all * * readings. * * * * To execute this program type G 5000 * * * ************************************************* * * * program origin and equates * * * ******************************* org $5000 putchar equ $fe04 ATDCTL2 equ $62 ATDCTL5 equ $65 ADR0H equ $70 ADR1H equ $72 ADR2H equ $74 ADR3H equ $76 ADR4H equ $78 ADR5H equ $7A ADR6H equ $7C ADR7H equ $7E ADPU equ %10000000 * A/D pwr up bit ADMODE equ %01110000 admsg1 equ $5300 admsg2 equ $5360 ************************************************* * 8 conversion sequence, continuous conversion, * * multi-channel. * ************************************************* ldx #admsg1 ldy #table1 ldab #$29 loop1 ldaa 0,y staa 0,x inx iny decb cmpb #0 bne loop1 ldx #admsg2 ldy #table2 ldab #$29 loop2 ldaa 0,y staa 0,x inx iny decb cmpb #0 bne loop2 ************************ * * * Introductory message * * * ************************ ldab #$1a * clear screen jsr [putchar,PCR] ************************ * * * Main part of program * * * ************************ bset ATDCTL2,ADPU * pwr up A/D ldaa #!600 * >100us delay delay nop * before using A/D dbne a,delay start ldaa #ADMODE * scan=1,mult=1,ch1-8 staa ATDCTL5 ldaa ADR0H * read AD0 ldab ADR0H jsr lh * convert left nibble to ascii staa admsg1+13 * output to screen tba jsr rh * convert right nibble to ascii staa admsg1+14 * output to screen ldaa ADR1H * read AD1 ldab ADR1H jsr lh * convert left nibble to ascii staa admsg1+21 * output to screen tba jsr rh * convert right nibble to ascii staa admsg1+22 * output to screen ldaa ADR2H * read AD2 ldab ADR2H jsr lh * convert left nibble to ascii staa admsg1+29 * output to screen tba jsr rh * convert right nibble to ascii staa admsg1+30 * output to screen ldaa ADR3H * read AD3 ldab ADR3H jsr lh * convert left nibble to ascii staa admsg1+37 * output to screen tba jsr rh * convert right nibble to ascii staa admsg1+38 * output to screen ldaa ADR4H * read AD4 ldab ADR4H jsr lh * convert left nibble to ascii staa admsg2+13 * output to screen tba jsr rh * convert right nibble to ascii staa admsg2+14 * output to screen ldaa ADR5H * read AD5 ldab ADR5H jsr lh * convert left nibble to ascii staa admsg2+21 * output to screen tba jsr rh * convert right nibble to ascii staa admsg2+22 * output to screen ldaa ADR6H * read AD6 ldab ADR6H jsr lh * convert left nibble to ascii staa admsg2+29 * output to screen tba jsr rh * convert right nibble to ascii staa admsg2+30 * output to screen ldaa ADR7H * read AD7 ldab ADR7H jsr lh * convert left nibble to ascii staa admsg2+37 * output to screen tba jsr rh * convert right nibble to ascii staa admsg2+38 * output to screen ldx #admsg1 * display AD0-AD3 ldaa #$29 loop3 ldab 0,x pshd pshx jsr [putchar,PCR] * update readings pulx puld inx deca cmpa #0 bne loop3 jsr outcrlf jsr outcrlf ldx #admsg2 * display AD4-AD7 ldaa #$29 loop4 ldab 0,x pshd pshx jsr [putchar,PCR] * update readings pulx puld inx deca cmpa #0 bne loop4 jsr outcrlf ldab #$0b * go up 2 lines to ch1-4 jsr [putchar,PCR] jsr [putchar,PCR] jsr [putchar,PCR] jmp start * continue program *********************************** * * * Subroutine: outcrlf * * * *********************************** outcrlf pshd pshx ldab #$0D jsr [putchar,PCR] ldab #$0A jsr [putchar,PCR] pulx puld rts ******************************** * * * Subroutine to convert left * * half of binary byte in acca * * to an ascii character * * * ******************************** lh lsra lsra lsra lsra anda #$0f adda #$30 cmpa #$39 ble out adda #$07 out rts ******************************* * * * Subroutine to convert right * * half of binary byte in acca * * to an ascii character * * * ******************************* rh asla asla asla asla lsra lsra lsra lsra anda #$0f adda #$30 cmpa #$39 ble out1 adda #$07 out1 rts ****************************************************** * * * Screen messages * * * ****************************************************** table1 fcc 'reading AD0: AD1: AD2: AD3: ' fcb 4 table2 fcc 'reading AD4: AD5: AD6: AD7: ' fcb 4