Conversion on the amplified channel
2005-04-18 by Hugo Oliveira
Hi everyone, I am using the new AT90PWM3 and i am having some problems
with the AD conversion on the amplifier channel. The program gets
stuck when checking the flag ADASCR that supposedly would be clear
after the conversion.
I think few people have used this mic, but maybe those more
experienced could have a clue.
Below are the initialization and the conversion routine
Thank you all
Hugo
Read_Current:
push r16;
;;;;;;;;;;;;;;;;;
;first conversion (current)
;;;;;;;;;;;;;;;;;
lds r16,ADMUX ;Set AD to diferential amplifier
andi r16, 0xfC
ori r16, 0x0C
sts ADMUX, r16;
lds r16,ADCSRB ; start conversion
ori r16, 0x90 ; for this set bit 4
sts ADCSRB,r16;
conversion1_not_finished:
lds r16,ADCSRB;
bst r16, 4; <--------Checking ADASCR
brts conversion1_not_finished; Wait until and of convertion
lds r16, ADCH ; conversion complete, put it..
sts AD_ADCH_CURRENT, r16; ...into AD_ADCH_CURRENT variable
pop r16
ret
AD_init:
push r16
ldi r16,0x80;
sts ADCSRB,r16;
ldi r16,0b10100000; ;Diferential amplifier with 5x gain enabled
sincronized with clock
sts AMP0CSR,r16;
ldi r16, 0b11101010 ;
sts ADMUX, r16; Ref = External, connect Ground to ADC
; left adjusted (8bit input)
; change ADC-settings
ldi r16, 0b10000011 ; init ADC
sts ADCSRA, r16 ; value is :10000010
; single conversion mode, no interr, Clk/8
pop r16
ret