From: Robin Krens Date: Fri, 20 May 2022 13:06:59 +0000 (+0200) Subject: hbc: internal vref + switch off interrupts after detect X-Git-Url: https://robinkrens.nl/gitweb/?p=lra-as-sensor;a=commitdiff_plain;h=f99860f16348c1622450bb81db26a14ceb795a87 hbc: internal vref + switch off interrupts after detect --- 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);