X-Git-Url: https://robinkrens.nl/gitweb/?p=lra-as-sensor;a=blobdiff_plain;f=hbc.c;fp=hbc.c;h=38332a180a64a9eec360a56d3f095eb79d50dbd8;hp=c5c2c0d1a7377969723881cba060f510838ab09e;hb=f99860f16348c1622450bb81db26a14ceb795a87;hpb=5a12804f1173a21db44a671e2c74be9c6e76f394 diff --git a/hbc.c b/hbc.c index c5c2c0d..38332a1 100644 --- a/hbc.c +++ b/hbc.c @@ -13,6 +13,7 @@ ISR(SIG_COMPARATOR) { if (ACSR & (1 << ACO)) { PORTB |= (1 << PB4); + ACSR &= ~(1 << ACIE); } else { PORTB &= ~(1 << PB4); } @@ -22,7 +23,6 @@ EMPTY_INTERRUPT(TIM0_COMPA_vect); static void switch_idle(void) { - sei(); set_sleep_mode(SLEEP_MODE_IDLE); sleep_mode(); } @@ -55,7 +55,7 @@ static void config_comparator(void) //ADMUX |= (1 << MUX0); /* ADC1 as negative input */ ACSR &= ~(1 << ACD); /* enable comparator */ - //ACSR |= (1 << ACBG); + ACSR |= (1 << ACBG); //ACSR |= (1 << ACIS1) | (1 << ACIS0); DIDR0 |= (1 << AIN1D) | (1 << AIN0D); @@ -74,6 +74,7 @@ int main(void) //set_ref_voltage(); config_comparator(); sei(); + switch_idle(); while(1) { _delay_ms(100);