Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* analog_comp_01.c ATmega88 @ 1MHz */
- #include <avr/io.h>
- #include <avr/interrupt.h>
- #include <util/delay.h>
- #define LED PC5
- int main(void)
- {
- DDRC = 0xFF; //Richtungsregister PORTC auf Ausgang
- PORTC &= ~(1<<LED); //LED OFF
- ACSR |= (1<<ACBG); //Referenzspannung an AIN0 aktivieren
- ACSR |= (1<<ACIE); //AC-Interrupt enable
- sei(); //Global Interrupt enable
- while(1)
- {
- //Nichts tun…
- }
- }
- ISR (ANALOG_COMP_vect) //Analog Comparator Interrupt Service Routine
- {
- if ((ACSR & 0b00100000) == 0) //Wenn Bit ACO gelöscht ist
- PORTC |= (1<<LED); //LED ON
- else
- PORTC &= ~(1<<LED); //LED OFF
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement