AVR Assembler Analog Comparator (AC)

AVR Assembler Analog Comparator (AC)
  1. Arduino UNO
.nolist .include "./m328Pdef.inc" .list ; positive pin AIN0 = PD6 ; negative pin AIN1 = PD7 .def temp = r16 .def data = r17 .org 0x0000 rjmp start .org 0x002E rjmp ANALOG_COMP start: ldi temp, high(RAMEND) out sph, temp ldi temp, low(RAMEND) out spl, temp sbi ddrb, 5 ldi temp, (1<<ACIE) ; Analog Comparator Interrupt Enable out ACSR, temp sei loop: nop rjmp loop ANALOG_COMP: cli in temp, ACSR sbrs temp, ACO ; Analog Comparator Output sbi PORTB, 5 sbrc temp, ACO ; Analog Comparator Output cbi PORTB, 5 sei reti