Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

Problem with a-d converter on Tiny24

Problem with a-d converter on Tiny24

2007-06-28 by Tim Mitchell

Hello folks
I'm having a really hard time getting the a-d converter running on the
Tiny 24. It just won't go. I am probably doing something really stupid
but I can't see it.

Here is the code dealing with the adc...

.include <tn24def.inc>

	ldi tempA,(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0) ;enable ADC
and set lowest speed
	out ADCSRA,tempA
	ldi tempA,(1<<ADLAR)  ;enable left-adjust result
	out ADCSRB,tempA

	ldi tempA,0
	out ADMUX,tempA	  ;set input mux to 0 and vref to vcc

	sbi ADCSRA,ADSC	;start conversion

adc_wait:
	WDR
	sbis ADCSRA,ADIF	;wait for conversion to be complete
	rjmp adc_wait

adc_wait_end:
	in tempA,ADCH
	sbi ADCSRA,ADIF


By turning on an LED I can establish that the code hangs in the adc_wait
loop - the ADIF flag never becomes set. I cannot work out why this
should be so, I have used this code successfully on other AVRs. Can
anyone see it?


-- 
Tim Mitchell
tim@sabretechnology.co.uk http://www.sabretechnology.co.uk
Sabre Technology (Hull) Ltd, 3a Newlands Science Park, Hull HU6 7TQ
Registered in England and Wales no.3131504
t:01482 801003 f:01482 801078

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.