There is no reason to use assembler.
In my test code below, I set the relevant bits according to the datasheet
Although this is for Attiny2313, I think you could adopt it for the 1280
It is more or less the code I posted earlier http://kalshagar.wikispaces.com/attiny2313
#include <avr/interrupt.h>
#include <TinyDebugKnockBang.h>
int a=0;
static volatile uint8_t capture;
static volatile uint8_t flag;
const uint8_t led = 13;
//Interrupt code of the comparator
// NB : you need to stabilize the power rail with a capacitor (otherwise you'll have ripples and misreading). With AIN1=Comp-=0v a 200uF is fine.
ISR(ANA_COMP_vect) {
//with this test, ensure that indeed the interrupt result is 1 = V(AIN0) > V(AIN1)
//(double check ?)
if ( (ACSR & (1 << ACO))== 0 ) {
flag=true;
}
else
{
flag=false;
}
}
void setup() {
//factory settings is to divide internal clock 8MHz by 8.
//don't, and just run at 8 MHz (set the clock divider to 1 so no effect)
Debug.begin(250000);
pinMode(led,OUTPUT);
CLKPR = (1<<CLKPCE);
CLKPR = 0; // Divide by 1
PORTB &= ~(1<<PB0); // no Pull-up on PB0
ACSR |= (1<<ACI); // clear Analog Comparator interrupt
ACSR |=
(0<<ACD) | // Comparator ON
(0<<ACBG) | // Disconnect 1.23V reference from AIN0 (use AIN0 and AIN1 pins)
(1<<ACIE) | // Comparator Interrupt enabled
(0<<ACIC) | // input capture disabled
(0<<ACIS1) | // set interrupt bit on rising edge
(0<<ACIS0); // (ACIS1 and ACIS0 == 11)
// Enable the interrupt
ACSR = ACSR | (1 << ACIE);
sei(); // enable global interrupts
}
void loop() {/*all the job is done in the interrupt */
// Debug.println(flag);
if (flag==true){
digitalWrite(led,HIGH);
}
if (flag==false){
digitalWrite(led,LOW);
}
}