#include "c:\miniide\hcs12.inc" org $1500 lds #$1500 ldx #$1000 ; use index register X as a pointer to the buffer jsr openAD0 ; initialize the ATD0 converter ldy #5 loop5 movb #$87,ATD0CTL5 ; start an A/D conversion sequence brclr ATD0STAT0,SCF,* movw ATD0DR0,2,x+ ; collect and save the conversion results movw ATD0DR1,2,x+ ; post-increment the pointer by 2 movw ATD0DR2,2,x+ ; “ movw ATD0DR3,2,x+ ; “ dbne y,loop5 swi openAD0 movb #$E0,ATD0CTL2 jsr wait20us ; wait for 20 us movb #$22,ATD0CTL3 movb #$05,ATD0CTL4 rts wait20us movb #$90,TSCR1 ; enable TCNT and fast timer flag clear movb #0,TSCR2 ; set TCNT prescaler to 1 bset TIOS,$01 ; enable OC0 ldd TCNT ; start an OC0 operation addd #480 ; “ std TC0 ; “ brclr TFLG1,C0F,* ; wait for 20 us rts end