* * Read A/D from port E, pin 0. * Do a binary count on PortB and delay based on A/D value. * ORG $B600 bsr Init_A2D clr $1004 Main: bsr Get_A2D psha psha pulx bsr DelayX inc $1004 bra Main ; let's do it again ************************************************************************ * DelayX: Delay based on the value in X ************************************************************************ DelayX: pshx LoopX: dex bne LoopX pulx rts ************************************************************************ * Init_A2D ************************************************************************ Init_A2D: pshx psha ldx #$1000 ; needed for the brclr command ldaa #%10010000 ; Power up A/D with clock delay staa $39,x pula pulx rts ************************************************************************ * Get_A2D: Return the A2D value from E0 in A ************************************************************************ Get_A2D: pshx ldx #$1000 ; needed for the brclr command ldaa #%00010000 ; single scan, multi-mode, pins e0-3 staa $30,x ; write starts conversion Conversion_not_done brclr $30,x $80 Conversion_not_done ldaa $31,x ; get value from pin E0 pulx rts