;;; analogdemo.s ;;; reads analog port 0, ;;; divides it by 4 (yielding value from 0 to 63) ;;; and displays this as ASCII character from ;;; ! (ASCII 33) to back-quote (ASCII 96) ;;; Fred Martin Tue Oct 7 15:56:05 2003 BASE= 0x1000 SCSR= 0x102e ; serial comms status reg SCDR= 0x102f ; serial comms data reg ADCTL= 0x1030 ; analog-to-digital control reg ADR1= 0x1031 ; A/D result 1 reg OPTION= 0x1039 ; options register ldx #BASE ; pointer to register base lds #0x1ff ; set up stack ptr to top of RAM bset turn on A/Ds loop: ldaa #0 ; select channel 0 staa ADCTL ; start conversion donelp: ldaa ADCTL bpl donelp ; if high bit set, it's done ldaa ADR1 ; grab result into A lsra lsra ; divide by 4 -> value from 0 to 63 adda #33 ; add in ASCII for ! jsr xmit ; send it ldaa #0x0d ; send carriage return jsr xmit ldaa #0x0a ; send line feed jsr xmit ;; delay before recycling so as to not overrun the serial line ldy #0 delay: dey bne delay bra loop xmit: ;;; subroutine accepts value in A and sends it staa