

;++++++++++++++++++++Analisi riposta al gradino motore cc+++++++++++++++++++
org 8200h
P_VELOCE = P1.5 P_LENTO = P1.4 OUT_MOT = P1.3 ; Uscita pilotaggio motore DATA_OUT = P1.2 ; Uscita dati convertitore A/D IO_CLOCK = P1.1 ; Clock per convertitore A/D CS = P1.0 ; Chip select convertitore A/D ADCValue = 30h ; Valore dell'ultima conversione A/D Buffer = 9000h ; Indirizzo inizio buffer memorizzazione acquisizioni Soglia = 10 ; Soglia inizio acquisizioni BufCount = 3 ; Conteggio alla rovescia acquisizioni RitCount = 2 ; Contatore per ritardo RAcquisiz = 50 ; Ritardo acquisizione
start:
call Init ; Inizializzazione
call ReadADC ; Prima lettura dell'ADC
WaitSMot:
jb P_VELOCE,$
setb OUT_MOT ; Il motore parte
Acquisiz:
mov BufCount,#250 ; Inizializza BufCount per eseguire 250 acquisizioni
mov dptr,#Buffer
LoopAcq:
cpl P1.6
call ReadADC ; Il ciclo viene eseguito BufCount volte
movx @dptr,a ; I dati vengono registrati nella memoria esterna a
call RitAcq ; partire da Buffer
inc dptr
djnz BufCount,Acquisiz
clr OUT_MOT ; Stop motore
jmp $ ; fine
;Subr.Ritardo acquisizione
RitAcq:
mov RitCount,#RAcquisiz
djnz RitCount,$
ret
;Subr.Inizializzazione
Init:
clr OUT_MOT
setb P_AVANTI
setb P_INDIETRO
setb DATA_OUT
clr IO_CLOCK
clr CS
ret
;Subr.Lettura ADC
ReadADC:
clr CS
mov r0,#8
LReadADC:
mov c,DATA_OUT
rlc a
setb IO_CLOCK
clr IO_CLOCK
djnz r0,LReadADC
setb CS
mov ADCValue,a
ret
end
;++++++++++++++++++++Regolazione PWM velocità motore cc+++++++++++++++++++
.......................