Gast
#14151
ist dieses programm zur auslesung von analogen signalen und zur ausgabe
uber uart richtig?
.include "8535def.inc" ;Definitionsdatei einbinden,
.def temp =r19
.def hexl =r20
.def hexh =r21
ldi r17,RAMEND
out SPL,r17
ldi temp,4000000/(9600*16)-1 ;Baudrate einstellen
out UBRR,temp
adc:
ldi temp,$00
out ADMUX,temp ;choose channel 0 from ADC
sbi ADCSR,ADSC ;Singlemode on
rcall fertig ;wait until convert is finished
in hexl,ADCL ;read lowbyte
in hexh,ADCH ;read hibyte
sts $60,hexl ;save low byte
sts $68,hexh ;save high byte
;-----------------------
;ADC aktivieren, In 2
;-----------------------
ldi temp,$01
out ADMUX,temp ;choose channel 1 from ADC
sbi ADCSR,ADSC ;Singlemode on
rcall fertig ;wait until convert is finished
in hexl,ADCL ;read lowbyte
in hexh,ADCH ;read hibyte
sts $70,hexl ;save low byte
sts $78,hexh ;save high byte
;------------------------------------------------------------
;werte aus den speicher und dem UART Register ubergeben.
;------------------------------------------------------------
lds r16,$60
rcall serout
lds r16,$68
rcall serout
lds r16,$70
rcall serout
lds r16,$78
rcall serout
rjmp adc ;next conversion
fertig:
sbis ADCSR,ADIF ;wait until conversion is finished,ADCSR:ADC Control
and Status Register
rjmp fertig ;beendet
ret
serout:
sbis USR,UDRE ;wait until UDR is ready for the next
byte
out UDR,r16
ret