;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Author: Professor Barnekow ; Date: Oct. 2005 ; Purpose: ; This example demonstrates the use of the ADC system in free-running mode. ; A-to-D Conversions are repeatedly performed on ADC0(PORTA0). ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .NOLIST .include "m32def.inc" .LIST .cseg .org 0 rjmp start .DEF temp=r16 .org 0x2a start: ldi temp, 0xff ; setup PortB for digital output out DDRB, temp ldi temp, 0b11100111 ; ADEN=1, ADSC=1, ADATE=1(Auto trigger enable), set ADC clock freq. out ADCSRA, temp in temp, SFIOR andi temp, 0x1f ; select free-running ADC out SFIOR, temp ldi temp, 0b01100011 ; REFS0=1, ADLAR=1(left adjust result), select ADC3 (PA3) out ADMUX, temp loop: in temp, ADCH ; Read high 8 bits of result(8-bit resolution) com temp ; invert the bits out PORTB, temp ; Output result to PORTB rjmp loop ; repeat forever