Created
January 29, 2012 01:22
-
-
Save dccourt/1696583 to your computer and use it in GitHub Desktop.
Setting up the AVR analogue comparator registers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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