diff --git a/Geigerzaehler/Geigerzaehler.cproj b/Geigerzaehler/Geigerzaehler.cproj
index 63675f9..655c43a 100644
--- a/Geigerzaehler/Geigerzaehler.cproj
+++ b/Geigerzaehler/Geigerzaehler.cproj
@@ -20,103 +20,116 @@
false
true
true
-
+ 0x20000000
true
-
+ exception_table
2
0
0
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ com.atmel.avrdbg.tool.simulator
+
+ 0x1E950F
+
+
+
+
+
+ com.atmel.avrdbg.tool.simulator
+
+
+ Simulator
+
- -mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega328p"
- True
- True
- True
- True
- False
- True
- True
-
-
- NDEBUG
-
-
-
-
- %24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\include
-
-
- Optimize for size (-Os)
- True
- True
- True
-
-
- libm
-
-
-
-
- %24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\include
-
-
-
+ -mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega328p"
+ True
+ True
+ True
+ True
+ False
+ True
+ True
+
+
+ NDEBUG
+
+
+
+
+ %24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\include
+
+
+ Optimize for size (-Os)
+ True
+ True
+ True
+
+
+ libm
+
+
+
+
+ %24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\include
+
+
+
- -mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega328p"
- True
- True
- True
- True
- False
- True
- True
-
-
- DEBUG
-
-
-
-
- %24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\include
-
-
- Optimize (-O1)
- True
- True
- Default (-g2)
- True
-
-
- libm
-
-
-
-
- %24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\include
-
-
- Default (-Wa,-g)
-
+ -mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega328p"
+ True
+ True
+ True
+ True
+ False
+ True
+ True
+
+
+ DEBUG
+
+
+
+
+ %24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\include
+
+
+ Optimize (-O1)
+ True
+ True
+ Default (-g2)
+ True
+
+
+ libm
+
+
+
+
+ %24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\include
+
+
+ Default (-Wa,-g)
+
diff --git a/Geigerzaehler/main.c b/Geigerzaehler/main.c
index e4c63e2..7515981 100644
--- a/Geigerzaehler/main.c
+++ b/Geigerzaehler/main.c
@@ -20,13 +20,13 @@ uint16_t boost_frequency = 2000; // 2kHz frequency
uint8_t boost_enable = 0;
uint8_t boost_highVoltage_nextHigh = 1;
-clock_t boost_highVoltage_nextTick = 0;
+uint16_t boost_highVoltage_nextTick = 0;
// Todo [CRITICAL]: Clock does not exist! Use timer.
uint8_t signalOutput_enable = 0;
uint8_t signalOutput_nextHigh = 1;
-clock_t signalOutput_nextTick = 0;
+uint16_t signalOutput_nextTick = 0;
int main()
@@ -51,6 +51,9 @@ int main()
EICRA |= (1 << ISC11)|(1 << ISC10); // On rising edge [Code: 11]
EIMSK |= (1 <= boost_highVoltage_nextTick) // If we are on or after the tick it should be executed
+ if(TCNT1 >= boost_highVoltage_nextTick) // If we are on or after the tick it should be executed
{
// Set pin according to next exec
if(boost_highVoltage_nextHigh == 1) // Set it high
@@ -74,7 +77,7 @@ int main()
}
// Calculate when next high/low should be set
- boost_highVoltage_nextTick = clock() + F_CPU * 1/(boost_frequency/2); // Half of time it should be high/low
+ boost_highVoltage_nextTick = TCNT1 + F_CPU/256 * 1/(boost_frequency/2); // Half of time it should be high/low
}
}else
{
@@ -91,7 +94,7 @@ int main()
// Signal output
if(signalOutput_enable)
{
- if(clock() >= signalOutput_nextTick) // If we are on or after the tick it should be executed
+ if(TCNT1 >= signalOutput_nextTick) // If we are on or after the tick it should be executed
{
// Set pin according to next exec
if(signalOutput_nextHigh == 1) // Set it high
@@ -110,12 +113,34 @@ int main()
}
// When the signal should stop
- signalOutput_nextTick = clock() + F_CPU * 0.2; // nextTick is in 0.2s
+ signalOutput_nextTick = TCNT1 + F_CPU/256 * 0.2; // nextTick is in 0.2s
}
}
}
}
+void timer1_init()
+{
+ // set up timer with prescaler = 256
+ TCCR1B |= (1 << CS12);
+
+ // initialize counter
+ TCNT1 = 0;
+}
+
+ISR(TIMER1_COMPA_vect){
+
+ //Code Kanal A Timer 1
+
+}
+
+ISR(TIMER1_COMPB_vect){
+
+ //Code Kanal B Timer 1
+
+}
+
+
/*
* Interrupt-handler
* ISR - Interrupt service routine