Skip to content

Instantly share code, notes, and snippets.

@dccourt
Created January 29, 2012 01:22
Show Gist options
  • Save dccourt/1696583 to your computer and use it in GitHub Desktop.
Save dccourt/1696583 to your computer and use it in GitHub Desktop.
Setting up the AVR analogue comparator registers
// Set up the comparator.
pinMode(AIN0, INPUT);
pinMode(AIN1, INPUT);
// ACI : Ana Comp Interrupt flag - writing a 1 clears it, hardware autoclears it when calling ISR
// ACIE : Ana Comp Int Enable
// ACIS1, ACIS0 : Ana Comp Int mode select:
// 0 0 Int on output toggle
// 0 1 Reserved
// 1 0 Int on falling output edge
// 0 1 Int on rising output edge
// (See section 16 of ATTiny85 datasheet)
ACSR = 0 | (1 << ACI) | (1 << ACIE) | (1 << ACIS1); // Enable interrupts; falling edge mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment