You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1020 B
C

6 years ago
/*
* geigerzaehler.c
6 years ago
*
6 years ago
* Created : 28.02.2019 09:07:22
* Author : John Ditgens, Alexander Brandscheidt
* Git-Repository : https://gitea.Railduction.eu/JohnD/Geigerzaehler.git
*
* MController : AtMega328P
* Board : Arduino Nano
6 years ago
*/
#define F_CPU 20000000UL // Clock speed: 20 MHz - Maximum of AtMega328P
6 years ago
6 years ago
// Imports
6 years ago
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
6 years ago
int main()
6 years ago
{
6 years ago
DDRD &= ~(1<<2); // Activate PD2
DDRD &= ~(1<<3); // Activate PD3
PORTD |= (1<<2); // Enable Pull Up Resistor Pin D2
PORTD |= (1<<3); // Enable Pull Up Resistor Pin D3
6 years ago
EICRA |= (1 << ISC11)|(1 << ISC10); // Only at raising edge
EIMSK |= (1 << INT1); // Activate Interrupt INT0
6 years ago
EICRA |= (1 << ISC00); // Only at falling edge
EIMSK |= (1 << INT0); // Activate Interrupt INT1
6 years ago
6 years ago
sei(); // Activate global interrupts
6 years ago
6 years ago
// Endless loop
6 years ago
while (1)
{
}
}
6 years ago
ISR(INT0_vect)
6 years ago
{
reti();
6 years ago
}
ISR(INT1_vect)
{
reti();
6 years ago
}