* OPT l,c,cre,s * * Read A/D port and write to the Terminal. * Can be used through PGBUG11: * start PCBUG11 * loads program * run program (g b600) * type "term" in PCBUG11 * 68HC11 writes to the "terminal" * *======================================================================== A2D0 EQU $00 A2D1 EQU $01 A2D2 EQU $02 A2D3 EQU $03 A2D4 EQU $04 A2D5 EQU $05 A2D6 EQU $06 A2D7 EQU $07 *======================================================================== * START OF PROGRAM MAIN *======================================================================== ORG $B600 ; HC11E1 EEPROM Start ldx #$1000 ; ASSUME THAT X IS #$1000!!!!! clr $04,x ; clear portB jsr Init_Term jsr Init_A2D A2D_Loop jsr Read_A2D jsr Write_A2D ldab #$0D ; Carriage Return jsr Write_2_Term bsr Delay_Long bra A2D_Loop *======================================================================= * Delay *======================================================================= Delay: pshx ldx #$0000 DelayLoop: dex bne DelayLoop pulx rts *======================================================================= * Delay Long *======================================================================= Delay_Long: pshx pshy ldy #$0008 LLoopY ldx #$0000 LLoopX dex bne LLoopX dey bne LLoopY puly pulx rts *======================================================================= * Init_Term: Configure Serial port for pcbug11 communications: *======================================================================= Init_Term: ldx #$1000 clr $2c,x ; Set 8-bits, wake on Idle ldd #$3008 ; boot-loader loads #$302c staa $2b,x ; 9600 BAUD stab $2d,x ; No interrupts, enable transmitter rts *======================================================================= * Write 2 Terminal: * Input: ASCII data in the B register. * Action: Wait until transmit buffer is empty, then * transmit the data in the B register. *======================================================================= Write_2_Term: brclr $2e,x %10000000 Write_2_Term ; check Transmit-empty stab $2f,x rts *======================================================================= * Init A2D: Initialize the Analog to Digital convertor *======================================================================= Init_A2D: ldx #$1000 ; needed for the brclr command ldaa #%10010000 ; Power up A/D with clock delay staa $39,x rts *======================================================================= * Read A2D values: *======================================================================= Read_A2D: ldaa #%00010000 ; single scan, multi-mode, pins e0-3 staa $30,x ; write starts conversion Conversion_not_done03 brclr $30,x $80 Conversion_not_done03 ldd $31,x ; Read channels 0 and 1 std A2D0 ldd $33,x ; Read channels 2 and 3 std A2D2 ldaa #%00010100 ; single scan, multi-mode, pins e4-7 staa $30,x ; write starts conversion Conversion_not_done47 brclr $30,x $80 Conversion_not_done47 ldd $31,x ; Read channels 4 and 5 std A2D4 ldd $33,x ; Read channels 6 and 7 std A2D6 rts *======================================================================== * Write A2D: Write the 8 A2D values in Ram to the terminal. *======================================================================== Write_A2D: ldaa A2D0 ldab #'0 bsr Write_A2D_Byte ldaa A2D1 incb bsr Write_A2D_Byte ldaa A2D2 incb bsr Write_A2D_Byte ldaa A2D3 incb bsr Write_A2D_Byte ldaa A2D4 incb bsr Write_A2D_Byte ldaa A2D5 incb bsr Write_A2D_Byte ldaa A2D6 incb bsr Write_A2D_Byte ldaa A2D7 incb bsr Write_A2D_Byte rts Write_A2D_Byte: psha pshb bsr Write_2_Term ldab #': bsr Write_2_Term tab lsrb lsrb lsrb lsrb ldy #WA2D_Table ; 4-bits to HEX aby ldab $00,y bsr Write_2_Term tab andb #$0F ldy #WA2D_Table aby ldab $00,y jsr Write_2_Term ldab #$20 ; Space jsr Write_2_Term pulb pula rts WA2D_Table: fcc "0123456789ABCDEF" *======================================================================== *========================================================================